summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD.gn12
-rw-r--r--xfa/fde/css/cfde_csscolorvalue.cpp12
-rw-r--r--xfa/fde/css/cfde_csscolorvalue.h23
-rw-r--r--xfa/fde/css/cfde_cssenumvalue.cpp12
-rw-r--r--xfa/fde/css/cfde_cssenumvalue.h23
-rw-r--r--xfa/fde/css/cfde_cssnumbervalue.cpp39
-rw-r--r--xfa/fde/css/cfde_cssnumbervalue.h41
-rw-r--r--xfa/fde/css/cfde_cssstringvalue.cpp12
-rw-r--r--xfa/fde/css/cfde_cssstringvalue.h23
-rw-r--r--xfa/fde/css/cfde_cssstylesheet_unittest.cpp61
-rw-r--r--xfa/fde/css/cfde_cssvalue.cpp2
-rw-r--r--xfa/fde/css/cfde_cssvalue.h6
-rw-r--r--xfa/fde/css/cfde_cssvaluelist.cpp25
-rw-r--r--xfa/fde/css/cfde_cssvaluelist.h26
-rw-r--r--xfa/fde/css/cfde_cssvaluelistparser.cpp116
-rw-r--r--xfa/fde/css/cfde_cssvaluelistparser.h33
-rw-r--r--xfa/fde/css/fde_css.h15
-rw-r--r--xfa/fde/css/fde_cssdatatable.cpp225
-rw-r--r--xfa/fde/css/fde_cssdatatable.h85
-rw-r--r--xfa/fde/css/fde_cssdeclaration.cpp209
-rw-r--r--xfa/fde/css/fde_cssdeclaration.h11
-rw-r--r--xfa/fde/css/fde_cssstyleselector.cpp241
-rw-r--r--xfa/fde/css/fde_cssstyleselector.h8
-rw-r--r--xfa/fxfa/app/cxfa_textparser.cpp4
24 files changed, 636 insertions, 628 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 6281eee909..7f1a5f8df5 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1143,11 +1143,23 @@ if (pdf_enable_xfa) {
"xfa/fde/cfx_chariter.h",
"xfa/fde/cfx_wordbreak.cpp",
"xfa/fde/cfx_wordbreak.h",
+ "xfa/fde/css/cfde_csscolorvalue.cpp",
+ "xfa/fde/css/cfde_csscolorvalue.h",
+ "xfa/fde/css/cfde_cssenumvalue.cpp",
+ "xfa/fde/css/cfde_cssenumvalue.h",
+ "xfa/fde/css/cfde_cssnumbervalue.cpp",
+ "xfa/fde/css/cfde_cssnumbervalue.h",
"xfa/fde/css/cfde_cssrule.cpp",
"xfa/fde/css/cfde_cssrule.h",
"xfa/fde/css/cfde_cssrulecollection.cpp",
+ "xfa/fde/css/cfde_cssstringvalue.cpp",
+ "xfa/fde/css/cfde_cssstringvalue.h",
"xfa/fde/css/cfde_cssvalue.cpp",
"xfa/fde/css/cfde_cssvalue.h",
+ "xfa/fde/css/cfde_cssvaluelist.cpp",
+ "xfa/fde/css/cfde_cssvaluelist.h",
+ "xfa/fde/css/cfde_cssvaluelistparser.cpp",
+ "xfa/fde/css/cfde_cssvaluelistparser.h",
"xfa/fde/css/fde_css.h",
"xfa/fde/css/fde_csscache.cpp",
"xfa/fde/css/fde_csscache.h",
diff --git a/xfa/fde/css/cfde_csscolorvalue.cpp b/xfa/fde/css/cfde_csscolorvalue.cpp
new file mode 100644
index 0000000000..015355136c
--- /dev/null
+++ b/xfa/fde/css/cfde_csscolorvalue.cpp
@@ -0,0 +1,12 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fde/css/cfde_csscolorvalue.h"
+
+CFDE_CSSColorValue::CFDE_CSSColorValue(FX_ARGB value)
+ : CFDE_CSSValue(FDE_CSSPrimitiveType::RGB), value_(value) {}
+
+CFDE_CSSColorValue::~CFDE_CSSColorValue() {}
diff --git a/xfa/fde/css/cfde_csscolorvalue.h b/xfa/fde/css/cfde_csscolorvalue.h
new file mode 100644
index 0000000000..1d0441ad2a
--- /dev/null
+++ b/xfa/fde/css/cfde_csscolorvalue.h
@@ -0,0 +1,23 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FDE_CSS_CFDE_CSSCOLORVALUE_H_
+#define XFA_FDE_CSS_CFDE_CSSCOLORVALUE_H_
+
+#include "xfa/fde/css/cfde_cssvalue.h"
+
+class CFDE_CSSColorValue : public CFDE_CSSValue {
+ public:
+ explicit CFDE_CSSColorValue(FX_ARGB color);
+ ~CFDE_CSSColorValue() override;
+
+ FX_ARGB Value() const { return value_; }
+
+ private:
+ FX_ARGB value_;
+};
+
+#endif // XFA_FDE_CSS_CFDE_CSSCOLORVALUE_H_
diff --git a/xfa/fde/css/cfde_cssenumvalue.cpp b/xfa/fde/css/cfde_cssenumvalue.cpp
new file mode 100644
index 0000000000..c6b9d3ff73
--- /dev/null
+++ b/xfa/fde/css/cfde_cssenumvalue.cpp
@@ -0,0 +1,12 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fde/css/cfde_cssenumvalue.h"
+
+CFDE_CSSEnumValue::CFDE_CSSEnumValue(FDE_CSSPropertyValue value)
+ : CFDE_CSSValue(FDE_CSSPrimitiveType::Enum), value_(value) {}
+
+CFDE_CSSEnumValue::~CFDE_CSSEnumValue() {}
diff --git a/xfa/fde/css/cfde_cssenumvalue.h b/xfa/fde/css/cfde_cssenumvalue.h
new file mode 100644
index 0000000000..9fb1b69ef5
--- /dev/null
+++ b/xfa/fde/css/cfde_cssenumvalue.h
@@ -0,0 +1,23 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FDE_CSS_CFDE_CSSENUMVALUE_H_
+#define XFA_FDE_CSS_CFDE_CSSENUMVALUE_H_
+
+#include "xfa/fde/css/cfde_cssvalue.h"
+
+class CFDE_CSSEnumValue : public CFDE_CSSValue {
+ public:
+ explicit CFDE_CSSEnumValue(FDE_CSSPropertyValue value);
+ ~CFDE_CSSEnumValue() override;
+
+ FDE_CSSPropertyValue Value() const { return value_; }
+
+ private:
+ FDE_CSSPropertyValue value_;
+};
+
+#endif // XFA_FDE_CSS_CFDE_CSSENUMVALUE_H_
diff --git a/xfa/fde/css/cfde_cssnumbervalue.cpp b/xfa/fde/css/cfde_cssnumbervalue.cpp
new file mode 100644
index 0000000000..71566ca5a3
--- /dev/null
+++ b/xfa/fde/css/cfde_cssnumbervalue.cpp
@@ -0,0 +1,39 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fde/css/cfde_cssnumbervalue.h"
+
+CFDE_CSSNumberValue::CFDE_CSSNumberValue(FDE_CSSNumberType type, FX_FLOAT value)
+ : CFDE_CSSValue(FDE_CSSPrimitiveType::Number), type_(type), value_(value) {
+ if (type_ == FDE_CSSNumberType::Number && FXSYS_fabs(value_) < 0.001f)
+ value_ = 0.0f;
+}
+
+CFDE_CSSNumberValue::~CFDE_CSSNumberValue() {}
+
+FX_FLOAT CFDE_CSSNumberValue::Apply(FX_FLOAT percentBase) const {
+ switch (type_) {
+ case FDE_CSSNumberType::Pixels:
+ case FDE_CSSNumberType::Number:
+ return value_ * 72 / 96;
+ case FDE_CSSNumberType::EMS:
+ case FDE_CSSNumberType::EXS:
+ return value_ * percentBase;
+ case FDE_CSSNumberType::Percent:
+ return value_ * percentBase / 100.0f;
+ case FDE_CSSNumberType::CentiMeters:
+ return value_ * 28.3464f;
+ case FDE_CSSNumberType::MilliMeters:
+ return value_ * 2.8346f;
+ case FDE_CSSNumberType::Inches:
+ return value_ * 72.0f;
+ case FDE_CSSNumberType::Picas:
+ return value_ / 12.0f;
+ case FDE_CSSNumberType::Points:
+ return value_;
+ }
+ return value_;
+}
diff --git a/xfa/fde/css/cfde_cssnumbervalue.h b/xfa/fde/css/cfde_cssnumbervalue.h
new file mode 100644
index 0000000000..29e562e1e3
--- /dev/null
+++ b/xfa/fde/css/cfde_cssnumbervalue.h
@@ -0,0 +1,41 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FDE_CSS_CFDE_CSSNUMBERVALUE_H_
+#define XFA_FDE_CSS_CFDE_CSSNUMBERVALUE_H_
+
+#include "core/fxcrt/fx_system.h"
+#include "xfa/fde/css/cfde_cssvalue.h"
+
+enum class FDE_CSSNumberType {
+ Number,
+ Percent,
+ EMS,
+ EXS,
+ Pixels,
+ CentiMeters,
+ MilliMeters,
+ Inches,
+ Points,
+ Picas,
+};
+
+class CFDE_CSSNumberValue : public CFDE_CSSValue {
+ public:
+ CFDE_CSSNumberValue(FDE_CSSNumberType type, FX_FLOAT value);
+ ~CFDE_CSSNumberValue() override;
+
+ FX_FLOAT Value() const { return value_; }
+ FDE_CSSNumberType Kind() const { return type_; }
+
+ FX_FLOAT Apply(FX_FLOAT percentBase) const;
+
+ private:
+ FDE_CSSNumberType type_;
+ FX_FLOAT value_;
+};
+
+#endif // XFA_FDE_CSS_CFDE_CSSNUMBERVALUE_H_
diff --git a/xfa/fde/css/cfde_cssstringvalue.cpp b/xfa/fde/css/cfde_cssstringvalue.cpp
new file mode 100644
index 0000000000..deb9be3dc0
--- /dev/null
+++ b/xfa/fde/css/cfde_cssstringvalue.cpp
@@ -0,0 +1,12 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fde/css/cfde_cssstringvalue.h"
+
+CFDE_CSSStringValue::CFDE_CSSStringValue(const CFX_WideString& value)
+ : CFDE_CSSValue(FDE_CSSPrimitiveType::String), value_(value) {}
+
+CFDE_CSSStringValue::~CFDE_CSSStringValue() {}
diff --git a/xfa/fde/css/cfde_cssstringvalue.h b/xfa/fde/css/cfde_cssstringvalue.h
new file mode 100644
index 0000000000..33328cf52b
--- /dev/null
+++ b/xfa/fde/css/cfde_cssstringvalue.h
@@ -0,0 +1,23 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FDE_CSS_CFDE_CSSSTRINGVALUE_H_
+#define XFA_FDE_CSS_CFDE_CSSSTRINGVALUE_H_
+
+#include "xfa/fde/css/cfde_cssvalue.h"
+
+class CFDE_CSSStringValue : public CFDE_CSSValue {
+ public:
+ explicit CFDE_CSSStringValue(const CFX_WideString& value);
+ ~CFDE_CSSStringValue() override;
+
+ const CFX_WideString Value() const { return value_; }
+
+ private:
+ const CFX_WideString value_;
+};
+
+#endif // XFA_FDE_CSS_CFDE_CSSSTRINGVALUE_H_
diff --git a/xfa/fde/css/cfde_cssstylesheet_unittest.cpp b/xfa/fde/css/cfde_cssstylesheet_unittest.cpp
index 3715ef7005..e65e36d252 100644
--- a/xfa/fde/css/cfde_cssstylesheet_unittest.cpp
+++ b/xfa/fde/css/cfde_cssstylesheet_unittest.cpp
@@ -12,6 +12,9 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
+#include "xfa/fde/css/cfde_cssenumvalue.h"
+#include "xfa/fde/css/cfde_cssnumbervalue.h"
+#include "xfa/fde/css/cfde_cssvaluelist.h"
class CFDE_CSSStyleSheetTest : public testing::Test {
public:
@@ -45,14 +48,14 @@ class CFDE_CSSStyleSheetTest : public testing::Test {
EXPECT_EQ(decl_->PropertyCountForTesting(), decl_count);
}
- void VerifyFloat(FDE_CSSProperty prop, float val, FDE_CSSPrimitiveType type) {
+ void VerifyFloat(FDE_CSSProperty prop, float val, FDE_CSSNumberType type) {
ASSERT(decl_);
bool important;
CFDE_CSSValue* v = decl_->GetProperty(prop, important);
- CFDE_CSSPrimitiveValue* pval = static_cast<CFDE_CSSPrimitiveValue*>(v);
- EXPECT_EQ(pval->GetPrimitiveType(), type);
- EXPECT_EQ(pval->GetFloat(), val);
+ EXPECT_EQ(v->GetType(), FDE_CSSPrimitiveType::Number);
+ EXPECT_EQ(static_cast<CFDE_CSSNumberValue*>(v)->Kind(), type);
+ EXPECT_EQ(static_cast<CFDE_CSSNumberValue*>(v)->Value(), val);
}
void VerifyEnum(FDE_CSSProperty prop, FDE_CSSPropertyValue val) {
@@ -60,9 +63,8 @@ class CFDE_CSSStyleSheetTest : public testing::Test {
bool important;
CFDE_CSSValue* v = decl_->GetProperty(prop, important);
- CFDE_CSSPrimitiveValue* pval = static_cast<CFDE_CSSPrimitiveValue*>(v);
- EXPECT_EQ(pval->GetPrimitiveType(), FDE_CSSPrimitiveType::Enum);
- EXPECT_EQ(pval->GetEnum(), val);
+ EXPECT_EQ(v->GetType(), FDE_CSSPrimitiveType::Enum);
+ EXPECT_EQ(static_cast<CFDE_CSSEnumValue*>(v)->Value(), val);
}
void VerifyList(FDE_CSSProperty prop,
@@ -76,9 +78,8 @@ class CFDE_CSSStyleSheetTest : public testing::Test {
for (size_t i = 0; i < values.size(); i++) {
CFDE_CSSValue* val = list->GetValue(i);
- CFDE_CSSPrimitiveValue* pval = static_cast<CFDE_CSSPrimitiveValue*>(val);
- EXPECT_EQ(pval->GetPrimitiveType(), FDE_CSSPrimitiveType::Enum);
- EXPECT_EQ(pval->GetEnum(), values[i]);
+ EXPECT_EQ(val->GetType(), FDE_CSSPrimitiveType::Enum);
+ EXPECT_EQ(static_cast<CFDE_CSSEnumValue*>(val)->Value(), values[i]);
}
}
@@ -112,13 +113,12 @@ TEST_F(CFDE_CSSStyleSheetTest, ParseMultipleSelectors) {
EXPECT_EQ(4UL, decl_->PropertyCountForTesting());
VerifyFloat(FDE_CSSProperty::BorderLeftWidth, 10.0,
- FDE_CSSPrimitiveType::Pixels);
+ FDE_CSSNumberType::Pixels);
VerifyFloat(FDE_CSSProperty::BorderRightWidth, 10.0,
- FDE_CSSPrimitiveType::Pixels);
- VerifyFloat(FDE_CSSProperty::BorderTopWidth, 10.0,
- FDE_CSSPrimitiveType::Pixels);
+ FDE_CSSNumberType::Pixels);
+ VerifyFloat(FDE_CSSProperty::BorderTopWidth, 10.0, FDE_CSSNumberType::Pixels);
VerifyFloat(FDE_CSSProperty::BorderBottomWidth, 10.0,
- FDE_CSSPrimitiveType::Pixels);
+ FDE_CSSNumberType::Pixels);
rule = sheet_->GetRule(1);
EXPECT_EQ(FDE_CSSRuleType::Style, rule->GetType());
@@ -160,32 +160,27 @@ TEST_F(CFDE_CSSStyleSheetTest, ParseWithSelectorsAndPseudo) {
TEST_F(CFDE_CSSStyleSheetTest, ParseBorder) {
LoadAndVerifyDecl(L"a { border: 5px; }", {L"a"}, 4);
- VerifyFloat(FDE_CSSProperty::BorderLeftWidth, 5.0,
- FDE_CSSPrimitiveType::Pixels);
+ VerifyFloat(FDE_CSSProperty::BorderLeftWidth, 5.0, FDE_CSSNumberType::Pixels);
VerifyFloat(FDE_CSSProperty::BorderRightWidth, 5.0,
- FDE_CSSPrimitiveType::Pixels);
- VerifyFloat(FDE_CSSProperty::BorderTopWidth, 5.0,
- FDE_CSSPrimitiveType::Pixels);
+ FDE_CSSNumberType::Pixels);
+ VerifyFloat(FDE_CSSProperty::BorderTopWidth, 5.0, FDE_CSSNumberType::Pixels);
VerifyFloat(FDE_CSSProperty::BorderBottomWidth, 5.0,
- FDE_CSSPrimitiveType::Pixels);
+ FDE_CSSNumberType::Pixels);
}
TEST_F(CFDE_CSSStyleSheetTest, ParseBorderFull) {
LoadAndVerifyDecl(L"a { border: 5px solid red; }", {L"a"}, 4);
- VerifyFloat(FDE_CSSProperty::BorderLeftWidth, 5.0,
- FDE_CSSPrimitiveType::Pixels);
+ VerifyFloat(FDE_CSSProperty::BorderLeftWidth, 5.0, FDE_CSSNumberType::Pixels);
VerifyFloat(FDE_CSSProperty::BorderRightWidth, 5.0,
- FDE_CSSPrimitiveType::Pixels);
- VerifyFloat(FDE_CSSProperty::BorderTopWidth, 5.0,
- FDE_CSSPrimitiveType::Pixels);
+ FDE_CSSNumberType::Pixels);
+ VerifyFloat(FDE_CSSProperty::BorderTopWidth, 5.0, FDE_CSSNumberType::Pixels);
VerifyFloat(FDE_CSSProperty::BorderBottomWidth, 5.0,
- FDE_CSSPrimitiveType::Pixels);
+ FDE_CSSNumberType::Pixels);
}
TEST_F(CFDE_CSSStyleSheetTest, ParseBorderLeft) {
LoadAndVerifyDecl(L"a { border-left: 2.5pc; }", {L"a"}, 1);
- VerifyFloat(FDE_CSSProperty::BorderLeftWidth, 2.5,
- FDE_CSSPrimitiveType::Picas);
+ VerifyFloat(FDE_CSSProperty::BorderLeftWidth, 2.5, FDE_CSSNumberType::Picas);
}
TEST_F(CFDE_CSSStyleSheetTest, ParseBorderLeftThick) {
@@ -195,18 +190,16 @@ TEST_F(CFDE_CSSStyleSheetTest, ParseBorderLeftThick) {
TEST_F(CFDE_CSSStyleSheetTest, ParseBorderRight) {
LoadAndVerifyDecl(L"a { border-right: 2.5pc; }", {L"a"}, 1);
- VerifyFloat(FDE_CSSProperty::BorderRightWidth, 2.5,
- FDE_CSSPrimitiveType::Picas);
+ VerifyFloat(FDE_CSSProperty::BorderRightWidth, 2.5, FDE_CSSNumberType::Picas);
}
TEST_F(CFDE_CSSStyleSheetTest, ParseBorderTop) {
LoadAndVerifyDecl(L"a { border-top: 2.5pc; }", {L"a"}, 1);
- VerifyFloat(FDE_CSSProperty::BorderTopWidth, 2.5,
- FDE_CSSPrimitiveType::Picas);
+ VerifyFloat(FDE_CSSProperty::BorderTopWidth, 2.5, FDE_CSSNumberType::Picas);
}
TEST_F(CFDE_CSSStyleSheetTest, ParseBorderBottom) {
LoadAndVerifyDecl(L"a { border-bottom: 2.5pc; }", {L"a"}, 1);
VerifyFloat(FDE_CSSProperty::BorderBottomWidth, 2.5,
- FDE_CSSPrimitiveType::Picas);
+ FDE_CSSNumberType::Picas);
}
diff --git a/xfa/fde/css/cfde_cssvalue.cpp b/xfa/fde/css/cfde_cssvalue.cpp
index 0dc577beb0..ef7029f9a5 100644
--- a/xfa/fde/css/cfde_cssvalue.cpp
+++ b/xfa/fde/css/cfde_cssvalue.cpp
@@ -6,4 +6,4 @@
#include "xfa/fde/css/cfde_cssvalue.h"
-CFDE_CSSValue::CFDE_CSSValue(FDE_CSSVALUETYPE type) : m_value(type) {}
+CFDE_CSSValue::CFDE_CSSValue(FDE_CSSPrimitiveType type) : m_value(type) {}
diff --git a/xfa/fde/css/cfde_cssvalue.h b/xfa/fde/css/cfde_cssvalue.h
index a5ac24c38a..71d254bbea 100644
--- a/xfa/fde/css/cfde_cssvalue.h
+++ b/xfa/fde/css/cfde_cssvalue.h
@@ -11,13 +11,13 @@
class CFDE_CSSValue : public CFX_Retainable {
public:
- FDE_CSSVALUETYPE GetType() const { return m_value; }
+ FDE_CSSPrimitiveType GetType() const { return m_value; }
protected:
- explicit CFDE_CSSValue(FDE_CSSVALUETYPE type);
+ explicit CFDE_CSSValue(FDE_CSSPrimitiveType type);
private:
- FDE_CSSVALUETYPE m_value;
+ FDE_CSSPrimitiveType m_value;
};
#endif // XFA_FDE_CSS_CFDE_CSSVALUE_H_
diff --git a/xfa/fde/css/cfde_cssvaluelist.cpp b/xfa/fde/css/cfde_cssvaluelist.cpp
new file mode 100644
index 0000000000..64ffb9a174
--- /dev/null
+++ b/xfa/fde/css/cfde_cssvaluelist.cpp
@@ -0,0 +1,25 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fde/css/cfde_cssvaluelist.h"
+
+#include <utility>
+
+#include "xfa/fde/css/fde_css.h"
+
+CFDE_CSSValueList::CFDE_CSSValueList(
+ std::vector<CFX_RetainPtr<CFDE_CSSValue>>& list)
+ : CFDE_CSSValue(FDE_CSSPrimitiveType::List), m_ppList(std::move(list)) {}
+
+CFDE_CSSValueList::~CFDE_CSSValueList() {}
+
+int32_t CFDE_CSSValueList::CountValues() const {
+ return m_ppList.size();
+}
+
+CFDE_CSSValue* CFDE_CSSValueList::GetValue(int32_t index) const {
+ return m_ppList[index].Get();
+}
diff --git a/xfa/fde/css/cfde_cssvaluelist.h b/xfa/fde/css/cfde_cssvaluelist.h
new file mode 100644
index 0000000000..117b925678
--- /dev/null
+++ b/xfa/fde/css/cfde_cssvaluelist.h
@@ -0,0 +1,26 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FDE_CSS_CFDE_CSSVALUELIST_H_
+#define XFA_FDE_CSS_CFDE_CSSVALUELIST_H_
+
+#include <vector>
+
+#include "xfa/fde/css/cfde_cssvalue.h"
+
+class CFDE_CSSValueList : public CFDE_CSSValue {
+ public:
+ explicit CFDE_CSSValueList(std::vector<CFX_RetainPtr<CFDE_CSSValue>>& list);
+ ~CFDE_CSSValueList() override;
+
+ int32_t CountValues() const;
+ CFDE_CSSValue* GetValue(int32_t index) const;
+
+ protected:
+ std::vector<CFX_RetainPtr<CFDE_CSSValue>> m_ppList;
+};
+
+#endif // XFA_FDE_CSS_CFDE_CSSVALUELIST_H_
diff --git a/xfa/fde/css/cfde_cssvaluelistparser.cpp b/xfa/fde/css/cfde_cssvaluelistparser.cpp
new file mode 100644
index 0000000000..3c204b0d2b
--- /dev/null
+++ b/xfa/fde/css/cfde_cssvaluelistparser.cpp
@@ -0,0 +1,116 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fde/css/cfde_cssvaluelistparser.h"
+
+CFDE_CSSValueListParser::CFDE_CSSValueListParser(const FX_WCHAR* psz,
+ int32_t iLen,
+ FX_WCHAR separator)
+ : m_Separator(separator), m_pCur(psz), m_pEnd(psz + iLen) {
+ ASSERT(psz && iLen > 0);
+}
+
+bool CFDE_CSSValueListParser::NextValue(FDE_CSSPrimitiveType& eType,
+ const FX_WCHAR*& 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 = FDE_CSSPrimitiveType::Unknown;
+ pStart = m_pCur;
+ iLength = 0;
+ FX_WCHAR wch = *m_pCur;
+ if (wch == '#') {
+ iLength = SkipTo(' ');
+ if (iLength == 4 || iLength == 7) {
+ eType = FDE_CSSPrimitiveType::RGB;
+ }
+ } else if ((wch >= '0' && wch <= '9') || wch == '.' || wch == '-' ||
+ wch == '+') {
+ while (m_pCur < m_pEnd && (*m_pCur > ' ' && *m_pCur != m_Separator)) {
+ ++m_pCur;
+ }
+ iLength = m_pCur - pStart;
+ if (iLength > 0) {
+ eType = FDE_CSSPrimitiveType::Number;
+ }
+ } else if (wch == '\"' || wch == '\'') {
+ pStart++;
+ iLength = SkipTo(wch) - 1;
+ m_pCur++;
+ eType = FDE_CSSPrimitiveType::String;
+ } else if (m_pEnd - m_pCur > 5 && m_pCur[3] == '(') {
+ if (FXSYS_wcsnicmp(L"url", m_pCur, 3) == 0) {
+ wch = m_pCur[4];
+ if (wch == '\"' || wch == '\'') {
+ pStart += 5;
+ iLength = SkipTo(wch) - 6;
+ m_pCur += 2;
+ } else {
+ pStart += 4;
+ iLength = SkipTo(')') - 4;
+ m_pCur++;
+ }
+ eType = FDE_CSSPrimitiveType::String;
+ } else if (FXSYS_wcsnicmp(L"rgb", m_pCur, 3) == 0) {
+ iLength = SkipTo(')') + 1;
+ m_pCur++;
+ eType = FDE_CSSPrimitiveType::RGB;
+ }
+ } else {
+ iLength = SkipTo(m_Separator, true, true);
+ eType = FDE_CSSPrimitiveType::String;
+ }
+ return m_pCur <= m_pEnd && iLength > 0;
+}
+int32_t CFDE_CSSValueListParser::SkipTo(FX_WCHAR wch,
+ bool bWSSeparator,
+ bool bBrContinue) {
+ const FX_WCHAR* pStart = m_pCur;
+ if (!bBrContinue) {
+ if (bWSSeparator) {
+ while ((++m_pCur < m_pEnd) && (*m_pCur != wch) && (*m_pCur > ' ')) {
+ continue;
+ }
+ } else {
+ while (++m_pCur < m_pEnd && *m_pCur != wch) {
+ continue;
+ }
+ }
+
+ } else {
+ int32_t iBracketCount = 0;
+ if (bWSSeparator) {
+ while ((m_pCur < m_pEnd) && (*m_pCur != wch) && (*m_pCur > ' ')) {
+ if (*m_pCur == '(') {
+ iBracketCount++;
+ } else if (*m_pCur == ')') {
+ iBracketCount--;
+ }
+ m_pCur++;
+ }
+ } else {
+ while (m_pCur < m_pEnd && *m_pCur != wch) {
+ if (*m_pCur == '(') {
+ iBracketCount++;
+ } else if (*m_pCur == ')') {
+ iBracketCount--;
+ }
+ m_pCur++;
+ }
+ }
+ while (iBracketCount > 0 && m_pCur < m_pEnd) {
+ if (*m_pCur == ')') {
+ iBracketCount--;
+ }
+ m_pCur++;
+ }
+ }
+ return m_pCur - pStart;
+}
diff --git a/xfa/fde/css/cfde_cssvaluelistparser.h b/xfa/fde/css/cfde_cssvaluelistparser.h
new file mode 100644
index 0000000000..731ac3c84b
--- /dev/null
+++ b/xfa/fde/css/cfde_cssvaluelistparser.h
@@ -0,0 +1,33 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FDE_CSS_CFDE_CSSVALUELISTPARSER_H_
+#define XFA_FDE_CSS_CFDE_CSSVALUELISTPARSER_H_
+
+#include "core/fxcrt/fx_system.h"
+#include "xfa/fde/css/fde_css.h"
+
+class CFDE_CSSValueListParser {
+ public:
+ CFDE_CSSValueListParser(const FX_WCHAR* psz,
+ int32_t iLen,
+ FX_WCHAR separator);
+
+ bool NextValue(FDE_CSSPrimitiveType& eType,
+ const FX_WCHAR*& pStart,
+ int32_t& iLength);
+ FX_WCHAR m_Separator;
+
+ protected:
+ int32_t SkipTo(FX_WCHAR wch,
+ bool bWSSeparator = false,
+ bool bBrContinue = false);
+
+ const FX_WCHAR* m_pCur;
+ const FX_WCHAR* m_pEnd;
+};
+
+#endif // XFA_FDE_CSS_CFDE_CSSVALUELISTPARSER_H_
diff --git a/xfa/fde/css/fde_css.h b/xfa/fde/css/fde_css.h
index b18a67f238..f9bd7673ad 100644
--- a/xfa/fde/css/fde_css.h
+++ b/xfa/fde/css/fde_css.h
@@ -31,29 +31,18 @@ enum FDE_CSSVALUETYPE {
// Note the values below this comment must be > 0x0F so we can mask the above.
FDE_CSSVALUETYPE_MaybeNumber = 1 << 4,
FDE_CSSVALUETYPE_MaybeEnum = 1 << 5,
- FDE_CSSVALUETYPE_MaybeURI = 1 << 6,
FDE_CSSVALUETYPE_MaybeString = 1 << 7,
- FDE_CSSVALUETYPE_MaybeColor = 1 << 8,
- FDE_CSSVALUETYPE_MaybeFunction = 1 << 9
+ FDE_CSSVALUETYPE_MaybeColor = 1 << 8
};
enum class FDE_CSSPrimitiveType : uint8_t {
Unknown = 0,
Number,
- Percent,
- EMS,
- EXS,
- Pixels,
- CentiMeters,
- MilliMeters,
- Inches,
- Points,
- Picas,
String,
- URI,
RGB,
Enum,
Function,
+ List,
};
enum class FDE_CSSPropertyValue : uint8_t {
diff --git a/xfa/fde/css/fde_cssdatatable.cpp b/xfa/fde/css/fde_cssdatatable.cpp
index 82a29e2f06..d645e2e508 100644
--- a/xfa/fde/css/fde_cssdatatable.cpp
+++ b/xfa/fde/css/fde_cssdatatable.cpp
@@ -9,6 +9,7 @@
#include <utility>
#include "core/fxcrt/fx_ext.h"
+#include "xfa/fde/css/cfde_cssvaluelistparser.h"
#include "xfa/fde/css/fde_cssstyleselector.h"
#include "xfa/fgas/crt/fgas_codepage.h"
@@ -275,14 +276,14 @@ static const FDE_CSSMEDIATYPETABLE g_FDE_CSSMediaTypes[] = {
};
static const FDE_CSSLengthUnitTable g_FDE_CSSLengthUnits[] = {
- {0x0672, FDE_CSSPrimitiveType::EMS},
- {0x067D, FDE_CSSPrimitiveType::EXS},
- {0x1AF7, FDE_CSSPrimitiveType::Inches},
- {0x2F7A, FDE_CSSPrimitiveType::MilliMeters},
- {0x3ED3, FDE_CSSPrimitiveType::Picas},
- {0x3EE4, FDE_CSSPrimitiveType::Points},
- {0x3EE8, FDE_CSSPrimitiveType::Pixels},
- {0xFC30, FDE_CSSPrimitiveType::CentiMeters},
+ {0x0672, FDE_CSSNumberType::EMS},
+ {0x067D, FDE_CSSNumberType::EXS},
+ {0x1AF7, FDE_CSSNumberType::Inches},
+ {0x2F7A, FDE_CSSNumberType::MilliMeters},
+ {0x3ED3, FDE_CSSNumberType::Picas},
+ {0x3EE4, FDE_CSSNumberType::Points},
+ {0x3EE8, FDE_CSSNumberType::Pixels},
+ {0xFC30, FDE_CSSNumberType::CentiMeters},
};
static const FDE_CSSCOLORTABLE g_FDE_CSSColors[] = {
@@ -424,7 +425,7 @@ const FDE_CSSCOLORTABLE* FDE_GetCSSColorByName(const CFX_WideStringC& wsName) {
bool FDE_ParseCSSNumber(const FX_WCHAR* pszValue,
int32_t iValueLen,
FX_FLOAT& fValue,
- FDE_CSSPrimitiveType& eUnit) {
+ FDE_CSSNumberType& eUnit) {
ASSERT(pszValue && iValueLen > 0);
int32_t iUsedLen = 0;
fValue = FXSYS_wcstof(pszValue, iValueLen, &iUsedLen);
@@ -433,9 +434,9 @@ bool FDE_ParseCSSNumber(const FX_WCHAR* pszValue,
iValueLen -= iUsedLen;
pszValue += iUsedLen;
- eUnit = FDE_CSSPrimitiveType::Number;
+ eUnit = FDE_CSSNumberType::Number;
if (iValueLen >= 1 && *pszValue == '%') {
- eUnit = FDE_CSSPrimitiveType::Percent;
+ eUnit = FDE_CSSNumberType::Percent;
} else if (iValueLen == 2) {
const FDE_CSSLengthUnitTable* pUnit =
FDE_GetCSSLengthUnitByName(CFX_WideStringC(pszValue, 2));
@@ -516,10 +517,11 @@ bool FDE_ParseCSSColor(const FX_WCHAR* pszValue,
return false;
if (eType != FDE_CSSPrimitiveType::Number)
return false;
- if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType))
+ FDE_CSSNumberType eNumType;
+ if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eNumType))
return false;
- rgb[i] = eType == FDE_CSSPrimitiveType::Percent
+ rgb[i] = eNumType == FDE_CSSNumberType::Percent
? FXSYS_round(fValue * 2.55f)
: FXSYS_round(fValue);
}
@@ -536,200 +538,3 @@ bool FDE_ParseCSSColor(const FX_WCHAR* pszValue,
return true;
}
-CFDE_CSSValueList::CFDE_CSSValueList(
- std::vector<CFX_RetainPtr<CFDE_CSSValue>>& list)
- : CFDE_CSSValue(FDE_CSSVALUETYPE_List), m_ppList(std::move(list)) {}
-
-CFDE_CSSValueList::~CFDE_CSSValueList() {}
-
-int32_t CFDE_CSSValueList::CountValues() const {
- return m_ppList.size();
-}
-
-CFDE_CSSValue* CFDE_CSSValueList::GetValue(int32_t index) const {
- return m_ppList[index].Get();
-}
-
-bool CFDE_CSSValueListParser::NextValue(FDE_CSSPrimitiveType& eType,
- const FX_WCHAR*& 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 = FDE_CSSPrimitiveType::Unknown;
- pStart = m_pCur;
- iLength = 0;
- FX_WCHAR wch = *m_pCur;
- if (wch == '#') {
- iLength = SkipTo(' ');
- if (iLength == 4 || iLength == 7) {
- eType = FDE_CSSPrimitiveType::RGB;
- }
- } else if ((wch >= '0' && wch <= '9') || wch == '.' || wch == '-' ||
- wch == '+') {
- while (m_pCur < m_pEnd && (*m_pCur > ' ' && *m_pCur != m_Separator)) {
- ++m_pCur;
- }
- iLength = m_pCur - pStart;
- if (iLength > 0) {
- eType = FDE_CSSPrimitiveType::Number;
- }
- } else if (wch == '\"' || wch == '\'') {
- pStart++;
- iLength = SkipTo(wch) - 1;
- m_pCur++;
- eType = FDE_CSSPrimitiveType::String;
- } else if (m_pEnd - m_pCur > 5 && m_pCur[3] == '(') {
- if (FXSYS_wcsnicmp(L"url", m_pCur, 3) == 0) {
- wch = m_pCur[4];
- if (wch == '\"' || wch == '\'') {
- pStart += 5;
- iLength = SkipTo(wch) - 6;
- m_pCur += 2;
- } else {
- pStart += 4;
- iLength = SkipTo(')') - 4;
- m_pCur++;
- }
- eType = FDE_CSSPrimitiveType::URI;
- } else if (FXSYS_wcsnicmp(L"rgb", m_pCur, 3) == 0) {
- iLength = SkipTo(')') + 1;
- m_pCur++;
- eType = FDE_CSSPrimitiveType::RGB;
- }
- } else {
- iLength = SkipTo(m_Separator, true, true);
- eType = FDE_CSSPrimitiveType::String;
- }
- return m_pCur <= m_pEnd && iLength > 0;
-}
-int32_t CFDE_CSSValueListParser::SkipTo(FX_WCHAR wch,
- bool bWSSeparator,
- bool bBrContinue) {
- const FX_WCHAR* pStart = m_pCur;
- if (!bBrContinue) {
- if (bWSSeparator) {
- while ((++m_pCur < m_pEnd) && (*m_pCur != wch) && (*m_pCur > ' ')) {
- continue;
- }
- } else {
- while (++m_pCur < m_pEnd && *m_pCur != wch) {
- continue;
- }
- }
-
- } else {
- int32_t iBracketCount = 0;
- if (bWSSeparator) {
- while ((m_pCur < m_pEnd) && (*m_pCur != wch) && (*m_pCur > ' ')) {
- if (*m_pCur == '(') {
- iBracketCount++;
- } else if (*m_pCur == ')') {
- iBracketCount--;
- }
- m_pCur++;
- }
- } else {
- while (m_pCur < m_pEnd && *m_pCur != wch) {
- if (*m_pCur == '(') {
- iBracketCount++;
- } else if (*m_pCur == ')') {
- iBracketCount--;
- }
- m_pCur++;
- }
- }
- while (iBracketCount > 0 && m_pCur < m_pEnd) {
- if (*m_pCur == ')') {
- iBracketCount--;
- }
- m_pCur++;
- }
- }
- return m_pCur - pStart;
-}
-
-CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(FX_ARGB color)
- : CFDE_CSSValue(FDE_CSSVALUETYPE_Primitive),
- m_eType(FDE_CSSPrimitiveType::RGB),
- m_dwColor(color) {}
-
-CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(FDE_CSSPropertyValue eValue)
- : CFDE_CSSValue(FDE_CSSVALUETYPE_Primitive),
- m_eType(FDE_CSSPrimitiveType::Enum),
- m_eEnum(eValue) {}
-
-CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(FDE_CSSPrimitiveType eType,
- FX_FLOAT fValue)
- : CFDE_CSSValue(FDE_CSSVALUETYPE_Primitive),
- m_eType(eType),
- m_fNumber(fValue) {}
-
-CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(FDE_CSSPrimitiveType eType,
- const FX_WCHAR* pValue)
- : CFDE_CSSValue(FDE_CSSVALUETYPE_Primitive),
- m_eType(eType),
- m_pString(pValue) {
- ASSERT(m_pString);
-}
-
-CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(
- std::unique_ptr<CFDE_CSSFunction> pFunction)
- : CFDE_CSSValue(FDE_CSSVALUETYPE_Primitive),
- m_eType(FDE_CSSPrimitiveType::Function),
- m_pFunction(std::move(pFunction)) {}
-
-CFDE_CSSPrimitiveValue::~CFDE_CSSPrimitiveValue() {}
-
-FDE_CSSPrimitiveType CFDE_CSSPrimitiveValue::GetPrimitiveType() const {
- return m_eType;
-}
-
-FX_ARGB CFDE_CSSPrimitiveValue::GetRGBColor() const {
- ASSERT(m_eType == FDE_CSSPrimitiveType::RGB);
- return m_dwColor;
-}
-
-FX_FLOAT CFDE_CSSPrimitiveValue::GetFloat() const {
- ASSERT(m_eType >= FDE_CSSPrimitiveType::Number &&
- m_eType <= FDE_CSSPrimitiveType::Picas);
- return m_fNumber;
-}
-
-const FX_WCHAR* CFDE_CSSPrimitiveValue::GetString(int32_t& iLength) const {
- ASSERT(m_eType >= FDE_CSSPrimitiveType::String &&
- m_eType <= FDE_CSSPrimitiveType::URI);
- iLength = FXSYS_wcslen(m_pString);
- return m_pString;
-}
-
-FDE_CSSPropertyValue CFDE_CSSPrimitiveValue::GetEnum() const {
- ASSERT(m_eType == FDE_CSSPrimitiveType::Enum);
- return m_eEnum;
-}
-
-const FX_WCHAR* CFDE_CSSPrimitiveValue::GetFuncName() const {
- ASSERT(m_eType == FDE_CSSPrimitiveType::Function);
- return m_pFunction->GetFuncName();
-}
-
-int32_t CFDE_CSSPrimitiveValue::CountArgs() const {
- ASSERT(m_eType == FDE_CSSPrimitiveType::Function);
- return m_pFunction->CountArgs();
-}
-
-CFDE_CSSValue* CFDE_CSSPrimitiveValue::GetArgs(int32_t index) const {
- ASSERT(m_eType == FDE_CSSPrimitiveType::Function);
- return m_pFunction->GetArgs(index);
-}
-
-CFDE_CSSFunction::CFDE_CSSFunction(const FX_WCHAR* pszFuncName,
- CFX_RetainPtr<CFDE_CSSValueList> pArgList)
- : m_pArgList(pArgList), m_pszFuncName(pszFuncName) {
- ASSERT(pArgList);
-}
-
-CFDE_CSSFunction::~CFDE_CSSFunction() {}
diff --git a/xfa/fde/css/fde_cssdatatable.h b/xfa/fde/css/fde_cssdatatable.h
index 0b14ffc101..f2cc2b45d4 100644
--- a/xfa/fde/css/fde_cssdatatable.h
+++ b/xfa/fde/css/fde_cssdatatable.h
@@ -11,89 +11,10 @@
#include <vector>
#include "core/fxcrt/fx_system.h"
+#include "xfa/fde/css/cfde_cssnumbervalue.h"
#include "xfa/fde/css/cfde_cssvalue.h"
#include "xfa/fde/css/fde_css.h"
-class CFDE_CSSFunction;
-
-class CFDE_CSSPrimitiveValue : public CFDE_CSSValue {
- public:
- explicit CFDE_CSSPrimitiveValue(FX_ARGB color);
- explicit CFDE_CSSPrimitiveValue(FDE_CSSPropertyValue eValue);
- explicit CFDE_CSSPrimitiveValue(std::unique_ptr<CFDE_CSSFunction> pFunction);
- CFDE_CSSPrimitiveValue(FDE_CSSPrimitiveType eType, FX_FLOAT fValue);
- CFDE_CSSPrimitiveValue(FDE_CSSPrimitiveType eType, const FX_WCHAR* pValue);
- CFDE_CSSPrimitiveValue(const CFDE_CSSPrimitiveValue& src);
- ~CFDE_CSSPrimitiveValue() override;
-
- FDE_CSSPrimitiveType GetPrimitiveType() const;
- FX_ARGB GetRGBColor() const;
- FX_FLOAT GetFloat() const;
- const FX_WCHAR* GetString(int32_t& iLength) const;
- FDE_CSSPropertyValue GetEnum() const;
- const FX_WCHAR* GetFuncName() const;
- int32_t CountArgs() const;
- CFDE_CSSValue* GetArgs(int32_t index) const;
-
- FDE_CSSPrimitiveType m_eType;
- union {
- FX_ARGB m_dwColor;
- FX_FLOAT m_fNumber;
- const FX_WCHAR* m_pString;
- FDE_CSSPropertyValue m_eEnum;
- };
- std::unique_ptr<CFDE_CSSFunction> m_pFunction;
-};
-
-class CFDE_CSSValueList : public CFDE_CSSValue {
- public:
- explicit CFDE_CSSValueList(std::vector<CFX_RetainPtr<CFDE_CSSValue>>& list);
- ~CFDE_CSSValueList() override;
-
- int32_t CountValues() const;
- CFDE_CSSValue* GetValue(int32_t index) const;
-
- protected:
- std::vector<CFX_RetainPtr<CFDE_CSSValue>> m_ppList;
-};
-
-class CFDE_CSSValueListParser {
- public:
- CFDE_CSSValueListParser(const FX_WCHAR* psz, int32_t iLen, FX_WCHAR separator)
- : m_Separator(separator), m_pCur(psz), m_pEnd(psz + iLen) {
- ASSERT(psz && iLen > 0);
- }
- bool NextValue(FDE_CSSPrimitiveType& eType,
- const FX_WCHAR*& pStart,
- int32_t& iLength);
- FX_WCHAR m_Separator;
-
- protected:
- int32_t SkipTo(FX_WCHAR wch,
- bool bWSSeparator = false,
- bool bBrContinue = false);
-
- const FX_WCHAR* m_pCur;
- const FX_WCHAR* m_pEnd;
-};
-
-class CFDE_CSSFunction {
- public:
- CFDE_CSSFunction(const FX_WCHAR* pszFuncName,
- CFX_RetainPtr<CFDE_CSSValueList> pArgList);
- ~CFDE_CSSFunction();
-
- int32_t CountArgs() const { return m_pArgList->CountValues(); }
- CFDE_CSSValue* GetArgs(int32_t index) const {
- return m_pArgList->GetValue(index);
- }
- const FX_WCHAR* GetFuncName() const { return m_pszFuncName; }
-
- protected:
- CFX_RetainPtr<CFDE_CSSValueList> m_pArgList;
- const FX_WCHAR* m_pszFuncName;
-};
-
#define FDE_IsOnlyValue(type, enum) \
(((type) & ~(enum)) == FDE_CSSVALUETYPE_Primitive)
@@ -129,7 +50,7 @@ const FDE_CSSMEDIATYPETABLE* FDE_GetCSSMediaTypeByName(
struct FDE_CSSLengthUnitTable {
uint16_t wHash;
- FDE_CSSPrimitiveType wValue;
+ FDE_CSSNumberType wValue;
};
const FDE_CSSLengthUnitTable* FDE_GetCSSLengthUnitByName(
@@ -153,7 +74,7 @@ const FDE_CSSPseudoTable* FDE_GetCSSPseudoByEnum(FDE_CSSPseudo ePseudo);
bool FDE_ParseCSSNumber(const FX_WCHAR* pszValue,
int32_t iValueLen,
FX_FLOAT& fValue,
- FDE_CSSPrimitiveType& eUnit);
+ FDE_CSSNumberType& eUnit);
bool FDE_ParseCSSString(const FX_WCHAR* pszValue,
int32_t iValueLen,
int32_t* iOffset,
diff --git a/xfa/fde/css/fde_cssdeclaration.cpp b/xfa/fde/css/fde_cssdeclaration.cpp
index 14ed101500..e82b279c04 100644
--- a/xfa/fde/css/fde_cssdeclaration.cpp
+++ b/xfa/fde/css/fde_cssdeclaration.cpp
@@ -8,6 +8,12 @@
#include "core/fxcrt/fx_ext.h"
#include "third_party/base/ptr_util.h"
+#include "xfa/fde/css/cfde_csscolorvalue.h"
+#include "xfa/fde/css/cfde_cssenumvalue.h"
+#include "xfa/fde/css/cfde_cssnumbervalue.h"
+#include "xfa/fde/css/cfde_cssstringvalue.h"
+#include "xfa/fde/css/cfde_cssvaluelist.h"
+#include "xfa/fde/css/cfde_cssvaluelistparser.h"
CFDE_CSSDeclaration::CFDE_CSSDeclaration() {}
@@ -46,19 +52,6 @@ const FX_WCHAR* CFDE_CSSDeclaration::CopyToLocal(
return psz;
}
-CFX_RetainPtr<CFDE_CSSPrimitiveValue> CFDE_CSSDeclaration::NewNumberValue(
- FDE_CSSPrimitiveType eUnit,
- FX_FLOAT fValue) const {
- if (eUnit == FDE_CSSPrimitiveType::Number && FXSYS_fabs(fValue) < 0.001f)
- fValue = 0.0f;
- return pdfium::MakeRetain<CFDE_CSSPrimitiveValue>(eUnit, fValue);
-}
-
-CFX_RetainPtr<CFDE_CSSPrimitiveValue> CFDE_CSSDeclaration::NewEnumValue(
- FDE_CSSPropertyValue eValue) const {
- return pdfium::MakeRetain<CFDE_CSSPrimitiveValue>(eValue);
-}
-
void CFDE_CSSDeclaration::AddPropertyHolder(FDE_CSSProperty eProperty,
CFX_RetainPtr<CFDE_CSSValue> pValue,
bool bImportant) {
@@ -85,9 +78,8 @@ void CFDE_CSSDeclaration::AddProperty(const FDE_CSSPropertyArgs* pArgs,
switch (dwType & 0x0F) {
case FDE_CSSVALUETYPE_Primitive: {
static const uint32_t g_ValueGuessOrder[] = {
- FDE_CSSVALUETYPE_MaybeNumber, FDE_CSSVALUETYPE_MaybeEnum,
- FDE_CSSVALUETYPE_MaybeColor, FDE_CSSVALUETYPE_MaybeURI,
- FDE_CSSVALUETYPE_MaybeFunction, FDE_CSSVALUETYPE_MaybeString,
+ FDE_CSSVALUETYPE_MaybeNumber, FDE_CSSVALUETYPE_MaybeEnum,
+ FDE_CSSVALUETYPE_MaybeColor, FDE_CSSVALUETYPE_MaybeString,
};
static const int32_t g_ValueGuessCount =
sizeof(g_ValueGuessOrder) / sizeof(uint32_t);
@@ -98,9 +90,6 @@ void CFDE_CSSDeclaration::AddProperty(const FDE_CSSPropertyArgs* pArgs,
}
CFX_RetainPtr<CFDE_CSSValue> pCSSValue;
switch (dwMatch) {
- case FDE_CSSVALUETYPE_MaybeFunction:
- pCSSValue = ParseFunction(pArgs, pszValue, iValueLen);
- break;
case FDE_CSSVALUETYPE_MaybeNumber:
pCSSValue = ParseNumber(pArgs, pszValue, iValueLen);
break;
@@ -110,9 +99,6 @@ void CFDE_CSSDeclaration::AddProperty(const FDE_CSSPropertyArgs* pArgs,
case FDE_CSSVALUETYPE_MaybeColor:
pCSSValue = ParseColor(pArgs, pszValue, iValueLen);
break;
- case FDE_CSSVALUETYPE_MaybeURI:
- pCSSValue = ParseURI(pArgs, pszValue, iValueLen);
- break;
case FDE_CSSVALUETYPE_MaybeString:
pCSSValue = ParseString(pArgs, pszValue, iValueLen);
break;
@@ -204,10 +190,10 @@ CFX_RetainPtr<CFDE_CSSValue> CFDE_CSSDeclaration::ParseNumber(
const FX_WCHAR* pszValue,
int32_t iValueLen) {
FX_FLOAT fValue;
- FDE_CSSPrimitiveType eUnit;
+ FDE_CSSNumberType eUnit;
if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eUnit))
return nullptr;
- return NewNumberValue(eUnit, fValue);
+ return pdfium::MakeRetain<CFDE_CSSNumberValue>(eUnit, fValue);
}
CFX_RetainPtr<CFDE_CSSValue> CFDE_CSSDeclaration::ParseEnum(
@@ -216,7 +202,8 @@ CFX_RetainPtr<CFDE_CSSValue> CFDE_CSSDeclaration::ParseEnum(
int32_t iValueLen) {
const FDE_CSSPropertyValueTable* pValue =
FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
- return pValue ? NewEnumValue(pValue->eName) : nullptr;
+ return pValue ? pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName)
+ : nullptr;
}
CFX_RetainPtr<CFDE_CSSValue> CFDE_CSSDeclaration::ParseColor(
@@ -226,24 +213,7 @@ CFX_RetainPtr<CFDE_CSSValue> CFDE_CSSDeclaration::ParseColor(
FX_ARGB dwColor;
if (!FDE_ParseCSSColor(pszValue, iValueLen, dwColor))
return nullptr;
- return pdfium::MakeRetain<CFDE_CSSPrimitiveValue>(dwColor);
-}
-
-CFX_RetainPtr<CFDE_CSSValue> CFDE_CSSDeclaration::ParseURI(
- const FDE_CSSPropertyArgs* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen) {
- int32_t iOffset;
- if (!FDE_ParseCSSURI(pszValue, &iOffset, &iValueLen))
- return nullptr;
-
- if (iValueLen <= 0)
- return nullptr;
-
- pszValue = CopyToLocal(pArgs, pszValue + iOffset, iValueLen);
- return pszValue ? pdfium::MakeRetain<CFDE_CSSPrimitiveValue>(
- FDE_CSSPrimitiveType::URI, pszValue)
- : nullptr;
+ return pdfium::MakeRetain<CFDE_CSSColorValue>(dwColor);
}
CFX_RetainPtr<CFDE_CSSValue> CFDE_CSSDeclaration::ParseString(
@@ -258,71 +228,7 @@ CFX_RetainPtr<CFDE_CSSValue> CFDE_CSSDeclaration::ParseString(
return nullptr;
pszValue = CopyToLocal(pArgs, pszValue + iOffset, iValueLen);
- return pszValue ? pdfium::MakeRetain<CFDE_CSSPrimitiveValue>(
- FDE_CSSPrimitiveType::String, pszValue)
- : nullptr;
-}
-
-CFX_RetainPtr<CFDE_CSSValue> CFDE_CSSDeclaration::ParseFunction(
- const FDE_CSSPropertyArgs* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen) {
- if (pszValue[iValueLen - 1] != ')')
- return nullptr;
-
- int32_t iStartBracket = 0;
- while (pszValue[iStartBracket] != '(') {
- if (iStartBracket >= iValueLen)
- return nullptr;
- iStartBracket++;
- }
- if (iStartBracket == 0)
- return nullptr;
-
- const FX_WCHAR* pszFuncName = CopyToLocal(pArgs, pszValue, iStartBracket);
- pszValue += (iStartBracket + 1);
- iValueLen -= (iStartBracket + 2);
- std::vector<CFX_RetainPtr<CFDE_CSSValue>> argumentArr;
- CFDE_CSSValueListParser parser(pszValue, iValueLen, ',');
- FDE_CSSPrimitiveType ePrimitiveType;
- while (parser.NextValue(ePrimitiveType, pszValue, iValueLen)) {
- switch (ePrimitiveType) {
- case FDE_CSSPrimitiveType::String: {
- const FDE_CSSPropertyValueTable* pPropertyValue =
- FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
- if (pPropertyValue) {
- argumentArr.push_back(NewEnumValue(pPropertyValue->eName));
- continue;
- }
-
- auto pFunctionValue = ParseFunction(pArgs, pszValue, iValueLen);
- if (pFunctionValue) {
- argumentArr.push_back(pFunctionValue);
- continue;
- }
- argumentArr.push_back(pdfium::MakeRetain<CFDE_CSSPrimitiveValue>(
- FDE_CSSPrimitiveType::String,
- CopyToLocal(pArgs, pszValue, iValueLen)));
- break;
- }
- case FDE_CSSPrimitiveType::Number: {
- FX_FLOAT fValue;
- if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, ePrimitiveType))
- argumentArr.push_back(NewNumberValue(ePrimitiveType, fValue));
- break;
- }
- default:
- argumentArr.push_back(pdfium::MakeRetain<CFDE_CSSPrimitiveValue>(
- FDE_CSSPrimitiveType::String,
- CopyToLocal(pArgs, pszValue, iValueLen)));
- break;
- }
- }
-
- auto pArgumentList = pdfium::MakeRetain<CFDE_CSSValueList>(argumentArr);
- auto pFunction =
- pdfium::MakeUnique<CFDE_CSSFunction>(pszFuncName, pArgumentList);
- return pdfium::MakeRetain<CFDE_CSSPrimitiveValue>(std::move(pFunction));
+ return pszValue ? pdfium::MakeRetain<CFDE_CSSStringValue>(pszValue) : nullptr;
}
void CFDE_CSSDeclaration::ParseValueListProperty(
@@ -342,15 +248,17 @@ void CFDE_CSSDeclaration::ParseValueListProperty(
case FDE_CSSPrimitiveType::Number:
if (dwType & FDE_CSSVALUETYPE_MaybeNumber) {
FX_FLOAT fValue;
- if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType))
- list.push_back(NewNumberValue(eType, fValue));
+ FDE_CSSNumberType eNumType;
+ if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eNumType))
+ list.push_back(
+ pdfium::MakeRetain<CFDE_CSSNumberValue>(eNumType, fValue));
}
break;
case FDE_CSSPrimitiveType::String:
if (dwType & FDE_CSSVALUETYPE_MaybeColor) {
FX_ARGB dwColor;
if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) {
- list.push_back(pdfium::MakeRetain<CFDE_CSSPrimitiveValue>(dwColor));
+ list.push_back(pdfium::MakeRetain<CFDE_CSSColorValue>(dwColor));
continue;
}
}
@@ -359,21 +267,21 @@ void CFDE_CSSDeclaration::ParseValueListProperty(
FDE_GetCSSPropertyValueByName(
CFX_WideStringC(pszValue, iValueLen));
if (pValue) {
- list.push_back(NewEnumValue(pValue->eName));
+ list.push_back(
+ pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName));
continue;
}
}
if (dwType & FDE_CSSVALUETYPE_MaybeString) {
pszValue = CopyToLocal(pArgs, pszValue, iValueLen);
- list.push_back(pdfium::MakeRetain<CFDE_CSSPrimitiveValue>(
- FDE_CSSPrimitiveType::String, pszValue));
+ list.push_back(pdfium::MakeRetain<CFDE_CSSStringValue>(pszValue));
}
break;
case FDE_CSSPrimitiveType::RGB:
if (dwType & FDE_CSSVALUETYPE_MaybeColor) {
FX_ARGB dwColor;
if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) {
- list.push_back(pdfium::MakeRetain<CFDE_CSSPrimitiveValue>(dwColor));
+ list.push_back(pdfium::MakeRetain<CFDE_CSSColorValue>(dwColor));
}
}
break;
@@ -463,8 +371,9 @@ bool CFDE_CSSDeclaration::ParseBorderProperty(
continue;
FX_FLOAT fValue;
- if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType))
- pWidth = NewNumberValue(eType, fValue);
+ FDE_CSSNumberType eNumType;
+ if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eNumType))
+ pWidth = pdfium::MakeRetain<CFDE_CSSNumberValue>(eNumType, fValue);
break;
}
case FDE_CSSPrimitiveType::String: {
@@ -483,7 +392,7 @@ bool CFDE_CSSDeclaration::ParseBorderProperty(
case FDE_CSSPropertyValue::Thick:
case FDE_CSSPropertyValue::Medium:
if (!pWidth)
- pWidth = NewEnumValue(pValue->eName);
+ pWidth = pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
break;
default:
break;
@@ -495,7 +404,8 @@ bool CFDE_CSSDeclaration::ParseBorderProperty(
}
}
if (!pWidth)
- pWidth = NewNumberValue(FDE_CSSPrimitiveType::Number, 0.0f);
+ pWidth = pdfium::MakeRetain<CFDE_CSSNumberValue>(FDE_CSSNumberType::Number,
+ 0.0f);
return true;
}
@@ -505,11 +415,11 @@ void CFDE_CSSDeclaration::ParseFontProperty(const FDE_CSSPropertyArgs* pArgs,
int32_t iValueLen,
bool bImportant) {
CFDE_CSSValueListParser parser(pszValue, iValueLen, '/');
- CFX_RetainPtr<CFDE_CSSPrimitiveValue> pStyle;
- CFX_RetainPtr<CFDE_CSSPrimitiveValue> pVariant;
- CFX_RetainPtr<CFDE_CSSPrimitiveValue> pWeight;
- CFX_RetainPtr<CFDE_CSSPrimitiveValue> pFontSize;
- CFX_RetainPtr<CFDE_CSSPrimitiveValue> pLineHeight;
+ CFX_RetainPtr<CFDE_CSSValue> pStyle;
+ CFX_RetainPtr<CFDE_CSSValue> pVariant;
+ CFX_RetainPtr<CFDE_CSSValue> pWeight;
+ CFX_RetainPtr<CFDE_CSSValue> pFontSize;
+ CFX_RetainPtr<CFDE_CSSValue> pLineHeight;
std::vector<CFX_RetainPtr<CFDE_CSSValue>> familyList;
FDE_CSSPrimitiveType eType;
while (parser.NextValue(eType, pszValue, iValueLen)) {
@@ -529,49 +439,53 @@ void CFDE_CSSDeclaration::ParseFontProperty(const FDE_CSSPropertyArgs* pArgs,
case FDE_CSSPropertyValue::Smaller:
case FDE_CSSPropertyValue::Larger:
if (!pFontSize)
- pFontSize = NewEnumValue(pValue->eName);
+ pFontSize =
+ pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
continue;
case FDE_CSSPropertyValue::Bold:
case FDE_CSSPropertyValue::Bolder:
case FDE_CSSPropertyValue::Lighter:
if (!pWeight)
- pWeight = NewEnumValue(pValue->eName);
+ pWeight = pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
continue;
case FDE_CSSPropertyValue::Italic:
case FDE_CSSPropertyValue::Oblique:
if (!pStyle)
- pStyle = NewEnumValue(pValue->eName);
+ pStyle = pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
continue;
case FDE_CSSPropertyValue::SmallCaps:
if (!pVariant)
- pVariant = NewEnumValue(pValue->eName);
+ pVariant = pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
continue;
case FDE_CSSPropertyValue::Normal:
if (!pStyle)
- pStyle = NewEnumValue(pValue->eName);
+ pStyle = pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
else if (!pVariant)
- pVariant = NewEnumValue(pValue->eName);
+ pVariant = pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
else if (!pWeight)
- pWeight = NewEnumValue(pValue->eName);
+ pWeight = pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
else if (!pFontSize)
- pFontSize = NewEnumValue(pValue->eName);
+ pFontSize =
+ pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
else if (!pLineHeight)
- pLineHeight = NewEnumValue(pValue->eName);
+ pLineHeight =
+ pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
continue;
default:
break;
}
}
if (pFontSize) {
- familyList.push_back(pdfium::MakeRetain<CFDE_CSSPrimitiveValue>(
- eType, CopyToLocal(pArgs, pszValue, iValueLen)));
+ familyList.push_back(pdfium::MakeRetain<CFDE_CSSStringValue>(
+ CopyToLocal(pArgs, pszValue, iValueLen)));
}
parser.m_Separator = ',';
break;
}
case FDE_CSSPrimitiveType::Number: {
FX_FLOAT fValue;
- if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType))
+ FDE_CSSNumberType eNumType;
+ if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eNumType))
break;
if (eType == FDE_CSSPrimitiveType::Number) {
switch ((int32_t)fValue) {
@@ -585,14 +499,16 @@ void CFDE_CSSDeclaration::ParseFontProperty(const FDE_CSSPropertyArgs* pArgs,
case 800:
case 900:
if (!pWeight)
- pWeight = NewNumberValue(FDE_CSSPrimitiveType::Number, fValue);
+ pWeight = pdfium::MakeRetain<CFDE_CSSNumberValue>(
+ FDE_CSSNumberType::Number, fValue);
continue;
}
}
if (!pFontSize)
- pFontSize = NewNumberValue(eType, fValue);
+ pFontSize = pdfium::MakeRetain<CFDE_CSSNumberValue>(eNumType, fValue);
else if (!pLineHeight)
- pLineHeight = NewNumberValue(eType, fValue);
+ pLineHeight =
+ pdfium::MakeRetain<CFDE_CSSNumberValue>(eNumType, fValue);
break;
}
default:
@@ -601,15 +517,20 @@ void CFDE_CSSDeclaration::ParseFontProperty(const FDE_CSSPropertyArgs* pArgs,
}
if (!pStyle)
- pStyle = NewEnumValue(FDE_CSSPropertyValue::Normal);
+ pStyle =
+ pdfium::MakeRetain<CFDE_CSSEnumValue>(FDE_CSSPropertyValue::Normal);
if (!pVariant)
- pVariant = NewEnumValue(FDE_CSSPropertyValue::Normal);
+ pVariant =
+ pdfium::MakeRetain<CFDE_CSSEnumValue>(FDE_CSSPropertyValue::Normal);
if (!pWeight)
- pWeight = NewEnumValue(FDE_CSSPropertyValue::Normal);
+ pWeight =
+ pdfium::MakeRetain<CFDE_CSSEnumValue>(FDE_CSSPropertyValue::Normal);
if (!pFontSize)
- pFontSize = NewEnumValue(FDE_CSSPropertyValue::Medium);
+ pFontSize =
+ pdfium::MakeRetain<CFDE_CSSEnumValue>(FDE_CSSPropertyValue::Medium);
if (!pLineHeight)
- pLineHeight = NewEnumValue(FDE_CSSPropertyValue::Normal);
+ pLineHeight =
+ pdfium::MakeRetain<CFDE_CSSEnumValue>(FDE_CSSPropertyValue::Normal);
AddPropertyHolder(FDE_CSSProperty::FontStyle, pStyle, bImportant);
AddPropertyHolder(FDE_CSSProperty::FontVariant, pVariant, bImportant);
diff --git a/xfa/fde/css/fde_cssdeclaration.h b/xfa/fde/css/fde_cssdeclaration.h
index bb8795c446..72657184eb 100644
--- a/xfa/fde/css/fde_cssdeclaration.h
+++ b/xfa/fde/css/fde_cssdeclaration.h
@@ -95,26 +95,15 @@ class CFDE_CSSDeclaration {
CFX_RetainPtr<CFDE_CSSValue> ParseColor(const FDE_CSSPropertyArgs* pArgs,
const FX_WCHAR* pszValue,
int32_t iValueLen);
- CFX_RetainPtr<CFDE_CSSValue> ParseURI(const FDE_CSSPropertyArgs* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen);
CFX_RetainPtr<CFDE_CSSValue> ParseString(const FDE_CSSPropertyArgs* pArgs,
const FX_WCHAR* pszValue,
int32_t iValueLen);
- CFX_RetainPtr<CFDE_CSSValue> ParseFunction(const FDE_CSSPropertyArgs* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen);
const FX_WCHAR* CopyToLocal(const FDE_CSSPropertyArgs* pArgs,
const FX_WCHAR* pszValue,
int32_t iValueLen);
void AddPropertyHolder(FDE_CSSProperty eProperty,
CFX_RetainPtr<CFDE_CSSValue> pValue,
bool bImportant);
- CFX_RetainPtr<CFDE_CSSPrimitiveValue> NewNumberValue(
- FDE_CSSPrimitiveType eUnit,
- FX_FLOAT fValue) const;
- CFX_RetainPtr<CFDE_CSSPrimitiveValue> NewEnumValue(
- FDE_CSSPropertyValue eValue) const;
std::vector<std::unique_ptr<FDE_CSSPropertyHolder>> properties_;
std::vector<std::unique_ptr<FDE_CSSCustomProperty>> custom_properties_;
diff --git a/xfa/fde/css/fde_cssstyleselector.cpp b/xfa/fde/css/fde_cssstyleselector.cpp
index e6ee18f245..7184ce3f8a 100644
--- a/xfa/fde/css/fde_cssstyleselector.cpp
+++ b/xfa/fde/css/fde_cssstyleselector.cpp
@@ -11,12 +11,30 @@
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
+#include "xfa/fde/css/cfde_csscolorvalue.h"
+#include "xfa/fde/css/cfde_cssenumvalue.h"
+#include "xfa/fde/css/cfde_cssstringvalue.h"
+#include "xfa/fde/css/cfde_cssvaluelist.h"
#include "xfa/fde/css/fde_csscache.h"
#include "xfa/fde/css/fde_cssdeclaration.h"
#include "xfa/fde/css/fde_cssstylesheet.h"
#include "xfa/fde/css/fde_csssyntax.h"
#include "xfa/fxfa/app/cxfa_csstagprovider.h"
+namespace {
+
+template <class T>
+T* ToValue(CFDE_CSSValue* val) {
+ return static_cast<T*>(val);
+}
+
+template <class T>
+const T* ToValue(const CFDE_CSSValue* val) {
+ return static_cast<T*>(val);
+}
+
+} // namespace
+
#define FDE_CSSUNIVERSALHASH ('*')
FDE_CSSRuleData::FDE_CSSRuleData(CFDE_CSSSelector* pSel,
@@ -379,55 +397,54 @@ void CFDE_CSSStyleSelector::ApplyProperty(
FDE_CSSProperty eProperty,
CFDE_CSSValue* pValue,
CFDE_CSSComputedStyle* pComputedStyle) {
- if (pValue->GetType() == FDE_CSSVALUETYPE_Primitive) {
- CFDE_CSSPrimitiveValue* pPrimitive =
- static_cast<CFDE_CSSPrimitiveValue*>(pValue);
- FDE_CSSPrimitiveType eType = pPrimitive->GetPrimitiveType();
+ if (pValue->GetType() != FDE_CSSPrimitiveType::List) {
+ FDE_CSSPrimitiveType eType = pValue->GetType();
switch (eProperty) {
case FDE_CSSProperty::Display:
if (eType == FDE_CSSPrimitiveType::Enum) {
pComputedStyle->m_NonInheritedData.m_eDisplay =
- ToDisplay(pPrimitive->GetEnum());
+ ToDisplay(ToValue<CFDE_CSSEnumValue>(pValue)->Value());
}
break;
case FDE_CSSProperty::FontSize: {
FX_FLOAT& fFontSize = pComputedStyle->m_InheritedData.m_fFontSize;
- if (eType >= FDE_CSSPrimitiveType::Number &&
- eType <= FDE_CSSPrimitiveType::Picas) {
- fFontSize = ApplyNumber(eType, pPrimitive->GetFloat(), fFontSize);
+ if (eType == FDE_CSSPrimitiveType::Number) {
+ fFontSize = ToValue<CFDE_CSSNumberValue>(pValue)->Apply(fFontSize);
} else if (eType == FDE_CSSPrimitiveType::Enum) {
- fFontSize = ToFontSize(pPrimitive->GetEnum(), fFontSize);
+ fFontSize = ToFontSize(ToValue<CFDE_CSSEnumValue>(pValue)->Value(),
+ fFontSize);
}
} break;
case FDE_CSSProperty::LineHeight:
if (eType == FDE_CSSPrimitiveType::Number) {
- pComputedStyle->m_InheritedData.m_fLineHeight =
- pPrimitive->GetFloat() *
- pComputedStyle->m_InheritedData.m_fFontSize;
- } else if (eType > FDE_CSSPrimitiveType::Number &&
- eType <= FDE_CSSPrimitiveType::Picas) {
- pComputedStyle->m_InheritedData.m_fLineHeight =
- ApplyNumber(eType, pPrimitive->GetFloat(),
- pComputedStyle->m_InheritedData.m_fFontSize);
+ const CFDE_CSSNumberValue* v = ToValue<CFDE_CSSNumberValue>(pValue);
+ if (v->Kind() == FDE_CSSNumberType::Number) {
+ pComputedStyle->m_InheritedData.m_fLineHeight =
+ v->Value() * pComputedStyle->m_InheritedData.m_fFontSize;
+ } else {
+ pComputedStyle->m_InheritedData.m_fLineHeight =
+ v->Apply(pComputedStyle->m_InheritedData.m_fFontSize);
+ }
}
break;
case FDE_CSSProperty::TextAlign:
if (eType == FDE_CSSPrimitiveType::Enum) {
pComputedStyle->m_InheritedData.m_eTextAlign =
- ToTextAlign(pPrimitive->GetEnum());
+ ToTextAlign(ToValue<CFDE_CSSEnumValue>(pValue)->Value());
}
break;
case FDE_CSSProperty::TextIndent:
SetLengthWithPercent(pComputedStyle->m_InheritedData.m_TextIndent,
- eType, pPrimitive,
+ eType, pValue,
pComputedStyle->m_InheritedData.m_fFontSize);
break;
case FDE_CSSProperty::FontWeight:
if (eType == FDE_CSSPrimitiveType::Enum) {
pComputedStyle->m_InheritedData.m_wFontWeight =
- ToFontWeight(pPrimitive->GetEnum());
+ ToFontWeight(ToValue<CFDE_CSSEnumValue>(pValue)->Value());
} else if (eType == FDE_CSSPrimitiveType::Number) {
- int32_t iValue = (int32_t)pPrimitive->GetFloat() / 100;
+ int32_t iValue =
+ (int32_t)ToValue<CFDE_CSSNumberValue>(pValue)->Value() / 100;
if (iValue >= 1 && iValue <= 9) {
pComputedStyle->m_InheritedData.m_wFontWeight = iValue * 100;
}
@@ -436,169 +453,171 @@ void CFDE_CSSStyleSelector::ApplyProperty(
case FDE_CSSProperty::FontStyle:
if (eType == FDE_CSSPrimitiveType::Enum) {
pComputedStyle->m_InheritedData.m_eFontStyle =
- ToFontStyle(pPrimitive->GetEnum());
+ ToFontStyle(ToValue<CFDE_CSSEnumValue>(pValue)->Value());
}
break;
case FDE_CSSProperty::Color:
if (eType == FDE_CSSPrimitiveType::RGB) {
pComputedStyle->m_InheritedData.m_dwFontColor =
- pPrimitive->GetRGBColor();
+ ToValue<CFDE_CSSColorValue>(pValue)->Value();
}
break;
case FDE_CSSProperty::MarginLeft:
if (SetLengthWithPercent(
pComputedStyle->m_NonInheritedData.m_MarginWidth.left, eType,
- pPrimitive, pComputedStyle->m_InheritedData.m_fFontSize)) {
+ pValue, pComputedStyle->m_InheritedData.m_fFontSize)) {
pComputedStyle->m_NonInheritedData.m_bHasMargin = true;
}
break;
case FDE_CSSProperty::MarginTop:
if (SetLengthWithPercent(
pComputedStyle->m_NonInheritedData.m_MarginWidth.top, eType,
- pPrimitive, pComputedStyle->m_InheritedData.m_fFontSize)) {
+ pValue, pComputedStyle->m_InheritedData.m_fFontSize)) {
pComputedStyle->m_NonInheritedData.m_bHasMargin = true;
}
break;
case FDE_CSSProperty::MarginRight:
if (SetLengthWithPercent(
pComputedStyle->m_NonInheritedData.m_MarginWidth.right, eType,
- pPrimitive, pComputedStyle->m_InheritedData.m_fFontSize)) {
+ pValue, pComputedStyle->m_InheritedData.m_fFontSize)) {
pComputedStyle->m_NonInheritedData.m_bHasMargin = true;
}
break;
case FDE_CSSProperty::MarginBottom:
if (SetLengthWithPercent(
pComputedStyle->m_NonInheritedData.m_MarginWidth.bottom, eType,
- pPrimitive, pComputedStyle->m_InheritedData.m_fFontSize)) {
+ pValue, pComputedStyle->m_InheritedData.m_fFontSize)) {
pComputedStyle->m_NonInheritedData.m_bHasMargin = true;
}
break;
case FDE_CSSProperty::PaddingLeft:
if (SetLengthWithPercent(
pComputedStyle->m_NonInheritedData.m_PaddingWidth.left, eType,
- pPrimitive, pComputedStyle->m_InheritedData.m_fFontSize)) {
+ pValue, pComputedStyle->m_InheritedData.m_fFontSize)) {
pComputedStyle->m_NonInheritedData.m_bHasPadding = true;
}
break;
case FDE_CSSProperty::PaddingTop:
if (SetLengthWithPercent(
pComputedStyle->m_NonInheritedData.m_PaddingWidth.top, eType,
- pPrimitive, pComputedStyle->m_InheritedData.m_fFontSize)) {
+ pValue, pComputedStyle->m_InheritedData.m_fFontSize)) {
pComputedStyle->m_NonInheritedData.m_bHasPadding = true;
}
break;
case FDE_CSSProperty::PaddingRight:
if (SetLengthWithPercent(
pComputedStyle->m_NonInheritedData.m_PaddingWidth.right, eType,
- pPrimitive, pComputedStyle->m_InheritedData.m_fFontSize)) {
+ pValue, pComputedStyle->m_InheritedData.m_fFontSize)) {
pComputedStyle->m_NonInheritedData.m_bHasPadding = true;
}
break;
case FDE_CSSProperty::PaddingBottom:
if (SetLengthWithPercent(
pComputedStyle->m_NonInheritedData.m_PaddingWidth.bottom, eType,
- pPrimitive, pComputedStyle->m_InheritedData.m_fFontSize)) {
+ pValue, pComputedStyle->m_InheritedData.m_fFontSize)) {
pComputedStyle->m_NonInheritedData.m_bHasPadding = true;
}
break;
case FDE_CSSProperty::BorderLeftWidth:
if (SetLengthWithPercent(
pComputedStyle->m_NonInheritedData.m_BorderWidth.left, eType,
- pPrimitive, pComputedStyle->m_InheritedData.m_fFontSize)) {
+ pValue, pComputedStyle->m_InheritedData.m_fFontSize)) {
pComputedStyle->m_NonInheritedData.m_bHasBorder = true;
}
break;
case FDE_CSSProperty::BorderTopWidth:
if (SetLengthWithPercent(
pComputedStyle->m_NonInheritedData.m_BorderWidth.top, eType,
- pPrimitive, pComputedStyle->m_InheritedData.m_fFontSize)) {
+ pValue, pComputedStyle->m_InheritedData.m_fFontSize)) {
pComputedStyle->m_NonInheritedData.m_bHasBorder = true;
}
break;
case FDE_CSSProperty::BorderRightWidth:
if (SetLengthWithPercent(
pComputedStyle->m_NonInheritedData.m_BorderWidth.right, eType,
- pPrimitive, pComputedStyle->m_InheritedData.m_fFontSize)) {
+ pValue, pComputedStyle->m_InheritedData.m_fFontSize)) {
pComputedStyle->m_NonInheritedData.m_bHasBorder = true;
}
break;
case FDE_CSSProperty::BorderBottomWidth:
if (SetLengthWithPercent(
pComputedStyle->m_NonInheritedData.m_BorderWidth.bottom, eType,
- pPrimitive, pComputedStyle->m_InheritedData.m_fFontSize)) {
+ pValue, pComputedStyle->m_InheritedData.m_fFontSize)) {
pComputedStyle->m_NonInheritedData.m_bHasBorder = true;
}
break;
case FDE_CSSProperty::VerticalAlign:
if (eType == FDE_CSSPrimitiveType::Enum) {
pComputedStyle->m_NonInheritedData.m_eVerticalAlign =
- ToVerticalAlign(pPrimitive->GetEnum());
- } else if (eType >= FDE_CSSPrimitiveType::Number &&
- eType <= FDE_CSSPrimitiveType::Picas) {
+ ToVerticalAlign(ToValue<CFDE_CSSEnumValue>(pValue)->Value());
+ } else if (eType == FDE_CSSPrimitiveType::Number) {
pComputedStyle->m_NonInheritedData.m_eVerticalAlign =
FDE_CSSVerticalAlign::Number;
pComputedStyle->m_NonInheritedData.m_fVerticalAlign =
- ApplyNumber(eType, pPrimitive->GetFloat(),
- pComputedStyle->m_InheritedData.m_fFontSize);
+ ToValue<CFDE_CSSNumberValue>(pValue)->Apply(
+ pComputedStyle->m_InheritedData.m_fFontSize);
}
break;
case FDE_CSSProperty::FontVariant:
if (eType == FDE_CSSPrimitiveType::Enum) {
pComputedStyle->m_InheritedData.m_eFontVariant =
- ToFontVariant(pPrimitive->GetEnum());
+ ToFontVariant(ToValue<CFDE_CSSEnumValue>(pValue)->Value());
}
break;
case FDE_CSSProperty::LetterSpacing:
- if (eType == FDE_CSSPrimitiveType::Percent) {
- break;
- } else if (eType == FDE_CSSPrimitiveType::Enum) {
+ if (eType == FDE_CSSPrimitiveType::Enum) {
pComputedStyle->m_InheritedData.m_LetterSpacing.Set(
FDE_CSSLengthUnit::Normal);
- } else if (eType >= FDE_CSSPrimitiveType::Number &&
- eType <= FDE_CSSPrimitiveType::Picas) {
+ } else if (eType == FDE_CSSPrimitiveType::Number) {
+ if (ToValue<CFDE_CSSNumberValue>(pValue)->Kind() ==
+ FDE_CSSNumberType::Percent) {
+ break;
+ }
+
SetLengthWithPercent(pComputedStyle->m_InheritedData.m_LetterSpacing,
- eType, pPrimitive,
+ eType, pValue,
pComputedStyle->m_InheritedData.m_fFontSize);
}
break;
case FDE_CSSProperty::WordSpacing:
- if (eType == FDE_CSSPrimitiveType::Percent) {
- break;
- } else if (eType == FDE_CSSPrimitiveType::Enum) {
+ if (eType == FDE_CSSPrimitiveType::Enum) {
pComputedStyle->m_InheritedData.m_WordSpacing.Set(
FDE_CSSLengthUnit::Normal);
- } else if (eType >= FDE_CSSPrimitiveType::Number &&
- eType <= FDE_CSSPrimitiveType::Picas) {
+ } else if (eType == FDE_CSSPrimitiveType::Number) {
+ if (ToValue<CFDE_CSSNumberValue>(pValue)->Kind() ==
+ FDE_CSSNumberType::Percent) {
+ break;
+ }
SetLengthWithPercent(pComputedStyle->m_InheritedData.m_WordSpacing,
- eType, pPrimitive,
+ eType, pValue,
pComputedStyle->m_InheritedData.m_fFontSize);
}
break;
case FDE_CSSProperty::Top:
SetLengthWithPercent(pComputedStyle->m_NonInheritedData.m_Top, eType,
- pPrimitive,
+ pValue,
pComputedStyle->m_InheritedData.m_fFontSize);
break;
case FDE_CSSProperty::Bottom:
SetLengthWithPercent(pComputedStyle->m_NonInheritedData.m_Bottom, eType,
- pPrimitive,
+ pValue,
pComputedStyle->m_InheritedData.m_fFontSize);
break;
case FDE_CSSProperty::Left:
SetLengthWithPercent(pComputedStyle->m_NonInheritedData.m_Left, eType,
- pPrimitive,
+ pValue,
pComputedStyle->m_InheritedData.m_fFontSize);
break;
case FDE_CSSProperty::Right:
SetLengthWithPercent(pComputedStyle->m_NonInheritedData.m_Right, eType,
- pPrimitive,
+ pValue,
pComputedStyle->m_InheritedData.m_fFontSize);
break;
default:
break;
}
- } else if (pValue->GetType() == FDE_CSSVALUETYPE_List) {
- CFDE_CSSValueList* pList = static_cast<CFDE_CSSValueList*>(pValue);
+ } else if (pValue->GetType() == FDE_CSSPrimitiveType::List) {
+ CFDE_CSSValueList* pList = ToValue<CFDE_CSSValueList>(pValue);
int32_t iCount = pList->CountValues();
if (iCount > 0) {
switch (eProperty) {
@@ -618,32 +637,6 @@ void CFDE_CSSStyleSelector::ApplyProperty(
}
}
-FX_FLOAT CFDE_CSSStyleSelector::ApplyNumber(FDE_CSSPrimitiveType eUnit,
- FX_FLOAT fValue,
- FX_FLOAT fPercentBase) {
- switch (eUnit) {
- case FDE_CSSPrimitiveType::Pixels:
- case FDE_CSSPrimitiveType::Number:
- return fValue * 72 / 96;
- case FDE_CSSPrimitiveType::EMS:
- case FDE_CSSPrimitiveType::EXS:
- return fValue * fPercentBase;
- case FDE_CSSPrimitiveType::Percent:
- return fValue * fPercentBase / 100.0f;
- case FDE_CSSPrimitiveType::CentiMeters:
- return fValue * 28.3464f;
- case FDE_CSSPrimitiveType::MilliMeters:
- return fValue * 2.8346f;
- case FDE_CSSPrimitiveType::Inches:
- return fValue * 72.0f;
- case FDE_CSSPrimitiveType::Picas:
- return fValue / 12.0f;
- case FDE_CSSPrimitiveType::Points:
- default:
- return fValue;
- }
-}
-
FDE_CSSDisplay CFDE_CSSStyleSelector::ToDisplay(FDE_CSSPropertyValue eValue) {
switch (eValue) {
case FDE_CSSPropertyValue::Block:
@@ -702,21 +695,23 @@ FDE_CSSFontStyle CFDE_CSSStyleSelector::ToFontStyle(
}
}
-bool CFDE_CSSStyleSelector::SetLengthWithPercent(
- FDE_CSSLength& width,
- FDE_CSSPrimitiveType eType,
- CFDE_CSSPrimitiveValue* pPrimitive,
- FX_FLOAT fFontSize) {
- if (eType == FDE_CSSPrimitiveType::Percent) {
- width.Set(FDE_CSSLengthUnit::Percent, pPrimitive->GetFloat() / 100.0f);
- return width.NonZero();
- } else if (eType >= FDE_CSSPrimitiveType::Number &&
- eType <= FDE_CSSPrimitiveType::Picas) {
- FX_FLOAT fValue = ApplyNumber(eType, pPrimitive->GetFloat(), fFontSize);
+bool CFDE_CSSStyleSelector::SetLengthWithPercent(FDE_CSSLength& width,
+ FDE_CSSPrimitiveType eType,
+ CFDE_CSSValue* pValue,
+ FX_FLOAT fFontSize) {
+ if (eType == FDE_CSSPrimitiveType::Number) {
+ const CFDE_CSSNumberValue* v = ToValue<CFDE_CSSNumberValue>(pValue);
+ if (v->Kind() == FDE_CSSNumberType::Percent) {
+ width.Set(FDE_CSSLengthUnit::Percent,
+ ToValue<CFDE_CSSNumberValue>(pValue)->Value() / 100.0f);
+ return width.NonZero();
+ }
+
+ FX_FLOAT fValue = v->Apply(fFontSize);
width.Set(FDE_CSSLengthUnit::Point, fValue);
return width.NonZero();
} else if (eType == FDE_CSSPrimitiveType::Enum) {
- switch (pPrimitive->GetEnum()) {
+ switch (ToValue<CFDE_CSSEnumValue>(pValue)->Value()) {
case FDE_CSSPropertyValue::Auto:
width.Set(FDE_CSSLengthUnit::Auto);
return true;
@@ -791,28 +786,28 @@ FDE_CSSVerticalAlign CFDE_CSSStyleSelector::ToVerticalAlign(
uint32_t CFDE_CSSStyleSelector::ToTextDecoration(CFDE_CSSValueList* pValue) {
uint32_t dwDecoration = 0;
for (int32_t i = pValue->CountValues() - 1; i >= 0; --i) {
- CFDE_CSSPrimitiveValue* pPrimitive =
- static_cast<CFDE_CSSPrimitiveValue*>(pValue->GetValue(i));
- if (pPrimitive->GetPrimitiveType() == FDE_CSSPrimitiveType::Enum) {
- switch (pPrimitive->GetEnum()) {
- case FDE_CSSPropertyValue::Underline:
- dwDecoration |= FDE_CSSTEXTDECORATION_Underline;
- break;
- case FDE_CSSPropertyValue::LineThrough:
- dwDecoration |= FDE_CSSTEXTDECORATION_LineThrough;
- break;
- case FDE_CSSPropertyValue::Overline:
- dwDecoration |= FDE_CSSTEXTDECORATION_Overline;
- break;
- case FDE_CSSPropertyValue::Blink:
- dwDecoration |= FDE_CSSTEXTDECORATION_Blink;
- break;
- case FDE_CSSPropertyValue::Double:
- dwDecoration |= FDE_CSSTEXTDECORATION_Double;
- break;
- default:
- break;
- }
+ CFDE_CSSValue* pVal = pValue->GetValue(i);
+ if (pVal->GetType() != FDE_CSSPrimitiveType::Enum)
+ continue;
+
+ switch (ToValue<CFDE_CSSEnumValue>(pVal)->Value()) {
+ case FDE_CSSPropertyValue::Underline:
+ dwDecoration |= FDE_CSSTEXTDECORATION_Underline;
+ break;
+ case FDE_CSSPropertyValue::LineThrough:
+ dwDecoration |= FDE_CSSTEXTDECORATION_LineThrough;
+ break;
+ case FDE_CSSPropertyValue::Overline:
+ dwDecoration |= FDE_CSSTEXTDECORATION_Overline;
+ break;
+ case FDE_CSSPropertyValue::Blink:
+ dwDecoration |= FDE_CSSTEXTDECORATION_Blink;
+ break;
+ case FDE_CSSPropertyValue::Double:
+ dwDecoration |= FDE_CSSTEXTDECORATION_Double;
+ break;
+ default:
+ break;
}
}
return dwDecoration;
@@ -858,10 +853,10 @@ int32_t CFDE_CSSComputedStyle::CountFontFamilies() const {
: 0;
}
-const FX_WCHAR* CFDE_CSSComputedStyle::GetFontFamily(int32_t index) const {
- return (static_cast<CFDE_CSSPrimitiveValue*>(
- m_InheritedData.m_pFontFamily->GetValue(index)))
- ->GetString(index);
+const CFX_WideString CFDE_CSSComputedStyle::GetFontFamily(int32_t index) const {
+ return ToValue<CFDE_CSSStringValue>(
+ m_InheritedData.m_pFontFamily->GetValue(index))
+ ->Value();
}
uint16_t CFDE_CSSComputedStyle::GetFontWeight() const {
diff --git a/xfa/fde/css/fde_cssstyleselector.h b/xfa/fde/css/fde_cssstyleselector.h
index f9833f7594..f4c811b1e7 100644
--- a/xfa/fde/css/fde_cssstyleselector.h
+++ b/xfa/fde/css/fde_cssstyleselector.h
@@ -21,6 +21,7 @@ class CFDE_CSSComputedStyle;
class CFDE_CSSRule;
class CFDE_CSSSelector;
class CFDE_CSSStyleSheet;
+class CFDE_CSSValueList;
class CXFA_CSSTagProvider;
class FDE_CSSRuleData {
@@ -129,12 +130,9 @@ class CFDE_CSSStyleSelector {
CFDE_CSSValue* pValue,
CFDE_CSSComputedStyle* pComputedStyle);
- FX_FLOAT ApplyNumber(FDE_CSSPrimitiveType eUnit,
- FX_FLOAT fValue,
- FX_FLOAT fPercentBase);
bool SetLengthWithPercent(FDE_CSSLength& width,
FDE_CSSPrimitiveType eType,
- CFDE_CSSPrimitiveValue* pPrimitive,
+ CFDE_CSSValue* pValue,
FX_FLOAT fFontSize);
FX_FLOAT ToFontSize(FDE_CSSPropertyValue eValue, FX_FLOAT fCurFontSize);
FDE_CSSDisplay ToDisplay(FDE_CSSPropertyValue eValue);
@@ -201,7 +199,7 @@ class CFDE_CSSComputedStyle : public IFX_Retainable {
uint32_t Release() override;
int32_t CountFontFamilies() const;
- const FX_WCHAR* GetFontFamily(int32_t index) const;
+ const CFX_WideString GetFontFamily(int32_t index) const;
uint16_t GetFontWeight() const;
FDE_CSSFontVariant GetFontVariant() const;
FDE_CSSFontStyle GetFontStyle() const;
diff --git a/xfa/fxfa/app/cxfa_textparser.cpp b/xfa/fxfa/app/cxfa_textparser.cpp
index a0da99c8dc..1f8036937e 100644
--- a/xfa/fxfa/app/cxfa_textparser.cpp
+++ b/xfa/fxfa/app/cxfa_textparser.cpp
@@ -342,7 +342,7 @@ bool CXFA_TextParser::IsSpaceRun(CFDE_CSSComputedStyle* pStyle) const {
CFX_RetainPtr<CFGAS_GEFont> CXFA_TextParser::GetFont(
CXFA_TextProvider* pTextProvider,
CFDE_CSSComputedStyle* pStyle) const {
- CFX_WideStringC wsFamily = FX_WSTRC(L"Courier");
+ CFX_WideStringC wsFamily = L"Courier";
uint32_t dwStyle = 0;
CXFA_Font font = pTextProvider->GetFontNode();
if (font) {
@@ -356,7 +356,7 @@ CFX_RetainPtr<CFGAS_GEFont> CXFA_TextParser::GetFont(
if (pStyle) {
int32_t iCount = pStyle->CountFontFamilies();
if (iCount > 0)
- wsFamily = pStyle->GetFontFamily(iCount - 1);
+ wsFamily = pStyle->GetFontFamily(iCount - 1).AsStringC();
dwStyle = 0;
if (pStyle->GetFontWeight() > FXFONT_FW_NORMAL)