Nest CFX_CSSPrimitiveType in CFX_CSSValue
-- avoid virtual inline destructor for CFX_CSSValue.
Change-Id: Ia2194d22c3a2dfd87d839f1916249e066121af0a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/80694
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/css/cfx_css.h b/core/fxcrt/css/cfx_css.h
index 1c21586..534ed1f 100644
--- a/core/fxcrt/css/cfx_css.h
+++ b/core/fxcrt/css/cfx_css.h
@@ -20,16 +20,6 @@
CFX_CSSVALUETYPE_MaybeColor = 1 << 8
};
-enum class CFX_CSSPrimitiveType : uint8_t {
- Unknown = 0,
- Number,
- String,
- RGB,
- Enum,
- Function,
- List,
-};
-
// Any entries added/removed here, will need to be mirrored in
// propertyValueTable, in core/fxcrt/css/cfx_cssdata.cpp.
enum class CFX_CSSPropertyValue : uint8_t {
diff --git a/core/fxcrt/css/cfx_csscolorvalue.cpp b/core/fxcrt/css/cfx_csscolorvalue.cpp
index 587ee5b..990ba4f 100644
--- a/core/fxcrt/css/cfx_csscolorvalue.cpp
+++ b/core/fxcrt/css/cfx_csscolorvalue.cpp
@@ -7,6 +7,6 @@
#include "core/fxcrt/css/cfx_csscolorvalue.h"
CFX_CSSColorValue::CFX_CSSColorValue(FX_ARGB value)
- : CFX_CSSValue(CFX_CSSPrimitiveType::RGB), value_(value) {}
+ : CFX_CSSValue(PrimitiveType::kRGB), value_(value) {}
CFX_CSSColorValue::~CFX_CSSColorValue() = default;
diff --git a/core/fxcrt/css/cfx_cssdeclaration.cpp b/core/fxcrt/css/cfx_cssdeclaration.cpp
index 35bf63e..823659d 100644
--- a/core/fxcrt/css/cfx_cssdeclaration.cpp
+++ b/core/fxcrt/css/cfx_cssdeclaration.cpp
@@ -111,12 +111,12 @@
uint8_t rgb[3] = {0};
float fValue;
- CFX_CSSPrimitiveType eType;
+ CFX_CSSValue::PrimitiveType eType;
CFX_CSSValueListParser list(pszValue + 4, iValueLen - 5, ',');
for (int32_t i = 0; i < 3; ++i) {
if (!list.NextValue(&eType, &pszValue, &iValueLen))
return false;
- if (eType != CFX_CSSPrimitiveType::Number)
+ if (eType != CFX_CSSValue::PrimitiveType::kNumber)
return false;
CFX_CSSNumberValue::Unit eNumType;
if (!ParseCSSNumber(pszValue, iValueLen, &fValue, &eNumType))
@@ -333,11 +333,11 @@
CFX_CSSValueListParser parser(pszValue, iValueLen, separator);
const uint32_t dwType = pProperty->dwType;
- CFX_CSSPrimitiveType eType;
+ CFX_CSSValue::PrimitiveType eType;
std::vector<RetainPtr<CFX_CSSValue>> list;
while (parser.NextValue(&eType, &pszValue, &iValueLen)) {
switch (eType) {
- case CFX_CSSPrimitiveType::Number:
+ case CFX_CSSValue::PrimitiveType::kNumber:
if (dwType & CFX_CSSVALUETYPE_MaybeNumber) {
float fValue;
CFX_CSSNumberValue::Unit eNumType;
@@ -346,7 +346,7 @@
pdfium::MakeRetain<CFX_CSSNumberValue>(eNumType, fValue));
}
break;
- case CFX_CSSPrimitiveType::String:
+ case CFX_CSSValue::PrimitiveType::kString:
if (dwType & CFX_CSSVALUETYPE_MaybeColor) {
FX_ARGB dwColor;
if (ParseCSSColor(pszValue, iValueLen, &dwColor)) {
@@ -368,7 +368,7 @@
WideString(pszValue, iValueLen)));
}
break;
- case CFX_CSSPrimitiveType::RGB:
+ case CFX_CSSValue::PrimitiveType::kRGB:
if (dwType & CFX_CSSVALUETYPE_MaybeColor) {
FX_ARGB dwColor;
if (ParseCSSColor(pszValue, iValueLen, &dwColor)) {
@@ -453,11 +453,11 @@
RetainPtr<CFX_CSSValue>& pWidth) const {
pWidth.Reset(nullptr);
+ CFX_CSSValue::PrimitiveType eType;
CFX_CSSValueListParser parser(pszValue, iValueLen, ' ');
- CFX_CSSPrimitiveType eType;
while (parser.NextValue(&eType, &pszValue, &iValueLen)) {
switch (eType) {
- case CFX_CSSPrimitiveType::Number: {
+ case CFX_CSSValue::PrimitiveType::kNumber: {
if (pWidth)
continue;
@@ -467,7 +467,7 @@
pWidth = pdfium::MakeRetain<CFX_CSSNumberValue>(eNumType, fValue);
break;
}
- case CFX_CSSPrimitiveType::String: {
+ case CFX_CSSValue::PrimitiveType::kString: {
const CFX_CSSData::Color* pColorItem =
CFX_CSSData::GetColorByName(WideStringView(pszValue, iValueLen));
if (pColorItem)
@@ -512,10 +512,10 @@
RetainPtr<CFX_CSSValue> pFontSize;
RetainPtr<CFX_CSSValue> pLineHeight;
std::vector<RetainPtr<CFX_CSSValue>> family_list;
- CFX_CSSPrimitiveType eType;
+ CFX_CSSValue::PrimitiveType eType;
while (parser.NextValue(&eType, &pszValue, &iValueLen)) {
switch (eType) {
- case CFX_CSSPrimitiveType::String: {
+ case CFX_CSSValue::PrimitiveType::kString: {
const CFX_CSSData::PropertyValue* pValue =
CFX_CSSData::GetPropertyValueByName(
WideStringView(pszValue, iValueLen));
@@ -572,12 +572,12 @@
parser.UseCommaSeparator();
break;
}
- case CFX_CSSPrimitiveType::Number: {
+ case CFX_CSSValue::PrimitiveType::kNumber: {
float fValue;
CFX_CSSNumberValue::Unit eNumType;
if (!ParseCSSNumber(pszValue, iValueLen, &fValue, &eNumType))
break;
- if (eType == CFX_CSSPrimitiveType::Number) {
+ if (eType == CFX_CSSValue::PrimitiveType::kNumber) {
switch (static_cast<int32_t>(fValue)) {
case 100:
case 200:
diff --git a/core/fxcrt/css/cfx_cssenumvalue.cpp b/core/fxcrt/css/cfx_cssenumvalue.cpp
index f45a605..8127227 100644
--- a/core/fxcrt/css/cfx_cssenumvalue.cpp
+++ b/core/fxcrt/css/cfx_cssenumvalue.cpp
@@ -7,6 +7,6 @@
#include "core/fxcrt/css/cfx_cssenumvalue.h"
CFX_CSSEnumValue::CFX_CSSEnumValue(CFX_CSSPropertyValue value)
- : CFX_CSSValue(CFX_CSSPrimitiveType::Enum), value_(value) {}
+ : CFX_CSSValue(PrimitiveType::kEnum), value_(value) {}
CFX_CSSEnumValue::~CFX_CSSEnumValue() = default;
diff --git a/core/fxcrt/css/cfx_cssnumbervalue.cpp b/core/fxcrt/css/cfx_cssnumbervalue.cpp
index abb9901..78d53ea 100644
--- a/core/fxcrt/css/cfx_cssnumbervalue.cpp
+++ b/core/fxcrt/css/cfx_cssnumbervalue.cpp
@@ -7,7 +7,7 @@
#include "core/fxcrt/css/cfx_cssnumbervalue.h"
CFX_CSSNumberValue::CFX_CSSNumberValue(Unit unit, float value)
- : CFX_CSSValue(CFX_CSSPrimitiveType::Number), unit_(unit), value_(value) {
+ : CFX_CSSValue(PrimitiveType::kNumber), unit_(unit), value_(value) {
if (unit_ == Unit::kNumber && fabs(value_) < 0.001f)
value_ = 0.0f;
}
diff --git a/core/fxcrt/css/cfx_cssstringvalue.cpp b/core/fxcrt/css/cfx_cssstringvalue.cpp
index 1c8fb5d..edb1486 100644
--- a/core/fxcrt/css/cfx_cssstringvalue.cpp
+++ b/core/fxcrt/css/cfx_cssstringvalue.cpp
@@ -7,6 +7,6 @@
#include "core/fxcrt/css/cfx_cssstringvalue.h"
CFX_CSSStringValue::CFX_CSSStringValue(const WideString& value)
- : CFX_CSSValue(CFX_CSSPrimitiveType::String), value_(value) {}
+ : CFX_CSSValue(PrimitiveType::kString), value_(value) {}
CFX_CSSStringValue::~CFX_CSSStringValue() = default;
diff --git a/core/fxcrt/css/cfx_cssstyleselector.cpp b/core/fxcrt/css/cfx_cssstyleselector.cpp
index 772407c..78ad2da 100644
--- a/core/fxcrt/css/cfx_cssstyleselector.cpp
+++ b/core/fxcrt/css/cfx_cssstyleselector.cpp
@@ -173,26 +173,26 @@
void CFX_CSSStyleSelector::ApplyProperty(CFX_CSSProperty eProperty,
const RetainPtr<CFX_CSSValue>& pValue,
CFX_CSSComputedStyle* pComputedStyle) {
- if (pValue->GetType() != CFX_CSSPrimitiveType::List) {
- CFX_CSSPrimitiveType eType = pValue->GetType();
+ if (pValue->GetType() != CFX_CSSValue::PrimitiveType::kList) {
+ CFX_CSSValue::PrimitiveType eType = pValue->GetType();
switch (eProperty) {
case CFX_CSSProperty::Display:
- if (eType == CFX_CSSPrimitiveType::Enum) {
+ if (eType == CFX_CSSValue::PrimitiveType::kEnum) {
pComputedStyle->m_NonInheritedData.m_eDisplay =
ToDisplay(pValue.As<CFX_CSSEnumValue>()->Value());
}
break;
case CFX_CSSProperty::FontSize: {
float& fFontSize = pComputedStyle->m_InheritedData.m_fFontSize;
- if (eType == CFX_CSSPrimitiveType::Number) {
+ if (eType == CFX_CSSValue::PrimitiveType::kNumber) {
fFontSize = pValue.As<CFX_CSSNumberValue>()->Apply(fFontSize);
- } else if (eType == CFX_CSSPrimitiveType::Enum) {
+ } else if (eType == CFX_CSSValue::PrimitiveType::kEnum) {
fFontSize =
ToFontSize(pValue.As<CFX_CSSEnumValue>()->Value(), fFontSize);
}
} break;
case CFX_CSSProperty::LineHeight:
- if (eType == CFX_CSSPrimitiveType::Number) {
+ if (eType == CFX_CSSValue::PrimitiveType::kNumber) {
RetainPtr<CFX_CSSNumberValue> v = pValue.As<CFX_CSSNumberValue>();
if (v->unit() == CFX_CSSNumberValue::Unit::kNumber) {
pComputedStyle->m_InheritedData.m_fLineHeight =
@@ -204,7 +204,7 @@
}
break;
case CFX_CSSProperty::TextAlign:
- if (eType == CFX_CSSPrimitiveType::Enum) {
+ if (eType == CFX_CSSValue::PrimitiveType::kEnum) {
pComputedStyle->m_InheritedData.m_eTextAlign =
ToTextAlign(pValue.As<CFX_CSSEnumValue>()->Value());
}
@@ -215,10 +215,10 @@
pComputedStyle->m_InheritedData.m_fFontSize);
break;
case CFX_CSSProperty::FontWeight:
- if (eType == CFX_CSSPrimitiveType::Enum) {
+ if (eType == CFX_CSSValue::PrimitiveType::kEnum) {
pComputedStyle->m_InheritedData.m_wFontWeight =
ToFontWeight(pValue.As<CFX_CSSEnumValue>()->Value());
- } else if (eType == CFX_CSSPrimitiveType::Number) {
+ } else if (eType == CFX_CSSValue::PrimitiveType::kNumber) {
int32_t iValue =
static_cast<int32_t>(pValue.As<CFX_CSSNumberValue>()->value()) /
100;
@@ -228,13 +228,13 @@
}
break;
case CFX_CSSProperty::FontStyle:
- if (eType == CFX_CSSPrimitiveType::Enum) {
+ if (eType == CFX_CSSValue::PrimitiveType::kEnum) {
pComputedStyle->m_InheritedData.m_eFontStyle =
ToFontStyle(pValue.As<CFX_CSSEnumValue>()->Value());
}
break;
case CFX_CSSProperty::Color:
- if (eType == CFX_CSSPrimitiveType::RGB) {
+ if (eType == CFX_CSSValue::PrimitiveType::kRGB) {
pComputedStyle->m_InheritedData.m_dwFontColor =
pValue.As<CFX_CSSColorValue>()->Value();
}
@@ -324,10 +324,10 @@
}
break;
case CFX_CSSProperty::VerticalAlign:
- if (eType == CFX_CSSPrimitiveType::Enum) {
+ if (eType == CFX_CSSValue::PrimitiveType::kEnum) {
pComputedStyle->m_NonInheritedData.m_eVerticalAlignType =
ToVerticalAlign(pValue.As<CFX_CSSEnumValue>()->Value());
- } else if (eType == CFX_CSSPrimitiveType::Number) {
+ } else if (eType == CFX_CSSValue::PrimitiveType::kNumber) {
pComputedStyle->m_NonInheritedData.m_eVerticalAlignType =
CFX_CSSVerticalAlign::Number;
pComputedStyle->m_NonInheritedData.m_fVerticalAlign =
@@ -336,16 +336,16 @@
}
break;
case CFX_CSSProperty::FontVariant:
- if (eType == CFX_CSSPrimitiveType::Enum) {
+ if (eType == CFX_CSSValue::PrimitiveType::kEnum) {
pComputedStyle->m_InheritedData.m_eFontVariant =
ToFontVariant(pValue.As<CFX_CSSEnumValue>()->Value());
}
break;
case CFX_CSSProperty::LetterSpacing:
- if (eType == CFX_CSSPrimitiveType::Enum) {
+ if (eType == CFX_CSSValue::PrimitiveType::kEnum) {
pComputedStyle->m_InheritedData.m_LetterSpacing.Set(
CFX_CSSLengthUnit::Normal);
- } else if (eType == CFX_CSSPrimitiveType::Number) {
+ } else if (eType == CFX_CSSValue::PrimitiveType::kNumber) {
if (pValue.As<CFX_CSSNumberValue>()->unit() ==
CFX_CSSNumberValue::Unit::kPercent) {
break;
@@ -357,10 +357,10 @@
}
break;
case CFX_CSSProperty::WordSpacing:
- if (eType == CFX_CSSPrimitiveType::Enum) {
+ if (eType == CFX_CSSValue::PrimitiveType::kEnum) {
pComputedStyle->m_InheritedData.m_WordSpacing.Set(
CFX_CSSLengthUnit::Normal);
- } else if (eType == CFX_CSSPrimitiveType::Number) {
+ } else if (eType == CFX_CSSValue::PrimitiveType::kNumber) {
if (pValue.As<CFX_CSSNumberValue>()->unit() ==
CFX_CSSNumberValue::Unit::kPercent) {
break;
@@ -393,7 +393,7 @@
default:
break;
}
- } else if (pValue->GetType() == CFX_CSSPrimitiveType::List) {
+ } else if (pValue->GetType() == CFX_CSSValue::PrimitiveType::kList) {
RetainPtr<CFX_CSSValueList> value_list = pValue.As<CFX_CSSValueList>();
if (!value_list->values().empty()) {
switch (eProperty) {
@@ -473,10 +473,10 @@
bool CFX_CSSStyleSelector::SetLengthWithPercent(
CFX_CSSLength& width,
- CFX_CSSPrimitiveType eType,
+ CFX_CSSValue::PrimitiveType eType,
const RetainPtr<CFX_CSSValue>& pValue,
float fFontSize) {
- if (eType == CFX_CSSPrimitiveType::Number) {
+ if (eType == CFX_CSSValue::PrimitiveType::kNumber) {
RetainPtr<CFX_CSSNumberValue> v = pValue.As<CFX_CSSNumberValue>();
if (v->unit() == CFX_CSSNumberValue::Unit::kPercent) {
width.Set(CFX_CSSLengthUnit::Percent,
@@ -487,7 +487,7 @@
float fValue = v->Apply(fFontSize);
width.Set(CFX_CSSLengthUnit::Point, fValue);
return width.NonZero();
- } else if (eType == CFX_CSSPrimitiveType::Enum) {
+ } else if (eType == CFX_CSSValue::PrimitiveType::kEnum) {
switch (pValue.As<CFX_CSSEnumValue>()->Value()) {
case CFX_CSSPropertyValue::Auto:
width.Set(CFX_CSSLengthUnit::Auto);
@@ -565,7 +565,7 @@
uint32_t dwDecoration = 0;
for (const RetainPtr<CFX_CSSValue>& val :
pdfium::base::Reversed(pValue->values())) {
- if (val->GetType() != CFX_CSSPrimitiveType::Enum)
+ if (val->GetType() != CFX_CSSValue::PrimitiveType::kEnum)
continue;
switch (val.As<CFX_CSSEnumValue>()->Value()) {
diff --git a/core/fxcrt/css/cfx_cssstyleselector.h b/core/fxcrt/css/cfx_cssstyleselector.h
index e0e6861..00d4de8 100644
--- a/core/fxcrt/css/cfx_cssstyleselector.h
+++ b/core/fxcrt/css/cfx_cssstyleselector.h
@@ -12,6 +12,7 @@
#include "core/fxcrt/css/cfx_css.h"
#include "core/fxcrt/css/cfx_cssrulecollection.h"
+#include "core/fxcrt/css/cfx_cssvalue.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/retain_ptr.h"
@@ -21,7 +22,6 @@
class CFX_CSSPropertyHolder;
class CFX_CSSSelector;
class CFX_CSSStyleSheet;
-class CFX_CSSValue;
class CFX_CSSValueList;
class CFX_CSSStyleSelector {
@@ -64,7 +64,7 @@
std::vector<const CFX_CSSCustomProperty*>* custom);
bool SetLengthWithPercent(CFX_CSSLength& width,
- CFX_CSSPrimitiveType eType,
+ CFX_CSSValue::PrimitiveType eType,
const RetainPtr<CFX_CSSValue>& pValue,
float fFontSize);
float ToFontSize(CFX_CSSPropertyValue eValue, float fCurFontSize);
diff --git a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
index f470295..315c245 100644
--- a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
+++ b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
@@ -62,7 +62,7 @@
bool important;
RetainPtr<CFX_CSSValue> v = decl_->GetProperty(prop, &important);
- EXPECT_EQ(v->GetType(), CFX_CSSPrimitiveType::Number);
+ EXPECT_EQ(v->GetType(), CFX_CSSValue::PrimitiveType::kNumber);
EXPECT_EQ(v.As<CFX_CSSNumberValue>()->unit(), unit);
EXPECT_EQ(v.As<CFX_CSSNumberValue>()->value(), val);
}
@@ -72,7 +72,7 @@
bool important;
RetainPtr<CFX_CSSValue> v = decl_->GetProperty(prop, &important);
- EXPECT_EQ(v->GetType(), CFX_CSSPrimitiveType::Enum);
+ EXPECT_EQ(v->GetType(), CFX_CSSValue::PrimitiveType::kEnum);
EXPECT_EQ(v.As<CFX_CSSEnumValue>()->Value(), val);
}
@@ -89,7 +89,7 @@
for (size_t i = 0; i < expected_values.size(); ++i) {
const auto& val = values[i];
- EXPECT_EQ(val->GetType(), CFX_CSSPrimitiveType::Enum);
+ EXPECT_EQ(val->GetType(), CFX_CSSValue::PrimitiveType::kEnum);
EXPECT_EQ(val.As<CFX_CSSEnumValue>()->Value(), expected_values[i]);
}
}
diff --git a/core/fxcrt/css/cfx_cssvalue.cpp b/core/fxcrt/css/cfx_cssvalue.cpp
index a55fc74..1ffabf5 100644
--- a/core/fxcrt/css/cfx_cssvalue.cpp
+++ b/core/fxcrt/css/cfx_cssvalue.cpp
@@ -6,4 +6,6 @@
#include "core/fxcrt/css/cfx_cssvalue.h"
-CFX_CSSValue::CFX_CSSValue(CFX_CSSPrimitiveType type) : m_value(type) {}
+CFX_CSSValue::CFX_CSSValue(PrimitiveType type) : m_value(type) {}
+
+CFX_CSSValue::~CFX_CSSValue() = default;
diff --git a/core/fxcrt/css/cfx_cssvalue.h b/core/fxcrt/css/cfx_cssvalue.h
index 30aace2..b6f7130 100644
--- a/core/fxcrt/css/cfx_cssvalue.h
+++ b/core/fxcrt/css/cfx_cssvalue.h
@@ -12,13 +12,24 @@
class CFX_CSSValue : public Retainable {
public:
- CFX_CSSPrimitiveType GetType() const { return m_value; }
+ enum class PrimitiveType : uint8_t {
+ kUnknown = 0,
+ kNumber,
+ kString,
+ kRGB,
+ kEnum,
+ kFunction,
+ kList,
+ };
+
+ PrimitiveType GetType() const { return m_value; }
protected:
- explicit CFX_CSSValue(CFX_CSSPrimitiveType type);
+ explicit CFX_CSSValue(PrimitiveType type);
+ ~CFX_CSSValue() override;
private:
- CFX_CSSPrimitiveType m_value;
+ const PrimitiveType m_value;
};
#endif // CORE_FXCRT_CSS_CFX_CSSVALUE_H_
diff --git a/core/fxcrt/css/cfx_cssvaluelist.cpp b/core/fxcrt/css/cfx_cssvaluelist.cpp
index 2f34ecc..0c2f0c6 100644
--- a/core/fxcrt/css/cfx_cssvaluelist.cpp
+++ b/core/fxcrt/css/cfx_cssvaluelist.cpp
@@ -11,6 +11,6 @@
#include "core/fxcrt/css/cfx_css.h"
CFX_CSSValueList::CFX_CSSValueList(std::vector<RetainPtr<CFX_CSSValue>> list)
- : CFX_CSSValue(CFX_CSSPrimitiveType::List), list_(std::move(list)) {}
+ : CFX_CSSValue(PrimitiveType::kList), list_(std::move(list)) {}
CFX_CSSValueList::~CFX_CSSValueList() = default;
diff --git a/core/fxcrt/css/cfx_cssvaluelistparser.cpp b/core/fxcrt/css/cfx_cssvaluelistparser.cpp
index 8fb10ac..af6aa3c 100644
--- a/core/fxcrt/css/cfx_cssvaluelistparser.cpp
+++ b/core/fxcrt/css/cfx_cssvaluelistparser.cpp
@@ -17,7 +17,7 @@
DCHECK(iLen > 0);
}
-bool CFX_CSSValueListParser::NextValue(CFX_CSSPrimitiveType* eType,
+bool CFX_CSSValueListParser::NextValue(CFX_CSSValue::PrimitiveType* eType,
const wchar_t** pStart,
int32_t* iLength) {
while (m_pCur < m_pEnd && (*m_pCur <= ' ' || *m_pCur == m_Separator))
@@ -26,36 +26,36 @@
if (m_pCur >= m_pEnd)
return false;
- *eType = CFX_CSSPrimitiveType::Unknown;
+ *eType = CFX_CSSValue::PrimitiveType::kUnknown;
*pStart = m_pCur;
*iLength = 0;
wchar_t wch = *m_pCur;
if (wch == '#') {
*iLength = SkipTo(' ', false, false);
if (*iLength == 4 || *iLength == 7)
- *eType = CFX_CSSPrimitiveType::RGB;
+ *eType = CFX_CSSValue::PrimitiveType::kRGB;
} else if (FXSYS_IsDecimalDigit(wch) || wch == '.' || wch == '-' ||
wch == '+') {
while (m_pCur < m_pEnd && (*m_pCur > ' ' && *m_pCur != m_Separator))
++m_pCur;
*iLength = m_pCur - *pStart;
- *eType = CFX_CSSPrimitiveType::Number;
+ *eType = CFX_CSSValue::PrimitiveType::kNumber;
} else if (wch == '\"' || wch == '\'') {
++(*pStart);
m_pCur++;
*iLength = SkipTo(wch, false, false);
m_pCur++;
- *eType = CFX_CSSPrimitiveType::String;
+ *eType = CFX_CSSValue::PrimitiveType::kString;
} else if (m_pEnd - m_pCur > 5 && m_pCur[3] == '(') {
if (FXSYS_wcsnicmp(L"rgb", m_pCur, 3) == 0) {
*iLength = SkipTo(')', false, false) + 1;
m_pCur++;
- *eType = CFX_CSSPrimitiveType::RGB;
+ *eType = CFX_CSSValue::PrimitiveType::kRGB;
}
} else {
*iLength = SkipTo(m_Separator, true, true);
- *eType = CFX_CSSPrimitiveType::String;
+ *eType = CFX_CSSValue::PrimitiveType::kString;
}
return m_pCur <= m_pEnd && *iLength > 0;
}
diff --git a/core/fxcrt/css/cfx_cssvaluelistparser.h b/core/fxcrt/css/cfx_cssvaluelistparser.h
index 6872ee2..a47d065 100644
--- a/core/fxcrt/css/cfx_cssvaluelistparser.h
+++ b/core/fxcrt/css/cfx_cssvaluelistparser.h
@@ -7,14 +7,14 @@
#ifndef CORE_FXCRT_CSS_CFX_CSSVALUELISTPARSER_H_
#define CORE_FXCRT_CSS_CFX_CSSVALUELISTPARSER_H_
-#include "core/fxcrt/css/cfx_css.h"
+#include "core/fxcrt/css/cfx_cssvalue.h"
#include "core/fxcrt/fx_system.h"
class CFX_CSSValueListParser {
public:
CFX_CSSValueListParser(const wchar_t* psz, int32_t iLen, wchar_t separator);
- bool NextValue(CFX_CSSPrimitiveType* eType,
+ bool NextValue(CFX_CSSValue::PrimitiveType* eType,
const wchar_t** pStart,
int32_t* iLength);
void UseCommaSeparator() { m_Separator = ','; }
diff --git a/core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp b/core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp
index 12765ef..3754247 100644
--- a/core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp
+++ b/core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp
@@ -12,115 +12,115 @@
#include "testing/gtest/include/gtest/gtest.h"
TEST(CFX_CSSValueListParserTest, rgb_short) {
- CFX_CSSPrimitiveType type;
+ CFX_CSSValue::PrimitiveType type;
const wchar_t* start;
int32_t len;
auto parser = std::make_unique<CFX_CSSValueListParser>(L"#abc", 4, L' ');
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::RGB, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kRGB, type);
EXPECT_EQ(L"#abc", WideString(start, len));
EXPECT_FALSE(parser->NextValue(&type, &start, &len));
parser = std::make_unique<CFX_CSSValueListParser>(L"#abcdef", 7, L' ');
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::RGB, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kRGB, type);
EXPECT_EQ(L"#abcdef", WideString(start, len));
EXPECT_FALSE(parser->NextValue(&type, &start, &len));
parser =
std::make_unique<CFX_CSSValueListParser>(L"rgb(1, 255, 4)", 14, L' ');
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::RGB, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kRGB, type);
EXPECT_EQ(L"rgb(1, 255, 4)", WideString(start, len));
parser = std::make_unique<CFX_CSSValueListParser>(L"#abcdefghij", 11, L' ');
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::Unknown, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kUnknown, type);
EXPECT_EQ(L"#abcdefghij", WideString(start, len));
EXPECT_FALSE(parser->NextValue(&type, &start, &len));
}
TEST(CFX_CSSValueListParserTest, number_parsing) {
- CFX_CSSPrimitiveType type;
+ CFX_CSSValue::PrimitiveType type;
const wchar_t* start;
int32_t len;
auto parser = std::make_unique<CFX_CSSValueListParser>(L"1234", 4, L' ');
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kNumber, type);
EXPECT_EQ(L"1234", WideString(start, len));
parser = std::make_unique<CFX_CSSValueListParser>(L"-1234", 5, L' ');
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kNumber, type);
EXPECT_EQ(L"-1234", WideString(start, len));
parser = std::make_unique<CFX_CSSValueListParser>(L"+1234", 5, L' ');
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kNumber, type);
EXPECT_EQ(L"+1234", WideString(start, len));
parser = std::make_unique<CFX_CSSValueListParser>(L".1234", 5, L' ');
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kNumber, type);
EXPECT_EQ(L".1234", WideString(start, len));
parser = std::make_unique<CFX_CSSValueListParser>(L"4321.1234", 9, L' ');
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kNumber, type);
EXPECT_EQ(L"4321.1234", WideString(start, len));
// TODO(dsinclair): These should probably fail but currently don't.
parser = std::make_unique<CFX_CSSValueListParser>(L"4321.12.34", 10, L' ');
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kNumber, type);
EXPECT_EQ(L"4321.12.34", WideString(start, len));
parser = std::make_unique<CFX_CSSValueListParser>(L"43a1.12.34", 10, L' ');
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kNumber, type);
EXPECT_EQ(L"43a1.12.34", WideString(start, len));
}
TEST(CFX_CSSValueListParserTest, string_parsing) {
- CFX_CSSPrimitiveType type;
+ CFX_CSSValue::PrimitiveType type;
const wchar_t* start;
int32_t len;
auto parser = std::make_unique<CFX_CSSValueListParser>(L"'string'", 8, L' ');
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::String, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kString, type);
EXPECT_EQ(L"string", WideString(start, len));
parser =
std::make_unique<CFX_CSSValueListParser>(L"\"another string\"", 16, L' ');
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::String, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kString, type);
EXPECT_EQ(L"another string", WideString(start, len));
parser = std::make_unique<CFX_CSSValueListParser>(L"standalone", 10, L' ');
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::String, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kString, type);
EXPECT_EQ(L"standalone", WideString(start, len));
}
TEST(CFX_CSSValueListParserTest, multiparsing) {
- CFX_CSSPrimitiveType type;
+ CFX_CSSValue::PrimitiveType type;
const wchar_t* start;
int32_t len;
auto parser = std::make_unique<CFX_CSSValueListParser>(L"1, 2, 3", 7, L',');
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kNumber, type);
EXPECT_EQ(L"1", WideString(start, len));
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kNumber, type);
EXPECT_EQ(L"2", WideString(start, len));
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kNumber, type);
EXPECT_EQ(L"3", WideString(start, len));
EXPECT_FALSE(parser->NextValue(&type, &start, &len));
@@ -128,14 +128,14 @@
parser = std::make_unique<CFX_CSSValueListParser>(L"'str', rgb(1, 2, 3), 4",
22, L',');
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::String, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kString, type);
EXPECT_EQ(L"str", WideString(start, len));
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::RGB, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kRGB, type);
EXPECT_EQ(L"rgb(1, 2, 3)", WideString(start, len));
EXPECT_TRUE(parser->NextValue(&type, &start, &len));
- EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
+ EXPECT_EQ(CFX_CSSValue::PrimitiveType::kNumber, type);
EXPECT_EQ(L"4", WideString(start, len));
}