summaryrefslogtreecommitdiff
path: root/core/fxcrt/css
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt/css')
-rw-r--r--core/fxcrt/css/cfx_cssdeclaration.cpp10
-rw-r--r--core/fxcrt/css/cfx_cssvaluelistparser.cpp38
-rw-r--r--core/fxcrt/css/cfx_cssvaluelistparser.h10
-rw-r--r--core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp48
4 files changed, 53 insertions, 53 deletions
diff --git a/core/fxcrt/css/cfx_cssdeclaration.cpp b/core/fxcrt/css/cfx_cssdeclaration.cpp
index c44c878196..90bdf4e0ea 100644
--- a/core/fxcrt/css/cfx_cssdeclaration.cpp
+++ b/core/fxcrt/css/cfx_cssdeclaration.cpp
@@ -256,7 +256,7 @@ bool CFX_CSSDeclaration::ParseCSSColor(const wchar_t* pszValue,
CFX_CSSPrimitiveType eType;
CFX_CSSValueListParser list(pszValue + 4, iValueLen - 5, ',');
for (int32_t i = 0; i < 3; ++i) {
- if (!list.NextValue(eType, pszValue, iValueLen))
+ if (!list.NextValue(&eType, &pszValue, &iValueLen))
return false;
if (eType != CFX_CSSPrimitiveType::Number)
return false;
@@ -477,7 +477,7 @@ void CFX_CSSDeclaration::ParseValueListProperty(
const uint32_t dwType = pTable->dwType;
CFX_CSSPrimitiveType eType;
std::vector<RetainPtr<CFX_CSSValue>> list;
- while (parser.NextValue(eType, pszValue, iValueLen)) {
+ while (parser.NextValue(&eType, &pszValue, &iValueLen)) {
switch (eType) {
case CFX_CSSPrimitiveType::Number:
if (dwType & CFX_CSSVALUETYPE_MaybeNumber) {
@@ -596,7 +596,7 @@ bool CFX_CSSDeclaration::ParseBorderProperty(
CFX_CSSValueListParser parser(pszValue, iValueLen, ' ');
CFX_CSSPrimitiveType eType;
- while (parser.NextValue(eType, pszValue, iValueLen)) {
+ while (parser.NextValue(&eType, &pszValue, &iValueLen)) {
switch (eType) {
case CFX_CSSPrimitiveType::Number: {
if (pWidth)
@@ -653,7 +653,7 @@ void CFX_CSSDeclaration::ParseFontProperty(const wchar_t* pszValue,
RetainPtr<CFX_CSSValue> pLineHeight;
std::vector<RetainPtr<CFX_CSSValue>> familyList;
CFX_CSSPrimitiveType eType;
- while (parser.NextValue(eType, pszValue, iValueLen)) {
+ while (parser.NextValue(&eType, &pszValue, &iValueLen)) {
switch (eType) {
case CFX_CSSPrimitiveType::String: {
const CFX_CSSPropertyValueTable* pValue =
@@ -708,7 +708,7 @@ void CFX_CSSDeclaration::ParseFontProperty(const wchar_t* pszValue,
familyList.push_back(pdfium::MakeRetain<CFX_CSSStringValue>(
WideString(pszValue, iValueLen)));
}
- parser.m_Separator = ',';
+ parser.UseCommaSeparator();
break;
}
case CFX_CSSPrimitiveType::Number: {
diff --git a/core/fxcrt/css/cfx_cssvaluelistparser.cpp b/core/fxcrt/css/cfx_cssvaluelistparser.cpp
index 05204e5621..2339dec386 100644
--- a/core/fxcrt/css/cfx_cssvaluelistparser.cpp
+++ b/core/fxcrt/css/cfx_cssvaluelistparser.cpp
@@ -15,46 +15,46 @@ CFX_CSSValueListParser::CFX_CSSValueListParser(const wchar_t* psz,
ASSERT(psz && iLen > 0);
}
-bool CFX_CSSValueListParser::NextValue(CFX_CSSPrimitiveType& eType,
- const wchar_t*& pStart,
- int32_t& iLength) {
+bool CFX_CSSValueListParser::NextValue(CFX_CSSPrimitiveType* eType,
+ const wchar_t** pStart,
+ int32_t* iLength) {
while (m_pCur < m_pEnd && (*m_pCur <= ' ' || *m_pCur == m_Separator))
++m_pCur;
if (m_pCur >= m_pEnd)
return false;
- eType = CFX_CSSPrimitiveType::Unknown;
- pStart = m_pCur;
- iLength = 0;
+ *eType = CFX_CSSPrimitiveType::Unknown;
+ *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;
+ *iLength = SkipTo(' ', false, false);
+ if (*iLength == 4 || *iLength == 7)
+ *eType = CFX_CSSPrimitiveType::RGB;
} else if (std::iswdigit(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;
+ *iLength = m_pCur - *pStart;
+ *eType = CFX_CSSPrimitiveType::Number;
} else if (wch == '\"' || wch == '\'') {
- pStart++;
+ ++(*pStart);
m_pCur++;
- iLength = SkipTo(wch, false, false);
+ *iLength = SkipTo(wch, false, false);
m_pCur++;
- eType = CFX_CSSPrimitiveType::String;
+ *eType = CFX_CSSPrimitiveType::String;
} else if (m_pEnd - m_pCur > 5 && m_pCur[3] == '(') {
if (FXSYS_wcsnicmp(L"rgb", m_pCur, 3) == 0) {
- iLength = SkipTo(')', false, false) + 1;
+ *iLength = SkipTo(')', false, false) + 1;
m_pCur++;
- eType = CFX_CSSPrimitiveType::RGB;
+ *eType = CFX_CSSPrimitiveType::RGB;
}
} else {
- iLength = SkipTo(m_Separator, true, true);
- eType = CFX_CSSPrimitiveType::String;
+ *iLength = SkipTo(m_Separator, true, true);
+ *eType = CFX_CSSPrimitiveType::String;
}
- return m_pCur <= m_pEnd && iLength > 0;
+ return m_pCur <= m_pEnd && *iLength > 0;
}
int32_t CFX_CSSValueListParser::SkipTo(wchar_t wch,
diff --git a/core/fxcrt/css/cfx_cssvaluelistparser.h b/core/fxcrt/css/cfx_cssvaluelistparser.h
index 514db9e192..6872ee278c 100644
--- a/core/fxcrt/css/cfx_cssvaluelistparser.h
+++ b/core/fxcrt/css/cfx_cssvaluelistparser.h
@@ -14,15 +14,15 @@ class CFX_CSSValueListParser {
public:
CFX_CSSValueListParser(const wchar_t* psz, int32_t iLen, wchar_t separator);
- bool NextValue(CFX_CSSPrimitiveType& eType,
- const wchar_t*& pStart,
- int32_t& iLength);
-
- wchar_t m_Separator;
+ bool NextValue(CFX_CSSPrimitiveType* eType,
+ const wchar_t** pStart,
+ int32_t* iLength);
+ void UseCommaSeparator() { m_Separator = ','; }
private:
int32_t SkipTo(wchar_t wch, bool breakOnSpace, bool matchBrackets);
+ wchar_t m_Separator;
const wchar_t* m_pCur;
const wchar_t* m_pEnd;
};
diff --git a/core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp b/core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp
index 62a542bc52..e232a2dc65 100644
--- a/core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp
+++ b/core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp
@@ -16,28 +16,28 @@ TEST(CFX_CSSValueListParserTest, rgb_short) {
int32_t len;
auto parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"#abc", 4, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::RGB, type);
EXPECT_EQ(L"#abc", WideString(start, len));
- EXPECT_FALSE(parser->NextValue(type, start, len));
+ EXPECT_FALSE(parser->NextValue(&type, &start, &len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"#abcdef", 7, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::RGB, type);
EXPECT_EQ(L"#abcdef", WideString(start, len));
- EXPECT_FALSE(parser->NextValue(type, start, len));
+ EXPECT_FALSE(parser->NextValue(&type, &start, &len));
parser =
pdfium::MakeUnique<CFX_CSSValueListParser>(L"rgb(1, 255, 4)", 14, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::RGB, type);
EXPECT_EQ(L"rgb(1, 255, 4)", WideString(start, len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"#abcdefghij", 11, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::Unknown, type);
EXPECT_EQ(L"#abcdefghij", WideString(start, len));
- EXPECT_FALSE(parser->NextValue(type, start, len));
+ EXPECT_FALSE(parser->NextValue(&type, &start, &len));
}
TEST(CFX_CSSValueListParserTest, number_parsing) {
@@ -46,38 +46,38 @@ TEST(CFX_CSSValueListParserTest, number_parsing) {
int32_t len;
auto parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"1234", 4, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
EXPECT_EQ(L"1234", WideString(start, len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"-1234", 5, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
EXPECT_EQ(L"-1234", WideString(start, len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"+1234", 5, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
EXPECT_EQ(L"+1234", WideString(start, len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L".1234", 5, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
EXPECT_EQ(L".1234", WideString(start, len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"4321.1234", 9, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
EXPECT_EQ(L"4321.1234", WideString(start, len));
// TODO(dsinclair): These should probably fail but currently don't.
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"4321.12.34", 10, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
EXPECT_EQ(L"4321.12.34", WideString(start, len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"43a1.12.34", 10, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
EXPECT_EQ(L"43a1.12.34", WideString(start, len));
}
@@ -89,18 +89,18 @@ TEST(CFX_CSSValueListParserTest, string_parsing) {
auto parser =
pdfium::MakeUnique<CFX_CSSValueListParser>(L"'string'", 8, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::String, type);
EXPECT_EQ(L"string", WideString(start, len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"\"another string\"", 16,
L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::String, type);
EXPECT_EQ(L"another string", WideString(start, len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"standalone", 10, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::String, type);
EXPECT_EQ(L"standalone", WideString(start, len));
}
@@ -111,31 +111,31 @@ TEST(CFX_CSSValueListParserTest, multiparsing) {
int32_t len;
auto parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"1, 2, 3", 7, L',');
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
EXPECT_EQ(L"1", WideString(start, len));
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
EXPECT_EQ(L"2", WideString(start, len));
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
EXPECT_EQ(L"3", WideString(start, len));
- EXPECT_FALSE(parser->NextValue(type, start, len));
+ EXPECT_FALSE(parser->NextValue(&type, &start, &len));
parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"'str', rgb(1, 2, 3), 4",
22, L',');
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::String, type);
EXPECT_EQ(L"str", WideString(start, len));
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::RGB, type);
EXPECT_EQ(L"rgb(1, 2, 3)", WideString(start, len));
- EXPECT_TRUE(parser->NextValue(type, start, len));
+ EXPECT_TRUE(parser->NextValue(&type, &start, &len));
EXPECT_EQ(CFX_CSSPrimitiveType::Number, type);
EXPECT_EQ(L"4", WideString(start, len));
}