summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/css/cfx_cssdatatable.cpp138
-rw-r--r--core/fxcrt/css/cfx_cssdatatable.h24
-rw-r--r--core/fxcrt/css/cfx_cssdeclaration.cpp170
3 files changed, 160 insertions, 172 deletions
diff --git a/core/fxcrt/css/cfx_cssdatatable.cpp b/core/fxcrt/css/cfx_cssdatatable.cpp
index ef555b395f..833b81b93b 100644
--- a/core/fxcrt/css/cfx_cssdatatable.cpp
+++ b/core/fxcrt/css/cfx_cssdatatable.cpp
@@ -121,81 +121,6 @@ static_assert(g_iCSSPropertyCount ==
static_cast<int32_t>(CFX_CSSProperty::LAST_MARKER),
"Property table differs in size from property enum");
-static const CFX_CSSPropertyValueTable g_CFX_CSSPropertyValues[] = {
- {CFX_CSSPropertyValue::Bolder, L"bolder", 0x009F1058},
- {CFX_CSSPropertyValue::None, L"none", 0x048B6670},
- {CFX_CSSPropertyValue::Dot, L"dot", 0x0A48CB27},
- {CFX_CSSPropertyValue::Sub, L"sub", 0x0BD37FAA},
- {CFX_CSSPropertyValue::Top, L"top", 0x0BEDAF33},
- {CFX_CSSPropertyValue::Right, L"right", 0x193ADE3E},
- {CFX_CSSPropertyValue::Normal, L"normal", 0x247CF3E9},
- {CFX_CSSPropertyValue::Auto, L"auto", 0x2B35B6D9},
- {CFX_CSSPropertyValue::Text, L"text", 0x2D08AF85},
- {CFX_CSSPropertyValue::XSmall, L"x-small", 0x2D2FCAFE},
- {CFX_CSSPropertyValue::Thin, L"thin", 0x2D574D53},
- {CFX_CSSPropertyValue::Small, L"small", 0x316A3739},
- {CFX_CSSPropertyValue::Bottom, L"bottom", 0x399F02B5},
- {CFX_CSSPropertyValue::Underline, L"underline", 0x3A0273A6},
- {CFX_CSSPropertyValue::Double, L"double", 0x3D98515B},
- {CFX_CSSPropertyValue::Lighter, L"lighter", 0x45BEB7AF},
- {CFX_CSSPropertyValue::Oblique, L"oblique", 0x53EBDDB1},
- {CFX_CSSPropertyValue::Super, L"super", 0x6A4F842F},
- {CFX_CSSPropertyValue::Center, L"center", 0x6C51AFC1},
- {CFX_CSSPropertyValue::XxLarge, L"xx-large", 0x70BB1508},
- {CFX_CSSPropertyValue::Smaller, L"smaller", 0x849769F0},
- {CFX_CSSPropertyValue::Baseline, L"baseline", 0x87436BA3},
- {CFX_CSSPropertyValue::Thick, L"thick", 0x8CC35EB3},
- {CFX_CSSPropertyValue::Justify, L"justify", 0x8D269CAE},
- {CFX_CSSPropertyValue::Middle, L"middle", 0x947FA00F},
- {CFX_CSSPropertyValue::Medium, L"medium", 0xA084A381},
- {CFX_CSSPropertyValue::ListItem, L"list-item", 0xA32382B8},
- {CFX_CSSPropertyValue::XxSmall, L"xx-small", 0xADE1FC76},
- {CFX_CSSPropertyValue::Bold, L"bold", 0xB18313A1},
- {CFX_CSSPropertyValue::SmallCaps, L"small-caps", 0xB299428D},
- {CFX_CSSPropertyValue::Inline, L"inline", 0xC02D649F},
- {CFX_CSSPropertyValue::Overline, L"overline", 0xC0EC9FA4},
- {CFX_CSSPropertyValue::TextBottom, L"text-bottom", 0xC7D08D87},
- {CFX_CSSPropertyValue::Larger, L"larger", 0xCD3C409D},
- {CFX_CSSPropertyValue::InlineTable, L"inline-table", 0xD131F494},
- {CFX_CSSPropertyValue::InlineBlock, L"inline-block", 0xD26A8BD7},
- {CFX_CSSPropertyValue::Blink, L"blink", 0xDC36E390},
- {CFX_CSSPropertyValue::Block, L"block", 0xDCD480AB},
- {CFX_CSSPropertyValue::Italic, L"italic", 0xE31D5396},
- {CFX_CSSPropertyValue::LineThrough, L"line-through", 0xE4C5A276},
- {CFX_CSSPropertyValue::XLarge, L"x-large", 0xF008E390},
- {CFX_CSSPropertyValue::Large, L"large", 0xF4434FCB},
- {CFX_CSSPropertyValue::Left, L"left", 0xF5AD782B},
- {CFX_CSSPropertyValue::TextTop, L"text-top", 0xFCB58D45},
-};
-const int32_t g_iCSSPropertyValueCount =
- sizeof(g_CFX_CSSPropertyValues) / sizeof(CFX_CSSPropertyValueTable);
-static_assert(g_iCSSPropertyValueCount ==
- static_cast<int32_t>(CFX_CSSPropertyValue::LAST_MARKER),
- "Property value table differs in size from property value enum");
-
-static const CFX_CSSLengthUnitTable g_CFX_CSSLengthUnits[] = {
- {0x0672, CFX_CSSNumberType::EMS},
- {0x067D, CFX_CSSNumberType::EXS},
- {0x1AF7, CFX_CSSNumberType::Inches},
- {0x2F7A, CFX_CSSNumberType::MilliMeters},
- {0x3ED3, CFX_CSSNumberType::Picas},
- {0x3EE4, CFX_CSSNumberType::Points},
- {0x3EE8, CFX_CSSNumberType::Pixels},
- {0xFC30, CFX_CSSNumberType::CentiMeters},
-};
-
-static const CFX_CSSCOLORTABLE g_CFX_CSSColors[] = {
- {0x031B47FE, 0xff000080}, {0x0BB8DF5B, 0xffff0000},
- {0x0D82A78C, 0xff800000}, {0x2ACC82E8, 0xff00ffff},
- {0x2D083986, 0xff008080}, {0x4A6A6195, 0xffc0c0c0},
- {0x546A8EF3, 0xff808080}, {0x65C9169C, 0xffffa500},
- {0x8422BB61, 0xffffffff}, {0x9271A558, 0xff800080},
- {0xA65A3EE3, 0xffff00ff}, {0xB1345708, 0xff0000ff},
- {0xB6D2CF1F, 0xff808000}, {0xD19B5E1C, 0xffffff00},
- {0xDB64391D, 0xff000000}, {0xF616D507, 0xff00ff00},
- {0xF6EFFF31, 0xff008000},
-};
-
const CFX_CSSPropertyTable* CFX_GetCSSPropertyByName(
const CFX_WideStringC& wsName) {
ASSERT(!wsName.IsEmpty());
@@ -220,66 +145,3 @@ const CFX_CSSPropertyTable* CFX_GetCSSPropertyByName(
const CFX_CSSPropertyTable* CFX_GetCSSPropertyByEnum(CFX_CSSProperty eName) {
return g_CFX_CSSProperties + static_cast<int>(eName);
}
-
-const CFX_CSSPropertyValueTable* CFX_GetCSSPropertyValueByName(
- const CFX_WideStringC& wsName) {
- ASSERT(!wsName.IsEmpty());
- uint32_t dwHash = FX_HashCode_GetW(wsName, true);
- int32_t iEnd = g_iCSSPropertyValueCount;
- int32_t iMid, iStart = 0;
- uint32_t dwMid;
- do {
- iMid = (iStart + iEnd) / 2;
- dwMid = g_CFX_CSSPropertyValues[iMid].dwHash;
- if (dwHash == dwMid) {
- return g_CFX_CSSPropertyValues + iMid;
- } else if (dwHash > dwMid) {
- iStart = iMid + 1;
- } else {
- iEnd = iMid - 1;
- }
- } while (iStart <= iEnd);
- return nullptr;
-}
-
-const CFX_CSSLengthUnitTable* CFX_GetCSSLengthUnitByName(
- const CFX_WideStringC& wsName) {
- ASSERT(!wsName.IsEmpty());
- uint16_t wHash = FX_HashCode_GetW(wsName, true);
- int32_t iEnd =
- sizeof(g_CFX_CSSLengthUnits) / sizeof(CFX_CSSLengthUnitTable) - 1;
- int32_t iMid, iStart = 0;
- uint16_t wMid;
- do {
- iMid = (iStart + iEnd) / 2;
- wMid = g_CFX_CSSLengthUnits[iMid].wHash;
- if (wHash == wMid) {
- return g_CFX_CSSLengthUnits + iMid;
- } else if (wHash > wMid) {
- iStart = iMid + 1;
- } else {
- iEnd = iMid - 1;
- }
- } while (iStart <= iEnd);
- return nullptr;
-}
-
-const CFX_CSSCOLORTABLE* CFX_GetCSSColorByName(const CFX_WideStringC& wsName) {
- ASSERT(!wsName.IsEmpty());
- uint32_t dwHash = FX_HashCode_GetW(wsName, true);
- int32_t iEnd = sizeof(g_CFX_CSSColors) / sizeof(CFX_CSSCOLORTABLE) - 1;
- int32_t iMid, iStart = 0;
- uint32_t dwMid;
- do {
- iMid = (iStart + iEnd) / 2;
- dwMid = g_CFX_CSSColors[iMid].dwHash;
- if (dwHash == dwMid) {
- return g_CFX_CSSColors + iMid;
- } else if (dwHash > dwMid) {
- iStart = iMid + 1;
- } else {
- iEnd = iMid - 1;
- }
- } while (iStart <= iEnd);
- return nullptr;
-}
diff --git a/core/fxcrt/css/cfx_cssdatatable.h b/core/fxcrt/css/cfx_cssdatatable.h
index 9a0b0af198..43310c7d5c 100644
--- a/core/fxcrt/css/cfx_cssdatatable.h
+++ b/core/fxcrt/css/cfx_cssdatatable.h
@@ -22,32 +22,8 @@ struct CFX_CSSPropertyTable {
uint32_t dwType;
};
-struct CFX_CSSPropertyValueTable {
- CFX_CSSPropertyValue eName;
- const wchar_t* pszName;
- uint32_t dwHash;
-};
-
-struct CFX_CSSLengthUnitTable {
- uint16_t wHash;
- CFX_CSSNumberType wValue;
-};
-
-struct CFX_CSSCOLORTABLE {
- uint32_t dwHash;
- FX_ARGB dwValue;
-};
-
const CFX_CSSPropertyTable* CFX_GetCSSPropertyByName(
const CFX_WideStringC& wsName);
const CFX_CSSPropertyTable* CFX_GetCSSPropertyByEnum(CFX_CSSProperty eName);
-const CFX_CSSPropertyValueTable* CFX_GetCSSPropertyValueByName(
- const CFX_WideStringC& wsName);
-
-const CFX_CSSLengthUnitTable* CFX_GetCSSLengthUnitByName(
- const CFX_WideStringC& wsName);
-
-const CFX_CSSCOLORTABLE* CFX_GetCSSColorByName(const CFX_WideStringC& wsName);
-
#endif // CORE_FXCRT_CSS_CFX_CSSDATATABLE_H_
diff --git a/core/fxcrt/css/cfx_cssdeclaration.cpp b/core/fxcrt/css/cfx_cssdeclaration.cpp
index c89f75c5fd..344fc842c4 100644
--- a/core/fxcrt/css/cfx_cssdeclaration.cpp
+++ b/core/fxcrt/css/cfx_cssdeclaration.cpp
@@ -24,6 +24,157 @@ uint8_t Hex2Dec(uint8_t hexHigh, uint8_t hexLow) {
return (FXSYS_HexCharToInt(hexHigh) << 4) + FXSYS_HexCharToInt(hexLow);
}
+struct CFX_CSSPropertyValueTable {
+ CFX_CSSPropertyValue eName;
+ const wchar_t* pszName;
+ uint32_t dwHash;
+};
+const CFX_CSSPropertyValueTable g_CFX_CSSPropertyValues[] = {
+ {CFX_CSSPropertyValue::Bolder, L"bolder", 0x009F1058},
+ {CFX_CSSPropertyValue::None, L"none", 0x048B6670},
+ {CFX_CSSPropertyValue::Dot, L"dot", 0x0A48CB27},
+ {CFX_CSSPropertyValue::Sub, L"sub", 0x0BD37FAA},
+ {CFX_CSSPropertyValue::Top, L"top", 0x0BEDAF33},
+ {CFX_CSSPropertyValue::Right, L"right", 0x193ADE3E},
+ {CFX_CSSPropertyValue::Normal, L"normal", 0x247CF3E9},
+ {CFX_CSSPropertyValue::Auto, L"auto", 0x2B35B6D9},
+ {CFX_CSSPropertyValue::Text, L"text", 0x2D08AF85},
+ {CFX_CSSPropertyValue::XSmall, L"x-small", 0x2D2FCAFE},
+ {CFX_CSSPropertyValue::Thin, L"thin", 0x2D574D53},
+ {CFX_CSSPropertyValue::Small, L"small", 0x316A3739},
+ {CFX_CSSPropertyValue::Bottom, L"bottom", 0x399F02B5},
+ {CFX_CSSPropertyValue::Underline, L"underline", 0x3A0273A6},
+ {CFX_CSSPropertyValue::Double, L"double", 0x3D98515B},
+ {CFX_CSSPropertyValue::Lighter, L"lighter", 0x45BEB7AF},
+ {CFX_CSSPropertyValue::Oblique, L"oblique", 0x53EBDDB1},
+ {CFX_CSSPropertyValue::Super, L"super", 0x6A4F842F},
+ {CFX_CSSPropertyValue::Center, L"center", 0x6C51AFC1},
+ {CFX_CSSPropertyValue::XxLarge, L"xx-large", 0x70BB1508},
+ {CFX_CSSPropertyValue::Smaller, L"smaller", 0x849769F0},
+ {CFX_CSSPropertyValue::Baseline, L"baseline", 0x87436BA3},
+ {CFX_CSSPropertyValue::Thick, L"thick", 0x8CC35EB3},
+ {CFX_CSSPropertyValue::Justify, L"justify", 0x8D269CAE},
+ {CFX_CSSPropertyValue::Middle, L"middle", 0x947FA00F},
+ {CFX_CSSPropertyValue::Medium, L"medium", 0xA084A381},
+ {CFX_CSSPropertyValue::ListItem, L"list-item", 0xA32382B8},
+ {CFX_CSSPropertyValue::XxSmall, L"xx-small", 0xADE1FC76},
+ {CFX_CSSPropertyValue::Bold, L"bold", 0xB18313A1},
+ {CFX_CSSPropertyValue::SmallCaps, L"small-caps", 0xB299428D},
+ {CFX_CSSPropertyValue::Inline, L"inline", 0xC02D649F},
+ {CFX_CSSPropertyValue::Overline, L"overline", 0xC0EC9FA4},
+ {CFX_CSSPropertyValue::TextBottom, L"text-bottom", 0xC7D08D87},
+ {CFX_CSSPropertyValue::Larger, L"larger", 0xCD3C409D},
+ {CFX_CSSPropertyValue::InlineTable, L"inline-table", 0xD131F494},
+ {CFX_CSSPropertyValue::InlineBlock, L"inline-block", 0xD26A8BD7},
+ {CFX_CSSPropertyValue::Blink, L"blink", 0xDC36E390},
+ {CFX_CSSPropertyValue::Block, L"block", 0xDCD480AB},
+ {CFX_CSSPropertyValue::Italic, L"italic", 0xE31D5396},
+ {CFX_CSSPropertyValue::LineThrough, L"line-through", 0xE4C5A276},
+ {CFX_CSSPropertyValue::XLarge, L"x-large", 0xF008E390},
+ {CFX_CSSPropertyValue::Large, L"large", 0xF4434FCB},
+ {CFX_CSSPropertyValue::Left, L"left", 0xF5AD782B},
+ {CFX_CSSPropertyValue::TextTop, L"text-top", 0xFCB58D45},
+};
+const int32_t g_iCSSPropertyValueCount =
+ sizeof(g_CFX_CSSPropertyValues) / sizeof(CFX_CSSPropertyValueTable);
+static_assert(g_iCSSPropertyValueCount ==
+ static_cast<int32_t>(CFX_CSSPropertyValue::LAST_MARKER),
+ "Property value table differs in size from property value enum");
+
+struct CFX_CSSLengthUnitTable {
+ uint16_t wHash;
+ CFX_CSSNumberType wValue;
+};
+const CFX_CSSLengthUnitTable g_CFX_CSSLengthUnits[] = {
+ {0x0672, CFX_CSSNumberType::EMS},
+ {0x067D, CFX_CSSNumberType::EXS},
+ {0x1AF7, CFX_CSSNumberType::Inches},
+ {0x2F7A, CFX_CSSNumberType::MilliMeters},
+ {0x3ED3, CFX_CSSNumberType::Picas},
+ {0x3EE4, CFX_CSSNumberType::Points},
+ {0x3EE8, CFX_CSSNumberType::Pixels},
+ {0xFC30, CFX_CSSNumberType::CentiMeters},
+};
+
+struct CFX_CSSColorTable {
+ uint32_t dwHash;
+ FX_ARGB dwValue;
+};
+const CFX_CSSColorTable g_CFX_CSSColors[] = {
+ {0x031B47FE, 0xff000080}, {0x0BB8DF5B, 0xffff0000},
+ {0x0D82A78C, 0xff800000}, {0x2ACC82E8, 0xff00ffff},
+ {0x2D083986, 0xff008080}, {0x4A6A6195, 0xffc0c0c0},
+ {0x546A8EF3, 0xff808080}, {0x65C9169C, 0xffffa500},
+ {0x8422BB61, 0xffffffff}, {0x9271A558, 0xff800080},
+ {0xA65A3EE3, 0xffff00ff}, {0xB1345708, 0xff0000ff},
+ {0xB6D2CF1F, 0xff808000}, {0xD19B5E1C, 0xffffff00},
+ {0xDB64391D, 0xff000000}, {0xF616D507, 0xff00ff00},
+ {0xF6EFFF31, 0xff008000},
+};
+
+const CFX_CSSPropertyValueTable* GetCSSPropertyValueByName(
+ const CFX_WideStringC& wsName) {
+ ASSERT(!wsName.IsEmpty());
+ uint32_t dwHash = FX_HashCode_GetW(wsName, true);
+ int32_t iEnd = g_iCSSPropertyValueCount;
+ int32_t iMid, iStart = 0;
+ uint32_t dwMid;
+ do {
+ iMid = (iStart + iEnd) / 2;
+ dwMid = g_CFX_CSSPropertyValues[iMid].dwHash;
+ if (dwHash == dwMid) {
+ return g_CFX_CSSPropertyValues + iMid;
+ } else if (dwHash > dwMid) {
+ iStart = iMid + 1;
+ } else {
+ iEnd = iMid - 1;
+ }
+ } while (iStart <= iEnd);
+ return nullptr;
+}
+
+const CFX_CSSLengthUnitTable* GetCSSLengthUnitByName(
+ const CFX_WideStringC& wsName) {
+ ASSERT(!wsName.IsEmpty());
+ uint16_t wHash = FX_HashCode_GetW(wsName, true);
+ int32_t iEnd =
+ sizeof(g_CFX_CSSLengthUnits) / sizeof(CFX_CSSLengthUnitTable) - 1;
+ int32_t iMid, iStart = 0;
+ uint16_t wMid;
+ do {
+ iMid = (iStart + iEnd) / 2;
+ wMid = g_CFX_CSSLengthUnits[iMid].wHash;
+ if (wHash == wMid) {
+ return g_CFX_CSSLengthUnits + iMid;
+ } else if (wHash > wMid) {
+ iStart = iMid + 1;
+ } else {
+ iEnd = iMid - 1;
+ }
+ } while (iStart <= iEnd);
+ return nullptr;
+}
+
+const CFX_CSSColorTable* GetCSSColorByName(const CFX_WideStringC& wsName) {
+ ASSERT(!wsName.IsEmpty());
+ uint32_t dwHash = FX_HashCode_GetW(wsName, true);
+ int32_t iEnd = sizeof(g_CFX_CSSColors) / sizeof(CFX_CSSColorTable) - 1;
+ int32_t iMid, iStart = 0;
+ uint32_t dwMid;
+ do {
+ iMid = (iStart + iEnd) / 2;
+ dwMid = g_CFX_CSSColors[iMid].dwHash;
+ if (dwHash == dwMid) {
+ return g_CFX_CSSColors + iMid;
+ } else if (dwHash > dwMid) {
+ iStart = iMid + 1;
+ } else {
+ iEnd = iMid - 1;
+ }
+ } while (iStart <= iEnd);
+ return nullptr;
+}
+
bool ParseCSSNumber(const wchar_t* pszValue,
int32_t iValueLen,
float& fValue,
@@ -41,7 +192,7 @@ bool ParseCSSNumber(const wchar_t* pszValue,
eUnit = CFX_CSSNumberType::Percent;
} else if (iValueLen == 2) {
const CFX_CSSLengthUnitTable* pUnit =
- CFX_GetCSSLengthUnitByName(CFX_WideStringC(pszValue, 2));
+ GetCSSLengthUnitByName(CFX_WideStringC(pszValue, 2));
if (pUnit)
eUnit = pUnit->wValue;
}
@@ -121,8 +272,8 @@ bool CFX_CSSDeclaration::ParseCSSColor(const wchar_t* pszValue,
return true;
}
- const CFX_CSSCOLORTABLE* pColor =
- CFX_GetCSSColorByName(CFX_WideStringC(pszValue, iValueLen));
+ const CFX_CSSColorTable* pColor =
+ GetCSSColorByName(CFX_WideStringC(pszValue, iValueLen));
if (!pColor)
return false;
@@ -291,7 +442,7 @@ CFX_RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseEnum(
const wchar_t* pszValue,
int32_t iValueLen) {
const CFX_CSSPropertyValueTable* pValue =
- CFX_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
+ GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
return pValue ? pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName) : nullptr;
}
@@ -351,8 +502,7 @@ void CFX_CSSDeclaration::ParseValueListProperty(
}
if (dwType & CFX_CSSVALUETYPE_MaybeEnum) {
const CFX_CSSPropertyValueTable* pValue =
- CFX_GetCSSPropertyValueByName(
- CFX_WideStringC(pszValue, iValueLen));
+ GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
if (pValue) {
list.push_back(pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName));
continue;
@@ -463,13 +613,13 @@ bool CFX_CSSDeclaration::ParseBorderProperty(
break;
}
case CFX_CSSPrimitiveType::String: {
- const CFX_CSSCOLORTABLE* pColorItem =
- CFX_GetCSSColorByName(CFX_WideStringC(pszValue, iValueLen));
+ const CFX_CSSColorTable* pColorItem =
+ GetCSSColorByName(CFX_WideStringC(pszValue, iValueLen));
if (pColorItem)
continue;
const CFX_CSSPropertyValueTable* pValue =
- CFX_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
+ GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
if (!pValue)
continue;
@@ -511,7 +661,7 @@ void CFX_CSSDeclaration::ParseFontProperty(const wchar_t* pszValue,
switch (eType) {
case CFX_CSSPrimitiveType::String: {
const CFX_CSSPropertyValueTable* pValue =
- CFX_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
+ GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
if (pValue) {
switch (pValue->eName) {
case CFX_CSSPropertyValue::XxSmall: