From 6efd0d7464e1f02ef3cd4f1abe5c6f8e5283fbbb Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 16 Jan 2017 16:05:17 -0500 Subject: Replace remaining CSS interfaces with concrete classes This Cl moves IFDE_CSSValue and IFDE_CSSRule to concrete classes and moves the holding of the type into the base class. Change-Id: Iea29cc55256dd2183b60ca8711367d5dc8daaa24 Reviewed-on: https://pdfium-review.googlesource.com/2178 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- BUILD.gn | 4 +++ xfa/fde/css/cfde_cssrule.cpp | 11 +++++++++ xfa/fde/css/cfde_cssrule.h | 25 +++++++++++++++++++ xfa/fde/css/cfde_cssrulecollection.cpp | 2 +- xfa/fde/css/cfde_cssvalue.cpp | 11 +++++++++ xfa/fde/css/cfde_cssvalue.h | 25 +++++++++++++++++++ xfa/fde/css/fde_css.h | 21 ---------------- xfa/fde/css/fde_csscache.h | 2 ++ xfa/fde/css/fde_cssdatatable.cpp | 41 +++++++++++++++++-------------- xfa/fde/css/fde_cssdatatable.h | 24 ++++++------------ xfa/fde/css/fde_cssdeclaration.cpp | 45 +++++++++++++++++----------------- xfa/fde/css/fde_cssdeclaration.h | 24 +++++++++--------- xfa/fde/css/fde_cssstyleselector.cpp | 8 +++--- xfa/fde/css/fde_cssstyleselector.h | 7 ++++-- xfa/fde/css/fde_cssstylesheet.cpp | 35 ++++++++++++-------------- xfa/fde/css/fde_cssstylesheet.h | 31 ++++++++++------------- 16 files changed, 182 insertions(+), 134 deletions(-) create mode 100644 xfa/fde/css/cfde_cssrule.cpp create mode 100644 xfa/fde/css/cfde_cssrule.h create mode 100644 xfa/fde/css/cfde_cssvalue.cpp create mode 100644 xfa/fde/css/cfde_cssvalue.h diff --git a/BUILD.gn b/BUILD.gn index e8f4f13ec8..fbede10eb0 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1134,7 +1134,11 @@ if (pdf_enable_xfa) { "xfa/fde/cfx_chariter.h", "xfa/fde/cfx_wordbreak.cpp", "xfa/fde/cfx_wordbreak.h", + "xfa/fde/css/cfde_cssrule.cpp", + "xfa/fde/css/cfde_cssrule.h", "xfa/fde/css/cfde_cssrulecollection.cpp", + "xfa/fde/css/cfde_cssvalue.cpp", + "xfa/fde/css/cfde_cssvalue.h", "xfa/fde/css/fde_css.h", "xfa/fde/css/fde_csscache.cpp", "xfa/fde/css/fde_csscache.h", diff --git a/xfa/fde/css/cfde_cssrule.cpp b/xfa/fde/css/cfde_cssrule.cpp new file mode 100644 index 0000000000..7a46703881 --- /dev/null +++ b/xfa/fde/css/cfde_cssrule.cpp @@ -0,0 +1,11 @@ +// 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_cssrule.h" + +CFDE_CSSRule::CFDE_CSSRule(FDE_CSSRuleType type) : m_type(type) {} + +CFDE_CSSRule::~CFDE_CSSRule() {} diff --git a/xfa/fde/css/cfde_cssrule.h b/xfa/fde/css/cfde_cssrule.h new file mode 100644 index 0000000000..946132179b --- /dev/null +++ b/xfa/fde/css/cfde_cssrule.h @@ -0,0 +1,25 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_FDE_CSS_CFDE_CSSRULE_H_ +#define XFA_FDE_CSS_CFDE_CSSRULE_H_ + +#include "xfa/fde/css/fde_css.h" + +class CFDE_CSSRule { + public: + virtual ~CFDE_CSSRule(); + + FDE_CSSRuleType GetType() const { return m_type; } + + protected: + explicit CFDE_CSSRule(FDE_CSSRuleType type); + + private: + FDE_CSSRuleType m_type; +}; + +#endif // XFA_FDE_CSS_CFDE_CSSRULE_H_ diff --git a/xfa/fde/css/cfde_cssrulecollection.cpp b/xfa/fde/css/cfde_cssrulecollection.cpp index d9bc9b7545..5c386effeb 100644 --- a/xfa/fde/css/cfde_cssrulecollection.cpp +++ b/xfa/fde/css/cfde_cssrulecollection.cpp @@ -49,7 +49,7 @@ void CFDE_CSSRuleCollection::AddRulesFrom( } void CFDE_CSSRuleCollection::AddRulesFrom(CFDE_CSSStyleSheet* pStyleSheet, - IFDE_CSSRule* pRule, + CFDE_CSSRule* pRule, uint32_t dwMediaList, CFGAS_FontMgr* pFontMgr) { switch (pRule->GetType()) { diff --git a/xfa/fde/css/cfde_cssvalue.cpp b/xfa/fde/css/cfde_cssvalue.cpp new file mode 100644 index 0000000000..84e99353a9 --- /dev/null +++ b/xfa/fde/css/cfde_cssvalue.cpp @@ -0,0 +1,11 @@ +// 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_CSSVALUETYPE type) : m_value(type) {} + +CFDE_CSSValue::~CFDE_CSSValue() {} diff --git a/xfa/fde/css/cfde_cssvalue.h b/xfa/fde/css/cfde_cssvalue.h new file mode 100644 index 0000000000..17cc565b5d --- /dev/null +++ b/xfa/fde/css/cfde_cssvalue.h @@ -0,0 +1,25 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#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: + virtual ~CFDE_CSSValue(); + + FDE_CSSVALUETYPE GetType() const { return m_value; } + + protected: + explicit CFDE_CSSValue(FDE_CSSVALUETYPE type); + + private: + FDE_CSSVALUETYPE m_value; +}; + +#endif // XFA_FDE_CSS_CFDE_CSSVALUE_H_ diff --git a/xfa/fde/css/fde_css.h b/xfa/fde/css/fde_css.h index 90763d6c38..40f234e878 100644 --- a/xfa/fde/css/fde_css.h +++ b/xfa/fde/css/fde_css.h @@ -12,15 +12,6 @@ #include "xfa/fgas/crt/fgas_utils.h" #include "xfa/fgas/font/cfgas_fontmgr.h" -class CFDE_CSSAccelerator; -class CFDE_CSSDeclaration; -class CFDE_CSSComputedStyle; -class CFDE_CSSSelector; -class CFDE_CSSStyleSheet; -class CXFA_CSSTagProvider; -class IFDE_CSSRule; -class IFDE_CSSValue; - enum FDE_CSSMEDIATYPE { FDE_CSSMEDIATYPE_Braille = 0x01, FDE_CSSMEDIATYPE_Emboss = 0x02, @@ -257,18 +248,6 @@ enum class FDE_CSSStyleSheetPriority : uint8_t { Low, }; -class IFDE_CSSValue { - public: - virtual ~IFDE_CSSValue() {} - virtual FDE_CSSVALUETYPE GetType() const = 0; -}; - -class IFDE_CSSRule { - public: - virtual ~IFDE_CSSRule() {} - virtual FDE_CSSRuleType GetType() const = 0; -}; - struct FDE_CSSLENGTH { FDE_CSSLENGTH() {} diff --git a/xfa/fde/css/fde_csscache.h b/xfa/fde/css/fde_csscache.h index 0ddaf39565..fd46880c1f 100644 --- a/xfa/fde/css/fde_csscache.h +++ b/xfa/fde/css/fde_csscache.h @@ -11,6 +11,8 @@ #include "xfa/fde/css/fde_css.h" +class CXFA_CSSTagProvider; + class FDE_CSSTagCache { public: FDE_CSSTagCache(FDE_CSSTagCache* parent, CXFA_CSSTagProvider* tag); diff --git a/xfa/fde/css/fde_cssdatatable.cpp b/xfa/fde/css/fde_cssdatatable.cpp index 7db704a8f5..8ebded5c2d 100644 --- a/xfa/fde/css/fde_cssdatatable.cpp +++ b/xfa/fde/css/fde_cssdatatable.cpp @@ -534,22 +534,19 @@ bool FDE_ParseCSSColor(const FX_WCHAR* pszValue, return true; } -CFDE_CSSValueList::CFDE_CSSValueList(const CFDE_CSSValueArray& list) { +CFDE_CSSValueList::CFDE_CSSValueList( + const CFX_ArrayTemplate& list) + : CFDE_CSSValue(FDE_CSSVALUETYPE_List) { m_iCount = list.GetSize(); - int32_t iByteCount = m_iCount * sizeof(IFDE_CSSValue*); - m_ppList = (IFDE_CSSValue**)FX_Alloc(uint8_t, iByteCount); - FXSYS_memcpy(m_ppList, list.GetData(), iByteCount); + m_ppList = FX_Alloc(CFDE_CSSValue*, m_iCount); + FXSYS_memcpy(m_ppList, list.GetData(), m_iCount * sizeof(CFDE_CSSValue*)); } int32_t CFDE_CSSValueList::CountValues() const { return m_iCount; } -FDE_CSSVALUETYPE CFDE_CSSValueList::GetType() const { - return FDE_CSSVALUETYPE_List; -} - -IFDE_CSSValue* CFDE_CSSValueList::GetValue(int32_t index) const { +CFDE_CSSValue* CFDE_CSSValueList::GetValue(int32_t index) const { return m_ppList[index]; } bool CFDE_CSSValueListParser::NextValue(FDE_CSSPrimitiveType& eType, @@ -658,27 +655,33 @@ CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue( const CFDE_CSSPrimitiveValue& src) = default; CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(FX_ARGB color) - : m_eType(FDE_CSSPrimitiveType::RGB), m_dwColor(color) {} + : CFDE_CSSValue(FDE_CSSVALUETYPE_Primitive), + m_eType(FDE_CSSPrimitiveType::RGB), + m_dwColor(color) {} CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(FDE_CSSPropertyValue eValue) - : m_eType(FDE_CSSPrimitiveType::Enum), m_eEnum(eValue) {} + : CFDE_CSSValue(FDE_CSSVALUETYPE_Primitive), + m_eType(FDE_CSSPrimitiveType::Enum), + m_eEnum(eValue) {} CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(FDE_CSSPrimitiveType eType, FX_FLOAT fValue) - : m_eType(eType), m_fNumber(fValue) {} + : CFDE_CSSValue(FDE_CSSVALUETYPE_Primitive), + m_eType(eType), + m_fNumber(fValue) {} CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(FDE_CSSPrimitiveType eType, const FX_WCHAR* pValue) - : m_eType(eType), m_pString(pValue) { + : CFDE_CSSValue(FDE_CSSVALUETYPE_Primitive), + m_eType(eType), + m_pString(pValue) { ASSERT(m_pString); } CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(CFDE_CSSFunction* pFunction) - : m_eType(FDE_CSSPrimitiveType::Function), m_pFunction(pFunction) {} - -FDE_CSSVALUETYPE CFDE_CSSPrimitiveValue::GetType() const { - return FDE_CSSVALUETYPE_Primitive; -} + : CFDE_CSSValue(FDE_CSSVALUETYPE_Primitive), + m_eType(FDE_CSSPrimitiveType::Function), + m_pFunction(pFunction) {} FDE_CSSPrimitiveType CFDE_CSSPrimitiveValue::GetPrimitiveType() const { return m_eType; @@ -717,7 +720,7 @@ int32_t CFDE_CSSPrimitiveValue::CountArgs() const { return m_pFunction->CountArgs(); } -IFDE_CSSValue* CFDE_CSSPrimitiveValue::GetArgs(int32_t index) const { +CFDE_CSSValue* CFDE_CSSPrimitiveValue::GetArgs(int32_t index) const { ASSERT(m_eType == FDE_CSSPrimitiveType::Function); return m_pFunction->GetArgs(index); } diff --git a/xfa/fde/css/fde_cssdatatable.h b/xfa/fde/css/fde_cssdatatable.h index d62ddf6b03..0904b445d9 100644 --- a/xfa/fde/css/fde_cssdatatable.h +++ b/xfa/fde/css/fde_cssdatatable.h @@ -8,11 +8,12 @@ #define XFA_FDE_CSS_FDE_CSSDATATABLE_H_ #include "core/fxcrt/fx_system.h" +#include "xfa/fde/css/cfde_cssvalue.h" #include "xfa/fde/css/fde_css.h" class CFDE_CSSFunction; -class CFDE_CSSPrimitiveValue : public IFDE_CSSValue { +class CFDE_CSSPrimitiveValue : public CFDE_CSSValue { public: explicit CFDE_CSSPrimitiveValue(FX_ARGB color); explicit CFDE_CSSPrimitiveValue(FDE_CSSPropertyValue eValue); @@ -21,9 +22,6 @@ class CFDE_CSSPrimitiveValue : public IFDE_CSSValue { CFDE_CSSPrimitiveValue(FDE_CSSPrimitiveType eType, const FX_WCHAR* pValue); CFDE_CSSPrimitiveValue(const CFDE_CSSPrimitiveValue& src); - // IFDE_CSSValue - FDE_CSSVALUETYPE GetType() const override; - FDE_CSSPrimitiveType GetPrimitiveType() const; FX_ARGB GetRGBColor() const; FX_FLOAT GetFloat() const; @@ -31,7 +29,7 @@ class CFDE_CSSPrimitiveValue : public IFDE_CSSValue { FDE_CSSPropertyValue GetEnum() const; const FX_WCHAR* GetFuncName() const; int32_t CountArgs() const; - IFDE_CSSValue* GetArgs(int32_t index) const; + CFDE_CSSValue* GetArgs(int32_t index) const; FDE_CSSPrimitiveType m_eType; union { @@ -43,21 +41,15 @@ class CFDE_CSSPrimitiveValue : public IFDE_CSSValue { }; }; -typedef CFX_ArrayTemplate CFDE_CSSPrimitiveArray; -typedef CFX_ArrayTemplate CFDE_CSSValueArray; - -class CFDE_CSSValueList : public IFDE_CSSValue { +class CFDE_CSSValueList : public CFDE_CSSValue { public: - explicit CFDE_CSSValueList(const CFDE_CSSValueArray& list); - - // IFDE_CSSValue - FDE_CSSVALUETYPE GetType() const override; + explicit CFDE_CSSValueList(const CFX_ArrayTemplate& list); int32_t CountValues() const; - IFDE_CSSValue* GetValue(int32_t index) const; + CFDE_CSSValue* GetValue(int32_t index) const; protected: - IFDE_CSSValue** m_ppList; + CFDE_CSSValue** m_ppList; int32_t m_iCount; }; @@ -88,7 +80,7 @@ class CFDE_CSSFunction { ASSERT(pArgList); } int32_t CountArgs() const { return m_pArgList->CountValues(); } - IFDE_CSSValue* GetArgs(int32_t index) const { + CFDE_CSSValue* GetArgs(int32_t index) const { return m_pArgList->GetValue(index); } const FX_WCHAR* GetFuncName() const { return m_pszFuncName; } diff --git a/xfa/fde/css/fde_cssdeclaration.cpp b/xfa/fde/css/fde_cssdeclaration.cpp index 50d0b8c854..b995649e6d 100644 --- a/xfa/fde/css/fde_cssdeclaration.cpp +++ b/xfa/fde/css/fde_cssdeclaration.cpp @@ -8,7 +8,7 @@ #include "core/fxcrt/fx_ext.h" -IFDE_CSSValue* CFDE_CSSDeclaration::GetProperty(FDE_CSSProperty eProperty, +CFDE_CSSValue* CFDE_CSSDeclaration::GetProperty(FDE_CSSProperty eProperty, bool& bImportant) const { for (const FDE_CSSPropertyHolder* pHolder = m_pFirstProperty; pHolder; pHolder = pHolder->pNext) { @@ -24,7 +24,7 @@ FX_POSITION CFDE_CSSDeclaration::GetStartPosition() const { } void CFDE_CSSDeclaration::GetNextProperty(FX_POSITION& pos, FDE_CSSProperty& eProperty, - IFDE_CSSValue*& pValue, + CFDE_CSSValue*& pValue, bool& bImportant) const { const FDE_CSSPropertyHolder* pHolder = (const FDE_CSSPropertyHolder*)pos; bImportant = pHolder->bImportant; @@ -81,7 +81,7 @@ CFDE_CSSPrimitiveValue* CFDE_CSSDeclaration::NewEnumValue( return new CFDE_CSSPrimitiveValue(eValue); } void CFDE_CSSDeclaration::AddPropertyHolder(FDE_CSSProperty eProperty, - IFDE_CSSValue* pValue, + CFDE_CSSValue* pValue, bool bImportant) { FDE_CSSPropertyHolder* pHolder = new FDE_CSSPropertyHolder; pHolder->bImportant = bImportant; @@ -121,7 +121,7 @@ bool CFDE_CSSDeclaration::AddProperty(const FDE_CSSPropertyArgs* pArgs, if (dwMatch == 0) { continue; } - IFDE_CSSValue* pCSSValue = nullptr; + CFDE_CSSValue* pCSSValue = nullptr; switch (dwMatch) { case FDE_CSSVALUETYPE_MaybeFunction: pCSSValue = ParseFunction(pArgs, pszValue, iValueLen); @@ -154,7 +154,7 @@ bool CFDE_CSSDeclaration::AddProperty(const FDE_CSSPropertyArgs* pArgs, } } break; case FDE_CSSVALUETYPE_Shorthand: { - IFDE_CSSValue* pWidth; + CFDE_CSSValue* pWidth; switch (pArgs->pProperty->eName) { case FDE_CSSProperty::Font: return ParseFontProperty(pArgs, pszValue, iValueLen, bImportant); @@ -227,7 +227,7 @@ bool CFDE_CSSDeclaration::AddProperty(const FDE_CSSPropertyArgs* pArgs, m_pLastCustom = pProperty; return true; } -IFDE_CSSValue* CFDE_CSSDeclaration::ParseNumber( +CFDE_CSSValue* CFDE_CSSDeclaration::ParseNumber( const FDE_CSSPropertyArgs* pArgs, const FX_WCHAR* pszValue, int32_t iValueLen) { @@ -238,14 +238,14 @@ IFDE_CSSValue* CFDE_CSSDeclaration::ParseNumber( } return NewNumberValue(eUnit, fValue); } -IFDE_CSSValue* CFDE_CSSDeclaration::ParseEnum(const FDE_CSSPropertyArgs* pArgs, +CFDE_CSSValue* CFDE_CSSDeclaration::ParseEnum(const FDE_CSSPropertyArgs* pArgs, const FX_WCHAR* pszValue, int32_t iValueLen) { const FDE_CSSPropertyValueTable* pValue = FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen)); return pValue ? NewEnumValue(pValue->eName) : nullptr; } -IFDE_CSSValue* CFDE_CSSDeclaration::ParseColor(const FDE_CSSPropertyArgs* pArgs, +CFDE_CSSValue* CFDE_CSSDeclaration::ParseColor(const FDE_CSSPropertyArgs* pArgs, const FX_WCHAR* pszValue, int32_t iValueLen) { FX_ARGB dwColor; @@ -255,7 +255,7 @@ IFDE_CSSValue* CFDE_CSSDeclaration::ParseColor(const FDE_CSSPropertyArgs* pArgs, return new CFDE_CSSPrimitiveValue(dwColor); } -IFDE_CSSValue* CFDE_CSSDeclaration::ParseURI(const FDE_CSSPropertyArgs* pArgs, +CFDE_CSSValue* CFDE_CSSDeclaration::ParseURI(const FDE_CSSPropertyArgs* pArgs, const FX_WCHAR* pszValue, int32_t iValueLen) { int32_t iOffset; @@ -271,7 +271,7 @@ IFDE_CSSValue* CFDE_CSSDeclaration::ParseURI(const FDE_CSSPropertyArgs* pArgs, : nullptr; } -IFDE_CSSValue* CFDE_CSSDeclaration::ParseString( +CFDE_CSSValue* CFDE_CSSDeclaration::ParseString( const FDE_CSSPropertyArgs* pArgs, const FX_WCHAR* pszValue, int32_t iValueLen) { @@ -287,7 +287,7 @@ IFDE_CSSValue* CFDE_CSSDeclaration::ParseString( pszValue) : nullptr; } -IFDE_CSSValue* CFDE_CSSDeclaration::ParseFunction( +CFDE_CSSValue* CFDE_CSSDeclaration::ParseFunction( const FDE_CSSPropertyArgs* pArgs, const FX_WCHAR* pszValue, int32_t iValueLen) { @@ -308,7 +308,7 @@ IFDE_CSSValue* CFDE_CSSDeclaration::ParseFunction( const FX_WCHAR* pszFuncName = CopyToLocal(pArgs, pszValue, iStartBracket); pszValue += (iStartBracket + 1); iValueLen -= (iStartBracket + 2); - CFDE_CSSValueArray argumentArr; + CFX_ArrayTemplate argumentArr; CFDE_CSSValueListParser parser(pszValue, iValueLen, ','); FDE_CSSPrimitiveType ePrimitiveType; while (parser.NextValue(ePrimitiveType, pszValue, iValueLen)) { @@ -321,7 +321,7 @@ IFDE_CSSValue* CFDE_CSSDeclaration::ParseFunction( continue; } - IFDE_CSSValue* pFunctionValue = + CFDE_CSSValue* pFunctionValue = ParseFunction(pArgs, pszValue, iValueLen); if (pFunctionValue) { argumentArr.Add(pFunctionValue); @@ -361,7 +361,7 @@ bool CFDE_CSSDeclaration::ParseValueListProperty( CFDE_CSSValueListParser parser(pszValue, iValueLen, separator); const uint32_t dwType = pArgs->pProperty->dwType; FDE_CSSPrimitiveType eType; - CFDE_CSSValueArray list; + CFX_ArrayTemplate list; while (parser.NextValue(eType, pszValue, iValueLen)) { switch (eType) { case FDE_CSSPrimitiveType::Number: @@ -434,12 +434,13 @@ bool CFDE_CSSDeclaration::ParseValueListProperty( return false; } -bool CFDE_CSSDeclaration::Add4ValuesProperty(const CFDE_CSSValueArray& list, - bool bImportant, - FDE_CSSProperty eLeft, - FDE_CSSProperty eTop, - FDE_CSSProperty eRight, - FDE_CSSProperty eBottom) { +bool CFDE_CSSDeclaration::Add4ValuesProperty( + const CFX_ArrayTemplate& list, + bool bImportant, + FDE_CSSProperty eLeft, + FDE_CSSProperty eTop, + FDE_CSSProperty eRight, + FDE_CSSProperty eBottom) { switch (list.GetSize()) { case 1: AddPropertyHolder(eLeft, list[0], bImportant); @@ -472,7 +473,7 @@ bool CFDE_CSSDeclaration::Add4ValuesProperty(const CFDE_CSSValueArray& list, } bool CFDE_CSSDeclaration::ParseBorderProperty(const FX_WCHAR* pszValue, int32_t iValueLen, - IFDE_CSSValue*& pWidth) const { + CFDE_CSSValue*& pWidth) const { pWidth = nullptr; CFDE_CSSValueListParser parser(pszValue, iValueLen, ' '); FDE_CSSPrimitiveType eType; @@ -530,7 +531,7 @@ bool CFDE_CSSDeclaration::ParseFontProperty(const FDE_CSSPropertyArgs* pArgs, CFDE_CSSPrimitiveValue* pWeight = nullptr; CFDE_CSSPrimitiveValue* pFontSize = nullptr; CFDE_CSSPrimitiveValue* pLineHeight = nullptr; - CFDE_CSSValueArray familyList; + CFX_ArrayTemplate familyList; FDE_CSSPrimitiveType eType; while (parser.NextValue(eType, pszValue, iValueLen)) { switch (eType) { diff --git a/xfa/fde/css/fde_cssdeclaration.h b/xfa/fde/css/fde_cssdeclaration.h index 8db6d7b6a1..2dbd7a0622 100644 --- a/xfa/fde/css/fde_cssdeclaration.h +++ b/xfa/fde/css/fde_cssdeclaration.h @@ -15,7 +15,7 @@ class FDE_CSSPropertyHolder { public: FDE_CSSProperty eProperty; bool bImportant; - IFDE_CSSValue* pValue; + CFDE_CSSValue* pValue; FDE_CSSPropertyHolder* pNext; }; @@ -39,11 +39,11 @@ class CFDE_CSSDeclaration { m_pFirstCustom(nullptr), m_pLastCustom(nullptr) {} - IFDE_CSSValue* GetProperty(FDE_CSSProperty eProperty, bool& bImportant) const; + CFDE_CSSValue* GetProperty(FDE_CSSProperty eProperty, bool& bImportant) const; FX_POSITION GetStartPosition() const; void GetNextProperty(FX_POSITION& pos, FDE_CSSProperty& eProperty, - IFDE_CSSValue*& pValue, + CFDE_CSSValue*& pValue, bool& bImportant) const; FX_POSITION GetStartCustom() const; void GetNextCustom(FX_POSITION& pos, @@ -65,40 +65,40 @@ class CFDE_CSSDeclaration { bool bImportant); bool ParseBorderProperty(const FX_WCHAR* pszValue, int32_t iValueLen, - IFDE_CSSValue*& pWidth) const; + CFDE_CSSValue*& pWidth) const; bool ParseValueListProperty(const FDE_CSSPropertyArgs* pArgs, const FX_WCHAR* pszValue, int32_t iValueLen, bool bImportant); - bool Add4ValuesProperty(const CFDE_CSSValueArray& list, + bool Add4ValuesProperty(const CFX_ArrayTemplate& list, bool bImportant, FDE_CSSProperty eLeft, FDE_CSSProperty eTop, FDE_CSSProperty eRight, FDE_CSSProperty eBottom); - IFDE_CSSValue* ParseNumber(const FDE_CSSPropertyArgs* pArgs, + CFDE_CSSValue* ParseNumber(const FDE_CSSPropertyArgs* pArgs, const FX_WCHAR* pszValue, int32_t iValueLen); - IFDE_CSSValue* ParseEnum(const FDE_CSSPropertyArgs* pArgs, + CFDE_CSSValue* ParseEnum(const FDE_CSSPropertyArgs* pArgs, const FX_WCHAR* pszValue, int32_t iValueLen); - IFDE_CSSValue* ParseColor(const FDE_CSSPropertyArgs* pArgs, + CFDE_CSSValue* ParseColor(const FDE_CSSPropertyArgs* pArgs, const FX_WCHAR* pszValue, int32_t iValueLen); - IFDE_CSSValue* ParseURI(const FDE_CSSPropertyArgs* pArgs, + CFDE_CSSValue* ParseURI(const FDE_CSSPropertyArgs* pArgs, const FX_WCHAR* pszValue, int32_t iValueLen); - IFDE_CSSValue* ParseString(const FDE_CSSPropertyArgs* pArgs, + CFDE_CSSValue* ParseString(const FDE_CSSPropertyArgs* pArgs, const FX_WCHAR* pszValue, int32_t iValueLen); - IFDE_CSSValue* ParseFunction(const FDE_CSSPropertyArgs* pArgs, + CFDE_CSSValue* ParseFunction(const FDE_CSSPropertyArgs* pArgs, const FX_WCHAR* pszValue, int32_t iValueLen); const FX_WCHAR* CopyToLocal(const FDE_CSSPropertyArgs* pArgs, const FX_WCHAR* pszValue, int32_t iValueLen); void AddPropertyHolder(FDE_CSSProperty eProperty, - IFDE_CSSValue* pValue, + CFDE_CSSValue* pValue, bool bImportant); CFDE_CSSPrimitiveValue* NewNumberValue(FDE_CSSPrimitiveType eUnit, FX_FLOAT fValue) const; diff --git a/xfa/fde/css/fde_cssstyleselector.cpp b/xfa/fde/css/fde_cssstyleselector.cpp index 53424a1d30..838a5042e9 100644 --- a/xfa/fde/css/fde_cssstyleselector.cpp +++ b/xfa/fde/css/fde_cssstyleselector.cpp @@ -280,12 +280,12 @@ void CFDE_CSSStyleSelector::ApplyDeclarations( int32_t iDeclCount, CFDE_CSSComputedStyle* pDestStyle) { CFDE_CSSComputedStyle* pComputedStyle = pDestStyle; - IFDE_CSSValue* pVal; + CFDE_CSSValue* pVal; bool bImportant; int32_t i; if (bPriority) { - IFDE_CSSValue* pLastest = nullptr; - IFDE_CSSValue* pImportant = nullptr; + CFDE_CSSValue* pLastest = nullptr; + CFDE_CSSValue* pImportant = nullptr; for (i = 0; i < iDeclCount; ++i) { pVal = ppDeclArray[i]->GetProperty(FDE_CSSProperty::FontSize, bImportant); if (!pVal) @@ -382,7 +382,7 @@ void CFDE_CSSStyleSelector::AppendInlineStyle(CFDE_CSSDeclaration* pDecl, void CFDE_CSSStyleSelector::ApplyProperty( FDE_CSSProperty eProperty, - IFDE_CSSValue* pValue, + CFDE_CSSValue* pValue, CFDE_CSSComputedStyle* pComputedStyle) { if (pValue->GetType() == FDE_CSSVALUETYPE_Primitive) { CFDE_CSSPrimitiveValue* pPrimitive = diff --git a/xfa/fde/css/fde_cssstyleselector.h b/xfa/fde/css/fde_cssstyleselector.h index 6c06f0e4e2..4de54a8c91 100644 --- a/xfa/fde/css/fde_cssstyleselector.h +++ b/xfa/fde/css/fde_cssstyleselector.h @@ -18,6 +18,9 @@ class CFDE_CSSAccelerator; class CFDE_CSSComputedStyle; +class CFDE_CSSRule; +class CFDE_CSSSelector; +class CFDE_CSSStyleSheet; class CXFA_CSSTagProvider; class FDE_CSSRuleData { @@ -63,7 +66,7 @@ class CFDE_CSSRuleCollection { protected: void AddRulesFrom(CFDE_CSSStyleSheet* pStyleSheet, - IFDE_CSSRule* pRule, + CFDE_CSSRule* pRule, uint32_t dwMediaList, CFGAS_FontMgr* pFontMgr); void AddRuleTo(std::map* pMap, @@ -123,7 +126,7 @@ class CFDE_CSSStyleSelector { int32_t iDeclCount, CFDE_CSSComputedStyle* pDestStyle); void ApplyProperty(FDE_CSSProperty eProperty, - IFDE_CSSValue* pValue, + CFDE_CSSValue* pValue, CFDE_CSSComputedStyle* pComputedStyle); FX_FLOAT ApplyNumber(FDE_CSSPrimitiveType eUnit, diff --git a/xfa/fde/css/fde_cssstylesheet.cpp b/xfa/fde/css/fde_cssstylesheet.cpp index a3783c3756..a5ac0c07cc 100644 --- a/xfa/fde/css/fde_cssstylesheet.cpp +++ b/xfa/fde/css/fde_cssstylesheet.cpp @@ -27,7 +27,7 @@ CFDE_CSSStyleSheet::~CFDE_CSSStyleSheet() { void CFDE_CSSStyleSheet::Reset() { for (int32_t i = m_RuleArray.GetSize() - 1; i >= 0; --i) { - IFDE_CSSRule* pRule = m_RuleArray.GetAt(i); + CFDE_CSSRule* pRule = m_RuleArray.GetAt(i); switch (pRule->GetType()) { case FDE_CSSRuleType::Style: static_cast(pRule)->~CFDE_CSSStyleRule(); @@ -76,7 +76,7 @@ int32_t CFDE_CSSStyleSheet::CountRules() const { return m_RuleArray.GetSize(); } -IFDE_CSSRule* CFDE_CSSStyleSheet::GetRule(int32_t index) { +CFDE_CSSRule* CFDE_CSSStyleSheet::GetRule(int32_t index) { return m_RuleArray.GetAt(index); } @@ -164,7 +164,7 @@ FDE_CSSSyntaxStatus CFDE_CSSStyleSheet::LoadMediaRule( FDE_CSSSyntaxStatus CFDE_CSSStyleSheet::LoadStyleRule( CFDE_CSSSyntaxParser* pSyntax, - CFX_MassArrayTemplate& ruleArray) { + CFX_MassArrayTemplate& ruleArray) { m_Selectors.RemoveAt(0, m_Selectors.GetSize()); CFDE_CSSStyleRule* pStyleRule = nullptr; const FX_WCHAR* pszValue = nullptr; @@ -232,7 +232,7 @@ FDE_CSSSyntaxStatus CFDE_CSSStyleSheet::LoadStyleRule( FDE_CSSSyntaxStatus CFDE_CSSStyleSheet::LoadFontFaceRule( CFDE_CSSSyntaxParser* pSyntax, - CFX_MassArrayTemplate& ruleArray) { + CFX_MassArrayTemplate& ruleArray) { CFDE_CSSFontFaceRule* pFontFaceRule = nullptr; const FX_WCHAR* pszValue = nullptr; int32_t iValueLen = 0; @@ -315,11 +315,9 @@ FDE_CSSSyntaxStatus CFDE_CSSStyleSheet::SkipRuleSet( } CFDE_CSSStyleRule::CFDE_CSSStyleRule() - : m_ppSelector(nullptr), m_iSelectors(0) {} - -FDE_CSSRuleType CFDE_CSSStyleRule::GetType() const { - return FDE_CSSRuleType::Style; -} + : CFDE_CSSRule(FDE_CSSRuleType::Style), + m_ppSelector(nullptr), + m_iSelectors(0) {} int32_t CFDE_CSSStyleRule::CountSelectorLists() const { return m_iSelectors; @@ -345,11 +343,13 @@ void CFDE_CSSStyleRule::SetSelector( } CFDE_CSSMediaRule::CFDE_CSSMediaRule(uint32_t dwMediaList) - : m_dwMediaList(dwMediaList), m_RuleArray(100) {} + : CFDE_CSSRule(FDE_CSSRuleType::Media), + m_dwMediaList(dwMediaList), + m_RuleArray(100) {} CFDE_CSSMediaRule::~CFDE_CSSMediaRule() { for (int32_t i = m_RuleArray.GetSize() - 1; i >= 0; --i) { - IFDE_CSSRule* pRule = m_RuleArray.GetAt(i); + CFDE_CSSRule* pRule = m_RuleArray.GetAt(i); switch (pRule->GetType()) { case FDE_CSSRuleType::Style: static_cast(pRule)->~CFDE_CSSStyleRule(); @@ -361,10 +361,6 @@ CFDE_CSSMediaRule::~CFDE_CSSMediaRule() { } } -FDE_CSSRuleType CFDE_CSSMediaRule::GetType() const { - return FDE_CSSRuleType::Media; -} - uint32_t CFDE_CSSMediaRule::GetMediaList() const { return m_dwMediaList; } @@ -373,7 +369,7 @@ int32_t CFDE_CSSMediaRule::CountRules() const { return m_RuleArray.GetSize(); } -IFDE_CSSRule* CFDE_CSSMediaRule::GetRule(int32_t index) { +CFDE_CSSRule* CFDE_CSSMediaRule::GetRule(int32_t index) { return m_RuleArray.GetAt(index); } @@ -524,6 +520,7 @@ CFDE_CSSSelector* CFDE_CSSSelector::FromString( return pPseudoFirst; } -FDE_CSSRuleType CFDE_CSSFontFaceRule::GetType() const { - return FDE_CSSRuleType::FontFace; -} +CFDE_CSSFontFaceRule::CFDE_CSSFontFaceRule() + : CFDE_CSSRule(FDE_CSSRuleType::FontFace) {} + +CFDE_CSSFontFaceRule::~CFDE_CSSFontFaceRule() {} diff --git a/xfa/fde/css/fde_cssstylesheet.h b/xfa/fde/css/fde_cssstylesheet.h index 2fc195c9dd..8cedb76526 100644 --- a/xfa/fde/css/fde_cssstylesheet.h +++ b/xfa/fde/css/fde_cssstylesheet.h @@ -11,6 +11,7 @@ #include #include "core/fxcrt/fx_ext.h" +#include "xfa/fde/css/cfde_cssrule.h" #include "xfa/fde/css/fde_cssdeclaration.h" class CFDE_CSSSyntaxParser; @@ -38,13 +39,10 @@ class CFDE_CSSSelector { CFDE_CSSSelector* m_pNext; }; -class CFDE_CSSStyleRule : public IFDE_CSSRule { +class CFDE_CSSStyleRule : public CFDE_CSSRule { public: CFDE_CSSStyleRule(); - // IFDE_CSSRule - FDE_CSSRuleType GetType() const override; - int32_t CountSelectorLists() const; CFDE_CSSSelector* GetSelectorList(int32_t index) const; CFDE_CSSDeclaration* GetDeclaration(); @@ -57,29 +55,26 @@ class CFDE_CSSStyleRule : public IFDE_CSSRule { int32_t m_iSelectors; }; -class CFDE_CSSMediaRule : public IFDE_CSSRule { +class CFDE_CSSMediaRule : public CFDE_CSSRule { public: explicit CFDE_CSSMediaRule(uint32_t dwMediaList); ~CFDE_CSSMediaRule() override; - // IFDE_CSSValue - FDE_CSSRuleType GetType() const override; - uint32_t GetMediaList() const; int32_t CountRules() const; - IFDE_CSSRule* GetRule(int32_t index); + CFDE_CSSRule* GetRule(int32_t index); - CFX_MassArrayTemplate& GetArray() { return m_RuleArray; } + CFX_MassArrayTemplate& GetArray() { return m_RuleArray; } protected: uint32_t m_dwMediaList; - CFX_MassArrayTemplate m_RuleArray; + CFX_MassArrayTemplate m_RuleArray; }; -class CFDE_CSSFontFaceRule : public IFDE_CSSRule { +class CFDE_CSSFontFaceRule : public CFDE_CSSRule { public: - // IFDE_CSSRule. - FDE_CSSRuleType GetType() const override; + CFDE_CSSFontFaceRule(); + ~CFDE_CSSFontFaceRule() override; CFDE_CSSDeclaration& GetDeclImp() { return m_Declaration; } @@ -102,26 +97,26 @@ class CFDE_CSSStyleSheet : public IFX_Retainable { uint32_t GetMediaList() const; uint16_t GetCodePage() const; int32_t CountRules() const; - IFDE_CSSRule* GetRule(int32_t index); + CFDE_CSSRule* GetRule(int32_t index); private: void Reset(); bool LoadFromSyntax(CFDE_CSSSyntaxParser* pSyntax); FDE_CSSSyntaxStatus LoadStyleRule( CFDE_CSSSyntaxParser* pSyntax, - CFX_MassArrayTemplate& ruleArray); + CFX_MassArrayTemplate& ruleArray); FDE_CSSSyntaxStatus LoadImportRule(CFDE_CSSSyntaxParser* pSyntax); FDE_CSSSyntaxStatus LoadPageRule(CFDE_CSSSyntaxParser* pSyntax); FDE_CSSSyntaxStatus LoadMediaRule(CFDE_CSSSyntaxParser* pSyntax); FDE_CSSSyntaxStatus LoadFontFaceRule( CFDE_CSSSyntaxParser* pSyntax, - CFX_MassArrayTemplate& ruleArray); + CFX_MassArrayTemplate& ruleArray); FDE_CSSSyntaxStatus SkipRuleSet(CFDE_CSSSyntaxParser* pSyntax); uint16_t m_wCodePage; uint16_t m_wRefCount; uint32_t m_dwMediaList; - CFX_MassArrayTemplate m_RuleArray; + CFX_MassArrayTemplate m_RuleArray; CFX_WideString m_szUrl; CFX_ArrayTemplate m_Selectors; std::unordered_map m_StringCache; -- cgit v1.2.3