summaryrefslogtreecommitdiff
path: root/xfa/fde
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fde')
-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_csscomputedstyle.cpp195
-rw-r--r--xfa/fde/css/cfde_csscomputedstyle.h111
-rw-r--r--xfa/fde/css/cfde_csscustomproperty.cpp15
-rw-r--r--xfa/fde/css/cfde_csscustomproperty.h27
-rw-r--r--xfa/fde/css/cfde_cssdeclaration.cpp639
-rw-r--r--xfa/fde/css/cfde_cssdeclaration.h93
-rw-r--r--xfa/fde/css/cfde_cssdeclaration_unittest.cpp62
-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_cssexttextbuf.cpp17
-rw-r--r--xfa/fde/css/cfde_cssexttextbuf.h34
-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_csspropertyholder.cpp11
-rw-r--r--xfa/fde/css/cfde_csspropertyholder.h24
-rw-r--r--xfa/fde/css/cfde_cssrulecollection.cpp56
-rw-r--r--xfa/fde/css/cfde_cssrulecollection.h49
-rw-r--r--xfa/fde/css/cfde_cssselector.cpp87
-rw-r--r--xfa/fde/css/cfde_cssselector.h43
-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_cssstylerule.cpp30
-rw-r--r--xfa/fde/css/cfde_cssstylerule.h32
-rw-r--r--xfa/fde/css/cfde_cssstyleselector.cpp599
-rw-r--r--xfa/fde/css/cfde_cssstyleselector.h85
-rw-r--r--xfa/fde/css/cfde_cssstylesheet.cpp140
-rw-r--r--xfa/fde/css/cfde_cssstylesheet.h40
-rw-r--r--xfa/fde/css/cfde_cssstylesheet_unittest.cpp239
-rw-r--r--xfa/fde/css/cfde_csssyntaxparser.cpp228
-rw-r--r--xfa/fde/css/cfde_csssyntaxparser.h75
-rw-r--r--xfa/fde/css/cfde_csstextbuf.cpp49
-rw-r--r--xfa/fde/css/cfde_csstextbuf.h35
-rw-r--r--xfa/fde/css/cfde_cssvalue.cpp9
-rw-r--r--xfa/fde/css/cfde_cssvalue.h23
-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.cpp87
-rw-r--r--xfa/fde/css/cfde_cssvaluelistparser.h30
-rw-r--r--xfa/fde/css/cfde_cssvaluelistparser_unittest.cpp143
-rw-r--r--xfa/fde/css/fde_css.h242
-rw-r--r--xfa/fde/css/fde_cssdatatable.cpp285
-rw-r--r--xfa/fde/css/fde_cssdatatable.h56
44 files changed, 0 insertions, 4126 deletions
diff --git a/xfa/fde/css/cfde_csscolorvalue.cpp b/xfa/fde/css/cfde_csscolorvalue.cpp
deleted file mode 100644
index 015355136c..0000000000
--- a/xfa/fde/css/cfde_csscolorvalue.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-// 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
deleted file mode 100644
index 1d0441ad2a..0000000000
--- a/xfa/fde/css/cfde_csscolorvalue.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// 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_csscomputedstyle.cpp b/xfa/fde/css/cfde_csscomputedstyle.cpp
deleted file mode 100644
index 92184d4259..0000000000
--- a/xfa/fde/css/cfde_csscomputedstyle.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-// 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_csscomputedstyle.h"
-
-#include "third_party/base/stl_util.h"
-#include "xfa/fde/css/cfde_cssstringvalue.h"
-#include "xfa/fde/css/cfde_cssvaluelist.h"
-
-CFDE_CSSComputedStyle::CFDE_CSSComputedStyle() {}
-
-CFDE_CSSComputedStyle::~CFDE_CSSComputedStyle() {}
-
-bool CFDE_CSSComputedStyle::GetCustomStyle(const CFX_WideString& wsName,
- CFX_WideString& wsValue) const {
- for (auto iter = m_CustomProperties.rbegin();
- iter != m_CustomProperties.rend(); iter++) {
- if (wsName == iter->name()) {
- wsValue = iter->value();
- return true;
- }
- }
- return false;
-}
-
-int32_t CFDE_CSSComputedStyle::CountFontFamilies() const {
- return m_InheritedData.m_pFontFamily
- ? m_InheritedData.m_pFontFamily->CountValues()
- : 0;
-}
-
-const CFX_WideString CFDE_CSSComputedStyle::GetFontFamily(int32_t index) const {
- return m_InheritedData.m_pFontFamily->GetValue(index)
- .As<CFDE_CSSStringValue>()
- ->Value();
-}
-
-uint16_t CFDE_CSSComputedStyle::GetFontWeight() const {
- return m_InheritedData.m_wFontWeight;
-}
-
-FDE_CSSFontVariant CFDE_CSSComputedStyle::GetFontVariant() const {
- return m_InheritedData.m_eFontVariant;
-}
-
-FDE_CSSFontStyle CFDE_CSSComputedStyle::GetFontStyle() const {
- return m_InheritedData.m_eFontStyle;
-}
-
-float CFDE_CSSComputedStyle::GetFontSize() const {
- return m_InheritedData.m_fFontSize;
-}
-
-FX_ARGB CFDE_CSSComputedStyle::GetColor() const {
- return m_InheritedData.m_dwFontColor;
-}
-
-void CFDE_CSSComputedStyle::SetFontWeight(uint16_t wFontWeight) {
- m_InheritedData.m_wFontWeight = wFontWeight;
-}
-
-void CFDE_CSSComputedStyle::SetFontVariant(FDE_CSSFontVariant eFontVariant) {
- m_InheritedData.m_eFontVariant = eFontVariant;
-}
-
-void CFDE_CSSComputedStyle::SetFontStyle(FDE_CSSFontStyle eFontStyle) {
- m_InheritedData.m_eFontStyle = eFontStyle;
-}
-
-void CFDE_CSSComputedStyle::SetFontSize(float fFontSize) {
- m_InheritedData.m_fFontSize = fFontSize;
-}
-
-void CFDE_CSSComputedStyle::SetColor(FX_ARGB dwFontColor) {
- m_InheritedData.m_dwFontColor = dwFontColor;
-}
-
-const FDE_CSSRect* CFDE_CSSComputedStyle::GetBorderWidth() const {
- return m_NonInheritedData.m_bHasBorder ? &(m_NonInheritedData.m_BorderWidth)
- : nullptr;
-}
-
-const FDE_CSSRect* CFDE_CSSComputedStyle::GetMarginWidth() const {
- return m_NonInheritedData.m_bHasMargin ? &(m_NonInheritedData.m_MarginWidth)
- : nullptr;
-}
-
-const FDE_CSSRect* CFDE_CSSComputedStyle::GetPaddingWidth() const {
- return m_NonInheritedData.m_bHasPadding ? &(m_NonInheritedData.m_PaddingWidth)
- : nullptr;
-}
-
-void CFDE_CSSComputedStyle::SetMarginWidth(const FDE_CSSRect& rect) {
- m_NonInheritedData.m_MarginWidth = rect;
- m_NonInheritedData.m_bHasMargin = true;
-}
-
-void CFDE_CSSComputedStyle::SetPaddingWidth(const FDE_CSSRect& rect) {
- m_NonInheritedData.m_PaddingWidth = rect;
- m_NonInheritedData.m_bHasPadding = true;
-}
-
-FDE_CSSDisplay CFDE_CSSComputedStyle::GetDisplay() const {
- return m_NonInheritedData.m_eDisplay;
-}
-
-float CFDE_CSSComputedStyle::GetLineHeight() const {
- return m_InheritedData.m_fLineHeight;
-}
-
-const FDE_CSSLength& CFDE_CSSComputedStyle::GetTextIndent() const {
- return m_InheritedData.m_TextIndent;
-}
-
-FDE_CSSTextAlign CFDE_CSSComputedStyle::GetTextAlign() const {
- return m_InheritedData.m_eTextAlign;
-}
-
-FDE_CSSVerticalAlign CFDE_CSSComputedStyle::GetVerticalAlign() const {
- return m_NonInheritedData.m_eVerticalAlign;
-}
-
-float CFDE_CSSComputedStyle::GetNumberVerticalAlign() const {
- return m_NonInheritedData.m_fVerticalAlign;
-}
-
-uint32_t CFDE_CSSComputedStyle::GetTextDecoration() const {
- return m_NonInheritedData.m_dwTextDecoration;
-}
-
-const FDE_CSSLength& CFDE_CSSComputedStyle::GetLetterSpacing() const {
- return m_InheritedData.m_LetterSpacing;
-}
-
-void CFDE_CSSComputedStyle::SetLineHeight(float fLineHeight) {
- m_InheritedData.m_fLineHeight = fLineHeight;
-}
-
-void CFDE_CSSComputedStyle::SetTextIndent(const FDE_CSSLength& textIndent) {
- m_InheritedData.m_TextIndent = textIndent;
-}
-
-void CFDE_CSSComputedStyle::SetTextAlign(FDE_CSSTextAlign eTextAlign) {
- m_InheritedData.m_eTextAlign = eTextAlign;
-}
-
-void CFDE_CSSComputedStyle::SetNumberVerticalAlign(float fAlign) {
- m_NonInheritedData.m_eVerticalAlign = FDE_CSSVerticalAlign::Number,
- m_NonInheritedData.m_fVerticalAlign = fAlign;
-}
-
-void CFDE_CSSComputedStyle::SetTextDecoration(uint32_t dwTextDecoration) {
- m_NonInheritedData.m_dwTextDecoration = dwTextDecoration;
-}
-
-void CFDE_CSSComputedStyle::SetLetterSpacing(
- const FDE_CSSLength& letterSpacing) {
- m_InheritedData.m_LetterSpacing = letterSpacing;
-}
-
-void CFDE_CSSComputedStyle::AddCustomStyle(const CFDE_CSSCustomProperty& prop) {
- // Force the property to be copied so we aren't dependent on the lifetime
- // of whatever currently owns it.
- m_CustomProperties.push_back(prop);
-}
-
-CFDE_CSSComputedStyle::InheritedData::InheritedData()
- : m_LetterSpacing(FDE_CSSLengthUnit::Normal),
- m_WordSpacing(FDE_CSSLengthUnit::Normal),
- m_TextIndent(FDE_CSSLengthUnit::Point, 0),
- m_pFontFamily(nullptr),
- m_fFontSize(12.0f),
- m_fLineHeight(14.0f),
- m_dwFontColor(0xFF000000),
- m_wFontWeight(400),
- m_eFontVariant(FDE_CSSFontVariant::Normal),
- m_eFontStyle(FDE_CSSFontStyle::Normal),
- m_eTextAlign(FDE_CSSTextAlign::Left) {}
-
-CFDE_CSSComputedStyle::InheritedData::~InheritedData() {}
-
-CFDE_CSSComputedStyle::NonInheritedData::NonInheritedData()
- : m_MarginWidth(FDE_CSSLengthUnit::Point, 0),
- m_BorderWidth(FDE_CSSLengthUnit::Point, 0),
- m_PaddingWidth(FDE_CSSLengthUnit::Point, 0),
- m_fVerticalAlign(0.0f),
- m_eDisplay(FDE_CSSDisplay::Inline),
- m_eVerticalAlign(FDE_CSSVerticalAlign::Baseline),
- m_dwTextDecoration(0),
- m_bHasMargin(false),
- m_bHasBorder(false),
- m_bHasPadding(false) {}
diff --git a/xfa/fde/css/cfde_csscomputedstyle.h b/xfa/fde/css/cfde_csscomputedstyle.h
deleted file mode 100644
index 448d2467ab..0000000000
--- a/xfa/fde/css/cfde_csscomputedstyle.h
+++ /dev/null
@@ -1,111 +0,0 @@
-// 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_CSSCOMPUTEDSTYLE_H_
-#define XFA_FDE_CSS_CFDE_CSSCOMPUTEDSTYLE_H_
-
-#include <vector>
-
-#include "core/fxcrt/fx_basic.h"
-#include "core/fxcrt/fx_string.h"
-#include "xfa/fde/css/cfde_csscustomproperty.h"
-#include "xfa/fde/css/fde_css.h"
-
-class CFDE_CSSValueList;
-
-class CFDE_CSSComputedStyle : public CFX_Retainable {
- public:
- class InheritedData {
- public:
- InheritedData();
- ~InheritedData();
-
- FDE_CSSLength m_LetterSpacing;
- FDE_CSSLength m_WordSpacing;
- FDE_CSSLength m_TextIndent;
- CFX_RetainPtr<CFDE_CSSValueList> m_pFontFamily;
- float m_fFontSize;
- float m_fLineHeight;
- FX_ARGB m_dwFontColor;
- uint16_t m_wFontWeight;
- FDE_CSSFontVariant m_eFontVariant;
- FDE_CSSFontStyle m_eFontStyle;
- FDE_CSSTextAlign m_eTextAlign;
- };
-
- class NonInheritedData {
- public:
- NonInheritedData();
-
- FDE_CSSRect m_MarginWidth;
- FDE_CSSRect m_BorderWidth;
- FDE_CSSRect m_PaddingWidth;
- FDE_CSSLength m_Top;
- FDE_CSSLength m_Bottom;
- FDE_CSSLength m_Left;
- FDE_CSSLength m_Right;
- float m_fVerticalAlign;
- FDE_CSSDisplay m_eDisplay;
- FDE_CSSVerticalAlign m_eVerticalAlign;
- uint8_t m_dwTextDecoration;
- bool m_bHasMargin;
- bool m_bHasBorder;
- bool m_bHasPadding;
- };
-
- int32_t CountFontFamilies() const;
- const CFX_WideString GetFontFamily(int32_t index) const;
- uint16_t GetFontWeight() const;
- FDE_CSSFontVariant GetFontVariant() const;
- FDE_CSSFontStyle GetFontStyle() const;
- float GetFontSize() const;
- FX_ARGB GetColor() const;
- void SetFontWeight(uint16_t wFontWeight);
- void SetFontVariant(FDE_CSSFontVariant eFontVariant);
- void SetFontStyle(FDE_CSSFontStyle eFontStyle);
- void SetFontSize(float fFontSize);
- void SetColor(FX_ARGB dwFontColor);
-
- const FDE_CSSRect* GetBorderWidth() const;
- const FDE_CSSRect* GetMarginWidth() const;
- const FDE_CSSRect* GetPaddingWidth() const;
- void SetMarginWidth(const FDE_CSSRect& rect);
- void SetPaddingWidth(const FDE_CSSRect& rect);
-
- FDE_CSSDisplay GetDisplay() const;
-
- float GetLineHeight() const;
- const FDE_CSSLength& GetTextIndent() const;
- FDE_CSSTextAlign GetTextAlign() const;
- FDE_CSSVerticalAlign GetVerticalAlign() const;
- float GetNumberVerticalAlign() const;
- uint32_t GetTextDecoration() const;
- const FDE_CSSLength& GetLetterSpacing() const;
- void SetLineHeight(float fLineHeight);
- void SetTextIndent(const FDE_CSSLength& textIndent);
- void SetTextAlign(FDE_CSSTextAlign eTextAlign);
- void SetNumberVerticalAlign(float fAlign);
- void SetTextDecoration(uint32_t dwTextDecoration);
- void SetLetterSpacing(const FDE_CSSLength& letterSpacing);
- void AddCustomStyle(const CFDE_CSSCustomProperty& prop);
-
- bool GetCustomStyle(const CFX_WideString& wsName,
- CFX_WideString& wsValue) const;
-
- InheritedData m_InheritedData;
- NonInheritedData m_NonInheritedData;
-
- private:
- template <typename T, typename... Args>
- friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
-
- CFDE_CSSComputedStyle();
- ~CFDE_CSSComputedStyle() override;
-
- std::vector<CFDE_CSSCustomProperty> m_CustomProperties;
-};
-
-#endif // XFA_FDE_CSS_CFDE_CSSCOMPUTEDSTYLE_H_
diff --git a/xfa/fde/css/cfde_csscustomproperty.cpp b/xfa/fde/css/cfde_csscustomproperty.cpp
deleted file mode 100644
index 92b288eb4f..0000000000
--- a/xfa/fde/css/cfde_csscustomproperty.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// 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.
-
-#include "xfa/fde/css/cfde_csscustomproperty.h"
-
-CFDE_CSSCustomProperty::CFDE_CSSCustomProperty(const CFX_WideString& name,
- const CFX_WideString& value)
- : name_(name), value_(value) {}
-
-CFDE_CSSCustomProperty::CFDE_CSSCustomProperty(
- const CFDE_CSSCustomProperty& prop)
- : name_(prop.name_), value_(prop.value_) {}
-
-CFDE_CSSCustomProperty::~CFDE_CSSCustomProperty() {}
diff --git a/xfa/fde/css/cfde_csscustomproperty.h b/xfa/fde/css/cfde_csscustomproperty.h
deleted file mode 100644
index 6970d49cbb..0000000000
--- a/xfa/fde/css/cfde_csscustomproperty.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// 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_CSSCUSTOMPROPERTY_H_
-#define XFA_FDE_CSS_CFDE_CSSCUSTOMPROPERTY_H_
-
-#include "core/fxcrt/fx_string.h"
-
-class CFDE_CSSCustomProperty {
- public:
- CFDE_CSSCustomProperty(const CFX_WideString& name,
- const CFX_WideString& value);
- CFDE_CSSCustomProperty(const CFDE_CSSCustomProperty& prop);
- ~CFDE_CSSCustomProperty();
-
- CFX_WideString name() const { return name_; }
- CFX_WideString value() const { return value_; }
-
- private:
- CFX_WideString name_;
- CFX_WideString value_;
-};
-
-#endif // XFA_FDE_CSS_CFDE_CSSCUSTOMPROPERTY_H_
diff --git a/xfa/fde/css/cfde_cssdeclaration.cpp b/xfa/fde/css/cfde_cssdeclaration.cpp
deleted file mode 100644
index e15e5f7fe7..0000000000
--- a/xfa/fde/css/cfde_cssdeclaration.cpp
+++ /dev/null
@@ -1,639 +0,0 @@
-// Copyright 2014 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_cssdeclaration.h"
-
-#include "core/fxcrt/fx_extension.h"
-#include "third_party/base/logging.h"
-#include "third_party/base/ptr_util.h"
-#include "xfa/fde/css/cfde_csscolorvalue.h"
-#include "xfa/fde/css/cfde_csscustomproperty.h"
-#include "xfa/fde/css/cfde_cssenumvalue.h"
-#include "xfa/fde/css/cfde_cssnumbervalue.h"
-#include "xfa/fde/css/cfde_csspropertyholder.h"
-#include "xfa/fde/css/cfde_cssstringvalue.h"
-#include "xfa/fde/css/cfde_cssvaluelist.h"
-#include "xfa/fde/css/cfde_cssvaluelistparser.h"
-
-namespace {
-
-uint8_t Hex2Dec(uint8_t hexHigh, uint8_t hexLow) {
- return (FXSYS_HexCharToInt(hexHigh) << 4) + FXSYS_HexCharToInt(hexLow);
-}
-
-bool ParseCSSNumber(const wchar_t* pszValue,
- int32_t iValueLen,
- float& fValue,
- FDE_CSSNumberType& eUnit) {
- ASSERT(pszValue && iValueLen > 0);
- int32_t iUsedLen = 0;
- fValue = FXSYS_wcstof(pszValue, iValueLen, &iUsedLen);
- if (iUsedLen <= 0)
- return false;
-
- iValueLen -= iUsedLen;
- pszValue += iUsedLen;
- eUnit = FDE_CSSNumberType::Number;
- if (iValueLen >= 1 && *pszValue == '%') {
- eUnit = FDE_CSSNumberType::Percent;
- } else if (iValueLen == 2) {
- const FDE_CSSLengthUnitTable* pUnit =
- FDE_GetCSSLengthUnitByName(CFX_WideStringC(pszValue, 2));
- if (pUnit)
- eUnit = pUnit->wValue;
- }
- return true;
-}
-
-} // namespace
-
-// static
-bool CFDE_CSSDeclaration::ParseCSSString(const wchar_t* pszValue,
- int32_t iValueLen,
- int32_t* iOffset,
- int32_t* iLength) {
- ASSERT(pszValue && iValueLen > 0);
- *iOffset = 0;
- *iLength = iValueLen;
- if (iValueLen >= 2) {
- wchar_t first = pszValue[0], last = pszValue[iValueLen - 1];
- if ((first == '\"' && last == '\"') || (first == '\'' && last == '\'')) {
- *iOffset = 1;
- *iLength -= 2;
- }
- }
- return iValueLen > 0;
-}
-
-// static.
-bool CFDE_CSSDeclaration::ParseCSSColor(const wchar_t* pszValue,
- int32_t iValueLen,
- FX_ARGB* dwColor) {
- ASSERT(pszValue && iValueLen > 0);
- ASSERT(dwColor);
-
- if (*pszValue == '#') {
- switch (iValueLen) {
- case 4: {
- uint8_t red = Hex2Dec((uint8_t)pszValue[1], (uint8_t)pszValue[1]);
- uint8_t green = Hex2Dec((uint8_t)pszValue[2], (uint8_t)pszValue[2]);
- uint8_t blue = Hex2Dec((uint8_t)pszValue[3], (uint8_t)pszValue[3]);
- *dwColor = ArgbEncode(255, red, green, blue);
- return true;
- }
- case 7: {
- uint8_t red = Hex2Dec((uint8_t)pszValue[1], (uint8_t)pszValue[2]);
- uint8_t green = Hex2Dec((uint8_t)pszValue[3], (uint8_t)pszValue[4]);
- uint8_t blue = Hex2Dec((uint8_t)pszValue[5], (uint8_t)pszValue[6]);
- *dwColor = ArgbEncode(255, red, green, blue);
- return true;
- }
- default:
- return false;
- }
- }
-
- if (iValueLen >= 10) {
- if (pszValue[iValueLen - 1] != ')' || FXSYS_wcsnicmp(L"rgb(", pszValue, 4))
- return false;
-
- uint8_t rgb[3] = {0};
- float fValue;
- FDE_CSSPrimitiveType eType;
- CFDE_CSSValueListParser list(pszValue + 4, iValueLen - 5, ',');
- for (int32_t i = 0; i < 3; ++i) {
- if (!list.NextValue(eType, pszValue, iValueLen))
- return false;
- if (eType != FDE_CSSPrimitiveType::Number)
- return false;
- FDE_CSSNumberType eNumType;
- if (!ParseCSSNumber(pszValue, iValueLen, fValue, eNumType))
- return false;
-
- rgb[i] = eNumType == FDE_CSSNumberType::Percent
- ? FXSYS_round(fValue * 2.55f)
- : FXSYS_round(fValue);
- }
- *dwColor = ArgbEncode(255, rgb[0], rgb[1], rgb[2]);
- return true;
- }
-
- const FDE_CSSCOLORTABLE* pColor =
- FDE_GetCSSColorByName(CFX_WideStringC(pszValue, iValueLen));
- if (!pColor)
- return false;
-
- *dwColor = pColor->dwValue;
- return true;
-}
-
-CFDE_CSSDeclaration::CFDE_CSSDeclaration() {}
-
-CFDE_CSSDeclaration::~CFDE_CSSDeclaration() {}
-
-CFX_RetainPtr<CFDE_CSSValue> CFDE_CSSDeclaration::GetProperty(
- FDE_CSSProperty eProperty,
- bool* bImportant) const {
- for (const auto& p : properties_) {
- if (p->eProperty == eProperty) {
- *bImportant = p->bImportant;
- return p->pValue;
- }
- }
- return nullptr;
-}
-
-void CFDE_CSSDeclaration::AddPropertyHolder(FDE_CSSProperty eProperty,
- CFX_RetainPtr<CFDE_CSSValue> pValue,
- bool bImportant) {
- auto pHolder = pdfium::MakeUnique<CFDE_CSSPropertyHolder>();
- pHolder->bImportant = bImportant;
- pHolder->eProperty = eProperty;
- pHolder->pValue = pValue;
- properties_.push_back(std::move(pHolder));
-}
-
-void CFDE_CSSDeclaration::AddProperty(const FDE_CSSPropertyTable* pTable,
- const CFX_WideStringC& value) {
- ASSERT(!value.IsEmpty());
-
- const wchar_t* pszValue = value.unterminated_c_str();
- int32_t iValueLen = value.GetLength();
- bool bImportant = false;
- if (iValueLen >= 10 && pszValue[iValueLen - 10] == '!' &&
- FXSYS_wcsnicmp(L"important", pszValue + iValueLen - 9, 9) == 0) {
- if ((iValueLen -= 10) == 0)
- return;
-
- bImportant = true;
- }
- const uint32_t dwType = pTable->dwType;
- switch (dwType & 0x0F) {
- case FDE_CSSVALUETYPE_Primitive: {
- static const uint32_t g_ValueGuessOrder[] = {
- FDE_CSSVALUETYPE_MaybeNumber, FDE_CSSVALUETYPE_MaybeEnum,
- FDE_CSSVALUETYPE_MaybeColor, FDE_CSSVALUETYPE_MaybeString,
- };
- static const int32_t g_ValueGuessCount =
- sizeof(g_ValueGuessOrder) / sizeof(uint32_t);
- for (int32_t i = 0; i < g_ValueGuessCount; ++i) {
- const uint32_t dwMatch = dwType & g_ValueGuessOrder[i];
- if (dwMatch == 0) {
- continue;
- }
- CFX_RetainPtr<CFDE_CSSValue> pCSSValue;
- switch (dwMatch) {
- case FDE_CSSVALUETYPE_MaybeNumber:
- pCSSValue = ParseNumber(pszValue, iValueLen);
- break;
- case FDE_CSSVALUETYPE_MaybeEnum:
- pCSSValue = ParseEnum(pszValue, iValueLen);
- break;
- case FDE_CSSVALUETYPE_MaybeColor:
- pCSSValue = ParseColor(pszValue, iValueLen);
- break;
- case FDE_CSSVALUETYPE_MaybeString:
- pCSSValue = ParseString(pszValue, iValueLen);
- break;
- default:
- break;
- }
- if (pCSSValue) {
- AddPropertyHolder(pTable->eName, pCSSValue, bImportant);
- return;
- }
- if (FDE_IsOnlyValue(dwType, g_ValueGuessOrder[i]))
- return;
- }
- break;
- }
- case FDE_CSSVALUETYPE_Shorthand: {
- CFX_RetainPtr<CFDE_CSSValue> pWidth;
- switch (pTable->eName) {
- case FDE_CSSProperty::Font:
- ParseFontProperty(pszValue, iValueLen, bImportant);
- return;
- case FDE_CSSProperty::Border:
- if (ParseBorderProperty(pszValue, iValueLen, pWidth)) {
- AddPropertyHolder(FDE_CSSProperty::BorderLeftWidth, pWidth,
- bImportant);
- AddPropertyHolder(FDE_CSSProperty::BorderTopWidth, pWidth,
- bImportant);
- AddPropertyHolder(FDE_CSSProperty::BorderRightWidth, pWidth,
- bImportant);
- AddPropertyHolder(FDE_CSSProperty::BorderBottomWidth, pWidth,
- bImportant);
- return;
- }
- break;
- case FDE_CSSProperty::BorderLeft:
- if (ParseBorderProperty(pszValue, iValueLen, pWidth)) {
- AddPropertyHolder(FDE_CSSProperty::BorderLeftWidth, pWidth,
- bImportant);
- return;
- }
- break;
- case FDE_CSSProperty::BorderTop:
- if (ParseBorderProperty(pszValue, iValueLen, pWidth)) {
- AddPropertyHolder(FDE_CSSProperty::BorderTopWidth, pWidth,
- bImportant);
- return;
- }
- break;
- case FDE_CSSProperty::BorderRight:
- if (ParseBorderProperty(pszValue, iValueLen, pWidth)) {
- AddPropertyHolder(FDE_CSSProperty::BorderRightWidth, pWidth,
- bImportant);
- return;
- }
- break;
- case FDE_CSSProperty::BorderBottom:
- if (ParseBorderProperty(pszValue, iValueLen, pWidth)) {
- AddPropertyHolder(FDE_CSSProperty::BorderBottomWidth, pWidth,
- bImportant);
- return;
- }
- break;
- default:
- break;
- }
- } break;
- case FDE_CSSVALUETYPE_List:
- ParseValueListProperty(pTable, pszValue, iValueLen, bImportant);
- return;
- default:
- NOTREACHED();
- break;
- }
-}
-
-void CFDE_CSSDeclaration::AddProperty(const CFX_WideString& prop,
- const CFX_WideString& value) {
- custom_properties_.push_back(
- pdfium::MakeUnique<CFDE_CSSCustomProperty>(prop, value));
-}
-
-CFX_RetainPtr<CFDE_CSSValue> CFDE_CSSDeclaration::ParseNumber(
- const wchar_t* pszValue,
- int32_t iValueLen) {
- float fValue;
- FDE_CSSNumberType eUnit;
- if (!ParseCSSNumber(pszValue, iValueLen, fValue, eUnit))
- return nullptr;
- return pdfium::MakeRetain<CFDE_CSSNumberValue>(eUnit, fValue);
-}
-
-CFX_RetainPtr<CFDE_CSSValue> CFDE_CSSDeclaration::ParseEnum(
- const wchar_t* pszValue,
- int32_t iValueLen) {
- const FDE_CSSPropertyValueTable* pValue =
- FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
- return pValue ? pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName)
- : nullptr;
-}
-
-CFX_RetainPtr<CFDE_CSSValue> CFDE_CSSDeclaration::ParseColor(
- const wchar_t* pszValue,
- int32_t iValueLen) {
- FX_ARGB dwColor;
- if (!ParseCSSColor(pszValue, iValueLen, &dwColor))
- return nullptr;
- return pdfium::MakeRetain<CFDE_CSSColorValue>(dwColor);
-}
-
-CFX_RetainPtr<CFDE_CSSValue> CFDE_CSSDeclaration::ParseString(
- const wchar_t* pszValue,
- int32_t iValueLen) {
- int32_t iOffset;
- if (!ParseCSSString(pszValue, iValueLen, &iOffset, &iValueLen))
- return nullptr;
-
- if (iValueLen <= 0)
- return nullptr;
-
- return pdfium::MakeRetain<CFDE_CSSStringValue>(
- CFX_WideString(pszValue + iOffset, iValueLen));
-}
-
-void CFDE_CSSDeclaration::ParseValueListProperty(
- const FDE_CSSPropertyTable* pTable,
- const wchar_t* pszValue,
- int32_t iValueLen,
- bool bImportant) {
- wchar_t separator =
- (pTable->eName == FDE_CSSProperty::FontFamily) ? ',' : ' ';
- CFDE_CSSValueListParser parser(pszValue, iValueLen, separator);
-
- const uint32_t dwType = pTable->dwType;
- FDE_CSSPrimitiveType eType;
- std::vector<CFX_RetainPtr<CFDE_CSSValue>> list;
- while (parser.NextValue(eType, pszValue, iValueLen)) {
- switch (eType) {
- case FDE_CSSPrimitiveType::Number:
- if (dwType & FDE_CSSVALUETYPE_MaybeNumber) {
- float fValue;
- FDE_CSSNumberType eNumType;
- if (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 (ParseCSSColor(pszValue, iValueLen, &dwColor)) {
- list.push_back(pdfium::MakeRetain<CFDE_CSSColorValue>(dwColor));
- continue;
- }
- }
- if (dwType & FDE_CSSVALUETYPE_MaybeEnum) {
- const FDE_CSSPropertyValueTable* pValue =
- FDE_GetCSSPropertyValueByName(
- CFX_WideStringC(pszValue, iValueLen));
- if (pValue) {
- list.push_back(
- pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName));
- continue;
- }
- }
- if (dwType & FDE_CSSVALUETYPE_MaybeString) {
- list.push_back(pdfium::MakeRetain<CFDE_CSSStringValue>(
- CFX_WideString(pszValue, iValueLen)));
- }
- break;
- case FDE_CSSPrimitiveType::RGB:
- if (dwType & FDE_CSSVALUETYPE_MaybeColor) {
- FX_ARGB dwColor;
- if (ParseCSSColor(pszValue, iValueLen, &dwColor)) {
- list.push_back(pdfium::MakeRetain<CFDE_CSSColorValue>(dwColor));
- }
- }
- break;
- default:
- break;
- }
- }
- if (list.empty())
- return;
-
- switch (pTable->eName) {
- case FDE_CSSProperty::BorderWidth:
- Add4ValuesProperty(list, bImportant, FDE_CSSProperty::BorderLeftWidth,
- FDE_CSSProperty::BorderTopWidth,
- FDE_CSSProperty::BorderRightWidth,
- FDE_CSSProperty::BorderBottomWidth);
- return;
- case FDE_CSSProperty::Margin:
- Add4ValuesProperty(list, bImportant, FDE_CSSProperty::MarginLeft,
- FDE_CSSProperty::MarginTop,
- FDE_CSSProperty::MarginRight,
- FDE_CSSProperty::MarginBottom);
- return;
- case FDE_CSSProperty::Padding:
- Add4ValuesProperty(list, bImportant, FDE_CSSProperty::PaddingLeft,
- FDE_CSSProperty::PaddingTop,
- FDE_CSSProperty::PaddingRight,
- FDE_CSSProperty::PaddingBottom);
- return;
- default: {
- auto pList = pdfium::MakeRetain<CFDE_CSSValueList>(list);
- AddPropertyHolder(pTable->eName, pList, bImportant);
- return;
- }
- }
-}
-
-void CFDE_CSSDeclaration::Add4ValuesProperty(
- const std::vector<CFX_RetainPtr<CFDE_CSSValue>>& list,
- bool bImportant,
- FDE_CSSProperty eLeft,
- FDE_CSSProperty eTop,
- FDE_CSSProperty eRight,
- FDE_CSSProperty eBottom) {
- switch (list.size()) {
- case 1:
- AddPropertyHolder(eLeft, list[0], bImportant);
- AddPropertyHolder(eTop, list[0], bImportant);
- AddPropertyHolder(eRight, list[0], bImportant);
- AddPropertyHolder(eBottom, list[0], bImportant);
- return;
- case 2:
- AddPropertyHolder(eLeft, list[1], bImportant);
- AddPropertyHolder(eTop, list[0], bImportant);
- AddPropertyHolder(eRight, list[1], bImportant);
- AddPropertyHolder(eBottom, list[0], bImportant);
- return;
- case 3:
- AddPropertyHolder(eLeft, list[1], bImportant);
- AddPropertyHolder(eTop, list[0], bImportant);
- AddPropertyHolder(eRight, list[1], bImportant);
- AddPropertyHolder(eBottom, list[2], bImportant);
- return;
- case 4:
- AddPropertyHolder(eLeft, list[3], bImportant);
- AddPropertyHolder(eTop, list[0], bImportant);
- AddPropertyHolder(eRight, list[1], bImportant);
- AddPropertyHolder(eBottom, list[2], bImportant);
- return;
- default:
- break;
- }
-}
-
-bool CFDE_CSSDeclaration::ParseBorderProperty(
- const wchar_t* pszValue,
- int32_t iValueLen,
- CFX_RetainPtr<CFDE_CSSValue>& pWidth) const {
- pWidth.Reset(nullptr);
-
- CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
- FDE_CSSPrimitiveType eType;
- while (parser.NextValue(eType, pszValue, iValueLen)) {
- switch (eType) {
- case FDE_CSSPrimitiveType::Number: {
- if (pWidth)
- continue;
-
- float fValue;
- FDE_CSSNumberType eNumType;
- if (ParseCSSNumber(pszValue, iValueLen, fValue, eNumType))
- pWidth = pdfium::MakeRetain<CFDE_CSSNumberValue>(eNumType, fValue);
- break;
- }
- case FDE_CSSPrimitiveType::String: {
- const FDE_CSSCOLORTABLE* pColorItem =
- FDE_GetCSSColorByName(CFX_WideStringC(pszValue, iValueLen));
- if (pColorItem)
- continue;
-
- const FDE_CSSPropertyValueTable* pValue =
- FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
- if (!pValue)
- continue;
-
- switch (pValue->eName) {
- case FDE_CSSPropertyValue::Thin:
- case FDE_CSSPropertyValue::Thick:
- case FDE_CSSPropertyValue::Medium:
- if (!pWidth)
- pWidth = pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
- break;
- default:
- break;
- }
- break;
- }
- default:
- break;
- }
- }
- if (!pWidth)
- pWidth = pdfium::MakeRetain<CFDE_CSSNumberValue>(FDE_CSSNumberType::Number,
- 0.0f);
-
- return true;
-}
-
-void CFDE_CSSDeclaration::ParseFontProperty(const wchar_t* pszValue,
- int32_t iValueLen,
- bool bImportant) {
- CFDE_CSSValueListParser parser(pszValue, iValueLen, '/');
- 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)) {
- switch (eType) {
- case FDE_CSSPrimitiveType::String: {
- const FDE_CSSPropertyValueTable* pValue =
- FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
- if (pValue) {
- switch (pValue->eName) {
- case FDE_CSSPropertyValue::XxSmall:
- case FDE_CSSPropertyValue::XSmall:
- case FDE_CSSPropertyValue::Small:
- case FDE_CSSPropertyValue::Medium:
- case FDE_CSSPropertyValue::Large:
- case FDE_CSSPropertyValue::XLarge:
- case FDE_CSSPropertyValue::XxLarge:
- case FDE_CSSPropertyValue::Smaller:
- case FDE_CSSPropertyValue::Larger:
- if (!pFontSize)
- pFontSize =
- pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
- continue;
- case FDE_CSSPropertyValue::Bold:
- case FDE_CSSPropertyValue::Bolder:
- case FDE_CSSPropertyValue::Lighter:
- if (!pWeight)
- pWeight = pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
- continue;
- case FDE_CSSPropertyValue::Italic:
- case FDE_CSSPropertyValue::Oblique:
- if (!pStyle)
- pStyle = pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
- continue;
- case FDE_CSSPropertyValue::SmallCaps:
- if (!pVariant)
- pVariant = pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
- continue;
- case FDE_CSSPropertyValue::Normal:
- if (!pStyle)
- pStyle = pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
- else if (!pVariant)
- pVariant = pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
- else if (!pWeight)
- pWeight = pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
- else if (!pFontSize)
- pFontSize =
- pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
- else if (!pLineHeight)
- pLineHeight =
- pdfium::MakeRetain<CFDE_CSSEnumValue>(pValue->eName);
- continue;
- default:
- break;
- }
- }
- if (pFontSize) {
- familyList.push_back(pdfium::MakeRetain<CFDE_CSSStringValue>(
- CFX_WideString(pszValue, iValueLen)));
- }
- parser.m_Separator = ',';
- break;
- }
- case FDE_CSSPrimitiveType::Number: {
- float fValue;
- FDE_CSSNumberType eNumType;
- if (!ParseCSSNumber(pszValue, iValueLen, fValue, eNumType))
- break;
- if (eType == FDE_CSSPrimitiveType::Number) {
- switch ((int32_t)fValue) {
- case 100:
- case 200:
- case 300:
- case 400:
- case 500:
- case 600:
- case 700:
- case 800:
- case 900:
- if (!pWeight)
- pWeight = pdfium::MakeRetain<CFDE_CSSNumberValue>(
- FDE_CSSNumberType::Number, fValue);
- continue;
- }
- }
- if (!pFontSize)
- pFontSize = pdfium::MakeRetain<CFDE_CSSNumberValue>(eNumType, fValue);
- else if (!pLineHeight)
- pLineHeight =
- pdfium::MakeRetain<CFDE_CSSNumberValue>(eNumType, fValue);
- break;
- }
- default:
- break;
- }
- }
-
- if (!pStyle) {
- pStyle =
- pdfium::MakeRetain<CFDE_CSSEnumValue>(FDE_CSSPropertyValue::Normal);
- }
- if (!pVariant) {
- pVariant =
- pdfium::MakeRetain<CFDE_CSSEnumValue>(FDE_CSSPropertyValue::Normal);
- }
- if (!pWeight) {
- pWeight =
- pdfium::MakeRetain<CFDE_CSSEnumValue>(FDE_CSSPropertyValue::Normal);
- }
- if (!pFontSize) {
- pFontSize =
- pdfium::MakeRetain<CFDE_CSSEnumValue>(FDE_CSSPropertyValue::Medium);
- }
- if (!pLineHeight) {
- pLineHeight =
- pdfium::MakeRetain<CFDE_CSSEnumValue>(FDE_CSSPropertyValue::Normal);
- }
-
- AddPropertyHolder(FDE_CSSProperty::FontStyle, pStyle, bImportant);
- AddPropertyHolder(FDE_CSSProperty::FontVariant, pVariant, bImportant);
- AddPropertyHolder(FDE_CSSProperty::FontWeight, pWeight, bImportant);
- AddPropertyHolder(FDE_CSSProperty::FontSize, pFontSize, bImportant);
- AddPropertyHolder(FDE_CSSProperty::LineHeight, pLineHeight, bImportant);
- if (!familyList.empty()) {
- auto pList = pdfium::MakeRetain<CFDE_CSSValueList>(familyList);
- AddPropertyHolder(FDE_CSSProperty::FontFamily, pList, bImportant);
- }
-}
-
-size_t CFDE_CSSDeclaration::PropertyCountForTesting() const {
- return properties_.size();
-}
diff --git a/xfa/fde/css/cfde_cssdeclaration.h b/xfa/fde/css/cfde_cssdeclaration.h
deleted file mode 100644
index 3c2e058a43..0000000000
--- a/xfa/fde/css/cfde_cssdeclaration.h
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2014 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_CSSDECLARATION_H_
-#define XFA_FDE_CSS_CFDE_CSSDECLARATION_H_
-
-#include <memory>
-#include <utility>
-#include <vector>
-
-#include "xfa/fde/css/fde_cssdatatable.h"
-
-class CFDE_CSSPropertyHolder;
-class CFDE_CSSCustomProperty;
-
-class CFDE_CSSDeclaration {
- public:
- using const_prop_iterator =
- std::vector<std::unique_ptr<CFDE_CSSPropertyHolder>>::const_iterator;
- using const_custom_iterator =
- std::vector<std::unique_ptr<CFDE_CSSCustomProperty>>::const_iterator;
-
- static bool ParseCSSString(const wchar_t* pszValue,
- int32_t iValueLen,
- int32_t* iOffset,
- int32_t* iLength);
- static bool ParseCSSColor(const wchar_t* pszValue,
- int32_t iValueLen,
- FX_ARGB* dwColor);
-
- CFDE_CSSDeclaration();
- ~CFDE_CSSDeclaration();
-
- CFX_RetainPtr<CFDE_CSSValue> GetProperty(FDE_CSSProperty eProperty,
- bool* bImportant) const;
-
- const_prop_iterator begin() const { return properties_.begin(); }
- const_prop_iterator end() const { return properties_.end(); }
-
- const_custom_iterator custom_begin() const {
- return custom_properties_.begin();
- }
- const_custom_iterator custom_end() const { return custom_properties_.end(); }
-
- bool empty() const { return properties_.empty(); }
-
- void AddProperty(const FDE_CSSPropertyTable* pTable,
- const CFX_WideStringC& value);
- void AddProperty(const CFX_WideString& prop, const CFX_WideString& value);
-
- size_t PropertyCountForTesting() const;
-
- FX_ARGB ParseColorForTest(const wchar_t* pszValue,
- int32_t iValueLen,
- FX_ARGB* dwColor) const;
-
- private:
- void ParseFontProperty(const wchar_t* pszValue,
- int32_t iValueLen,
- bool bImportant);
- bool ParseBorderProperty(const wchar_t* pszValue,
- int32_t iValueLen,
- CFX_RetainPtr<CFDE_CSSValue>& pWidth) const;
- void ParseValueListProperty(const FDE_CSSPropertyTable* pTable,
- const wchar_t* pszValue,
- int32_t iValueLen,
- bool bImportant);
- void Add4ValuesProperty(const std::vector<CFX_RetainPtr<CFDE_CSSValue>>& list,
- bool bImportant,
- FDE_CSSProperty eLeft,
- FDE_CSSProperty eTop,
- FDE_CSSProperty eRight,
- FDE_CSSProperty eBottom);
- CFX_RetainPtr<CFDE_CSSValue> ParseNumber(const wchar_t* pszValue,
- int32_t iValueLen);
- CFX_RetainPtr<CFDE_CSSValue> ParseEnum(const wchar_t* pszValue,
- int32_t iValueLen);
- CFX_RetainPtr<CFDE_CSSValue> ParseColor(const wchar_t* pszValue,
- int32_t iValueLen);
- CFX_RetainPtr<CFDE_CSSValue> ParseString(const wchar_t* pszValue,
- int32_t iValueLen);
- void AddPropertyHolder(FDE_CSSProperty eProperty,
- CFX_RetainPtr<CFDE_CSSValue> pValue,
- bool bImportant);
-
- std::vector<std::unique_ptr<CFDE_CSSPropertyHolder>> properties_;
- std::vector<std::unique_ptr<CFDE_CSSCustomProperty>> custom_properties_;
-};
-
-#endif // XFA_FDE_CSS_CFDE_CSSDECLARATION_H_
diff --git a/xfa/fde/css/cfde_cssdeclaration_unittest.cpp b/xfa/fde/css/cfde_cssdeclaration_unittest.cpp
deleted file mode 100644
index f43f941880..0000000000
--- a/xfa/fde/css/cfde_cssdeclaration_unittest.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-// 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.
-
-#include "xfa/fde/css/cfde_cssdeclaration.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-#include "testing/test_support.h"
-
-TEST(CFDE_CSSDecalrationTest, HexEncodingParsing) {
- FX_ARGB color;
-
- // Length value invalid.
- EXPECT_FALSE(CFDE_CSSDeclaration::ParseCSSColor(L"#000", 3, &color));
- EXPECT_FALSE(CFDE_CSSDeclaration::ParseCSSColor(L"#000000", 5, &color));
- EXPECT_FALSE(CFDE_CSSDeclaration::ParseCSSColor(L"#000000", 8, &color));
-
- // Invalid characters
- EXPECT_TRUE(CFDE_CSSDeclaration::ParseCSSColor(L"#zxytlm", 7, &color));
- EXPECT_EQ(0, FXARGB_R(color));
- EXPECT_EQ(0, FXARGB_G(color));
- EXPECT_EQ(0, FXARGB_B(color));
-
- EXPECT_TRUE(CFDE_CSSDeclaration::ParseCSSColor(L"#000", 4, &color));
- EXPECT_EQ(0, FXARGB_R(color));
- EXPECT_EQ(0, FXARGB_G(color));
- EXPECT_EQ(0, FXARGB_B(color));
-
- EXPECT_TRUE(CFDE_CSSDeclaration::ParseCSSColor(L"#FFF", 4, &color));
- EXPECT_EQ(255, FXARGB_R(color));
- EXPECT_EQ(255, FXARGB_G(color));
- EXPECT_EQ(255, FXARGB_B(color));
-
- EXPECT_TRUE(CFDE_CSSDeclaration::ParseCSSColor(L"#F0F0F0", 7, &color));
- EXPECT_EQ(240, FXARGB_R(color));
- EXPECT_EQ(240, FXARGB_G(color));
- EXPECT_EQ(240, FXARGB_B(color));
-
- // Upper and lower case characters.
- EXPECT_TRUE(CFDE_CSSDeclaration::ParseCSSColor(L"#1b2F3c", 7, &color));
- EXPECT_EQ(27, FXARGB_R(color));
- EXPECT_EQ(47, FXARGB_G(color));
- EXPECT_EQ(60, FXARGB_B(color));
-}
-
-TEST(CFDE_CSSDecalrationTest, RGBEncodingParsing) {
- FX_ARGB color;
-
- // Invalid input for rgb() syntax.
- EXPECT_FALSE(CFDE_CSSDeclaration::ParseCSSColor(L"blahblahblah", 11, &color));
-
- EXPECT_TRUE(CFDE_CSSDeclaration::ParseCSSColor(L"rgb(0, 0, 0)", 12, &color));
- EXPECT_EQ(0, FXARGB_R(color));
- EXPECT_EQ(0, FXARGB_G(color));
- EXPECT_EQ(0, FXARGB_B(color));
-
- EXPECT_TRUE(
- CFDE_CSSDeclaration::ParseCSSColor(L"rgb(128,255,48)", 15, &color));
- EXPECT_EQ(128, FXARGB_R(color));
- EXPECT_EQ(255, FXARGB_G(color));
- EXPECT_EQ(48, FXARGB_B(color));
-}
diff --git a/xfa/fde/css/cfde_cssenumvalue.cpp b/xfa/fde/css/cfde_cssenumvalue.cpp
deleted file mode 100644
index c6b9d3ff73..0000000000
--- a/xfa/fde/css/cfde_cssenumvalue.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-// 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
deleted file mode 100644
index 9fb1b69ef5..0000000000
--- a/xfa/fde/css/cfde_cssenumvalue.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// 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_cssexttextbuf.cpp b/xfa/fde/css/cfde_cssexttextbuf.cpp
deleted file mode 100644
index 86f6776c48..0000000000
--- a/xfa/fde/css/cfde_cssexttextbuf.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-// 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_cssexttextbuf.h"
-
-CFDE_CSSExtTextBuf::CFDE_CSSExtTextBuf()
- : m_pExtBuffer(nullptr), m_iDatLen(0), m_iDatPos(0) {}
-
-CFDE_CSSExtTextBuf::~CFDE_CSSExtTextBuf() {}
-
-void CFDE_CSSExtTextBuf::AttachBuffer(const wchar_t* pBuffer, int32_t iBufLen) {
- m_pExtBuffer = pBuffer;
- m_iDatLen = iBufLen;
-}
diff --git a/xfa/fde/css/cfde_cssexttextbuf.h b/xfa/fde/css/cfde_cssexttextbuf.h
deleted file mode 100644
index 0760182f25..0000000000
--- a/xfa/fde/css/cfde_cssexttextbuf.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// 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_CSSEXTTEXTBUF_H_
-#define XFA_FDE_CSS_CFDE_CSSEXTTEXTBUF_H_
-
-#include "core/fxcrt/fx_system.h"
-
-class CFDE_CSSExtTextBuf {
- public:
- CFDE_CSSExtTextBuf();
- ~CFDE_CSSExtTextBuf();
-
- void AttachBuffer(const wchar_t* pBuffer, int32_t iBufLen);
-
- bool IsEOF() const { return m_iDatPos >= m_iDatLen; }
-
- wchar_t GetChar() const { return m_pExtBuffer[m_iDatPos]; }
- wchar_t GetNextChar() const {
- return (m_iDatPos + 1 >= m_iDatLen) ? 0 : m_pExtBuffer[m_iDatPos + 1];
- }
-
- void MoveNext() { m_iDatPos++; }
-
- protected:
- const wchar_t* m_pExtBuffer;
- int32_t m_iDatLen;
- int32_t m_iDatPos;
-};
-
-#endif // XFA_FDE_CSS_CFDE_CSSEXTTEXTBUF_H_
diff --git a/xfa/fde/css/cfde_cssnumbervalue.cpp b/xfa/fde/css/cfde_cssnumbervalue.cpp
deleted file mode 100644
index 45a9c917b1..0000000000
--- a/xfa/fde/css/cfde_cssnumbervalue.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-// 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, float value)
- : CFDE_CSSValue(FDE_CSSPrimitiveType::Number), type_(type), value_(value) {
- if (type_ == FDE_CSSNumberType::Number && fabs(value_) < 0.001f)
- value_ = 0.0f;
-}
-
-CFDE_CSSNumberValue::~CFDE_CSSNumberValue() {}
-
-float CFDE_CSSNumberValue::Apply(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
deleted file mode 100644
index c4d0bd25f0..0000000000
--- a/xfa/fde/css/cfde_cssnumbervalue.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// 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, float value);
- ~CFDE_CSSNumberValue() override;
-
- float Value() const { return value_; }
- FDE_CSSNumberType Kind() const { return type_; }
-
- float Apply(float percentBase) const;
-
- private:
- FDE_CSSNumberType type_;
- float value_;
-};
-
-#endif // XFA_FDE_CSS_CFDE_CSSNUMBERVALUE_H_
diff --git a/xfa/fde/css/cfde_csspropertyholder.cpp b/xfa/fde/css/cfde_csspropertyholder.cpp
deleted file mode 100644
index 9f47c8f08b..0000000000
--- a/xfa/fde/css/cfde_csspropertyholder.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-// 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_csspropertyholder.h"
-
-CFDE_CSSPropertyHolder::CFDE_CSSPropertyHolder() {}
-
-CFDE_CSSPropertyHolder::~CFDE_CSSPropertyHolder() {}
diff --git a/xfa/fde/css/cfde_csspropertyholder.h b/xfa/fde/css/cfde_csspropertyholder.h
deleted file mode 100644
index 7f8526d92e..0000000000
--- a/xfa/fde/css/cfde_csspropertyholder.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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_CSSPROPERTYHOLDER_H_
-#define XFA_FDE_CSS_CFDE_CSSPROPERTYHOLDER_H_
-
-#include "core/fxcrt/cfx_retain_ptr.h"
-#include "xfa/fde/css/cfde_cssvalue.h"
-#include "xfa/fde/css/fde_css.h"
-
-class CFDE_CSSPropertyHolder {
- public:
- CFDE_CSSPropertyHolder();
- ~CFDE_CSSPropertyHolder();
-
- FDE_CSSProperty eProperty;
- bool bImportant;
- CFX_RetainPtr<CFDE_CSSValue> pValue;
-};
-
-#endif // XFA_FDE_CSS_CFDE_CSSPROPERTYHOLDER_H_
diff --git a/xfa/fde/css/cfde_cssrulecollection.cpp b/xfa/fde/css/cfde_cssrulecollection.cpp
deleted file mode 100644
index b945fd518b..0000000000
--- a/xfa/fde/css/cfde_cssrulecollection.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2016 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_cssrulecollection.h"
-
-#include <algorithm>
-#include <utility>
-
-#include "third_party/base/ptr_util.h"
-#include "xfa/fde/css/cfde_cssdeclaration.h"
-#include "xfa/fde/css/cfde_cssselector.h"
-#include "xfa/fde/css/cfde_cssstylerule.h"
-#include "xfa/fde/css/cfde_cssstylesheet.h"
-#include "xfa/fde/css/cfde_csssyntaxparser.h"
-
-CFDE_CSSRuleCollection::CFDE_CSSRuleCollection() : m_iSelectors(0) {}
-
-CFDE_CSSRuleCollection::~CFDE_CSSRuleCollection() {
- Clear();
-}
-
-void CFDE_CSSRuleCollection::Clear() {
- m_TagRules.clear();
- m_iSelectors = 0;
-}
-
-const std::vector<std::unique_ptr<CFDE_CSSRuleCollection::Data>>*
-CFDE_CSSRuleCollection::GetTagRuleData(const CFX_WideString& tagname) const {
- auto it = m_TagRules.find(FX_HashCode_GetW(tagname.c_str(), true));
- return it != m_TagRules.end() ? &it->second : nullptr;
-}
-
-void CFDE_CSSRuleCollection::AddRulesFrom(const CFDE_CSSStyleSheet* sheet) {
- int32_t iRules = sheet->CountRules();
- for (int32_t j = 0; j < iRules; j++)
- AddRulesFrom(sheet, sheet->GetRule(j));
-}
-
-void CFDE_CSSRuleCollection::AddRulesFrom(const CFDE_CSSStyleSheet* pStyleSheet,
- CFDE_CSSStyleRule* pStyleRule) {
- CFDE_CSSDeclaration* pDeclaration = pStyleRule->GetDeclaration();
- int32_t iSelectors = pStyleRule->CountSelectorLists();
- for (int32_t i = 0; i < iSelectors; ++i) {
- CFDE_CSSSelector* pSelector = pStyleRule->GetSelectorList(i);
- m_TagRules[pSelector->GetNameHash()].push_back(
- pdfium::MakeUnique<Data>(pSelector, pDeclaration));
- m_iSelectors++;
- }
-}
-
-CFDE_CSSRuleCollection::Data::Data(CFDE_CSSSelector* pSel,
- CFDE_CSSDeclaration* pDecl)
- : pSelector(pSel), pDeclaration(pDecl) {}
diff --git a/xfa/fde/css/cfde_cssrulecollection.h b/xfa/fde/css/cfde_cssrulecollection.h
deleted file mode 100644
index e9ce7c31d3..0000000000
--- a/xfa/fde/css/cfde_cssrulecollection.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// 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_CSSRULECOLLECTION_H_
-#define XFA_FDE_CSS_CFDE_CSSRULECOLLECTION_H_
-
-#include <map>
-#include <memory>
-#include <vector>
-
-#include "core/fxcrt/fx_basic.h"
-
-class CFDE_CSSDeclaration;
-class CFDE_CSSSelector;
-class CFDE_CSSStyleRule;
-class CFDE_CSSStyleSheet;
-
-class CFDE_CSSRuleCollection {
- public:
- class Data {
- public:
- Data(CFDE_CSSSelector* pSel, CFDE_CSSDeclaration* pDecl);
-
- CFDE_CSSSelector* const pSelector;
- CFDE_CSSDeclaration* const pDeclaration;
- };
-
- CFDE_CSSRuleCollection();
- ~CFDE_CSSRuleCollection();
-
- void AddRulesFrom(const CFDE_CSSStyleSheet* sheet);
- void Clear();
- int32_t CountSelectors() const { return m_iSelectors; }
-
- const std::vector<std::unique_ptr<Data>>* GetTagRuleData(
- const CFX_WideString& tagname) const;
-
- private:
- void AddRulesFrom(const CFDE_CSSStyleSheet* pStyleSheet,
- CFDE_CSSStyleRule* pRule);
-
- std::map<uint32_t, std::vector<std::unique_ptr<Data>>> m_TagRules;
- int32_t m_iSelectors;
-};
-
-#endif // XFA_FDE_CSS_CFDE_CSSRULECOLLECTION_H_
diff --git a/xfa/fde/css/cfde_cssselector.cpp b/xfa/fde/css/cfde_cssselector.cpp
deleted file mode 100644
index ad2ec40c2b..0000000000
--- a/xfa/fde/css/cfde_cssselector.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-// 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_cssselector.h"
-
-#include <utility>
-
-#include "core/fxcrt/fx_extension.h"
-#include "third_party/base/ptr_util.h"
-
-namespace {
-
-int32_t GetCSSNameLen(const wchar_t* psz, const wchar_t* pEnd) {
- const wchar_t* pStart = psz;
- while (psz < pEnd) {
- wchar_t wch = *psz;
- if (!FXSYS_iswalnum(wch) && wch != '_' && wch != '-')
- break;
- ++psz;
- }
- return psz - pStart;
-}
-
-} // namespace
-
-CFDE_CSSSelector::CFDE_CSSSelector(FDE_CSSSelectorType eType,
- const wchar_t* psz,
- int32_t iLen,
- bool bIgnoreCase)
- : m_eType(eType),
- m_dwHash(FX_HashCode_GetW(CFX_WideStringC(psz, iLen), bIgnoreCase)) {}
-
-CFDE_CSSSelector::~CFDE_CSSSelector() {}
-
-FDE_CSSSelectorType CFDE_CSSSelector::GetType() const {
- return m_eType;
-}
-
-uint32_t CFDE_CSSSelector::GetNameHash() const {
- return m_dwHash;
-}
-
-CFDE_CSSSelector* CFDE_CSSSelector::GetNextSelector() const {
- return m_pNext.get();
-}
-
-// static.
-std::unique_ptr<CFDE_CSSSelector> CFDE_CSSSelector::FromString(
- const CFX_WideStringC& str) {
- ASSERT(!str.IsEmpty());
-
- const wchar_t* psz = str.unterminated_c_str();
- const wchar_t* pStart = psz;
- const wchar_t* pEnd = psz + str.GetLength();
- for (; psz < pEnd; ++psz) {
- switch (*psz) {
- case '>':
- case '[':
- case '+':
- return nullptr;
- }
- }
-
- std::unique_ptr<CFDE_CSSSelector> pFirst = nullptr;
- for (psz = pStart; psz < pEnd;) {
- wchar_t wch = *psz;
- if (FXSYS_iswalpha(wch) || wch == '*') {
- int32_t iNameLen = wch == '*' ? 1 : GetCSSNameLen(psz, pEnd);
- auto p = pdfium::MakeUnique<CFDE_CSSSelector>(
- FDE_CSSSelectorType::Element, psz, iNameLen, true);
- if (pFirst) {
- pFirst->SetType(FDE_CSSSelectorType::Descendant);
- p->SetNext(std::move(pFirst));
- }
- pFirst = std::move(p);
- psz += iNameLen;
- } else if (wch == ' ') {
- psz++;
- } else {
- return nullptr;
- }
- }
- return pFirst;
-}
diff --git a/xfa/fde/css/cfde_cssselector.h b/xfa/fde/css/cfde_cssselector.h
deleted file mode 100644
index 048c51339e..0000000000
--- a/xfa/fde/css/cfde_cssselector.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// 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_CSSSELECTOR_H_
-#define XFA_FDE_CSS_CFDE_CSSSELECTOR_H_
-
-#include <memory>
-#include <utility>
-
-#include "core/fxcrt/fx_string.h"
-#include "xfa/fde/css/fde_css.h"
-
-class CFDE_CSSSelector {
- public:
- static std::unique_ptr<CFDE_CSSSelector> FromString(
- const CFX_WideStringC& str);
-
- CFDE_CSSSelector(FDE_CSSSelectorType eType,
- const wchar_t* psz,
- int32_t iLen,
- bool bIgnoreCase);
- ~CFDE_CSSSelector();
-
- FDE_CSSSelectorType GetType() const;
- uint32_t GetNameHash() const;
- CFDE_CSSSelector* GetNextSelector() const;
-
- void SetNext(std::unique_ptr<CFDE_CSSSelector> pNext) {
- m_pNext = std::move(pNext);
- }
-
- private:
- void SetType(FDE_CSSSelectorType eType) { m_eType = eType; }
-
- FDE_CSSSelectorType m_eType;
- uint32_t m_dwHash;
- std::unique_ptr<CFDE_CSSSelector> m_pNext;
-};
-
-#endif // XFA_FDE_CSS_CFDE_CSSSELECTOR_H_
diff --git a/xfa/fde/css/cfde_cssstringvalue.cpp b/xfa/fde/css/cfde_cssstringvalue.cpp
deleted file mode 100644
index deb9be3dc0..0000000000
--- a/xfa/fde/css/cfde_cssstringvalue.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-// 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
deleted file mode 100644
index 33328cf52b..0000000000
--- a/xfa/fde/css/cfde_cssstringvalue.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// 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_cssstylerule.cpp b/xfa/fde/css/cfde_cssstylerule.cpp
deleted file mode 100644
index 04f6cfff08..0000000000
--- a/xfa/fde/css/cfde_cssstylerule.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-// 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_cssstylerule.h"
-
-CFDE_CSSStyleRule::CFDE_CSSStyleRule() {}
-
-CFDE_CSSStyleRule::~CFDE_CSSStyleRule() {}
-
-size_t CFDE_CSSStyleRule::CountSelectorLists() const {
- return m_ppSelector.size();
-}
-
-CFDE_CSSSelector* CFDE_CSSStyleRule::GetSelectorList(int32_t index) const {
- return m_ppSelector[index].get();
-}
-
-CFDE_CSSDeclaration* CFDE_CSSStyleRule::GetDeclaration() {
- return &m_Declaration;
-}
-
-void CFDE_CSSStyleRule::SetSelector(
- std::vector<std::unique_ptr<CFDE_CSSSelector>>* list) {
- ASSERT(m_ppSelector.empty());
-
- m_ppSelector.swap(*list);
-}
diff --git a/xfa/fde/css/cfde_cssstylerule.h b/xfa/fde/css/cfde_cssstylerule.h
deleted file mode 100644
index 075ab8d478..0000000000
--- a/xfa/fde/css/cfde_cssstylerule.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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_CSSSTYLERULE_H_
-#define XFA_FDE_CSS_CFDE_CSSSTYLERULE_H_
-
-#include <memory>
-#include <vector>
-
-#include "xfa/fde/css/cfde_cssdeclaration.h"
-#include "xfa/fde/css/cfde_cssselector.h"
-
-class CFDE_CSSStyleRule {
- public:
- CFDE_CSSStyleRule();
- ~CFDE_CSSStyleRule();
-
- size_t CountSelectorLists() const;
- CFDE_CSSSelector* GetSelectorList(int32_t index) const;
- CFDE_CSSDeclaration* GetDeclaration();
-
- void SetSelector(std::vector<std::unique_ptr<CFDE_CSSSelector>>* list);
-
- private:
- CFDE_CSSDeclaration m_Declaration;
- std::vector<std::unique_ptr<CFDE_CSSSelector>> m_ppSelector;
-};
-
-#endif // XFA_FDE_CSS_CFDE_CSSSTYLERULE_H_
diff --git a/xfa/fde/css/cfde_cssstyleselector.cpp b/xfa/fde/css/cfde_cssstyleselector.cpp
deleted file mode 100644
index 141e74c865..0000000000
--- a/xfa/fde/css/cfde_cssstyleselector.cpp
+++ /dev/null
@@ -1,599 +0,0 @@
-// Copyright 2014 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_cssstyleselector.h"
-
-#include <algorithm>
-#include <utility>
-
-#include "third_party/base/logging.h"
-#include "third_party/base/ptr_util.h"
-#include "xfa/fde/css/cfde_csscolorvalue.h"
-#include "xfa/fde/css/cfde_csscomputedstyle.h"
-#include "xfa/fde/css/cfde_csscustomproperty.h"
-#include "xfa/fde/css/cfde_cssdeclaration.h"
-#include "xfa/fde/css/cfde_cssenumvalue.h"
-#include "xfa/fde/css/cfde_csspropertyholder.h"
-#include "xfa/fde/css/cfde_cssselector.h"
-#include "xfa/fde/css/cfde_cssstylesheet.h"
-#include "xfa/fde/css/cfde_csssyntaxparser.h"
-#include "xfa/fde/css/cfde_cssvaluelist.h"
-
-CFDE_CSSStyleSelector::CFDE_CSSStyleSelector() : m_fDefFontSize(12.0f) {}
-
-CFDE_CSSStyleSelector::~CFDE_CSSStyleSelector() {}
-
-void CFDE_CSSStyleSelector::SetDefFontSize(float fFontSize) {
- ASSERT(fFontSize > 0);
- m_fDefFontSize = fFontSize;
-}
-
-CFX_RetainPtr<CFDE_CSSComputedStyle> CFDE_CSSStyleSelector::CreateComputedStyle(
- CFDE_CSSComputedStyle* pParentStyle) {
- auto pStyle = pdfium::MakeRetain<CFDE_CSSComputedStyle>();
- if (pParentStyle)
- pStyle->m_InheritedData = pParentStyle->m_InheritedData;
- return pStyle;
-}
-
-void CFDE_CSSStyleSelector::SetUAStyleSheet(
- std::unique_ptr<CFDE_CSSStyleSheet> pSheet) {
- m_UAStyles = std::move(pSheet);
-}
-
-void CFDE_CSSStyleSelector::UpdateStyleIndex() {
- m_UARules.Clear();
- m_UARules.AddRulesFrom(m_UAStyles.get());
-}
-
-std::vector<const CFDE_CSSDeclaration*>
-CFDE_CSSStyleSelector::MatchDeclarations(const CFX_WideString& tagname) {
- std::vector<const CFDE_CSSDeclaration*> matchedDecls;
- if (m_UARules.CountSelectors() == 0 || tagname.IsEmpty())
- return matchedDecls;
-
- auto* rules = m_UARules.GetTagRuleData(tagname);
- if (!rules)
- return matchedDecls;
-
- for (const auto& d : *rules) {
- if (MatchSelector(tagname, d->pSelector))
- matchedDecls.push_back(d->pDeclaration);
- }
- return matchedDecls;
-}
-
-bool CFDE_CSSStyleSelector::MatchSelector(const CFX_WideString& tagname,
- CFDE_CSSSelector* pSel) {
- // TODO(dsinclair): The code only supports a single level of selector at this
- // point. None of the code using selectors required the complexity so lets
- // just say we don't support them to simplify the code for now.
- if (!pSel || pSel->GetNextSelector() ||
- pSel->GetType() == FDE_CSSSelectorType::Descendant) {
- return false;
- }
- return pSel->GetNameHash() == FX_HashCode_GetW(tagname.c_str(), true);
-}
-
-void CFDE_CSSStyleSelector::ComputeStyle(
- const std::vector<const CFDE_CSSDeclaration*>& declArray,
- const CFX_WideString& styleString,
- const CFX_WideString& alignString,
- CFDE_CSSComputedStyle* pDest) {
- std::unique_ptr<CFDE_CSSDeclaration> pDecl;
- if (!styleString.IsEmpty() || !alignString.IsEmpty()) {
- pDecl = pdfium::MakeUnique<CFDE_CSSDeclaration>();
-
- if (!styleString.IsEmpty())
- AppendInlineStyle(pDecl.get(), styleString);
- if (!alignString.IsEmpty()) {
- pDecl->AddProperty(FDE_GetCSSPropertyByEnum(FDE_CSSProperty::TextAlign),
- alignString.AsStringC());
- }
- }
- ApplyDeclarations(declArray, pDecl.get(), pDest);
-}
-
-void CFDE_CSSStyleSelector::ApplyDeclarations(
- const std::vector<const CFDE_CSSDeclaration*>& declArray,
- const CFDE_CSSDeclaration* extraDecl,
- CFDE_CSSComputedStyle* pComputedStyle) {
- std::vector<const CFDE_CSSPropertyHolder*> importants;
- std::vector<const CFDE_CSSPropertyHolder*> normals;
- std::vector<const CFDE_CSSCustomProperty*> customs;
-
- for (auto* decl : declArray)
- ExtractValues(decl, &importants, &normals, &customs);
-
- if (extraDecl)
- ExtractValues(extraDecl, &importants, &normals, &customs);
-
- for (auto* prop : normals)
- ApplyProperty(prop->eProperty, prop->pValue, pComputedStyle);
-
- for (auto* prop : customs)
- pComputedStyle->AddCustomStyle(*prop);
-
- for (auto* prop : importants)
- ApplyProperty(prop->eProperty, prop->pValue, pComputedStyle);
-}
-
-void CFDE_CSSStyleSelector::ExtractValues(
- const CFDE_CSSDeclaration* decl,
- std::vector<const CFDE_CSSPropertyHolder*>* importants,
- std::vector<const CFDE_CSSPropertyHolder*>* normals,
- std::vector<const CFDE_CSSCustomProperty*>* custom) {
- for (const auto& holder : *decl) {
- if (holder->bImportant)
- importants->push_back(holder.get());
- else
- normals->push_back(holder.get());
- }
- for (auto it = decl->custom_begin(); it != decl->custom_end(); it++)
- custom->push_back(it->get());
-}
-
-void CFDE_CSSStyleSelector::AppendInlineStyle(CFDE_CSSDeclaration* pDecl,
- const CFX_WideString& style) {
- ASSERT(pDecl && !style.IsEmpty());
-
- auto pSyntax = pdfium::MakeUnique<CFDE_CSSSyntaxParser>(
- style.c_str(), style.GetLength(), 32, true);
- int32_t iLen2 = 0;
- const FDE_CSSPropertyTable* table = nullptr;
- CFX_WideString wsName;
- while (1) {
- FDE_CSSSyntaxStatus eStatus = pSyntax->DoSyntaxParse();
- if (eStatus == FDE_CSSSyntaxStatus::PropertyName) {
- CFX_WideStringC strValue = pSyntax->GetCurrentString();
- table = FDE_GetCSSPropertyByName(strValue);
- if (!table)
- wsName = CFX_WideString(strValue);
- } else if (eStatus == FDE_CSSSyntaxStatus::PropertyValue) {
- if (table || iLen2 > 0) {
- CFX_WideStringC strValue = pSyntax->GetCurrentString();
- if (!strValue.IsEmpty()) {
- if (table)
- pDecl->AddProperty(table, strValue);
- else if (iLen2 > 0)
- pDecl->AddProperty(wsName, CFX_WideString(strValue));
- }
- }
- } else {
- break;
- }
- }
-}
-
-void CFDE_CSSStyleSelector::ApplyProperty(
- FDE_CSSProperty eProperty,
- const CFX_RetainPtr<CFDE_CSSValue>& pValue,
- CFDE_CSSComputedStyle* pComputedStyle) {
- 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(pValue.As<CFDE_CSSEnumValue>()->Value());
- }
- break;
- case FDE_CSSProperty::FontSize: {
- float& fFontSize = pComputedStyle->m_InheritedData.m_fFontSize;
- if (eType == FDE_CSSPrimitiveType::Number) {
- fFontSize = pValue.As<CFDE_CSSNumberValue>()->Apply(fFontSize);
- } else if (eType == FDE_CSSPrimitiveType::Enum) {
- fFontSize =
- ToFontSize(pValue.As<CFDE_CSSEnumValue>()->Value(), fFontSize);
- }
- } break;
- case FDE_CSSProperty::LineHeight:
- if (eType == FDE_CSSPrimitiveType::Number) {
- CFX_RetainPtr<CFDE_CSSNumberValue> v =
- pValue.As<CFDE_CSSNumberValue>();
- 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(pValue.As<CFDE_CSSEnumValue>()->Value());
- }
- break;
- case FDE_CSSProperty::TextIndent:
- SetLengthWithPercent(pComputedStyle->m_InheritedData.m_TextIndent,
- eType, pValue,
- pComputedStyle->m_InheritedData.m_fFontSize);
- break;
- case FDE_CSSProperty::FontWeight:
- if (eType == FDE_CSSPrimitiveType::Enum) {
- pComputedStyle->m_InheritedData.m_wFontWeight =
- ToFontWeight(pValue.As<CFDE_CSSEnumValue>()->Value());
- } else if (eType == FDE_CSSPrimitiveType::Number) {
- int32_t iValue =
- (int32_t)pValue.As<CFDE_CSSNumberValue>()->Value() / 100;
- if (iValue >= 1 && iValue <= 9) {
- pComputedStyle->m_InheritedData.m_wFontWeight = iValue * 100;
- }
- }
- break;
- case FDE_CSSProperty::FontStyle:
- if (eType == FDE_CSSPrimitiveType::Enum) {
- pComputedStyle->m_InheritedData.m_eFontStyle =
- ToFontStyle(pValue.As<CFDE_CSSEnumValue>()->Value());
- }
- break;
- case FDE_CSSProperty::Color:
- if (eType == FDE_CSSPrimitiveType::RGB) {
- pComputedStyle->m_InheritedData.m_dwFontColor =
- pValue.As<CFDE_CSSColorValue>()->Value();
- }
- break;
- case FDE_CSSProperty::MarginLeft:
- if (SetLengthWithPercent(
- pComputedStyle->m_NonInheritedData.m_MarginWidth.left, eType,
- 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,
- 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,
- 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,
- 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,
- 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,
- 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,
- 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,
- 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,
- 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,
- 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,
- 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,
- 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(pValue.As<CFDE_CSSEnumValue>()->Value());
- } else if (eType == FDE_CSSPrimitiveType::Number) {
- pComputedStyle->m_NonInheritedData.m_eVerticalAlign =
- FDE_CSSVerticalAlign::Number;
- pComputedStyle->m_NonInheritedData.m_fVerticalAlign =
- pValue.As<CFDE_CSSNumberValue>()->Apply(
- pComputedStyle->m_InheritedData.m_fFontSize);
- }
- break;
- case FDE_CSSProperty::FontVariant:
- if (eType == FDE_CSSPrimitiveType::Enum) {
- pComputedStyle->m_InheritedData.m_eFontVariant =
- ToFontVariant(pValue.As<CFDE_CSSEnumValue>()->Value());
- }
- break;
- case FDE_CSSProperty::LetterSpacing:
- if (eType == FDE_CSSPrimitiveType::Enum) {
- pComputedStyle->m_InheritedData.m_LetterSpacing.Set(
- FDE_CSSLengthUnit::Normal);
- } else if (eType == FDE_CSSPrimitiveType::Number) {
- if (pValue.As<CFDE_CSSNumberValue>()->Kind() ==
- FDE_CSSNumberType::Percent) {
- break;
- }
-
- SetLengthWithPercent(pComputedStyle->m_InheritedData.m_LetterSpacing,
- eType, pValue,
- pComputedStyle->m_InheritedData.m_fFontSize);
- }
- break;
- case FDE_CSSProperty::WordSpacing:
- if (eType == FDE_CSSPrimitiveType::Enum) {
- pComputedStyle->m_InheritedData.m_WordSpacing.Set(
- FDE_CSSLengthUnit::Normal);
- } else if (eType == FDE_CSSPrimitiveType::Number) {
- if (pValue.As<CFDE_CSSNumberValue>()->Kind() ==
- FDE_CSSNumberType::Percent) {
- break;
- }
- SetLengthWithPercent(pComputedStyle->m_InheritedData.m_WordSpacing,
- eType, pValue,
- pComputedStyle->m_InheritedData.m_fFontSize);
- }
- break;
- case FDE_CSSProperty::Top:
- SetLengthWithPercent(pComputedStyle->m_NonInheritedData.m_Top, eType,
- pValue,
- pComputedStyle->m_InheritedData.m_fFontSize);
- break;
- case FDE_CSSProperty::Bottom:
- SetLengthWithPercent(pComputedStyle->m_NonInheritedData.m_Bottom, eType,
- pValue,
- pComputedStyle->m_InheritedData.m_fFontSize);
- break;
- case FDE_CSSProperty::Left:
- SetLengthWithPercent(pComputedStyle->m_NonInheritedData.m_Left, eType,
- pValue,
- pComputedStyle->m_InheritedData.m_fFontSize);
- break;
- case FDE_CSSProperty::Right:
- SetLengthWithPercent(pComputedStyle->m_NonInheritedData.m_Right, eType,
- pValue,
- pComputedStyle->m_InheritedData.m_fFontSize);
- break;
- default:
- break;
- }
- } else if (pValue->GetType() == FDE_CSSPrimitiveType::List) {
- CFX_RetainPtr<CFDE_CSSValueList> pList = pValue.As<CFDE_CSSValueList>();
- int32_t iCount = pList->CountValues();
- if (iCount > 0) {
- switch (eProperty) {
- case FDE_CSSProperty::FontFamily:
- pComputedStyle->m_InheritedData.m_pFontFamily = pList;
- break;
- case FDE_CSSProperty::TextDecoration:
- pComputedStyle->m_NonInheritedData.m_dwTextDecoration =
- ToTextDecoration(pList);
- break;
- default:
- break;
- }
- }
- } else {
- NOTREACHED();
- }
-}
-
-FDE_CSSDisplay CFDE_CSSStyleSelector::ToDisplay(FDE_CSSPropertyValue eValue) {
- switch (eValue) {
- case FDE_CSSPropertyValue::Block:
- return FDE_CSSDisplay::Block;
- case FDE_CSSPropertyValue::None:
- return FDE_CSSDisplay::None;
- case FDE_CSSPropertyValue::ListItem:
- return FDE_CSSDisplay::ListItem;
- case FDE_CSSPropertyValue::InlineTable:
- return FDE_CSSDisplay::InlineTable;
- case FDE_CSSPropertyValue::InlineBlock:
- return FDE_CSSDisplay::InlineBlock;
- case FDE_CSSPropertyValue::Inline:
- default:
- return FDE_CSSDisplay::Inline;
- }
-}
-
-FDE_CSSTextAlign CFDE_CSSStyleSelector::ToTextAlign(
- FDE_CSSPropertyValue eValue) {
- switch (eValue) {
- case FDE_CSSPropertyValue::Center:
- return FDE_CSSTextAlign::Center;
- case FDE_CSSPropertyValue::Right:
- return FDE_CSSTextAlign::Right;
- case FDE_CSSPropertyValue::Justify:
- return FDE_CSSTextAlign::Justify;
- case FDE_CSSPropertyValue::Left:
- default:
- return FDE_CSSTextAlign::Left;
- }
-}
-
-uint16_t CFDE_CSSStyleSelector::ToFontWeight(FDE_CSSPropertyValue eValue) {
- switch (eValue) {
- case FDE_CSSPropertyValue::Bold:
- return 700;
- case FDE_CSSPropertyValue::Bolder:
- return 900;
- case FDE_CSSPropertyValue::Lighter:
- return 200;
- case FDE_CSSPropertyValue::Normal:
- default:
- return 400;
- }
-}
-
-FDE_CSSFontStyle CFDE_CSSStyleSelector::ToFontStyle(
- FDE_CSSPropertyValue eValue) {
- switch (eValue) {
- case FDE_CSSPropertyValue::Italic:
- case FDE_CSSPropertyValue::Oblique:
- return FDE_CSSFontStyle::Italic;
- default:
- return FDE_CSSFontStyle::Normal;
- }
-}
-
-bool CFDE_CSSStyleSelector::SetLengthWithPercent(
- FDE_CSSLength& width,
- FDE_CSSPrimitiveType eType,
- const CFX_RetainPtr<CFDE_CSSValue>& pValue,
- float fFontSize) {
- if (eType == FDE_CSSPrimitiveType::Number) {
- CFX_RetainPtr<CFDE_CSSNumberValue> v = pValue.As<CFDE_CSSNumberValue>();
- if (v->Kind() == FDE_CSSNumberType::Percent) {
- width.Set(FDE_CSSLengthUnit::Percent,
- pValue.As<CFDE_CSSNumberValue>()->Value() / 100.0f);
- return width.NonZero();
- }
-
- float fValue = v->Apply(fFontSize);
- width.Set(FDE_CSSLengthUnit::Point, fValue);
- return width.NonZero();
- } else if (eType == FDE_CSSPrimitiveType::Enum) {
- switch (pValue.As<CFDE_CSSEnumValue>()->Value()) {
- case FDE_CSSPropertyValue::Auto:
- width.Set(FDE_CSSLengthUnit::Auto);
- return true;
- case FDE_CSSPropertyValue::None:
- width.Set(FDE_CSSLengthUnit::None);
- return true;
- case FDE_CSSPropertyValue::Thin:
- width.Set(FDE_CSSLengthUnit::Point, 2);
- return true;
- case FDE_CSSPropertyValue::Medium:
- width.Set(FDE_CSSLengthUnit::Point, 3);
- return true;
- case FDE_CSSPropertyValue::Thick:
- width.Set(FDE_CSSLengthUnit::Point, 4);
- return true;
- default:
- return false;
- }
- }
- return false;
-}
-
-float CFDE_CSSStyleSelector::ToFontSize(FDE_CSSPropertyValue eValue,
- float fCurFontSize) {
- switch (eValue) {
- case FDE_CSSPropertyValue::XxSmall:
- return m_fDefFontSize / 1.2f / 1.2f / 1.2f;
- case FDE_CSSPropertyValue::XSmall:
- return m_fDefFontSize / 1.2f / 1.2f;
- case FDE_CSSPropertyValue::Small:
- return m_fDefFontSize / 1.2f;
- case FDE_CSSPropertyValue::Medium:
- return m_fDefFontSize;
- case FDE_CSSPropertyValue::Large:
- return m_fDefFontSize * 1.2f;
- case FDE_CSSPropertyValue::XLarge:
- return m_fDefFontSize * 1.2f * 1.2f;
- case FDE_CSSPropertyValue::XxLarge:
- return m_fDefFontSize * 1.2f * 1.2f * 1.2f;
- case FDE_CSSPropertyValue::Larger:
- return fCurFontSize * 1.2f;
- case FDE_CSSPropertyValue::Smaller:
- return fCurFontSize / 1.2f;
- default:
- return fCurFontSize;
- }
-}
-
-FDE_CSSVerticalAlign CFDE_CSSStyleSelector::ToVerticalAlign(
- FDE_CSSPropertyValue eValue) {
- switch (eValue) {
- case FDE_CSSPropertyValue::Middle:
- return FDE_CSSVerticalAlign::Middle;
- case FDE_CSSPropertyValue::Bottom:
- return FDE_CSSVerticalAlign::Bottom;
- case FDE_CSSPropertyValue::Super:
- return FDE_CSSVerticalAlign::Super;
- case FDE_CSSPropertyValue::Sub:
- return FDE_CSSVerticalAlign::Sub;
- case FDE_CSSPropertyValue::Top:
- return FDE_CSSVerticalAlign::Top;
- case FDE_CSSPropertyValue::TextTop:
- return FDE_CSSVerticalAlign::TextTop;
- case FDE_CSSPropertyValue::TextBottom:
- return FDE_CSSVerticalAlign::TextBottom;
- case FDE_CSSPropertyValue::Baseline:
- default:
- return FDE_CSSVerticalAlign::Baseline;
- }
-}
-
-uint32_t CFDE_CSSStyleSelector::ToTextDecoration(
- const CFX_RetainPtr<CFDE_CSSValueList>& pValue) {
- uint32_t dwDecoration = 0;
- for (int32_t i = pValue->CountValues() - 1; i >= 0; --i) {
- const CFX_RetainPtr<CFDE_CSSValue> pVal = pValue->GetValue(i);
- if (pVal->GetType() != FDE_CSSPrimitiveType::Enum)
- continue;
-
- switch (pVal.As<CFDE_CSSEnumValue>()->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;
-}
-
-FDE_CSSFontVariant CFDE_CSSStyleSelector::ToFontVariant(
- FDE_CSSPropertyValue eValue) {
- return eValue == FDE_CSSPropertyValue::SmallCaps
- ? FDE_CSSFontVariant::SmallCaps
- : FDE_CSSFontVariant::Normal;
-}
diff --git a/xfa/fde/css/cfde_cssstyleselector.h b/xfa/fde/css/cfde_cssstyleselector.h
deleted file mode 100644
index 7ead812fd2..0000000000
--- a/xfa/fde/css/cfde_cssstyleselector.h
+++ /dev/null
@@ -1,85 +0,0 @@
-// 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_CSSSTYLESELECTOR_H_
-#define XFA_FDE_CSS_CFDE_CSSSTYLESELECTOR_H_
-
-#include <memory>
-#include <vector>
-
-#include "core/fxcrt/fx_basic.h"
-#include "core/fxcrt/fx_system.h"
-#include "xfa/fde/css/cfde_cssrulecollection.h"
-#include "xfa/fde/css/fde_css.h"
-
-class CFDE_CSSComputedStyle;
-class CFDE_CSSCustomProperty;
-class CFDE_CSSDeclaration;
-class CFDE_CSSPropertyHolder;
-class CFDE_CSSSelector;
-class CFDE_CSSStyleSheet;
-class CFDE_CSSValue;
-class CFDE_CSSValueList;
-
-class CFDE_CSSStyleSelector {
- public:
- CFDE_CSSStyleSelector();
- ~CFDE_CSSStyleSelector();
-
- void SetDefFontSize(float fFontSize);
- void SetUAStyleSheet(std::unique_ptr<CFDE_CSSStyleSheet> pSheet);
- void UpdateStyleIndex();
-
- CFX_RetainPtr<CFDE_CSSComputedStyle> CreateComputedStyle(
- CFDE_CSSComputedStyle* pParentStyle);
-
- // Note, the dest style has to be an out param because the CXFA_TextParser
- // adds non-inherited data from the parent style. Attempting to copy
- // internally will fail as you'll lose the non-inherited data.
- void ComputeStyle(const std::vector<const CFDE_CSSDeclaration*>& declArray,
- const CFX_WideString& styleString,
- const CFX_WideString& alignString,
- CFDE_CSSComputedStyle* pDestStyle);
-
- std::vector<const CFDE_CSSDeclaration*> MatchDeclarations(
- const CFX_WideString& tagname);
-
- private:
- bool MatchSelector(const CFX_WideString& tagname, CFDE_CSSSelector* pSel);
-
- void AppendInlineStyle(CFDE_CSSDeclaration* pDecl,
- const CFX_WideString& style);
- void ApplyDeclarations(
- const std::vector<const CFDE_CSSDeclaration*>& declArray,
- const CFDE_CSSDeclaration* extraDecl,
- CFDE_CSSComputedStyle* pDestStyle);
- void ApplyProperty(FDE_CSSProperty eProperty,
- const CFX_RetainPtr<CFDE_CSSValue>& pValue,
- CFDE_CSSComputedStyle* pComputedStyle);
- void ExtractValues(const CFDE_CSSDeclaration* decl,
- std::vector<const CFDE_CSSPropertyHolder*>* importants,
- std::vector<const CFDE_CSSPropertyHolder*>* normals,
- std::vector<const CFDE_CSSCustomProperty*>* custom);
-
- bool SetLengthWithPercent(FDE_CSSLength& width,
- FDE_CSSPrimitiveType eType,
- const CFX_RetainPtr<CFDE_CSSValue>& pValue,
- float fFontSize);
- float ToFontSize(FDE_CSSPropertyValue eValue, float fCurFontSize);
- FDE_CSSDisplay ToDisplay(FDE_CSSPropertyValue eValue);
- FDE_CSSTextAlign ToTextAlign(FDE_CSSPropertyValue eValue);
- uint16_t ToFontWeight(FDE_CSSPropertyValue eValue);
- FDE_CSSFontStyle ToFontStyle(FDE_CSSPropertyValue eValue);
- FDE_CSSVerticalAlign ToVerticalAlign(FDE_CSSPropertyValue eValue);
- uint32_t ToTextDecoration(const CFX_RetainPtr<CFDE_CSSValueList>& pList);
- FDE_CSSFontVariant ToFontVariant(FDE_CSSPropertyValue eValue);
-
- float m_fDefFontSize;
- std::unique_ptr<CFDE_CSSStyleSheet> m_UAStyles;
- CFDE_CSSRuleCollection m_UARules;
-};
-
-#endif // XFA_FDE_CSS_CFDE_CSSSTYLESELECTOR_H_
diff --git a/xfa/fde/css/cfde_cssstylesheet.cpp b/xfa/fde/css/cfde_cssstylesheet.cpp
deleted file mode 100644
index 369279853e..0000000000
--- a/xfa/fde/css/cfde_cssstylesheet.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-// Copyright 2014 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_cssstylesheet.h"
-
-#include <utility>
-
-#include "core/fxcrt/fx_codepage.h"
-#include "third_party/base/ptr_util.h"
-#include "third_party/base/stl_util.h"
-#include "xfa/fde/css/cfde_cssdeclaration.h"
-#include "xfa/fde/css/cfde_cssstylerule.h"
-#include "xfa/fde/css/fde_cssdatatable.h"
-
-CFDE_CSSStyleSheet::CFDE_CSSStyleSheet() {}
-
-CFDE_CSSStyleSheet::~CFDE_CSSStyleSheet() {
- Reset();
-}
-
-void CFDE_CSSStyleSheet::Reset() {
- m_RuleArray.clear();
- m_StringCache.clear();
-}
-
-int32_t CFDE_CSSStyleSheet::CountRules() const {
- return pdfium::CollectionSize<int32_t>(m_RuleArray);
-}
-
-CFDE_CSSStyleRule* CFDE_CSSStyleSheet::GetRule(int32_t index) const {
- return m_RuleArray[index].get();
-}
-
-bool CFDE_CSSStyleSheet::LoadBuffer(const wchar_t* pBuffer, int32_t iBufSize) {
- ASSERT(pBuffer);
- ASSERT(iBufSize > 0);
-
- auto pSyntax = pdfium::MakeUnique<CFDE_CSSSyntaxParser>(pBuffer, iBufSize);
- Reset();
- FDE_CSSSyntaxStatus eStatus;
- do {
- switch (eStatus = pSyntax->DoSyntaxParse()) {
- case FDE_CSSSyntaxStatus::StyleRule:
- eStatus = LoadStyleRule(pSyntax.get(), &m_RuleArray);
- break;
- default:
- break;
- }
- } while (eStatus >= FDE_CSSSyntaxStatus::None);
-
- m_StringCache.clear();
- return eStatus != FDE_CSSSyntaxStatus::Error;
-}
-
-FDE_CSSSyntaxStatus CFDE_CSSStyleSheet::LoadStyleRule(
- CFDE_CSSSyntaxParser* pSyntax,
- std::vector<std::unique_ptr<CFDE_CSSStyleRule>>* ruleArray) {
- std::vector<std::unique_ptr<CFDE_CSSSelector>> selectors;
-
- CFDE_CSSStyleRule* pStyleRule = nullptr;
- int32_t iValueLen = 0;
- const FDE_CSSPropertyTable* propertyTable = nullptr;
- CFX_WideString wsName;
- while (1) {
- switch (pSyntax->DoSyntaxParse()) {
- case FDE_CSSSyntaxStatus::Selector: {
- CFX_WideStringC strValue = pSyntax->GetCurrentString();
- auto pSelector = CFDE_CSSSelector::FromString(strValue);
- if (pSelector)
- selectors.push_back(std::move(pSelector));
- break;
- }
- case FDE_CSSSyntaxStatus::PropertyName: {
- CFX_WideStringC strValue = pSyntax->GetCurrentString();
- propertyTable = FDE_GetCSSPropertyByName(strValue);
- if (!propertyTable)
- wsName = CFX_WideString(strValue);
- break;
- }
- case FDE_CSSSyntaxStatus::PropertyValue: {
- if (propertyTable || iValueLen > 0) {
- CFX_WideStringC strValue = pSyntax->GetCurrentString();
- auto* decl = pStyleRule->GetDeclaration();
- if (!strValue.IsEmpty()) {
- if (propertyTable) {
- decl->AddProperty(propertyTable, strValue);
- } else {
- decl->AddProperty(wsName, CFX_WideString(strValue));
- }
- }
- }
- break;
- }
- case FDE_CSSSyntaxStatus::DeclOpen: {
- if (!pStyleRule && !selectors.empty()) {
- auto rule = pdfium::MakeUnique<CFDE_CSSStyleRule>();
- pStyleRule = rule.get();
- pStyleRule->SetSelector(&selectors);
- ruleArray->push_back(std::move(rule));
- } else {
- SkipRuleSet(pSyntax);
- return FDE_CSSSyntaxStatus::None;
- }
- break;
- }
- case FDE_CSSSyntaxStatus::DeclClose: {
- if (pStyleRule && pStyleRule->GetDeclaration()->empty()) {
- ruleArray->pop_back();
- pStyleRule = nullptr;
- }
- return FDE_CSSSyntaxStatus::None;
- }
- case FDE_CSSSyntaxStatus::EOS:
- return FDE_CSSSyntaxStatus::EOS;
- case FDE_CSSSyntaxStatus::Error:
- default:
- return FDE_CSSSyntaxStatus::Error;
- }
- }
-}
-
-void CFDE_CSSStyleSheet::SkipRuleSet(CFDE_CSSSyntaxParser* pSyntax) {
- while (1) {
- switch (pSyntax->DoSyntaxParse()) {
- case FDE_CSSSyntaxStatus::Selector:
- case FDE_CSSSyntaxStatus::DeclOpen:
- case FDE_CSSSyntaxStatus::PropertyName:
- case FDE_CSSSyntaxStatus::PropertyValue:
- break;
- case FDE_CSSSyntaxStatus::DeclClose:
- case FDE_CSSSyntaxStatus::EOS:
- case FDE_CSSSyntaxStatus::Error:
- default:
- return;
- }
- }
-}
diff --git a/xfa/fde/css/cfde_cssstylesheet.h b/xfa/fde/css/cfde_cssstylesheet.h
deleted file mode 100644
index 24bebddcbf..0000000000
--- a/xfa/fde/css/cfde_cssstylesheet.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// 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_CSSSTYLESHEET_H_
-#define XFA_FDE_CSS_CFDE_CSSSTYLESHEET_H_
-
-#include <map>
-#include <memory>
-#include <vector>
-
-#include "core/fxcrt/fx_string.h"
-#include "xfa/fde/css/cfde_csssyntaxparser.h"
-
-class CFDE_CSSStyleRule;
-
-class CFDE_CSSStyleSheet {
- public:
- CFDE_CSSStyleSheet();
- ~CFDE_CSSStyleSheet();
-
- bool LoadBuffer(const wchar_t* pBuffer, int32_t iBufSize);
-
- int32_t CountRules() const;
- CFDE_CSSStyleRule* GetRule(int32_t index) const;
-
- private:
- void Reset();
- FDE_CSSSyntaxStatus LoadStyleRule(
- CFDE_CSSSyntaxParser* pSyntax,
- std::vector<std::unique_ptr<CFDE_CSSStyleRule>>* ruleArray);
- void SkipRuleSet(CFDE_CSSSyntaxParser* pSyntax);
-
- std::vector<std::unique_ptr<CFDE_CSSStyleRule>> m_RuleArray;
- std::map<uint32_t, wchar_t*> m_StringCache;
-};
-
-#endif // XFA_FDE_CSS_CFDE_CSSSTYLESHEET_H_
diff --git a/xfa/fde/css/cfde_cssstylesheet_unittest.cpp b/xfa/fde/css/cfde_cssstylesheet_unittest.cpp
deleted file mode 100644
index 0f450e9c3a..0000000000
--- a/xfa/fde/css/cfde_cssstylesheet_unittest.cpp
+++ /dev/null
@@ -1,239 +0,0 @@
-// 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_cssstylesheet.h"
-
-#include <memory>
-#include <vector>
-
-#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_cssdeclaration.h"
-#include "xfa/fde/css/cfde_cssenumvalue.h"
-#include "xfa/fde/css/cfde_cssnumbervalue.h"
-#include "xfa/fde/css/cfde_cssstylerule.h"
-#include "xfa/fde/css/cfde_cssvaluelist.h"
-
-class CFDE_CSSStyleSheetTest : public testing::Test {
- public:
- void SetUp() override {
- sheet_ = pdfium::MakeUnique<CFDE_CSSStyleSheet>();
- decl_ = nullptr;
- }
-
- void TearDown() override { decl_ = nullptr; }
-
- void LoadAndVerifyDecl(const wchar_t* buf,
- const std::vector<CFX_WideString>& selectors,
- size_t decl_count) {
- ASSERT(sheet_);
-
- EXPECT_TRUE(sheet_->LoadBuffer(buf, FXSYS_wcslen(buf)));
- EXPECT_EQ(sheet_->CountRules(), 1);
-
- CFDE_CSSStyleRule* style = sheet_->GetRule(0);
- EXPECT_EQ(selectors.size(), style->CountSelectorLists());
-
- for (size_t i = 0; i < selectors.size(); i++) {
- uint32_t hash = FX_HashCode_GetW(selectors[i].AsStringC(), true);
- EXPECT_EQ(hash, style->GetSelectorList(i)->GetNameHash());
- }
-
- decl_ = style->GetDeclaration();
- EXPECT_EQ(decl_->PropertyCountForTesting(), decl_count);
- }
-
- void VerifyFloat(FDE_CSSProperty prop, float val, FDE_CSSNumberType type) {
- ASSERT(decl_);
-
- bool important;
- CFX_RetainPtr<CFDE_CSSValue> v = decl_->GetProperty(prop, &important);
- EXPECT_EQ(v->GetType(), FDE_CSSPrimitiveType::Number);
- EXPECT_EQ(v.As<CFDE_CSSNumberValue>()->Kind(), type);
- EXPECT_EQ(v.As<CFDE_CSSNumberValue>()->Value(), val);
- }
-
- void VerifyEnum(FDE_CSSProperty prop, FDE_CSSPropertyValue val) {
- ASSERT(decl_);
-
- bool important;
- CFX_RetainPtr<CFDE_CSSValue> v = decl_->GetProperty(prop, &important);
- EXPECT_EQ(v->GetType(), FDE_CSSPrimitiveType::Enum);
- EXPECT_EQ(v.As<CFDE_CSSEnumValue>()->Value(), val);
- }
-
- void VerifyList(FDE_CSSProperty prop,
- std::vector<FDE_CSSPropertyValue> values) {
- ASSERT(decl_);
-
- bool important;
- CFX_RetainPtr<CFDE_CSSValueList> list =
- decl_->GetProperty(prop, &important).As<CFDE_CSSValueList>();
- EXPECT_EQ(list->CountValues(), pdfium::CollectionSize<int32_t>(values));
-
- for (size_t i = 0; i < values.size(); i++) {
- CFX_RetainPtr<CFDE_CSSValue> val = list->GetValue(i);
- EXPECT_EQ(val->GetType(), FDE_CSSPrimitiveType::Enum);
- EXPECT_EQ(val.As<CFDE_CSSEnumValue>()->Value(), values[i]);
- }
- }
-
- std::unique_ptr<CFDE_CSSStyleSheet> sheet_;
- CFDE_CSSDeclaration* decl_;
-};
-
-TEST_F(CFDE_CSSStyleSheetTest, ParseMultipleSelectors) {
- const wchar_t* buf =
- L"a { border: 10px; }\nb { text-decoration: underline; }";
- EXPECT_TRUE(sheet_->LoadBuffer(buf, FXSYS_wcslen(buf)));
- EXPECT_EQ(2, sheet_->CountRules());
-
- CFDE_CSSStyleRule* style = sheet_->GetRule(0);
- EXPECT_EQ(1UL, style->CountSelectorLists());
-
- bool found_selector = false;
- uint32_t hash = FX_HashCode_GetW(L"a", true);
- for (size_t i = 0; i < style->CountSelectorLists(); i++) {
- if (style->GetSelectorList(i)->GetNameHash() == hash) {
- found_selector = true;
- break;
- }
- }
- EXPECT_TRUE(found_selector);
-
- decl_ = style->GetDeclaration();
- EXPECT_EQ(4UL, decl_->PropertyCountForTesting());
-
- VerifyFloat(FDE_CSSProperty::BorderLeftWidth, 10.0,
- FDE_CSSNumberType::Pixels);
- VerifyFloat(FDE_CSSProperty::BorderRightWidth, 10.0,
- FDE_CSSNumberType::Pixels);
- VerifyFloat(FDE_CSSProperty::BorderTopWidth, 10.0, FDE_CSSNumberType::Pixels);
- VerifyFloat(FDE_CSSProperty::BorderBottomWidth, 10.0,
- FDE_CSSNumberType::Pixels);
-
- style = sheet_->GetRule(1);
- EXPECT_EQ(1UL, style->CountSelectorLists());
-
- found_selector = false;
- hash = FX_HashCode_GetW(L"b", true);
- for (size_t i = 0; i < style->CountSelectorLists(); i++) {
- if (style->GetSelectorList(i)->GetNameHash() == hash) {
- found_selector = true;
- break;
- }
- }
- EXPECT_TRUE(found_selector);
-
- decl_ = style->GetDeclaration();
- EXPECT_EQ(1UL, decl_->PropertyCountForTesting());
- VerifyList(FDE_CSSProperty::TextDecoration,
- {FDE_CSSPropertyValue::Underline});
-}
-
-TEST_F(CFDE_CSSStyleSheetTest, ParseChildSelectors) {
- const wchar_t* buf = L"a b c { border: 10px; }";
- EXPECT_TRUE(sheet_->LoadBuffer(buf, FXSYS_wcslen(buf)));
- EXPECT_EQ(1, sheet_->CountRules());
-
- CFDE_CSSStyleRule* style = sheet_->GetRule(0);
- EXPECT_EQ(1UL, style->CountSelectorLists());
-
- auto* sel = style->GetSelectorList(0);
- EXPECT_TRUE(sel != nullptr);
- EXPECT_EQ(FX_HashCode_GetW(L"c", true), sel->GetNameHash());
-
- sel = sel->GetNextSelector();
- EXPECT_TRUE(sel != nullptr);
- EXPECT_EQ(FX_HashCode_GetW(L"b", true), sel->GetNameHash());
-
- sel = sel->GetNextSelector();
- EXPECT_TRUE(sel != nullptr);
- EXPECT_EQ(FX_HashCode_GetW(L"a", true), sel->GetNameHash());
-
- sel = sel->GetNextSelector();
- EXPECT_TRUE(sel == nullptr);
-
- decl_ = style->GetDeclaration();
- EXPECT_EQ(4UL, decl_->PropertyCountForTesting());
-
- VerifyFloat(FDE_CSSProperty::BorderLeftWidth, 10.0,
- FDE_CSSNumberType::Pixels);
- VerifyFloat(FDE_CSSProperty::BorderRightWidth, 10.0,
- FDE_CSSNumberType::Pixels);
- VerifyFloat(FDE_CSSProperty::BorderTopWidth, 10.0, FDE_CSSNumberType::Pixels);
- VerifyFloat(FDE_CSSProperty::BorderBottomWidth, 10.0,
- FDE_CSSNumberType::Pixels);
-}
-
-TEST_F(CFDE_CSSStyleSheetTest, ParseUnhandledSelectors) {
- const wchar_t* buf = L"a > b { padding: 0; }";
- EXPECT_TRUE(sheet_->LoadBuffer(buf, FXSYS_wcslen(buf)));
- EXPECT_EQ(0, sheet_->CountRules());
-
- buf = L"a[first] { padding: 0; }";
- EXPECT_TRUE(sheet_->LoadBuffer(buf, FXSYS_wcslen(buf)));
- EXPECT_EQ(0, sheet_->CountRules());
-
- buf = L"a+b { padding: 0; }";
- EXPECT_TRUE(sheet_->LoadBuffer(buf, FXSYS_wcslen(buf)));
- EXPECT_EQ(0, sheet_->CountRules());
-
- buf = L"a ^ b { padding: 0; }";
- EXPECT_TRUE(sheet_->LoadBuffer(buf, FXSYS_wcslen(buf)));
- EXPECT_EQ(0, sheet_->CountRules());
-}
-
-TEST_F(CFDE_CSSStyleSheetTest, ParseMultipleSelectorsCombined) {
- LoadAndVerifyDecl(L"a, b, c { border: 5px; }", {L"a", L"b", L"c"}, 4);
-}
-
-TEST_F(CFDE_CSSStyleSheetTest, ParseBorder) {
- LoadAndVerifyDecl(L"a { border: 5px; }", {L"a"}, 4);
- VerifyFloat(FDE_CSSProperty::BorderLeftWidth, 5.0, FDE_CSSNumberType::Pixels);
- VerifyFloat(FDE_CSSProperty::BorderRightWidth, 5.0,
- FDE_CSSNumberType::Pixels);
- VerifyFloat(FDE_CSSProperty::BorderTopWidth, 5.0, FDE_CSSNumberType::Pixels);
- VerifyFloat(FDE_CSSProperty::BorderBottomWidth, 5.0,
- 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_CSSNumberType::Pixels);
- VerifyFloat(FDE_CSSProperty::BorderRightWidth, 5.0,
- FDE_CSSNumberType::Pixels);
- VerifyFloat(FDE_CSSProperty::BorderTopWidth, 5.0, FDE_CSSNumberType::Pixels);
- VerifyFloat(FDE_CSSProperty::BorderBottomWidth, 5.0,
- 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_CSSNumberType::Picas);
-}
-
-TEST_F(CFDE_CSSStyleSheetTest, ParseBorderLeftThick) {
- LoadAndVerifyDecl(L"a { border-left: thick; }", {L"a"}, 1);
- VerifyEnum(FDE_CSSProperty::BorderLeftWidth, FDE_CSSPropertyValue::Thick);
-}
-
-TEST_F(CFDE_CSSStyleSheetTest, ParseBorderRight) {
- LoadAndVerifyDecl(L"a { border-right: 2.5pc; }", {L"a"}, 1);
- 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_CSSNumberType::Picas);
-}
-
-TEST_F(CFDE_CSSStyleSheetTest, ParseBorderBottom) {
- LoadAndVerifyDecl(L"a { border-bottom: 2.5pc; }", {L"a"}, 1);
- VerifyFloat(FDE_CSSProperty::BorderBottomWidth, 2.5,
- FDE_CSSNumberType::Picas);
-}
diff --git a/xfa/fde/css/cfde_csssyntaxparser.cpp b/xfa/fde/css/cfde_csssyntaxparser.cpp
deleted file mode 100644
index 51d99f1992..0000000000
--- a/xfa/fde/css/cfde_csssyntaxparser.cpp
+++ /dev/null
@@ -1,228 +0,0 @@
-// Copyright 2014 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_csssyntaxparser.h"
-
-#include <algorithm>
-
-#include "core/fxcrt/fx_codepage.h"
-#include "core/fxcrt/fx_extension.h"
-#include "third_party/base/logging.h"
-#include "xfa/fde/css/cfde_cssdeclaration.h"
-#include "xfa/fde/css/fde_cssdatatable.h"
-
-namespace {
-
-bool IsSelectorStart(wchar_t wch) {
- return wch == '.' || wch == '#' || wch == '*' || FXSYS_iswalpha(wch);
-}
-
-} // namespace
-
-CFDE_CSSSyntaxParser::CFDE_CSSSyntaxParser(const wchar_t* pBuffer,
- int32_t iBufferSize)
- : CFDE_CSSSyntaxParser(pBuffer, iBufferSize, 32, false) {}
-
-CFDE_CSSSyntaxParser::CFDE_CSSSyntaxParser(const wchar_t* pBuffer,
- int32_t iBufferSize,
- int32_t iTextDatSize,
- bool bOnlyDeclaration)
- : m_iTextDataLen(0),
- m_dwCheck(0xFFFFFFFF),
- m_eStatus(FDE_CSSSyntaxStatus::None) {
- ASSERT(pBuffer && iBufferSize > 0 && iTextDatSize > 0);
- m_eMode = bOnlyDeclaration ? FDE_CSSSyntaxMode::PropertyName
- : FDE_CSSSyntaxMode::RuleSet;
- m_TextData.InitWithSize(iTextDatSize);
- m_TextPlane.AttachBuffer(pBuffer, iBufferSize);
-}
-
-CFDE_CSSSyntaxParser::~CFDE_CSSSyntaxParser() {}
-
-FDE_CSSSyntaxStatus CFDE_CSSSyntaxParser::DoSyntaxParse() {
- while (m_eStatus >= FDE_CSSSyntaxStatus::None) {
- if (m_TextPlane.IsEOF()) {
- if (m_eMode == FDE_CSSSyntaxMode::PropertyValue &&
- m_TextData.GetLength() > 0) {
- SaveTextData();
- m_eStatus = FDE_CSSSyntaxStatus::PropertyValue;
- return m_eStatus;
- }
- m_eStatus = FDE_CSSSyntaxStatus::EOS;
- return m_eStatus;
- }
- wchar_t wch;
- while (!m_TextPlane.IsEOF()) {
- wch = m_TextPlane.GetChar();
- switch (m_eMode) {
- case FDE_CSSSyntaxMode::RuleSet:
- switch (wch) {
- case '}':
- m_TextPlane.MoveNext();
- if (RestoreMode())
- return FDE_CSSSyntaxStatus::DeclClose;
-
- m_eStatus = FDE_CSSSyntaxStatus::Error;
- return m_eStatus;
- case '/':
- if (m_TextPlane.GetNextChar() == '*') {
- m_ModeStack.push(m_eMode);
- SwitchMode(FDE_CSSSyntaxMode::Comment);
- break;
- }
- default:
- if (wch <= ' ') {
- m_TextPlane.MoveNext();
- } else if (IsSelectorStart(wch)) {
- SwitchMode(FDE_CSSSyntaxMode::Selector);
- return FDE_CSSSyntaxStatus::StyleRule;
- } else {
- m_eStatus = FDE_CSSSyntaxStatus::Error;
- return m_eStatus;
- }
- break;
- }
- break;
- case FDE_CSSSyntaxMode::Selector:
- switch (wch) {
- case ',':
- m_TextPlane.MoveNext();
- SwitchMode(FDE_CSSSyntaxMode::Selector);
- if (m_iTextDataLen > 0)
- return FDE_CSSSyntaxStatus::Selector;
- break;
- case '{':
- if (m_TextData.GetLength() > 0) {
- SaveTextData();
- return FDE_CSSSyntaxStatus::Selector;
- }
- m_TextPlane.MoveNext();
- m_ModeStack.push(FDE_CSSSyntaxMode::RuleSet);
- SwitchMode(FDE_CSSSyntaxMode::PropertyName);
- return FDE_CSSSyntaxStatus::DeclOpen;
- case '/':
- if (m_TextPlane.GetNextChar() == '*') {
- if (SwitchToComment() > 0)
- return FDE_CSSSyntaxStatus::Selector;
- break;
- }
- default:
- AppendChar(wch);
- break;
- }
- break;
- case FDE_CSSSyntaxMode::PropertyName:
- switch (wch) {
- case ':':
- m_TextPlane.MoveNext();
- SwitchMode(FDE_CSSSyntaxMode::PropertyValue);
- return FDE_CSSSyntaxStatus::PropertyName;
- case '}':
- m_TextPlane.MoveNext();
- if (RestoreMode())
- return FDE_CSSSyntaxStatus::DeclClose;
-
- m_eStatus = FDE_CSSSyntaxStatus::Error;
- return m_eStatus;
- case '/':
- if (m_TextPlane.GetNextChar() == '*') {
- if (SwitchToComment() > 0)
- return FDE_CSSSyntaxStatus::PropertyName;
- break;
- }
- default:
- AppendChar(wch);
- break;
- }
- break;
- case FDE_CSSSyntaxMode::PropertyValue:
- switch (wch) {
- case ';':
- m_TextPlane.MoveNext();
- case '}':
- SwitchMode(FDE_CSSSyntaxMode::PropertyName);
- return FDE_CSSSyntaxStatus::PropertyValue;
- case '/':
- if (m_TextPlane.GetNextChar() == '*') {
- if (SwitchToComment() > 0)
- return FDE_CSSSyntaxStatus::PropertyValue;
- break;
- }
- default:
- AppendChar(wch);
- break;
- }
- break;
- case FDE_CSSSyntaxMode::Comment:
- if (wch == '/' && m_TextData.GetLength() > 0 &&
- m_TextData.GetBuffer()[m_TextData.GetLength() - 1] == '*') {
- RestoreMode();
- } else {
- m_TextData.AppendChar(wch);
- }
- m_TextPlane.MoveNext();
- break;
- case FDE_CSSSyntaxMode::UnknownRule:
- if (wch == ';')
- SwitchMode(FDE_CSSSyntaxMode::RuleSet);
- m_TextPlane.MoveNext();
- break;
- default:
- NOTREACHED();
- break;
- }
- }
- }
- return m_eStatus;
-}
-
-bool CFDE_CSSSyntaxParser::IsImportEnabled() const {
- if ((m_dwCheck & FDE_CSSSYNTAXCHECK_AllowImport) == 0)
- return false;
- if (m_ModeStack.size() > 1)
- return false;
- return true;
-}
-
-bool CFDE_CSSSyntaxParser::AppendChar(wchar_t wch) {
- m_TextPlane.MoveNext();
- if (m_TextData.GetLength() > 0 || wch > ' ') {
- m_TextData.AppendChar(wch);
- return true;
- }
- return false;
-}
-
-int32_t CFDE_CSSSyntaxParser::SaveTextData() {
- m_iTextDataLen = m_TextData.TrimEnd();
- m_TextData.Clear();
- return m_iTextDataLen;
-}
-
-void CFDE_CSSSyntaxParser::SwitchMode(FDE_CSSSyntaxMode eMode) {
- m_eMode = eMode;
- SaveTextData();
-}
-
-int32_t CFDE_CSSSyntaxParser::SwitchToComment() {
- int32_t iLength = m_TextData.GetLength();
- m_ModeStack.push(m_eMode);
- SwitchMode(FDE_CSSSyntaxMode::Comment);
- return iLength;
-}
-
-bool CFDE_CSSSyntaxParser::RestoreMode() {
- if (m_ModeStack.empty())
- return false;
-
- SwitchMode(m_ModeStack.top());
- m_ModeStack.pop();
- return true;
-}
-
-CFX_WideStringC CFDE_CSSSyntaxParser::GetCurrentString() const {
- return CFX_WideStringC(m_TextData.GetBuffer(), m_iTextDataLen);
-}
diff --git a/xfa/fde/css/cfde_csssyntaxparser.h b/xfa/fde/css/cfde_csssyntaxparser.h
deleted file mode 100644
index c17d84aef1..0000000000
--- a/xfa/fde/css/cfde_csssyntaxparser.h
+++ /dev/null
@@ -1,75 +0,0 @@
-// 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_CSSSYNTAXPARSER_H_
-#define XFA_FDE_CSS_CFDE_CSSSYNTAXPARSER_H_
-
-#include <stack>
-
-#include "core/fxcrt/fx_string.h"
-#include "xfa/fde/css/cfde_cssexttextbuf.h"
-#include "xfa/fde/css/cfde_csstextbuf.h"
-
-#define FDE_CSSSYNTAXCHECK_AllowCharset 1
-#define FDE_CSSSYNTAXCHECK_AllowImport 2
-
-enum class FDE_CSSSyntaxMode {
- RuleSet,
- Comment,
- UnknownRule,
- Selector,
- PropertyName,
- PropertyValue,
-};
-
-enum class FDE_CSSSyntaxStatus : uint8_t {
- Error,
- EOS,
- None,
- StyleRule,
- Selector,
- DeclOpen,
- DeclClose,
- PropertyName,
- PropertyValue,
-};
-
-class CFDE_CSSSyntaxParser {
- public:
- CFDE_CSSSyntaxParser(const wchar_t* pBuffer, int32_t iBufferSize);
- CFDE_CSSSyntaxParser(const wchar_t* pBuffer,
- int32_t iBufferSize,
- int32_t iTextDatSize,
- bool bOnlyDeclaration);
- ~CFDE_CSSSyntaxParser();
-
- FDE_CSSSyntaxStatus DoSyntaxParse();
- CFX_WideStringC GetCurrentString() const;
-
- protected:
- void SwitchMode(FDE_CSSSyntaxMode eMode);
- int32_t SwitchToComment();
-
- bool RestoreMode();
- bool AppendChar(wchar_t wch);
- int32_t SaveTextData();
- bool IsCharsetEnabled() const {
- return (m_dwCheck & FDE_CSSSYNTAXCHECK_AllowCharset) != 0;
- }
- void DisableCharset() { m_dwCheck = FDE_CSSSYNTAXCHECK_AllowImport; }
- bool IsImportEnabled() const;
- void DisableImport() { m_dwCheck = 0; }
-
- CFDE_CSSTextBuf m_TextData;
- CFDE_CSSExtTextBuf m_TextPlane;
- int32_t m_iTextDataLen;
- uint32_t m_dwCheck;
- FDE_CSSSyntaxMode m_eMode;
- FDE_CSSSyntaxStatus m_eStatus;
- std::stack<FDE_CSSSyntaxMode> m_ModeStack;
-};
-
-#endif // XFA_FDE_CSS_CFDE_CSSSYNTAXPARSER_H_
diff --git a/xfa/fde/css/cfde_csstextbuf.cpp b/xfa/fde/css/cfde_csstextbuf.cpp
deleted file mode 100644
index 0d8ba2d6ce..0000000000
--- a/xfa/fde/css/cfde_csstextbuf.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-// 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_csstextbuf.h"
-
-#include "core/fxcrt/fx_memory.h"
-
-CFDE_CSSTextBuf::CFDE_CSSTextBuf()
- : m_pBuffer(nullptr), m_iBufLen(0), m_iDatLen(0) {}
-
-CFDE_CSSTextBuf::~CFDE_CSSTextBuf() {
- FX_Free(m_pBuffer);
- m_pBuffer = nullptr;
- m_iDatLen = m_iBufLen;
-}
-
-void CFDE_CSSTextBuf::InitWithSize(int32_t iAllocSize) {
- ExpandBuf(iAllocSize);
-}
-
-void CFDE_CSSTextBuf::AppendChar(wchar_t wch) {
- if (m_iDatLen >= m_iBufLen)
- ExpandBuf(m_iBufLen * 2);
-
- m_pBuffer[m_iDatLen++] = wch;
-}
-
-int32_t CFDE_CSSTextBuf::TrimEnd() {
- while (m_iDatLen > 0 && m_pBuffer[m_iDatLen - 1] <= ' ')
- --m_iDatLen;
- AppendChar(0);
- return --m_iDatLen;
-}
-
-void CFDE_CSSTextBuf::ExpandBuf(int32_t iDesiredSize) {
- ASSERT(iDesiredSize > 0);
- if (m_pBuffer && m_iBufLen == iDesiredSize)
- return;
-
- if (m_pBuffer)
- m_pBuffer = FX_Realloc(wchar_t, m_pBuffer, iDesiredSize);
- else
- m_pBuffer = FX_Alloc(wchar_t, iDesiredSize);
-
- m_iBufLen = iDesiredSize;
-}
diff --git a/xfa/fde/css/cfde_csstextbuf.h b/xfa/fde/css/cfde_csstextbuf.h
deleted file mode 100644
index b2c17c95f8..0000000000
--- a/xfa/fde/css/cfde_csstextbuf.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// 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_CSSTEXTBUF_H_
-#define XFA_FDE_CSS_CFDE_CSSTEXTBUF_H_
-
-#include "core/fxcrt/fx_system.h"
-
-class CFDE_CSSTextBuf {
- public:
- CFDE_CSSTextBuf();
- ~CFDE_CSSTextBuf();
-
- void InitWithSize(int32_t iAllocSize);
- void AppendChar(wchar_t wch);
-
- void Clear() { m_iDatLen = 0; }
-
- int32_t TrimEnd();
-
- int32_t GetLength() const { return m_iDatLen; }
- const wchar_t* GetBuffer() const { return m_pBuffer; }
-
- protected:
- void ExpandBuf(int32_t iDesiredSize);
-
- wchar_t* m_pBuffer;
- int32_t m_iBufLen;
- int32_t m_iDatLen;
-};
-
-#endif // XFA_FDE_CSS_CFDE_CSSTEXTBUF_H_
diff --git a/xfa/fde/css/cfde_cssvalue.cpp b/xfa/fde/css/cfde_cssvalue.cpp
deleted file mode 100644
index ef7029f9a5..0000000000
--- a/xfa/fde/css/cfde_cssvalue.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-// 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_cssvalue.h"
-
-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
deleted file mode 100644
index 71d254bbea..0000000000
--- a/xfa/fde/css/cfde_cssvalue.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// 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_CSSVALUE_H_
-#define XFA_FDE_CSS_CFDE_CSSVALUE_H_
-
-#include "xfa/fde/css/fde_css.h"
-
-class CFDE_CSSValue : public CFX_Retainable {
- public:
- FDE_CSSPrimitiveType GetType() const { return m_value; }
-
- protected:
- explicit CFDE_CSSValue(FDE_CSSPrimitiveType type);
-
- private:
- 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
deleted file mode 100644
index 737ffcb045..0000000000
--- a/xfa/fde/css/cfde_cssvaluelist.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-// 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();
-}
-
-CFX_RetainPtr<CFDE_CSSValue> CFDE_CSSValueList::GetValue(int32_t index) const {
- return m_ppList[index];
-}
diff --git a/xfa/fde/css/cfde_cssvaluelist.h b/xfa/fde/css/cfde_cssvaluelist.h
deleted file mode 100644
index a47f8a3250..0000000000
--- a/xfa/fde/css/cfde_cssvaluelist.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// 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;
- CFX_RetainPtr<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
deleted file mode 100644
index 79a79818dc..0000000000
--- a/xfa/fde/css/cfde_cssvaluelistparser.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-// 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"
-
-#include "core/fxcrt/fx_extension.h"
-
-CFDE_CSSValueListParser::CFDE_CSSValueListParser(const wchar_t* psz,
- int32_t iLen,
- wchar_t separator)
- : m_Separator(separator), m_pCur(psz), m_pEnd(psz + iLen) {
- ASSERT(psz && iLen > 0);
-}
-
-bool CFDE_CSSValueListParser::NextValue(FDE_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 = FDE_CSSPrimitiveType::Unknown;
- pStart = m_pCur;
- iLength = 0;
- wchar_t wch = *m_pCur;
- if (wch == '#') {
- iLength = SkipTo(' ', false, false);
- if (iLength == 4 || iLength == 7)
- eType = FDE_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 = FDE_CSSPrimitiveType::Number;
- } else if (wch == '\"' || wch == '\'') {
- pStart++;
- m_pCur++;
- iLength = SkipTo(wch, false, false);
- m_pCur++;
- eType = FDE_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;
- 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(wchar_t wch,
- bool breakOnSpace,
- bool matchBrackets) {
- const wchar_t* pStart = m_pCur;
- int32_t bracketCount = 0;
- while (m_pCur < m_pEnd && *m_pCur != wch) {
- if (breakOnSpace && *m_pCur <= ' ')
- break;
- if (!matchBrackets) {
- m_pCur++;
- continue;
- }
-
- if (*m_pCur == '(')
- bracketCount++;
- else if (*m_pCur == ')')
- bracketCount--;
-
- m_pCur++;
- }
-
- while (bracketCount > 0 && m_pCur < m_pEnd) {
- if (*m_pCur == ')')
- bracketCount--;
- m_pCur++;
- }
- return m_pCur - pStart;
-}
diff --git a/xfa/fde/css/cfde_cssvaluelistparser.h b/xfa/fde/css/cfde_cssvaluelistparser.h
deleted file mode 100644
index e41ee5c313..0000000000
--- a/xfa/fde/css/cfde_cssvaluelistparser.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// 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 wchar_t* psz, int32_t iLen, wchar_t separator);
-
- bool NextValue(FDE_CSSPrimitiveType& eType,
- const wchar_t*& pStart,
- int32_t& iLength);
-
- wchar_t m_Separator;
-
- private:
- int32_t SkipTo(wchar_t wch, bool breakOnSpace, bool matchBrackets);
-
- const wchar_t* m_pCur;
- const wchar_t* m_pEnd;
-};
-
-#endif // XFA_FDE_CSS_CFDE_CSSVALUELISTPARSER_H_
diff --git a/xfa/fde/css/cfde_cssvaluelistparser_unittest.cpp b/xfa/fde/css/cfde_cssvaluelistparser_unittest.cpp
deleted file mode 100644
index 53a0657e12..0000000000
--- a/xfa/fde/css/cfde_cssvaluelistparser_unittest.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-// 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"
-
-#include "testing/gtest/include/gtest/gtest.h"
-#include "testing/test_support.h"
-#include "third_party/base/ptr_util.h"
-
-TEST(CFDE_CSSValueListParserTest, rgb_short) {
- FDE_CSSPrimitiveType type;
- const wchar_t* start;
- int32_t len;
-
- auto parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"#abc", 4, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::RGB, type);
- EXPECT_EQ(L"#abc", CFX_WideString(start, len));
- EXPECT_FALSE(parser->NextValue(type, start, len));
-
- parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"#abcdef", 7, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::RGB, type);
- EXPECT_EQ(L"#abcdef", CFX_WideString(start, len));
- EXPECT_FALSE(parser->NextValue(type, start, len));
-
- parser =
- pdfium::MakeUnique<CFDE_CSSValueListParser>(L"rgb(1, 255, 4)", 14, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::RGB, type);
- EXPECT_EQ(L"rgb(1, 255, 4)", CFX_WideString(start, len));
-
- parser =
- pdfium::MakeUnique<CFDE_CSSValueListParser>(L"#abcdefghij", 11, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::Unknown, type);
- EXPECT_EQ(L"#abcdefghij", CFX_WideString(start, len));
- EXPECT_FALSE(parser->NextValue(type, start, len));
-}
-
-TEST(CFDE_CSSValueListParserTest, number_parsing) {
- FDE_CSSPrimitiveType type;
- const wchar_t* start;
- int32_t len;
-
- auto parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"1234", 4, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"1234", CFX_WideString(start, len));
-
- parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"-1234", 5, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"-1234", CFX_WideString(start, len));
-
- parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"+1234", 5, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"+1234", CFX_WideString(start, len));
-
- parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L".1234", 5, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L".1234", CFX_WideString(start, len));
-
- parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"4321.1234", 9, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"4321.1234", CFX_WideString(start, len));
-
- // TODO(dsinclair): These should probably fail but currently don't.
- parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"4321.12.34", 10, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"4321.12.34", CFX_WideString(start, len));
-
- parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"43a1.12.34", 10, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"43a1.12.34", CFX_WideString(start, len));
-}
-
-TEST(CFDE_CSSValueListParserTest, string_parsing) {
- FDE_CSSPrimitiveType type;
- const wchar_t* start;
- int32_t len;
-
- auto parser =
- pdfium::MakeUnique<CFDE_CSSValueListParser>(L"'string'", 8, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::String, type);
- EXPECT_EQ(L"string", CFX_WideString(start, len));
-
- parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"\"another string\"",
- 16, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::String, type);
- EXPECT_EQ(L"another string", CFX_WideString(start, len));
-
- parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(L"standalone", 10, L' ');
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::String, type);
- EXPECT_EQ(L"standalone", CFX_WideString(start, len));
-}
-
-TEST(CFDE_CSSValueListParserTest, multiparsing) {
- FDE_CSSPrimitiveType type;
- const wchar_t* start;
- int32_t len;
-
- auto parser =
- pdfium::MakeUnique<CFDE_CSSValueListParser>(L"1, 2, 3", 7, L',');
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"1", CFX_WideString(start, len));
-
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"2", CFX_WideString(start, len));
-
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"3", CFX_WideString(start, len));
-
- EXPECT_FALSE(parser->NextValue(type, start, len));
-
- parser = pdfium::MakeUnique<CFDE_CSSValueListParser>(
- L"'str', rgb(1, 2, 3), 4", 22, L',');
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::String, type);
- EXPECT_EQ(L"str", CFX_WideString(start, len));
-
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::RGB, type);
- EXPECT_EQ(L"rgb(1, 2, 3)", CFX_WideString(start, len));
-
- EXPECT_TRUE(parser->NextValue(type, start, len));
- EXPECT_EQ(FDE_CSSPrimitiveType::Number, type);
- EXPECT_EQ(L"4", CFX_WideString(start, len));
-}
diff --git a/xfa/fde/css/fde_css.h b/xfa/fde/css/fde_css.h
deleted file mode 100644
index 663db44de3..0000000000
--- a/xfa/fde/css/fde_css.h
+++ /dev/null
@@ -1,242 +0,0 @@
-// Copyright 2014 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_FDE_CSS_H_
-#define XFA_FDE_CSS_FDE_CSS_H_
-
-#include "core/fxcrt/cfx_seekablestreamproxy.h"
-#include "core/fxge/fx_dib.h"
-
-enum FDE_CSSVALUETYPE {
- FDE_CSSVALUETYPE_Primitive = 1 << 0,
- FDE_CSSVALUETYPE_List = 1 << 1,
- FDE_CSSVALUETYPE_Shorthand = 1 << 2,
- // 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_MaybeString = 1 << 7,
- FDE_CSSVALUETYPE_MaybeColor = 1 << 8
-};
-
-enum class FDE_CSSPrimitiveType : uint8_t {
- Unknown = 0,
- Number,
- String,
- RGB,
- Enum,
- Function,
- List,
-};
-
-enum class FDE_CSSPropertyValue : uint8_t {
- Bolder = 0,
- None,
- Dot,
- Sub,
- Top,
- Right,
- Normal,
- Auto,
- Text,
- XSmall,
- Thin,
- Small,
- Bottom,
- Underline,
- Double,
- Lighter,
- Oblique,
- Super,
- Center,
- XxLarge,
- Smaller,
- Baseline,
- Thick,
- Justify,
- Middle,
- Medium,
- ListItem,
- XxSmall,
- Bold,
- SmallCaps,
- Inline,
- Overline,
- TextBottom,
- Larger,
- InlineTable,
- InlineBlock,
- Blink,
- Block,
- Italic,
- LineThrough,
- XLarge,
- Large,
- Left,
- TextTop,
- LAST_MARKER
-};
-
-enum class FDE_CSSProperty : uint8_t {
- BorderLeft = 0,
- Top,
- Margin,
- TextIndent,
- Right,
- PaddingLeft,
- MarginLeft,
- Border,
- BorderTop,
- Bottom,
- PaddingRight,
- BorderBottom,
- FontFamily,
- FontWeight,
- Color,
- LetterSpacing,
- TextAlign,
- BorderRightWidth,
- VerticalAlign,
- PaddingTop,
- FontVariant,
- BorderWidth,
- BorderBottomWidth,
- BorderRight,
- FontSize,
- BorderSpacing,
- FontStyle,
- Font,
- LineHeight,
- MarginRight,
- BorderLeftWidth,
- Display,
- PaddingBottom,
- BorderTopWidth,
- WordSpacing,
- Left,
- TextDecoration,
- Padding,
- MarginBottom,
- MarginTop,
- LAST_MARKER
-};
-
-enum class FDE_CSSSelectorType : uint8_t { Element = 0, Descendant };
-
-enum class FDE_CSSLengthUnit : uint8_t {
- Auto,
- None,
- Normal,
- Point,
- Percent,
-};
-
-enum class FDE_CSSDisplay : uint8_t {
- None,
- ListItem,
- Block,
- Inline,
- InlineBlock,
- InlineTable,
-};
-
-enum class FDE_CSSFontStyle : uint8_t {
- Normal,
- Italic,
-};
-
-enum class FDE_CSSTextAlign : uint8_t {
- Left,
- Right,
- Center,
- Justify,
- JustifyAll,
-};
-
-enum class FDE_CSSVerticalAlign : uint8_t {
- Baseline,
- Sub,
- Super,
- Top,
- TextTop,
- Middle,
- Bottom,
- TextBottom,
- Number,
-};
-
-enum class FDE_CSSFontVariant : uint8_t {
- Normal,
- SmallCaps,
-};
-
-enum FDE_CSSTEXTDECORATION {
- FDE_CSSTEXTDECORATION_None = 0,
- FDE_CSSTEXTDECORATION_Underline = 1 << 0,
- FDE_CSSTEXTDECORATION_Overline = 1 << 1,
- FDE_CSSTEXTDECORATION_LineThrough = 1 << 2,
- FDE_CSSTEXTDECORATION_Blink = 1 << 3,
- FDE_CSSTEXTDECORATION_Double = 1 << 4,
-};
-
-class FDE_CSSLength {
- public:
- FDE_CSSLength() {}
-
- explicit FDE_CSSLength(FDE_CSSLengthUnit eUnit) : m_unit(eUnit) {}
-
- FDE_CSSLength(FDE_CSSLengthUnit eUnit, float fValue)
- : m_unit(eUnit), m_fValue(fValue) {}
-
- FDE_CSSLength& Set(FDE_CSSLengthUnit eUnit) {
- m_unit = eUnit;
- return *this;
- }
-
- FDE_CSSLength& Set(FDE_CSSLengthUnit eUnit, float fValue) {
- m_unit = eUnit;
- m_fValue = fValue;
- return *this;
- }
-
- FDE_CSSLengthUnit GetUnit() const { return m_unit; }
-
- float GetValue() const { return m_fValue; }
- bool NonZero() const { return static_cast<int>(m_fValue) != 0; }
-
- private:
- FDE_CSSLengthUnit m_unit;
- float m_fValue;
-};
-
-class FDE_CSSRect {
- public:
- FDE_CSSRect() {}
-
- FDE_CSSRect(FDE_CSSLengthUnit eUnit, float val)
- : left(eUnit, val),
- top(eUnit, val),
- right(eUnit, val),
- bottom(eUnit, val) {}
-
- FDE_CSSRect& Set(FDE_CSSLengthUnit eUnit) {
- left.Set(eUnit);
- top.Set(eUnit);
- right.Set(eUnit);
- bottom.Set(eUnit);
- return *this;
- }
- FDE_CSSRect& Set(FDE_CSSLengthUnit eUnit, float fValue) {
- left.Set(eUnit, fValue);
- top.Set(eUnit, fValue);
- right.Set(eUnit, fValue);
- bottom.Set(eUnit, fValue);
- return *this;
- }
-
- FDE_CSSLength left, top, right, bottom;
-};
-
-#endif // XFA_FDE_CSS_FDE_CSS_H_
diff --git a/xfa/fde/css/fde_cssdatatable.cpp b/xfa/fde/css/fde_cssdatatable.cpp
deleted file mode 100644
index 79170bc072..0000000000
--- a/xfa/fde/css/fde_cssdatatable.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-// Copyright 2014 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/fde_cssdatatable.h"
-
-#include <utility>
-
-#include "core/fxcrt/fx_codepage.h"
-#include "core/fxcrt/fx_extension.h"
-#include "xfa/fde/css/cfde_cssstyleselector.h"
-#include "xfa/fde/css/cfde_cssvaluelistparser.h"
-
-static const FDE_CSSPropertyTable g_FDE_CSSProperties[] = {
- {FDE_CSSProperty::BorderLeft, L"border-left", 0x04080036,
- FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSProperty::Top, L"top", 0x0BEDAF33,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::Margin, L"margin", 0x0CB016BE,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::TextIndent, L"text-indent", 0x169ADB74,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::Right, L"right", 0x193ADE3E,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::PaddingLeft, L"padding-left", 0x228CF02F,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::MarginLeft, L"margin-left", 0x297C5656,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber |
- FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSProperty::Border, L"border", 0x2A23349E,
- FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSProperty::BorderTop, L"border-top", 0x2B866ADE,
- FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSProperty::Bottom, L"bottom", 0x399F02B5,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::PaddingRight, L"padding-right", 0x3F616AC2,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::BorderBottom, L"border-bottom", 0x452CE780,
- FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSProperty::FontFamily, L"font-family", 0x574686E6,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeString},
- {FDE_CSSProperty::FontWeight, L"font-weight", 0x6692F60C,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::Color, L"color", 0x6E67921F,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeColor},
- {FDE_CSSProperty::LetterSpacing, L"letter-spacing", 0x70536102,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::TextAlign, L"text-align", 0x7553F1BD,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSProperty::BorderRightWidth, L"border-right-width", 0x8F5A6036,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::VerticalAlign, L"vertical-align", 0x934A87D2,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::PaddingTop, L"padding-top", 0x959D22B7,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::FontVariant, L"font-variant", 0x9C785779,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSProperty::BorderWidth, L"border-width", 0xA8DE4FEB,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::BorderBottomWidth, L"border-bottom-width", 0xAE41204D,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::BorderRight, L"border-right", 0xB78E9EA9,
- FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSProperty::FontSize, L"font-size", 0xB93956DF,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::BorderSpacing, L"border-spacing", 0xC72030F0,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::FontStyle, L"font-style", 0xCB1950F5,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSProperty::Font, L"font", 0xCD308B77, FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSProperty::LineHeight, L"line-height", 0xCFCACE2E,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::MarginRight, L"margin-right", 0xD13C58C9,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber |
- FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSProperty::BorderLeftWidth, L"border-left-width", 0xD1E93D83,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::Display, L"display", 0xD4224C36,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSProperty::PaddingBottom, L"padding-bottom", 0xE555B3B9,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::BorderTopWidth, L"border-top-width", 0xED2CB62B,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::WordSpacing, L"word-spacing", 0xEDA63BAE,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::Left, L"left", 0xF5AD782B,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::TextDecoration, L"text-decoration", 0xF7C634BA,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSProperty::Padding, L"padding", 0xF8C373F7,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSProperty::MarginBottom, L"margin-bottom", 0xF93485A0,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber |
- FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSProperty::MarginTop, L"margin-top", 0xFE51DCFE,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber |
- FDE_CSSVALUETYPE_MaybeEnum},
-};
-const int32_t g_iCSSPropertyCount =
- sizeof(g_FDE_CSSProperties) / sizeof(FDE_CSSPropertyTable);
-static_assert(g_iCSSPropertyCount ==
- static_cast<int32_t>(FDE_CSSProperty::LAST_MARKER),
- "Property table differs in size from property enum");
-
-static const FDE_CSSPropertyValueTable g_FDE_CSSPropertyValues[] = {
- {FDE_CSSPropertyValue::Bolder, L"bolder", 0x009F1058},
- {FDE_CSSPropertyValue::None, L"none", 0x048B6670},
- {FDE_CSSPropertyValue::Dot, L"dot", 0x0A48CB27},
- {FDE_CSSPropertyValue::Sub, L"sub", 0x0BD37FAA},
- {FDE_CSSPropertyValue::Top, L"top", 0x0BEDAF33},
- {FDE_CSSPropertyValue::Right, L"right", 0x193ADE3E},
- {FDE_CSSPropertyValue::Normal, L"normal", 0x247CF3E9},
- {FDE_CSSPropertyValue::Auto, L"auto", 0x2B35B6D9},
- {FDE_CSSPropertyValue::Text, L"text", 0x2D08AF85},
- {FDE_CSSPropertyValue::XSmall, L"x-small", 0x2D2FCAFE},
- {FDE_CSSPropertyValue::Thin, L"thin", 0x2D574D53},
- {FDE_CSSPropertyValue::Small, L"small", 0x316A3739},
- {FDE_CSSPropertyValue::Bottom, L"bottom", 0x399F02B5},
- {FDE_CSSPropertyValue::Underline, L"underline", 0x3A0273A6},
- {FDE_CSSPropertyValue::Double, L"double", 0x3D98515B},
- {FDE_CSSPropertyValue::Lighter, L"lighter", 0x45BEB7AF},
- {FDE_CSSPropertyValue::Oblique, L"oblique", 0x53EBDDB1},
- {FDE_CSSPropertyValue::Super, L"super", 0x6A4F842F},
- {FDE_CSSPropertyValue::Center, L"center", 0x6C51AFC1},
- {FDE_CSSPropertyValue::XxLarge, L"xx-large", 0x70BB1508},
- {FDE_CSSPropertyValue::Smaller, L"smaller", 0x849769F0},
- {FDE_CSSPropertyValue::Baseline, L"baseline", 0x87436BA3},
- {FDE_CSSPropertyValue::Thick, L"thick", 0x8CC35EB3},
- {FDE_CSSPropertyValue::Justify, L"justify", 0x8D269CAE},
- {FDE_CSSPropertyValue::Middle, L"middle", 0x947FA00F},
- {FDE_CSSPropertyValue::Medium, L"medium", 0xA084A381},
- {FDE_CSSPropertyValue::ListItem, L"list-item", 0xA32382B8},
- {FDE_CSSPropertyValue::XxSmall, L"xx-small", 0xADE1FC76},
- {FDE_CSSPropertyValue::Bold, L"bold", 0xB18313A1},
- {FDE_CSSPropertyValue::SmallCaps, L"small-caps", 0xB299428D},
- {FDE_CSSPropertyValue::Inline, L"inline", 0xC02D649F},
- {FDE_CSSPropertyValue::Overline, L"overline", 0xC0EC9FA4},
- {FDE_CSSPropertyValue::TextBottom, L"text-bottom", 0xC7D08D87},
- {FDE_CSSPropertyValue::Larger, L"larger", 0xCD3C409D},
- {FDE_CSSPropertyValue::InlineTable, L"inline-table", 0xD131F494},
- {FDE_CSSPropertyValue::InlineBlock, L"inline-block", 0xD26A8BD7},
- {FDE_CSSPropertyValue::Blink, L"blink", 0xDC36E390},
- {FDE_CSSPropertyValue::Block, L"block", 0xDCD480AB},
- {FDE_CSSPropertyValue::Italic, L"italic", 0xE31D5396},
- {FDE_CSSPropertyValue::LineThrough, L"line-through", 0xE4C5A276},
- {FDE_CSSPropertyValue::XLarge, L"x-large", 0xF008E390},
- {FDE_CSSPropertyValue::Large, L"large", 0xF4434FCB},
- {FDE_CSSPropertyValue::Left, L"left", 0xF5AD782B},
- {FDE_CSSPropertyValue::TextTop, L"text-top", 0xFCB58D45},
-};
-const int32_t g_iCSSPropertyValueCount =
- sizeof(g_FDE_CSSPropertyValues) / sizeof(FDE_CSSPropertyValueTable);
-static_assert(g_iCSSPropertyValueCount ==
- static_cast<int32_t>(FDE_CSSPropertyValue::LAST_MARKER),
- "Property value table differs in size from property value enum");
-
-static const FDE_CSSLengthUnitTable g_FDE_CSSLengthUnits[] = {
- {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[] = {
- {0x031B47FE, 0xff000080}, {0x0BB8DF5B, 0xffff0000},
- {0x0D82A78C, 0xff800000}, {0x2ACC82E8, 0xff00ffff},
- {0x2D083986, 0xff008080}, {0x4A6A6195, 0xffc0c0c0},
- {0x546A8EF3, 0xff808080}, {0x65C9169C, 0xffffa500},
- {0x8422BB61, 0xffffffff}, {0x9271A558, 0xff800080},
- {0xA65A3EE3, 0xffff00ff}, {0xB1345708, 0xff0000ff},
- {0xB6D2CF1F, 0xff808000}, {0xD19B5E1C, 0xffffff00},
- {0xDB64391D, 0xff000000}, {0xF616D507, 0xff00ff00},
- {0xF6EFFF31, 0xff008000},
-};
-
-const FDE_CSSPropertyTable* FDE_GetCSSPropertyByName(
- const CFX_WideStringC& wsName) {
- ASSERT(!wsName.IsEmpty());
- uint32_t dwHash = FX_HashCode_GetW(wsName, true);
- int32_t iEnd = g_iCSSPropertyCount;
- int32_t iMid, iStart = 0;
- uint32_t dwMid;
- do {
- iMid = (iStart + iEnd) / 2;
- dwMid = g_FDE_CSSProperties[iMid].dwHash;
- if (dwHash == dwMid) {
- return g_FDE_CSSProperties + iMid;
- } else if (dwHash > dwMid) {
- iStart = iMid + 1;
- } else {
- iEnd = iMid - 1;
- }
- } while (iStart <= iEnd);
- return nullptr;
-}
-
-const FDE_CSSPropertyTable* FDE_GetCSSPropertyByEnum(FDE_CSSProperty eName) {
- return g_FDE_CSSProperties + static_cast<int>(eName);
-}
-
-const FDE_CSSPropertyValueTable* FDE_GetCSSPropertyValueByName(
- const CFX_WideStringC& wsName) {
- ASSERT(!wsName.IsEmpty());
- uint32_t dwHash = FX_HashCode_GetW(wsName, true);
- int32_t iEnd = g_iCSSPropertyValueCount;
- int32_t iMid, iStart = 0;
- uint32_t dwMid;
- do {
- iMid = (iStart + iEnd) / 2;
- dwMid = g_FDE_CSSPropertyValues[iMid].dwHash;
- if (dwHash == dwMid) {
- return g_FDE_CSSPropertyValues + iMid;
- } else if (dwHash > dwMid) {
- iStart = iMid + 1;
- } else {
- iEnd = iMid - 1;
- }
- } while (iStart <= iEnd);
- return nullptr;
-}
-
-const FDE_CSSLengthUnitTable* FDE_GetCSSLengthUnitByName(
- const CFX_WideStringC& wsName) {
- ASSERT(!wsName.IsEmpty());
- uint16_t wHash = FX_HashCode_GetW(wsName, true);
- int32_t iEnd =
- sizeof(g_FDE_CSSLengthUnits) / sizeof(FDE_CSSLengthUnitTable) - 1;
- int32_t iMid, iStart = 0;
- uint16_t wMid;
- do {
- iMid = (iStart + iEnd) / 2;
- wMid = g_FDE_CSSLengthUnits[iMid].wHash;
- if (wHash == wMid) {
- return g_FDE_CSSLengthUnits + iMid;
- } else if (wHash > wMid) {
- iStart = iMid + 1;
- } else {
- iEnd = iMid - 1;
- }
- } while (iStart <= iEnd);
- return nullptr;
-}
-
-const FDE_CSSCOLORTABLE* FDE_GetCSSColorByName(const CFX_WideStringC& wsName) {
- ASSERT(!wsName.IsEmpty());
- uint32_t dwHash = FX_HashCode_GetW(wsName, true);
- int32_t iEnd = sizeof(g_FDE_CSSColors) / sizeof(FDE_CSSCOLORTABLE) - 1;
- int32_t iMid, iStart = 0;
- uint32_t dwMid;
- do {
- iMid = (iStart + iEnd) / 2;
- dwMid = g_FDE_CSSColors[iMid].dwHash;
- if (dwHash == dwMid) {
- return g_FDE_CSSColors + iMid;
- } else if (dwHash > dwMid) {
- iStart = iMid + 1;
- } else {
- iEnd = iMid - 1;
- }
- } while (iStart <= iEnd);
- return nullptr;
-}
diff --git a/xfa/fde/css/fde_cssdatatable.h b/xfa/fde/css/fde_cssdatatable.h
deleted file mode 100644
index d1745f5d50..0000000000
--- a/xfa/fde/css/fde_cssdatatable.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2014 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_FDE_CSSDATATABLE_H_
-#define XFA_FDE_CSS_FDE_CSSDATATABLE_H_
-
-#include <memory>
-#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"
-
-#define FDE_IsOnlyValue(type, enum) \
- (((type) & ~(enum)) == FDE_CSSVALUETYPE_Primitive)
-
-struct FDE_CSSPropertyTable {
- FDE_CSSProperty eName;
- const wchar_t* pszName;
- uint32_t dwHash;
- uint32_t dwType;
-};
-
-struct FDE_CSSPropertyValueTable {
- FDE_CSSPropertyValue eName;
- const wchar_t* pszName;
- uint32_t dwHash;
-};
-
-struct FDE_CSSLengthUnitTable {
- uint16_t wHash;
- FDE_CSSNumberType wValue;
-};
-
-struct FDE_CSSCOLORTABLE {
- uint32_t dwHash;
- FX_ARGB dwValue;
-};
-
-const FDE_CSSPropertyTable* FDE_GetCSSPropertyByName(
- const CFX_WideStringC& wsName);
-const FDE_CSSPropertyTable* FDE_GetCSSPropertyByEnum(FDE_CSSProperty eName);
-
-const FDE_CSSPropertyValueTable* FDE_GetCSSPropertyValueByName(
- const CFX_WideStringC& wsName);
-
-const FDE_CSSLengthUnitTable* FDE_GetCSSLengthUnitByName(
- const CFX_WideStringC& wsName);
-
-const FDE_CSSCOLORTABLE* FDE_GetCSSColorByName(const CFX_WideStringC& wsName);
-
-#endif // XFA_FDE_CSS_FDE_CSSDATATABLE_H_