From 9f0e85ac36826e39a242f8039c2b2c333ee99f4f Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 8 Aug 2017 13:23:24 -0400 Subject: Move CSS code to core The xfa/fde/css code has no other links into xfa/. This CL moves the css code to core/fxcrt/css and sets to only build when pdf_enable_xfa is enabled. Change-Id: Iefd208e1f83a28b80b567c574e841e87bce310be Reviewed-on: https://pdfium-review.googlesource.com/9251 Commit-Queue: dsinclair Reviewed-by: Tom Sepez --- xfa/fde/css/cfde_csscolorvalue.cpp | 12 - xfa/fde/css/cfde_csscolorvalue.h | 23 - xfa/fde/css/cfde_csscomputedstyle.cpp | 195 ------- xfa/fde/css/cfde_csscomputedstyle.h | 111 ---- xfa/fde/css/cfde_csscustomproperty.cpp | 15 - xfa/fde/css/cfde_csscustomproperty.h | 27 - xfa/fde/css/cfde_cssdeclaration.cpp | 639 ----------------------- xfa/fde/css/cfde_cssdeclaration.h | 93 ---- xfa/fde/css/cfde_cssdeclaration_unittest.cpp | 62 --- xfa/fde/css/cfde_cssenumvalue.cpp | 12 - xfa/fde/css/cfde_cssenumvalue.h | 23 - xfa/fde/css/cfde_cssexttextbuf.cpp | 17 - xfa/fde/css/cfde_cssexttextbuf.h | 34 -- xfa/fde/css/cfde_cssnumbervalue.cpp | 39 -- xfa/fde/css/cfde_cssnumbervalue.h | 41 -- xfa/fde/css/cfde_csspropertyholder.cpp | 11 - xfa/fde/css/cfde_csspropertyholder.h | 24 - xfa/fde/css/cfde_cssrulecollection.cpp | 56 -- xfa/fde/css/cfde_cssrulecollection.h | 49 -- xfa/fde/css/cfde_cssselector.cpp | 87 --- xfa/fde/css/cfde_cssselector.h | 43 -- xfa/fde/css/cfde_cssstringvalue.cpp | 12 - xfa/fde/css/cfde_cssstringvalue.h | 23 - xfa/fde/css/cfde_cssstylerule.cpp | 30 -- xfa/fde/css/cfde_cssstylerule.h | 32 -- xfa/fde/css/cfde_cssstyleselector.cpp | 599 --------------------- xfa/fde/css/cfde_cssstyleselector.h | 85 --- xfa/fde/css/cfde_cssstylesheet.cpp | 140 ----- xfa/fde/css/cfde_cssstylesheet.h | 40 -- xfa/fde/css/cfde_cssstylesheet_unittest.cpp | 239 --------- xfa/fde/css/cfde_csssyntaxparser.cpp | 228 -------- xfa/fde/css/cfde_csssyntaxparser.h | 75 --- xfa/fde/css/cfde_csstextbuf.cpp | 49 -- xfa/fde/css/cfde_csstextbuf.h | 35 -- xfa/fde/css/cfde_cssvalue.cpp | 9 - xfa/fde/css/cfde_cssvalue.h | 23 - xfa/fde/css/cfde_cssvaluelist.cpp | 25 - xfa/fde/css/cfde_cssvaluelist.h | 26 - xfa/fde/css/cfde_cssvaluelistparser.cpp | 87 --- xfa/fde/css/cfde_cssvaluelistparser.h | 30 -- xfa/fde/css/cfde_cssvaluelistparser_unittest.cpp | 143 ----- xfa/fde/css/fde_css.h | 242 --------- xfa/fde/css/fde_cssdatatable.cpp | 285 ---------- xfa/fde/css/fde_cssdatatable.h | 56 -- xfa/fxfa/cxfa_loadercontext.h | 4 +- xfa/fxfa/cxfa_textlayout.cpp | 76 +-- xfa/fxfa/cxfa_textlayout.h | 14 +- xfa/fxfa/cxfa_textparsecontext.cpp | 8 +- xfa/fxfa/cxfa_textparsecontext.h | 20 +- xfa/fxfa/cxfa_textparser.cpp | 108 ++-- xfa/fxfa/cxfa_textparser.h | 49 +- xfa/fxfa/cxfa_textuserdata.cpp | 10 +- xfa/fxfa/cxfa_textuserdata.h | 9 +- 53 files changed, 148 insertions(+), 4276 deletions(-) delete mode 100644 xfa/fde/css/cfde_csscolorvalue.cpp delete mode 100644 xfa/fde/css/cfde_csscolorvalue.h delete mode 100644 xfa/fde/css/cfde_csscomputedstyle.cpp delete mode 100644 xfa/fde/css/cfde_csscomputedstyle.h delete mode 100644 xfa/fde/css/cfde_csscustomproperty.cpp delete mode 100644 xfa/fde/css/cfde_csscustomproperty.h delete mode 100644 xfa/fde/css/cfde_cssdeclaration.cpp delete mode 100644 xfa/fde/css/cfde_cssdeclaration.h delete mode 100644 xfa/fde/css/cfde_cssdeclaration_unittest.cpp delete mode 100644 xfa/fde/css/cfde_cssenumvalue.cpp delete mode 100644 xfa/fde/css/cfde_cssenumvalue.h delete mode 100644 xfa/fde/css/cfde_cssexttextbuf.cpp delete mode 100644 xfa/fde/css/cfde_cssexttextbuf.h delete mode 100644 xfa/fde/css/cfde_cssnumbervalue.cpp delete mode 100644 xfa/fde/css/cfde_cssnumbervalue.h delete mode 100644 xfa/fde/css/cfde_csspropertyholder.cpp delete mode 100644 xfa/fde/css/cfde_csspropertyholder.h delete mode 100644 xfa/fde/css/cfde_cssrulecollection.cpp delete mode 100644 xfa/fde/css/cfde_cssrulecollection.h delete mode 100644 xfa/fde/css/cfde_cssselector.cpp delete mode 100644 xfa/fde/css/cfde_cssselector.h delete mode 100644 xfa/fde/css/cfde_cssstringvalue.cpp delete mode 100644 xfa/fde/css/cfde_cssstringvalue.h delete mode 100644 xfa/fde/css/cfde_cssstylerule.cpp delete mode 100644 xfa/fde/css/cfde_cssstylerule.h delete mode 100644 xfa/fde/css/cfde_cssstyleselector.cpp delete mode 100644 xfa/fde/css/cfde_cssstyleselector.h delete mode 100644 xfa/fde/css/cfde_cssstylesheet.cpp delete mode 100644 xfa/fde/css/cfde_cssstylesheet.h delete mode 100644 xfa/fde/css/cfde_cssstylesheet_unittest.cpp delete mode 100644 xfa/fde/css/cfde_csssyntaxparser.cpp delete mode 100644 xfa/fde/css/cfde_csssyntaxparser.h delete mode 100644 xfa/fde/css/cfde_csstextbuf.cpp delete mode 100644 xfa/fde/css/cfde_csstextbuf.h delete mode 100644 xfa/fde/css/cfde_cssvalue.cpp delete mode 100644 xfa/fde/css/cfde_cssvalue.h delete mode 100644 xfa/fde/css/cfde_cssvaluelist.cpp delete mode 100644 xfa/fde/css/cfde_cssvaluelist.h delete mode 100644 xfa/fde/css/cfde_cssvaluelistparser.cpp delete mode 100644 xfa/fde/css/cfde_cssvaluelistparser.h delete mode 100644 xfa/fde/css/cfde_cssvaluelistparser_unittest.cpp delete mode 100644 xfa/fde/css/fde_css.h delete mode 100644 xfa/fde/css/fde_cssdatatable.cpp delete mode 100644 xfa/fde/css/fde_cssdatatable.h (limited to 'xfa') 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() - ->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 - -#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 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 - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); - - CFDE_CSSComputedStyle(); - ~CFDE_CSSComputedStyle() override; - - std::vector 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_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 pValue, - bool bImportant) { - auto pHolder = pdfium::MakeUnique(); - 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 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 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(prop, value)); -} - -CFX_RetainPtr 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(eUnit, fValue); -} - -CFX_RetainPtr CFDE_CSSDeclaration::ParseEnum( - const wchar_t* pszValue, - int32_t iValueLen) { - const FDE_CSSPropertyValueTable* pValue = - FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen)); - return pValue ? pdfium::MakeRetain(pValue->eName) - : nullptr; -} - -CFX_RetainPtr CFDE_CSSDeclaration::ParseColor( - const wchar_t* pszValue, - int32_t iValueLen) { - FX_ARGB dwColor; - if (!ParseCSSColor(pszValue, iValueLen, &dwColor)) - return nullptr; - return pdfium::MakeRetain(dwColor); -} - -CFX_RetainPtr 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( - 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> 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(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(dwColor)); - continue; - } - } - if (dwType & FDE_CSSVALUETYPE_MaybeEnum) { - const FDE_CSSPropertyValueTable* pValue = - FDE_GetCSSPropertyValueByName( - CFX_WideStringC(pszValue, iValueLen)); - if (pValue) { - list.push_back( - pdfium::MakeRetain(pValue->eName)); - continue; - } - } - if (dwType & FDE_CSSVALUETYPE_MaybeString) { - list.push_back(pdfium::MakeRetain( - 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(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(list); - AddPropertyHolder(pTable->eName, pList, bImportant); - return; - } - } -} - -void CFDE_CSSDeclaration::Add4ValuesProperty( - const std::vector>& 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& 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(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(pValue->eName); - break; - default: - break; - } - break; - } - default: - break; - } - } - if (!pWidth) - pWidth = pdfium::MakeRetain(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 pStyle; - CFX_RetainPtr pVariant; - CFX_RetainPtr pWeight; - CFX_RetainPtr pFontSize; - CFX_RetainPtr pLineHeight; - std::vector> 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(pValue->eName); - continue; - case FDE_CSSPropertyValue::Bold: - case FDE_CSSPropertyValue::Bolder: - case FDE_CSSPropertyValue::Lighter: - if (!pWeight) - pWeight = pdfium::MakeRetain(pValue->eName); - continue; - case FDE_CSSPropertyValue::Italic: - case FDE_CSSPropertyValue::Oblique: - if (!pStyle) - pStyle = pdfium::MakeRetain(pValue->eName); - continue; - case FDE_CSSPropertyValue::SmallCaps: - if (!pVariant) - pVariant = pdfium::MakeRetain(pValue->eName); - continue; - case FDE_CSSPropertyValue::Normal: - if (!pStyle) - pStyle = pdfium::MakeRetain(pValue->eName); - else if (!pVariant) - pVariant = pdfium::MakeRetain(pValue->eName); - else if (!pWeight) - pWeight = pdfium::MakeRetain(pValue->eName); - else if (!pFontSize) - pFontSize = - pdfium::MakeRetain(pValue->eName); - else if (!pLineHeight) - pLineHeight = - pdfium::MakeRetain(pValue->eName); - continue; - default: - break; - } - } - if (pFontSize) { - familyList.push_back(pdfium::MakeRetain( - 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( - FDE_CSSNumberType::Number, fValue); - continue; - } - } - if (!pFontSize) - pFontSize = pdfium::MakeRetain(eNumType, fValue); - else if (!pLineHeight) - pLineHeight = - pdfium::MakeRetain(eNumType, fValue); - break; - } - default: - break; - } - } - - if (!pStyle) { - pStyle = - pdfium::MakeRetain(FDE_CSSPropertyValue::Normal); - } - if (!pVariant) { - pVariant = - pdfium::MakeRetain(FDE_CSSPropertyValue::Normal); - } - if (!pWeight) { - pWeight = - pdfium::MakeRetain(FDE_CSSPropertyValue::Normal); - } - if (!pFontSize) { - pFontSize = - pdfium::MakeRetain(FDE_CSSPropertyValue::Medium); - } - if (!pLineHeight) { - pLineHeight = - pdfium::MakeRetain(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(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 -#include -#include - -#include "xfa/fde/css/fde_cssdatatable.h" - -class CFDE_CSSPropertyHolder; -class CFDE_CSSCustomProperty; - -class CFDE_CSSDeclaration { - public: - using const_prop_iterator = - std::vector>::const_iterator; - using const_custom_iterator = - std::vector>::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 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& pWidth) const; - void ParseValueListProperty(const FDE_CSSPropertyTable* pTable, - const wchar_t* pszValue, - int32_t iValueLen, - bool bImportant); - void Add4ValuesProperty(const std::vector>& list, - bool bImportant, - FDE_CSSProperty eLeft, - FDE_CSSProperty eTop, - FDE_CSSProperty eRight, - FDE_CSSProperty eBottom); - CFX_RetainPtr ParseNumber(const wchar_t* pszValue, - int32_t iValueLen); - CFX_RetainPtr ParseEnum(const wchar_t* pszValue, - int32_t iValueLen); - CFX_RetainPtr ParseColor(const wchar_t* pszValue, - int32_t iValueLen); - CFX_RetainPtr ParseString(const wchar_t* pszValue, - int32_t iValueLen); - void AddPropertyHolder(FDE_CSSProperty eProperty, - CFX_RetainPtr pValue, - bool bImportant); - - std::vector> properties_; - std::vector> 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 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 -#include - -#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>* -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(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 -#include -#include - -#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>* GetTagRuleData( - const CFX_WideString& tagname) const; - - private: - void AddRulesFrom(const CFDE_CSSStyleSheet* pStyleSheet, - CFDE_CSSStyleRule* pRule); - - std::map>> 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 - -#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::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 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( - 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 -#include - -#include "core/fxcrt/fx_string.h" -#include "xfa/fde/css/fde_css.h" - -class CFDE_CSSSelector { - public: - static std::unique_ptr 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 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 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>* 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 -#include - -#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>* list); - - private: - CFDE_CSSDeclaration m_Declaration; - std::vector> 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 -#include - -#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_CSSStyleSelector::CreateComputedStyle( - CFDE_CSSComputedStyle* pParentStyle) { - auto pStyle = pdfium::MakeRetain(); - if (pParentStyle) - pStyle->m_InheritedData = pParentStyle->m_InheritedData; - return pStyle; -} - -void CFDE_CSSStyleSelector::SetUAStyleSheet( - std::unique_ptr pSheet) { - m_UAStyles = std::move(pSheet); -} - -void CFDE_CSSStyleSelector::UpdateStyleIndex() { - m_UARules.Clear(); - m_UARules.AddRulesFrom(m_UAStyles.get()); -} - -std::vector -CFDE_CSSStyleSelector::MatchDeclarations(const CFX_WideString& tagname) { - std::vector 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& declArray, - const CFX_WideString& styleString, - const CFX_WideString& alignString, - CFDE_CSSComputedStyle* pDest) { - std::unique_ptr pDecl; - if (!styleString.IsEmpty() || !alignString.IsEmpty()) { - pDecl = pdfium::MakeUnique(); - - 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& declArray, - const CFDE_CSSDeclaration* extraDecl, - CFDE_CSSComputedStyle* pComputedStyle) { - std::vector importants; - std::vector normals; - std::vector 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* importants, - std::vector* normals, - std::vector* 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( - 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& 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()->Value()); - } - break; - case FDE_CSSProperty::FontSize: { - float& fFontSize = pComputedStyle->m_InheritedData.m_fFontSize; - if (eType == FDE_CSSPrimitiveType::Number) { - fFontSize = pValue.As()->Apply(fFontSize); - } else if (eType == FDE_CSSPrimitiveType::Enum) { - fFontSize = - ToFontSize(pValue.As()->Value(), fFontSize); - } - } break; - case FDE_CSSProperty::LineHeight: - if (eType == FDE_CSSPrimitiveType::Number) { - CFX_RetainPtr v = - pValue.As(); - 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()->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()->Value()); - } else if (eType == FDE_CSSPrimitiveType::Number) { - int32_t iValue = - (int32_t)pValue.As()->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()->Value()); - } - break; - case FDE_CSSProperty::Color: - if (eType == FDE_CSSPrimitiveType::RGB) { - pComputedStyle->m_InheritedData.m_dwFontColor = - pValue.As()->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()->Value()); - } else if (eType == FDE_CSSPrimitiveType::Number) { - pComputedStyle->m_NonInheritedData.m_eVerticalAlign = - FDE_CSSVerticalAlign::Number; - pComputedStyle->m_NonInheritedData.m_fVerticalAlign = - pValue.As()->Apply( - pComputedStyle->m_InheritedData.m_fFontSize); - } - break; - case FDE_CSSProperty::FontVariant: - if (eType == FDE_CSSPrimitiveType::Enum) { - pComputedStyle->m_InheritedData.m_eFontVariant = - ToFontVariant(pValue.As()->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()->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()->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 pList = pValue.As(); - 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& pValue, - float fFontSize) { - if (eType == FDE_CSSPrimitiveType::Number) { - CFX_RetainPtr v = pValue.As(); - if (v->Kind() == FDE_CSSNumberType::Percent) { - width.Set(FDE_CSSLengthUnit::Percent, - pValue.As()->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()->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& pValue) { - uint32_t dwDecoration = 0; - for (int32_t i = pValue->CountValues() - 1; i >= 0; --i) { - const CFX_RetainPtr pVal = pValue->GetValue(i); - if (pVal->GetType() != FDE_CSSPrimitiveType::Enum) - continue; - - switch (pVal.As()->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 -#include - -#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 pSheet); - void UpdateStyleIndex(); - - CFX_RetainPtr 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& declArray, - const CFX_WideString& styleString, - const CFX_WideString& alignString, - CFDE_CSSComputedStyle* pDestStyle); - - std::vector 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& declArray, - const CFDE_CSSDeclaration* extraDecl, - CFDE_CSSComputedStyle* pDestStyle); - void ApplyProperty(FDE_CSSProperty eProperty, - const CFX_RetainPtr& pValue, - CFDE_CSSComputedStyle* pComputedStyle); - void ExtractValues(const CFDE_CSSDeclaration* decl, - std::vector* importants, - std::vector* normals, - std::vector* custom); - - bool SetLengthWithPercent(FDE_CSSLength& width, - FDE_CSSPrimitiveType eType, - const CFX_RetainPtr& 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& pList); - FDE_CSSFontVariant ToFontVariant(FDE_CSSPropertyValue eValue); - - float m_fDefFontSize; - std::unique_ptr 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 - -#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(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(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>* ruleArray) { - std::vector> 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(); - 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 -#include -#include - -#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>* ruleArray); - void SkipRuleSet(CFDE_CSSSyntaxParser* pSyntax); - - std::vector> m_RuleArray; - std::map 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 -#include - -#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(); - decl_ = nullptr; - } - - void TearDown() override { decl_ = nullptr; } - - void LoadAndVerifyDecl(const wchar_t* buf, - const std::vector& 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 v = decl_->GetProperty(prop, &important); - EXPECT_EQ(v->GetType(), FDE_CSSPrimitiveType::Number); - EXPECT_EQ(v.As()->Kind(), type); - EXPECT_EQ(v.As()->Value(), val); - } - - void VerifyEnum(FDE_CSSProperty prop, FDE_CSSPropertyValue val) { - ASSERT(decl_); - - bool important; - CFX_RetainPtr v = decl_->GetProperty(prop, &important); - EXPECT_EQ(v->GetType(), FDE_CSSPrimitiveType::Enum); - EXPECT_EQ(v.As()->Value(), val); - } - - void VerifyList(FDE_CSSProperty prop, - std::vector values) { - ASSERT(decl_); - - bool important; - CFX_RetainPtr list = - decl_->GetProperty(prop, &important).As(); - EXPECT_EQ(list->CountValues(), pdfium::CollectionSize(values)); - - for (size_t i = 0; i < values.size(); i++) { - CFX_RetainPtr val = list->GetValue(i); - EXPECT_EQ(val->GetType(), FDE_CSSPrimitiveType::Enum); - EXPECT_EQ(val.As()->Value(), values[i]); - } - } - - std::unique_ptr 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 - -#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 - -#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 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 - -#include "xfa/fde/css/fde_css.h" - -CFDE_CSSValueList::CFDE_CSSValueList( - std::vector>& 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_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 - -#include "xfa/fde/css/cfde_cssvalue.h" - -class CFDE_CSSValueList : public CFDE_CSSValue { - public: - explicit CFDE_CSSValueList(std::vector>& list); - ~CFDE_CSSValueList() override; - - int32_t CountValues() const; - CFX_RetainPtr GetValue(int32_t index) const; - - protected: - std::vector> 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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( - 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(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 - -#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(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(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(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 -#include - -#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_ diff --git a/xfa/fxfa/cxfa_loadercontext.h b/xfa/fxfa/cxfa_loadercontext.h index 5bf8ed3661..48077ff538 100644 --- a/xfa/fxfa/cxfa_loadercontext.h +++ b/xfa/fxfa/cxfa_loadercontext.h @@ -9,9 +9,9 @@ #include +#include "core/fxcrt/css/cfx_csscomputedstyle.h" #include "core/fxcrt/fx_basic.h" #include "core/fxcrt/fx_system.h" -#include "xfa/fde/css/cfde_csscomputedstyle.h" class CFX_XMLNode; class CXFA_Node; @@ -32,7 +32,7 @@ class CXFA_LoaderContext { uint32_t m_dwFlags; CFX_XMLNode* m_pXMLNode; CXFA_Node* m_pNode; - CFX_RetainPtr m_pParentStyle; + CFX_RetainPtr m_pParentStyle; std::vector m_lineHeights; std::vector m_BlocksHeight; }; diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp index 138587c2fc..125c73a11d 100644 --- a/xfa/fxfa/cxfa_textlayout.cpp +++ b/xfa/fxfa/cxfa_textlayout.cpp @@ -9,6 +9,8 @@ #include #include +#include "core/fxcrt/css/cfx_csscomputedstyle.h" +#include "core/fxcrt/css/cfx_cssstyleselector.h" #include "core/fxcrt/xml/cfx_xmlelement.h" #include "core/fxcrt/xml/cfx_xmlnode.h" #include "core/fxcrt/xml/cfx_xmltext.h" @@ -18,8 +20,6 @@ #include "xfa/fde/cfde_path.h" #include "xfa/fde/cfde_pen.h" #include "xfa/fde/cfde_renderdevice.h" -#include "xfa/fde/css/cfde_csscomputedstyle.h" -#include "xfa/fde/css/cfde_cssstyleselector.h" #include "xfa/fxfa/cxfa_linkuserdata.h" #include "xfa/fxfa/cxfa_loadercontext.h" #include "xfa/fxfa/cxfa_pieceline.h" @@ -155,30 +155,30 @@ void CXFA_TextLayout::InitBreak(float fLineWidth) { m_pBreak->SetLineBreakTolerance(fFontSize * 0.2f); } -void CXFA_TextLayout::InitBreak(CFDE_CSSComputedStyle* pStyle, - FDE_CSSDisplay eDisplay, +void CXFA_TextLayout::InitBreak(CFX_CSSComputedStyle* pStyle, + CFX_CSSDisplay eDisplay, float fLineWidth, CFX_XMLNode* pXMLNode, - CFDE_CSSComputedStyle* pParentStyle) { + CFX_CSSComputedStyle* pParentStyle) { if (!pStyle) { InitBreak(fLineWidth); return; } - if (eDisplay == FDE_CSSDisplay::Block || - eDisplay == FDE_CSSDisplay::ListItem) { + if (eDisplay == CFX_CSSDisplay::Block || + eDisplay == CFX_CSSDisplay::ListItem) { CFX_RTFLineAlignment iAlign = CFX_RTFLineAlignment::Left; switch (pStyle->GetTextAlign()) { - case FDE_CSSTextAlign::Right: + case CFX_CSSTextAlign::Right: iAlign = CFX_RTFLineAlignment::Right; break; - case FDE_CSSTextAlign::Center: + case CFX_CSSTextAlign::Center: iAlign = CFX_RTFLineAlignment::Center; break; - case FDE_CSSTextAlign::Justify: + case CFX_CSSTextAlign::Justify: iAlign = CFX_RTFLineAlignment::Justified; break; - case FDE_CSSTextAlign::JustifyAll: + case CFX_CSSTextAlign::JustifyAll: iAlign = CFX_RTFLineAlignment::Distributed; break; default: @@ -187,8 +187,8 @@ void CXFA_TextLayout::InitBreak(CFDE_CSSComputedStyle* pStyle, m_pBreak->SetAlignment(iAlign); float fStart = 0; - const FDE_CSSRect* pRect = pStyle->GetMarginWidth(); - const FDE_CSSRect* pPaddingRect = pStyle->GetPaddingWidth(); + const CFX_CSSRect* pRect = pStyle->GetMarginWidth(); + const CFX_CSSRect* pPaddingRect = pStyle->GetPaddingWidth(); if (pRect) { fStart = pRect->left.GetValue(); fLineWidth -= pRect->right.GetValue(); @@ -196,9 +196,9 @@ void CXFA_TextLayout::InitBreak(CFDE_CSSComputedStyle* pStyle, fStart += pPaddingRect->left.GetValue(); fLineWidth -= pPaddingRect->right.GetValue(); } - if (eDisplay == FDE_CSSDisplay::ListItem) { - const FDE_CSSRect* pParRect = pParentStyle->GetMarginWidth(); - const FDE_CSSRect* pParPaddingRect = pParentStyle->GetPaddingWidth(); + if (eDisplay == CFX_CSSDisplay::ListItem) { + const CFX_CSSRect* pParRect = pParentStyle->GetMarginWidth(); + const CFX_CSSRect* pParPaddingRect = pParentStyle->GetPaddingWidth(); if (pParRect) { fStart += pParRect->left.GetValue(); fLineWidth -= pParRect->right.GetValue(); @@ -207,11 +207,11 @@ void CXFA_TextLayout::InitBreak(CFDE_CSSComputedStyle* pStyle, fLineWidth -= pParPaddingRect->right.GetValue(); } } - FDE_CSSRect pNewRect; - pNewRect.left.Set(FDE_CSSLengthUnit::Point, fStart); - pNewRect.right.Set(FDE_CSSLengthUnit::Point, pRect->right.GetValue()); - pNewRect.top.Set(FDE_CSSLengthUnit::Point, pRect->top.GetValue()); - pNewRect.bottom.Set(FDE_CSSLengthUnit::Point, pRect->bottom.GetValue()); + CFX_CSSRect pNewRect; + pNewRect.left.Set(CFX_CSSLengthUnit::Point, fStart); + pNewRect.right.Set(CFX_CSSLengthUnit::Point, pRect->right.GetValue()); + pNewRect.top.Set(CFX_CSSLengthUnit::Point, pRect->top.GetValue()); + pNewRect.bottom.Set(CFX_CSSLengthUnit::Point, pRect->bottom.GetValue()); pStyle->SetMarginWidth(pNewRect); } } @@ -696,7 +696,7 @@ bool CXFA_TextLayout::LoadRichText( CFX_XMLNode* pXMLNode, const CFX_SizeF& szText, float& fLinePos, - const CFX_RetainPtr& pParentStyle, + const CFX_RetainPtr& pParentStyle, bool bSavePieces, CFX_RetainPtr pLinkData, bool bEndBreak, @@ -707,10 +707,10 @@ bool CXFA_TextLayout::LoadRichText( CXFA_TextParseContext* pContext = m_textParser.GetParseContextFromMap(pXMLNode); - FDE_CSSDisplay eDisplay = FDE_CSSDisplay::None; + CFX_CSSDisplay eDisplay = CFX_CSSDisplay::None; bool bContentNode = false; float fSpaceBelow = 0; - CFX_RetainPtr pStyle; + CFX_RetainPtr pStyle; CFX_WideString wsName; if (bEndBreak) { bool bCurOl = false; @@ -733,21 +733,21 @@ bool CXFA_TextLayout::LoadRichText( } if (m_bBlockContinue || bContentNode == false) { eDisplay = pContext->GetDisplay(); - if (eDisplay != FDE_CSSDisplay::Block && - eDisplay != FDE_CSSDisplay::Inline && - eDisplay != FDE_CSSDisplay::ListItem) { + if (eDisplay != CFX_CSSDisplay::Block && + eDisplay != CFX_CSSDisplay::Inline && + eDisplay != CFX_CSSDisplay::ListItem) { return true; } pStyle = m_textParser.ComputeStyle(pXMLNode, pParentStyle.Get()); InitBreak(bContentNode ? pParentStyle.Get() : pStyle.Get(), eDisplay, szText.width, pXMLNode, pParentStyle.Get()); - if ((eDisplay == FDE_CSSDisplay::Block || - eDisplay == FDE_CSSDisplay::ListItem) && + if ((eDisplay == CFX_CSSDisplay::Block || + eDisplay == CFX_CSSDisplay::ListItem) && pStyle && (wsName.IsEmpty() || (wsName != L"body" && wsName != L"html" && wsName != L"ol" && wsName != L"ul"))) { - const FDE_CSSRect* pRect = pStyle->GetMarginWidth(); + const CFX_CSSRect* pRect = pStyle->GetMarginWidth(); if (pRect) { fLinePos += pRect->top.GetValue(); fSpaceBelow = pRect->bottom.GetValue(); @@ -797,9 +797,9 @@ bool CXFA_TextLayout::LoadRichText( (m_pLoader->m_dwFlags & XFA_LOADERCNTXTFLG_FILTERSPACE)) { wsText.TrimLeft(0x20); } - if (FDE_CSSDisplay::Block == eDisplay) { + if (CFX_CSSDisplay::Block == eDisplay) { m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; - } else if (FDE_CSSDisplay::Inline == eDisplay && + } else if (CFX_CSSDisplay::Inline == eDisplay && (m_pLoader->m_dwFlags & XFA_LOADERCNTXTFLG_FILTERSPACE)) { m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; } else if (wsText.GetLength() > 0 && @@ -847,7 +847,7 @@ bool CXFA_TextLayout::LoadRichText( } if (m_pLoader) { - if (FDE_CSSDisplay::Block == eDisplay) + if (CFX_CSSDisplay::Block == eDisplay) m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; } if (bCurLi) @@ -859,11 +859,11 @@ bool CXFA_TextLayout::LoadRichText( if (m_bBlockContinue) { if (pContext && !bContentNode) { - CFX_BreakType dwStatus = (eDisplay == FDE_CSSDisplay::Block) + CFX_BreakType dwStatus = (eDisplay == CFX_CSSDisplay::Block) ? CFX_BreakType::Paragraph : CFX_BreakType::Piece; EndBreak(dwStatus, fLinePos, bSavePieces); - if (eDisplay == FDE_CSSDisplay::Block) { + if (eDisplay == CFX_CSSDisplay::Block) { fLinePos += fSpaceBelow; if (m_pTabstopContext) m_pTabstopContext->RemoveAll(); @@ -952,7 +952,7 @@ void CXFA_TextLayout::EndBreak(CFX_BreakType dwStatus, AppendTextLine(dwStatus, fLinePos, bSavePieces, true); } -void CXFA_TextLayout::DoTabstops(CFDE_CSSComputedStyle* pStyle, +void CXFA_TextLayout::DoTabstops(CFX_CSSComputedStyle* pStyle, CXFA_PieceLine* pPieceLine) { if (!pStyle || !pPieceLine) return; @@ -1015,7 +1015,7 @@ void CXFA_TextLayout::AppendTextLine(CFX_BreakType dwStatus, if (iPieces < 1) return; - CFX_RetainPtr pStyle; + CFX_RetainPtr pStyle; if (bSavePieces) { auto pNew = pdfium::MakeUnique(); CXFA_PieceLine* pPieceLine = pNew.get(); @@ -1130,7 +1130,7 @@ void CXFA_TextLayout::AppendTextLine(CFX_BreakType dwStatus, if (pStyle) { float fStart = 0; - const FDE_CSSRect* pRect = pStyle->GetMarginWidth(); + const CFX_CSSRect* pRect = pStyle->GetMarginWidth(); if (pRect) fStart = pRect->left.GetValue(); diff --git a/xfa/fxfa/cxfa_textlayout.h b/xfa/fxfa/cxfa_textlayout.h index 079fff8fe2..642fa25dd9 100644 --- a/xfa/fxfa/cxfa_textlayout.h +++ b/xfa/fxfa/cxfa_textlayout.h @@ -10,15 +10,15 @@ #include #include +#include "core/fxcrt/css/cfx_css.h" #include "core/fxcrt/fx_basic.h" #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_string.h" -#include "xfa/fde/css/fde_css.h" #include "xfa/fgas/layout/cfx_rtfbreak.h" #include "xfa/fxfa/cxfa_textparser.h" class CFDE_Brush; -class CFDE_CSSComputedStyle; +class CFX_CSSComputedStyle; class CFDE_Pen; class CFDE_RenderDevice; class CFX_XMLNode; @@ -67,11 +67,11 @@ class CXFA_TextLayout { CFX_XMLNode* GetXMLContainerNode(); std::unique_ptr CreateBreak(bool bDefault); void InitBreak(float fLineWidth); - void InitBreak(CFDE_CSSComputedStyle* pStyle, - FDE_CSSDisplay eDisplay, + void InitBreak(CFX_CSSComputedStyle* pStyle, + CFX_CSSDisplay eDisplay, float fLineWidth, CFX_XMLNode* pXMLNode, - CFDE_CSSComputedStyle* pParentStyle = nullptr); + CFX_CSSComputedStyle* pParentStyle = nullptr); bool Loader(const CFX_SizeF& szText, float& fLinePos, bool bSavePieces = true); @@ -82,7 +82,7 @@ class CXFA_TextLayout { bool LoadRichText(CFX_XMLNode* pXMLNode, const CFX_SizeF& szText, float& fLinePos, - const CFX_RetainPtr& pParentStyle, + const CFX_RetainPtr& pParentStyle, bool bSavePieces, CFX_RetainPtr pLinkData, bool bEndBreak = true, @@ -116,7 +116,7 @@ class CXFA_TextLayout { FXTEXT_CHARPOS* pCharPos, bool bCharCode = false); bool ToRun(const CXFA_TextPiece* pPiece, FX_RTFTEXTOBJ* tr); - void DoTabstops(CFDE_CSSComputedStyle* pStyle, CXFA_PieceLine* pPieceLine); + void DoTabstops(CFX_CSSComputedStyle* pStyle, CXFA_PieceLine* pPieceLine); bool Layout(int32_t iBlock); int32_t CountBlocks() const; diff --git a/xfa/fxfa/cxfa_textparsecontext.cpp b/xfa/fxfa/cxfa_textparsecontext.cpp index 7231f388e2..bd21afc864 100644 --- a/xfa/fxfa/cxfa_textparsecontext.cpp +++ b/xfa/fxfa/cxfa_textparsecontext.cpp @@ -6,11 +6,11 @@ #include "xfa/fxfa/cxfa_textparsecontext.h" -#include "xfa/fde/css/cfde_csscomputedstyle.h" -#include "xfa/fde/css/cfde_cssdeclaration.h" -#include "xfa/fde/css/cfde_cssstyleselector.h" +#include "core/fxcrt/css/cfx_csscomputedstyle.h" +#include "core/fxcrt/css/cfx_cssdeclaration.h" +#include "core/fxcrt/css/cfx_cssstyleselector.h" CXFA_TextParseContext::CXFA_TextParseContext() - : m_pParentStyle(nullptr), m_eDisplay(FDE_CSSDisplay::None) {} + : m_pParentStyle(nullptr), m_eDisplay(CFX_CSSDisplay::None) {} CXFA_TextParseContext::~CXFA_TextParseContext() {} diff --git a/xfa/fxfa/cxfa_textparsecontext.h b/xfa/fxfa/cxfa_textparsecontext.h index c3236570e5..3cd5710728 100644 --- a/xfa/fxfa/cxfa_textparsecontext.h +++ b/xfa/fxfa/cxfa_textparsecontext.h @@ -10,30 +10,30 @@ #include #include +#include "core/fxcrt/css/cfx_css.h" +#include "core/fxcrt/css/cfx_cssdeclaration.h" #include "third_party/base/stl_util.h" -#include "xfa/fde/css/cfde_cssdeclaration.h" -#include "xfa/fde/css/fde_css.h" -class CFDE_CSSComputedStyle; +class CFX_CSSComputedStyle; class CXFA_TextParseContext { public: CXFA_TextParseContext(); ~CXFA_TextParseContext(); - void SetDisplay(FDE_CSSDisplay eDisplay) { m_eDisplay = eDisplay; } - FDE_CSSDisplay GetDisplay() const { return m_eDisplay; } + void SetDisplay(CFX_CSSDisplay eDisplay) { m_eDisplay = eDisplay; } + CFX_CSSDisplay GetDisplay() const { return m_eDisplay; } - void SetDecls(std::vector&& decl) { + void SetDecls(std::vector&& decl) { decls_ = std::move(decl); } - const std::vector& GetDecls() { return decls_; } + const std::vector& GetDecls() { return decls_; } - CFX_RetainPtr m_pParentStyle; + CFX_RetainPtr m_pParentStyle; private: - std::vector decls_; - FDE_CSSDisplay m_eDisplay; + std::vector decls_; + CFX_CSSDisplay m_eDisplay; }; #endif // XFA_FXFA_CXFA_TEXTPARSECONTEXT_H_ diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp index de5490a766..7e16202b16 100644 --- a/xfa/fxfa/cxfa_textparser.cpp +++ b/xfa/fxfa/cxfa_textparser.cpp @@ -10,14 +10,14 @@ #include #include +#include "core/fxcrt/css/cfx_css.h" +#include "core/fxcrt/css/cfx_csscomputedstyle.h" +#include "core/fxcrt/css/cfx_cssstyleselector.h" +#include "core/fxcrt/css/cfx_cssstylesheet.h" #include "core/fxcrt/fx_codepage.h" #include "core/fxcrt/xml/cfx_xmlelement.h" #include "core/fxcrt/xml/cfx_xmlnode.h" #include "third_party/base/ptr_util.h" -#include "xfa/fde/css/cfde_csscomputedstyle.h" -#include "xfa/fde/css/cfde_cssstyleselector.h" -#include "xfa/fde/css/cfde_cssstylesheet.h" -#include "xfa/fde/css/fde_css.h" #include "xfa/fgas/font/cfgas_fontmgr.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffdoc.h" @@ -56,7 +56,7 @@ void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) { return; if (!m_pSelector) { - m_pSelector = pdfium::MakeUnique(); + m_pSelector = pdfium::MakeUnique(); CXFA_Font font = pTextProvider->GetFontNode(); m_pSelector->SetDefFontSize(font ? font.GetFontSize() : 10.0f); @@ -71,7 +71,7 @@ void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) { m_pSelector->UpdateStyleIndex(); } -std::unique_ptr CXFA_TextParser::LoadDefaultSheetStyle() { +std::unique_ptr CXFA_TextParser::LoadDefaultSheetStyle() { static const wchar_t s_pStyle[] = L"html,body,ol,p,ul{display:block}" L"li{display:list-item}" @@ -83,12 +83,12 @@ std::unique_ptr CXFA_TextParser::LoadDefaultSheetStyle() { L"sup{vertical-align:+15em;font-size:.66em}" L"sub{vertical-align:-15em;font-size:.66em}"; - auto sheet = pdfium::MakeUnique(); + auto sheet = pdfium::MakeUnique(); return sheet->LoadBuffer(s_pStyle, FXSYS_wcslen(s_pStyle)) ? std::move(sheet) : nullptr; } -CFX_RetainPtr CXFA_TextParser::CreateRootStyle( +CFX_RetainPtr CXFA_TextParser::CreateRootStyle( CXFA_TextProvider* pTextProvider) { CXFA_Font font = pTextProvider->GetFontNode(); CXFA_Para para = pTextProvider->GetParaNode(); @@ -98,50 +98,50 @@ CFX_RetainPtr CXFA_TextParser::CreateRootStyle( if (para) { fLineHeight = para.GetLineHeight(); - FDE_CSSLength indent; - indent.Set(FDE_CSSLengthUnit::Point, para.GetTextIndent()); + CFX_CSSLength indent; + indent.Set(CFX_CSSLengthUnit::Point, para.GetTextIndent()); pStyle->SetTextIndent(indent); - FDE_CSSTextAlign hAlign = FDE_CSSTextAlign::Left; + CFX_CSSTextAlign hAlign = CFX_CSSTextAlign::Left; switch (para.GetHorizontalAlign()) { case XFA_ATTRIBUTEENUM_Center: - hAlign = FDE_CSSTextAlign::Center; + hAlign = CFX_CSSTextAlign::Center; break; case XFA_ATTRIBUTEENUM_Right: - hAlign = FDE_CSSTextAlign::Right; + hAlign = CFX_CSSTextAlign::Right; break; case XFA_ATTRIBUTEENUM_Justify: - hAlign = FDE_CSSTextAlign::Justify; + hAlign = CFX_CSSTextAlign::Justify; break; case XFA_ATTRIBUTEENUM_JustifyAll: - hAlign = FDE_CSSTextAlign::JustifyAll; + hAlign = CFX_CSSTextAlign::JustifyAll; break; } pStyle->SetTextAlign(hAlign); - FDE_CSSRect rtMarginWidth; - rtMarginWidth.left.Set(FDE_CSSLengthUnit::Point, para.GetMarginLeft()); - rtMarginWidth.top.Set(FDE_CSSLengthUnit::Point, para.GetSpaceAbove()); - rtMarginWidth.right.Set(FDE_CSSLengthUnit::Point, para.GetMarginRight()); - rtMarginWidth.bottom.Set(FDE_CSSLengthUnit::Point, para.GetSpaceBelow()); + CFX_CSSRect rtMarginWidth; + rtMarginWidth.left.Set(CFX_CSSLengthUnit::Point, para.GetMarginLeft()); + rtMarginWidth.top.Set(CFX_CSSLengthUnit::Point, para.GetSpaceAbove()); + rtMarginWidth.right.Set(CFX_CSSLengthUnit::Point, para.GetMarginRight()); + rtMarginWidth.bottom.Set(CFX_CSSLengthUnit::Point, para.GetSpaceBelow()); pStyle->SetMarginWidth(rtMarginWidth); } if (font) { pStyle->SetColor(font.GetColor()); - pStyle->SetFontStyle(font.IsItalic() ? FDE_CSSFontStyle::Italic - : FDE_CSSFontStyle::Normal); + pStyle->SetFontStyle(font.IsItalic() ? CFX_CSSFontStyle::Italic + : CFX_CSSFontStyle::Normal); pStyle->SetFontWeight(font.IsBold() ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL); pStyle->SetNumberVerticalAlign(-font.GetBaselineShift()); fFontSize = font.GetFontSize(); - FDE_CSSLength letterSpacing; - letterSpacing.Set(FDE_CSSLengthUnit::Point, font.GetLetterSpacing()); + CFX_CSSLength letterSpacing; + letterSpacing.Set(CFX_CSSLengthUnit::Point, font.GetLetterSpacing()); pStyle->SetLetterSpacing(letterSpacing); uint32_t dwDecoration = 0; if (font.GetLineThrough() > 0) - dwDecoration |= FDE_CSSTEXTDECORATION_LineThrough; + dwDecoration |= CFX_CSSTEXTDECORATION_LineThrough; if (font.GetUnderline() > 1) - dwDecoration |= FDE_CSSTEXTDECORATION_Double; + dwDecoration |= CFX_CSSTEXTDECORATION_Double; else if (font.GetUnderline() > 0) - dwDecoration |= FDE_CSSTEXTDECORATION_Underline; + dwDecoration |= CFX_CSSTEXTDECORATION_Underline; pStyle->SetTextDecoration(dwDecoration); } @@ -150,8 +150,8 @@ CFX_RetainPtr CXFA_TextParser::CreateRootStyle( return pStyle; } -CFX_RetainPtr CXFA_TextParser::CreateStyle( - CFDE_CSSComputedStyle* pParentStyle) { +CFX_RetainPtr CXFA_TextParser::CreateStyle( + CFX_CSSComputedStyle* pParentStyle) { auto pNewStyle = m_pSelector->CreateComputedStyle(pParentStyle); ASSERT(pNewStyle); if (!pParentStyle) @@ -159,21 +159,21 @@ CFX_RetainPtr CXFA_TextParser::CreateStyle( uint32_t dwDecoration = pParentStyle->GetTextDecoration(); float fBaseLine = 0; - if (pParentStyle->GetVerticalAlign() == FDE_CSSVerticalAlign::Number) + if (pParentStyle->GetVerticalAlign() == CFX_CSSVerticalAlign::Number) fBaseLine = pParentStyle->GetNumberVerticalAlign(); pNewStyle->SetTextDecoration(dwDecoration); pNewStyle->SetNumberVerticalAlign(fBaseLine); - const FDE_CSSRect* pRect = pParentStyle->GetMarginWidth(); + const CFX_CSSRect* pRect = pParentStyle->GetMarginWidth(); if (pRect) pNewStyle->SetMarginWidth(*pRect); return pNewStyle; } -CFX_RetainPtr CXFA_TextParser::ComputeStyle( +CFX_RetainPtr CXFA_TextParser::ComputeStyle( CFX_XMLNode* pXMLNode, - CFDE_CSSComputedStyle* pParentStyle) { + CFX_CSSComputedStyle* pParentStyle) { auto it = m_mapXMLNodeToParseContext.find(pXMLNode); if (it == m_mapXMLNodeToParseContext.end()) return nullptr; @@ -207,7 +207,7 @@ void CXFA_TextParser::DoParse(CFX_XMLNode* pXMLContainer, } void CXFA_TextParser::ParseRichText(CFX_XMLNode* pXMLNode, - CFDE_CSSComputedStyle* pParentStyle) { + CFX_CSSComputedStyle* pParentStyle) { if (!pXMLNode) return; @@ -215,11 +215,11 @@ void CXFA_TextParser::ParseRichText(CFX_XMLNode* pXMLNode, if (!tagProvider->m_bTagAvailable) return; - CFX_RetainPtr pNewStyle; + CFX_RetainPtr pNewStyle; if ((tagProvider->GetTagName() != L"body") || (tagProvider->GetTagName() != L"html")) { auto pTextContext = pdfium::MakeUnique(); - FDE_CSSDisplay eDisplay = FDE_CSSDisplay::Inline; + CFX_CSSDisplay eDisplay = CFX_CSSDisplay::Inline; if (!tagProvider->m_bContent) { auto declArray = m_pSelector->MatchDeclarations(tagProvider->GetTagName()); @@ -292,21 +292,21 @@ int32_t CXFA_TextParser::GetVAlign(CXFA_TextProvider* pTextProvider) const { return para ? para.GetVerticalAlign() : XFA_ATTRIBUTEENUM_Top; } -float CXFA_TextParser::GetTabInterval(CFDE_CSSComputedStyle* pStyle) const { +float CXFA_TextParser::GetTabInterval(CFX_CSSComputedStyle* pStyle) const { CFX_WideString wsValue; if (pStyle && pStyle->GetCustomStyle(L"tab-interval", wsValue)) return CXFA_Measurement(wsValue.AsStringC()).ToUnit(XFA_UNIT_Pt); return 36; } -int32_t CXFA_TextParser::CountTabs(CFDE_CSSComputedStyle* pStyle) const { +int32_t CXFA_TextParser::CountTabs(CFX_CSSComputedStyle* pStyle) const { CFX_WideString wsValue; if (pStyle && pStyle->GetCustomStyle(L"xfa-tab-count", wsValue)) return wsValue.GetInteger(); return 0; } -bool CXFA_TextParser::IsSpaceRun(CFDE_CSSComputedStyle* pStyle) const { +bool CXFA_TextParser::IsSpaceRun(CFX_CSSComputedStyle* pStyle) const { CFX_WideString wsValue; if (pStyle && pStyle->GetCustomStyle(L"xfa-spacerun", wsValue)) { wsValue.MakeLower(); @@ -317,7 +317,7 @@ bool CXFA_TextParser::IsSpaceRun(CFDE_CSSComputedStyle* pStyle) const { CFX_RetainPtr CXFA_TextParser::GetFont( CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle) const { + CFX_CSSComputedStyle* pStyle) const { CFX_WideStringC wsFamily = L"Courier"; uint32_t dwStyle = 0; CXFA_Font font = pTextProvider->GetFontNode(); @@ -337,7 +337,7 @@ CFX_RetainPtr CXFA_TextParser::GetFont( dwStyle = 0; if (pStyle->GetFontWeight() > FXFONT_FW_NORMAL) dwStyle |= FX_FONTSTYLE_Bold; - if (pStyle->GetFontStyle() == FDE_CSSFontStyle::Italic) + if (pStyle->GetFontStyle() == CFX_CSSFontStyle::Italic) dwStyle |= FX_FONTSTYLE_Italic; } @@ -347,7 +347,7 @@ CFX_RetainPtr CXFA_TextParser::GetFont( } float CXFA_TextParser::GetFontSize(CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle) const { + CFX_CSSComputedStyle* pStyle) const { if (pStyle) return pStyle->GetFontSize(); @@ -358,7 +358,7 @@ float CXFA_TextParser::GetFontSize(CXFA_TextProvider* pTextProvider, } int32_t CXFA_TextParser::GetHorScale(CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle, + CFX_CSSComputedStyle* pStyle, CFX_XMLNode* pXMLNode) const { if (pStyle) { CFX_WideString wsValue; @@ -385,7 +385,7 @@ int32_t CXFA_TextParser::GetHorScale(CXFA_TextProvider* pTextProvider, } int32_t CXFA_TextParser::GetVerScale(CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle) const { + CFX_CSSComputedStyle* pStyle) const { if (pStyle) { CFX_WideString wsValue; if (pStyle->GetCustomStyle(L"xfa-font-vertical-scale", wsValue)) @@ -398,7 +398,7 @@ int32_t CXFA_TextParser::GetVerScale(CXFA_TextProvider* pTextProvider, } void CXFA_TextParser::GetUnderline(CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle, + CFX_CSSComputedStyle* pStyle, int32_t& iUnderline, int32_t& iPeriod) const { iUnderline = 0; @@ -413,9 +413,9 @@ void CXFA_TextParser::GetUnderline(CXFA_TextProvider* pTextProvider, } uint32_t dwDecoration = pStyle->GetTextDecoration(); - if (dwDecoration & FDE_CSSTEXTDECORATION_Double) + if (dwDecoration & CFX_CSSTEXTDECORATION_Double) iUnderline = 2; - else if (dwDecoration & FDE_CSSTEXTDECORATION_Underline) + else if (dwDecoration & CFX_CSSTEXTDECORATION_Underline) iUnderline = 1; CFX_WideString wsValue; @@ -428,11 +428,11 @@ void CXFA_TextParser::GetUnderline(CXFA_TextProvider* pTextProvider, } void CXFA_TextParser::GetLinethrough(CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle, + CFX_CSSComputedStyle* pStyle, int32_t& iLinethrough) const { if (pStyle) { uint32_t dwDecoration = pStyle->GetTextDecoration(); - iLinethrough = (dwDecoration & FDE_CSSTEXTDECORATION_LineThrough) ? 1 : 0; + iLinethrough = (dwDecoration & CFX_CSSTEXTDECORATION_LineThrough) ? 1 : 0; return; } @@ -442,7 +442,7 @@ void CXFA_TextParser::GetLinethrough(CXFA_TextProvider* pTextProvider, } FX_ARGB CXFA_TextParser::GetColor(CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle) const { + CFX_CSSComputedStyle* pStyle) const { if (pStyle) return pStyle->GetColor(); if (CXFA_Font font = pTextProvider->GetFontNode()) @@ -452,9 +452,9 @@ FX_ARGB CXFA_TextParser::GetColor(CXFA_TextProvider* pTextProvider, } float CXFA_TextParser::GetBaseline(CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle) const { + CFX_CSSComputedStyle* pStyle) const { if (pStyle) { - if (pStyle->GetVerticalAlign() == FDE_CSSVerticalAlign::Number) + if (pStyle->GetVerticalAlign() == CFX_CSSVerticalAlign::Number) return pStyle->GetNumberVerticalAlign(); } else if (CXFA_Font font = pTextProvider->GetFontNode()) { return font.GetBaselineShift(); @@ -463,7 +463,7 @@ float CXFA_TextParser::GetBaseline(CXFA_TextProvider* pTextProvider, } float CXFA_TextParser::GetLineHeight(CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle, + CFX_CSSComputedStyle* pStyle, bool bFirst, float fVerScale) const { float fLineHeight = 0; @@ -532,7 +532,7 @@ CXFA_TextParseContext* CXFA_TextParser::GetParseContextFromMap( return it != m_mapXMLNodeToParseContext.end() ? it->second.get() : nullptr; } -bool CXFA_TextParser::GetTabstops(CFDE_CSSComputedStyle* pStyle, +bool CXFA_TextParser::GetTabstops(CFX_CSSComputedStyle* pStyle, CXFA_TextTabstopsContext* pTabstopContext) { if (!pStyle || !pTabstopContext) return false; diff --git a/xfa/fxfa/cxfa_textparser.h b/xfa/fxfa/cxfa_textparser.h index 303b10ce07..567aff0189 100644 --- a/xfa/fxfa/cxfa_textparser.h +++ b/xfa/fxfa/cxfa_textparser.h @@ -16,9 +16,9 @@ #include "core/fxge/fx_dib.h" #include "xfa/fgas/font/cfgas_gefont.h" -class CFDE_CSSComputedStyle; -class CFDE_CSSStyleSelector; -class CFDE_CSSStyleSheet; +class CFX_CSSComputedStyle; +class CFX_CSSStyleSelector; +class CFX_CSSStyleSheet; class CFX_XMLNode; class CXFA_TextParseContext; class CXFA_TextProvider; @@ -32,47 +32,47 @@ class CXFA_TextParser { void Reset(); void DoParse(CFX_XMLNode* pXMLContainer, CXFA_TextProvider* pTextProvider); - CFX_RetainPtr CreateRootStyle( + CFX_RetainPtr CreateRootStyle( CXFA_TextProvider* pTextProvider); - CFX_RetainPtr ComputeStyle( + CFX_RetainPtr ComputeStyle( CFX_XMLNode* pXMLNode, - CFDE_CSSComputedStyle* pParentStyle); + CFX_CSSComputedStyle* pParentStyle); bool IsParsed() const { return m_bParsed; } int32_t GetVAlign(CXFA_TextProvider* pTextProvider) const; - float GetTabInterval(CFDE_CSSComputedStyle* pStyle) const; - int32_t CountTabs(CFDE_CSSComputedStyle* pStyle) const; + float GetTabInterval(CFX_CSSComputedStyle* pStyle) const; + int32_t CountTabs(CFX_CSSComputedStyle* pStyle) const; - bool IsSpaceRun(CFDE_CSSComputedStyle* pStyle) const; - bool GetTabstops(CFDE_CSSComputedStyle* pStyle, + bool IsSpaceRun(CFX_CSSComputedStyle* pStyle) const; + bool GetTabstops(CFX_CSSComputedStyle* pStyle, CXFA_TextTabstopsContext* pTabstopContext); CFX_RetainPtr GetFont(CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle) const; + CFX_CSSComputedStyle* pStyle) const; float GetFontSize(CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle) const; + CFX_CSSComputedStyle* pStyle) const; int32_t GetHorScale(CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle, + CFX_CSSComputedStyle* pStyle, CFX_XMLNode* pXMLNode) const; int32_t GetVerScale(CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle) const; + CFX_CSSComputedStyle* pStyle) const; void GetUnderline(CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle, + CFX_CSSComputedStyle* pStyle, int32_t& iUnderline, int32_t& iPeriod) const; void GetLinethrough(CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle, + CFX_CSSComputedStyle* pStyle, int32_t& iLinethrough) const; FX_ARGB GetColor(CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle) const; + CFX_CSSComputedStyle* pStyle) const; float GetBaseline(CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle) const; + CFX_CSSComputedStyle* pStyle) const; float GetLineHeight(CXFA_TextProvider* pTextProvider, - CFDE_CSSComputedStyle* pStyle, + CFX_CSSComputedStyle* pStyle, bool bFirst, float fVerScale) const; @@ -111,16 +111,15 @@ class CXFA_TextParser { }; void InitCSSData(CXFA_TextProvider* pTextProvider); - void ParseRichText(CFX_XMLNode* pXMLNode, - CFDE_CSSComputedStyle* pParentStyle); + void ParseRichText(CFX_XMLNode* pXMLNode, CFX_CSSComputedStyle* pParentStyle); std::unique_ptr ParseTagInfo(CFX_XMLNode* pXMLNode); - std::unique_ptr LoadDefaultSheetStyle(); - CFX_RetainPtr CreateStyle( - CFDE_CSSComputedStyle* pParentStyle); + std::unique_ptr LoadDefaultSheetStyle(); + CFX_RetainPtr CreateStyle( + CFX_CSSComputedStyle* pParentStyle); bool m_bParsed; bool m_cssInitialized; - std::unique_ptr m_pSelector; + std::unique_ptr m_pSelector; std::map> m_mapXMLNodeToParseContext; }; diff --git a/xfa/fxfa/cxfa_textuserdata.cpp b/xfa/fxfa/cxfa_textuserdata.cpp index 4cec6b300a..51a2f43194 100644 --- a/xfa/fxfa/cxfa_textuserdata.cpp +++ b/xfa/fxfa/cxfa_textuserdata.cpp @@ -6,17 +6,17 @@ #include "xfa/fxfa/cxfa_textuserdata.h" -#include "xfa/fde/css/cfde_csscomputedstyle.h" -#include "xfa/fde/css/cfde_cssstyleselector.h" -#include "xfa/fde/css/fde_css.h" +#include "core/fxcrt/css/cfx_css.h" +#include "core/fxcrt/css/cfx_csscomputedstyle.h" +#include "core/fxcrt/css/cfx_cssstyleselector.h" #include "xfa/fxfa/cxfa_linkuserdata.h" CXFA_TextUserData::CXFA_TextUserData( - const CFX_RetainPtr& pStyle) + const CFX_RetainPtr& pStyle) : m_pStyle(pStyle) {} CXFA_TextUserData::CXFA_TextUserData( - const CFX_RetainPtr& pStyle, + const CFX_RetainPtr& pStyle, const CFX_RetainPtr& pLinkData) : m_pStyle(pStyle), m_pLinkData(pLinkData) {} diff --git a/xfa/fxfa/cxfa_textuserdata.h b/xfa/fxfa/cxfa_textuserdata.h index c9e90aa40f..f84e768166 100644 --- a/xfa/fxfa/cxfa_textuserdata.h +++ b/xfa/fxfa/cxfa_textuserdata.h @@ -10,7 +10,7 @@ #include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_basic.h" -class CFDE_CSSComputedStyle; +class CFX_CSSComputedStyle; class CXFA_LinkUserData; class CXFA_TextUserData : public CFX_Retainable { @@ -18,13 +18,12 @@ class CXFA_TextUserData : public CFX_Retainable { template friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); - CFX_RetainPtr m_pStyle; + CFX_RetainPtr m_pStyle; CFX_RetainPtr m_pLinkData; private: - explicit CXFA_TextUserData( - const CFX_RetainPtr& pStyle); - CXFA_TextUserData(const CFX_RetainPtr& pStyle, + explicit CXFA_TextUserData(const CFX_RetainPtr& pStyle); + CXFA_TextUserData(const CFX_RetainPtr& pStyle, const CFX_RetainPtr& pLinkData); ~CXFA_TextUserData() override; }; -- cgit v1.2.3