| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef XFA_FDE_CSS_FDE_CSSDECLARATION_H_ | 7 #ifndef XFA_FDE_CSS_FDE_CSSDECLARATION_H_ |
| 8 #define XFA_FDE_CSS_FDE_CSSDECLARATION_H_ | 8 #define XFA_FDE_CSS_FDE_CSSDECLARATION_H_ |
| 9 | 9 |
| 10 #include <unordered_map> | 10 #include <unordered_map> |
| 11 | 11 |
| 12 #include "xfa/fde/css/fde_cssdatatable.h" | 12 #include "xfa/fde/css/fde_cssdatatable.h" |
| 13 | 13 |
| 14 class FDE_CSSPropertyHolder : public CFX_Target { | 14 class FDE_CSSPropertyHolder : public CFX_Target { |
| 15 public: | 15 public: |
| 16 int16_t eProperty; | 16 int16_t eProperty; |
| 17 FX_BOOL bImportant; | 17 bool bImportant; |
| 18 IFDE_CSSValue* pValue; | 18 IFDE_CSSValue* pValue; |
| 19 FDE_CSSPropertyHolder* pNext; | 19 FDE_CSSPropertyHolder* pNext; |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 class FDE_CSSCustomProperty : public CFX_Target { | 22 class FDE_CSSCustomProperty : public CFX_Target { |
| 23 public: | 23 public: |
| 24 const FX_WCHAR* pwsName; | 24 const FX_WCHAR* pwsName; |
| 25 const FX_WCHAR* pwsValue; | 25 const FX_WCHAR* pwsValue; |
| 26 FDE_CSSCustomProperty* pNext; | 26 FDE_CSSCustomProperty* pNext; |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 struct FDE_CSSPROPERTYARGS { | 29 struct FDE_CSSPROPERTYARGS { |
| 30 IFX_MemoryAllocator* pStaticStore; | 30 IFX_MemoryAllocator* pStaticStore; |
| 31 std::unordered_map<uint32_t, FX_WCHAR*>* pStringCache; | 31 std::unordered_map<uint32_t, FX_WCHAR*>* pStringCache; |
| 32 const FDE_CSSPROPERTYTABLE* pProperty; | 32 const FDE_CSSPROPERTYTABLE* pProperty; |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 class CFDE_CSSDeclaration : public CFX_Target { | 35 class CFDE_CSSDeclaration : public CFX_Target { |
| 36 public: | 36 public: |
| 37 CFDE_CSSDeclaration() | 37 CFDE_CSSDeclaration() |
| 38 : m_pFirstProperty(nullptr), | 38 : m_pFirstProperty(nullptr), |
| 39 m_pLastProperty(nullptr), | 39 m_pLastProperty(nullptr), |
| 40 m_pFirstCustom(nullptr), | 40 m_pFirstCustom(nullptr), |
| 41 m_pLastCustom(nullptr) {} | 41 m_pLastCustom(nullptr) {} |
| 42 | 42 |
| 43 IFDE_CSSValue* GetProperty(FDE_CSSPROPERTY eProperty, | 43 IFDE_CSSValue* GetProperty(FDE_CSSPROPERTY eProperty, bool& bImportant) const; |
| 44 FX_BOOL& bImportant) const; | |
| 45 FX_POSITION GetStartPosition() const; | 44 FX_POSITION GetStartPosition() const; |
| 46 void GetNextProperty(FX_POSITION& pos, | 45 void GetNextProperty(FX_POSITION& pos, |
| 47 FDE_CSSPROPERTY& eProperty, | 46 FDE_CSSPROPERTY& eProperty, |
| 48 IFDE_CSSValue*& pValue, | 47 IFDE_CSSValue*& pValue, |
| 49 FX_BOOL& bImportant) const; | 48 bool& bImportant) const; |
| 50 FX_POSITION GetStartCustom() const; | 49 FX_POSITION GetStartCustom() const; |
| 51 void GetNextCustom(FX_POSITION& pos, | 50 void GetNextCustom(FX_POSITION& pos, |
| 52 CFX_WideString& wsName, | 51 CFX_WideString& wsName, |
| 53 CFX_WideString& wsValue) const; | 52 CFX_WideString& wsValue) const; |
| 54 FX_BOOL AddProperty(const FDE_CSSPROPERTYARGS* pArgs, | 53 bool AddProperty(const FDE_CSSPROPERTYARGS* pArgs, |
| 55 const FX_WCHAR* pszValue, | 54 const FX_WCHAR* pszValue, |
| 56 int32_t iValueLen); | 55 int32_t iValueLen); |
| 57 FX_BOOL AddProperty(const FDE_CSSPROPERTYARGS* pArgs, | 56 bool AddProperty(const FDE_CSSPROPERTYARGS* pArgs, |
| 58 const FX_WCHAR* pszName, | 57 const FX_WCHAR* pszName, |
| 59 int32_t iNameLen, | 58 int32_t iNameLen, |
| 60 const FX_WCHAR* pszValue, | 59 const FX_WCHAR* pszValue, |
| 61 int32_t iValueLen); | 60 int32_t iValueLen); |
| 62 | 61 |
| 63 protected: | 62 protected: |
| 64 FX_BOOL ParseTextEmphasisProperty(FDE_CSSPROPERTYARGS* pArgs, | 63 bool ParseTextEmphasisProperty(FDE_CSSPROPERTYARGS* pArgs, |
| 65 const FX_WCHAR* pszValue, | 64 const FX_WCHAR* pszValue, |
| 66 int32_t iValueLen, | 65 int32_t iValueLen, |
| 67 FX_BOOL bImportant); | 66 bool bImportant); |
| 68 FX_BOOL ParseColumnsProperty(const FDE_CSSPROPERTYARGS* pArgs, | 67 bool ParseColumnsProperty(const FDE_CSSPROPERTYARGS* pArgs, |
| 68 const FX_WCHAR* pszValue, |
| 69 int32_t iValueLen, |
| 70 bool bImportant); |
| 71 bool ParseColumnRuleProperty(const FDE_CSSPROPERTYARGS* pArgs, |
| 69 const FX_WCHAR* pszValue, | 72 const FX_WCHAR* pszValue, |
| 70 int32_t iValueLen, | 73 int32_t iValueLen, |
| 71 FX_BOOL bImportant); | 74 bool bImportant); |
| 72 FX_BOOL ParseColumnRuleProperty(const FDE_CSSPROPERTYARGS* pArgs, | 75 bool ParseOverflowProperty(const FDE_CSSPROPERTYARGS* pArgs, |
| 73 const FX_WCHAR* pszValue, | 76 const FX_WCHAR* pszValue, |
| 74 int32_t iValueLen, | 77 int32_t iValueLen, |
| 75 FX_BOOL bImportant); | 78 bool bImportant); |
| 76 FX_BOOL ParseOverflowProperty(const FDE_CSSPROPERTYARGS* pArgs, | 79 bool ParseFontProperty(const FDE_CSSPROPERTYARGS* pArgs, |
| 77 const FX_WCHAR* pszValue, | 80 const FX_WCHAR* pszValue, |
| 78 int32_t iValueLen, | 81 int32_t iValueLen, |
| 79 FX_BOOL bImportant); | 82 bool bImportant); |
| 80 FX_BOOL ParseFontProperty(const FDE_CSSPROPERTYARGS* pArgs, | 83 bool ParseBackgroundProperty(const FDE_CSSPROPERTYARGS* pArgs, |
| 84 const FX_WCHAR* pszValue, |
| 85 int32_t iValueLen, |
| 86 bool bImportant); |
| 87 bool ParseListStyleProperty(const FDE_CSSPROPERTYARGS* pArgs, |
| 88 const FX_WCHAR* pszValue, |
| 89 int32_t iValueLen, |
| 90 bool bImportant); |
| 91 bool ParseBorderPropoerty(IFX_MemoryAllocator* pStaticStore, |
| 81 const FX_WCHAR* pszValue, | 92 const FX_WCHAR* pszValue, |
| 82 int32_t iValueLen, | 93 int32_t iValueLen, |
| 83 FX_BOOL bImportant); | 94 IFDE_CSSValue*& pColor, |
| 84 FX_BOOL ParseBackgroundProperty(const FDE_CSSPROPERTYARGS* pArgs, | 95 IFDE_CSSValue*& pStyle, |
| 85 const FX_WCHAR* pszValue, | 96 IFDE_CSSValue*& pWidth) const; |
| 86 int32_t iValueLen, | |
| 87 FX_BOOL bImportant); | |
| 88 FX_BOOL ParseListStyleProperty(const FDE_CSSPROPERTYARGS* pArgs, | |
| 89 const FX_WCHAR* pszValue, | |
| 90 int32_t iValueLen, | |
| 91 FX_BOOL bImportant); | |
| 92 FX_BOOL ParseBorderPropoerty(IFX_MemoryAllocator* pStaticStore, | |
| 93 const FX_WCHAR* pszValue, | |
| 94 int32_t iValueLen, | |
| 95 IFDE_CSSValue*& pColor, | |
| 96 IFDE_CSSValue*& pStyle, | |
| 97 IFDE_CSSValue*& pWidth) const; | |
| 98 void AddBorderProperty(IFX_MemoryAllocator* pStaticStore, | 97 void AddBorderProperty(IFX_MemoryAllocator* pStaticStore, |
| 99 IFDE_CSSValue* pColor, | 98 IFDE_CSSValue* pColor, |
| 100 IFDE_CSSValue* pStyle, | 99 IFDE_CSSValue* pStyle, |
| 101 IFDE_CSSValue* pWidth, | 100 IFDE_CSSValue* pWidth, |
| 102 FX_BOOL bImportant, | 101 bool bImportant, |
| 103 FDE_CSSPROPERTY eColor, | 102 FDE_CSSPROPERTY eColor, |
| 104 FDE_CSSPROPERTY eStyle, | 103 FDE_CSSPROPERTY eStyle, |
| 105 FDE_CSSPROPERTY eWidth); | 104 FDE_CSSPROPERTY eWidth); |
| 106 FX_BOOL ParseContentProperty(const FDE_CSSPROPERTYARGS* pArgs, | 105 bool ParseContentProperty(const FDE_CSSPROPERTYARGS* pArgs, |
| 107 const FX_WCHAR* pszValue, | 106 const FX_WCHAR* pszValue, |
| 108 int32_t iValueLen, | 107 int32_t iValueLen, |
| 109 FX_BOOL bImportant); | 108 bool bImportant); |
| 110 FX_BOOL ParseCounterProperty(const FDE_CSSPROPERTYARGS* pArgs, | 109 bool ParseCounterProperty(const FDE_CSSPROPERTYARGS* pArgs, |
| 111 const FX_WCHAR* pszValue, | 110 const FX_WCHAR* pszValue, |
| 112 int32_t iValueLen, | 111 int32_t iValueLen, |
| 113 FX_BOOL bImportant); | 112 bool bImportant); |
| 114 FX_BOOL ParseValueListProperty(const FDE_CSSPROPERTYARGS* pArgs, | 113 bool ParseValueListProperty(const FDE_CSSPROPERTYARGS* pArgs, |
| 115 const FX_WCHAR* pszValue, | 114 const FX_WCHAR* pszValue, |
| 116 int32_t iValueLen, | 115 int32_t iValueLen, |
| 117 FX_BOOL bImportant); | 116 bool bImportant); |
| 118 FX_BOOL Add4ValuesProperty(IFX_MemoryAllocator* pStaticStore, | 117 bool Add4ValuesProperty(IFX_MemoryAllocator* pStaticStore, |
| 119 const CFDE_CSSValueArray& list, | 118 const CFDE_CSSValueArray& list, |
| 120 FX_BOOL bImportant, | 119 bool bImportant, |
| 121 FDE_CSSPROPERTY eLeft, | 120 FDE_CSSPROPERTY eLeft, |
| 122 FDE_CSSPROPERTY eTop, | 121 FDE_CSSPROPERTY eTop, |
| 123 FDE_CSSPROPERTY eRight, | 122 FDE_CSSPROPERTY eRight, |
| 124 FDE_CSSPROPERTY eBottom); | 123 FDE_CSSPROPERTY eBottom); |
| 125 IFDE_CSSValue* ParseNumber(const FDE_CSSPROPERTYARGS* pArgs, | 124 IFDE_CSSValue* ParseNumber(const FDE_CSSPROPERTYARGS* pArgs, |
| 126 const FX_WCHAR* pszValue, | 125 const FX_WCHAR* pszValue, |
| 127 int32_t iValueLen); | 126 int32_t iValueLen); |
| 128 IFDE_CSSValue* ParseEnum(const FDE_CSSPROPERTYARGS* pArgs, | 127 IFDE_CSSValue* ParseEnum(const FDE_CSSPROPERTYARGS* pArgs, |
| 129 const FX_WCHAR* pszValue, | 128 const FX_WCHAR* pszValue, |
| 130 int32_t iValueLen); | 129 int32_t iValueLen); |
| 131 IFDE_CSSValue* ParseColor(const FDE_CSSPROPERTYARGS* pArgs, | 130 IFDE_CSSValue* ParseColor(const FDE_CSSPROPERTYARGS* pArgs, |
| 132 const FX_WCHAR* pszValue, | 131 const FX_WCHAR* pszValue, |
| 133 int32_t iValueLen); | 132 int32_t iValueLen); |
| 134 IFDE_CSSValue* ParseURI(const FDE_CSSPROPERTYARGS* pArgs, | 133 IFDE_CSSValue* ParseURI(const FDE_CSSPROPERTYARGS* pArgs, |
| 135 const FX_WCHAR* pszValue, | 134 const FX_WCHAR* pszValue, |
| 136 int32_t iValueLen); | 135 int32_t iValueLen); |
| 137 IFDE_CSSValue* ParseString(const FDE_CSSPROPERTYARGS* pArgs, | 136 IFDE_CSSValue* ParseString(const FDE_CSSPROPERTYARGS* pArgs, |
| 138 const FX_WCHAR* pszValue, | 137 const FX_WCHAR* pszValue, |
| 139 int32_t iValueLen); | 138 int32_t iValueLen); |
| 140 IFDE_CSSValue* ParseFunction(const FDE_CSSPROPERTYARGS* pArgs, | 139 IFDE_CSSValue* ParseFunction(const FDE_CSSPROPERTYARGS* pArgs, |
| 141 const FX_WCHAR* pszValue, | 140 const FX_WCHAR* pszValue, |
| 142 int32_t iValueLen); | 141 int32_t iValueLen); |
| 143 const FX_WCHAR* CopyToLocal(const FDE_CSSPROPERTYARGS* pArgs, | 142 const FX_WCHAR* CopyToLocal(const FDE_CSSPROPERTYARGS* pArgs, |
| 144 const FX_WCHAR* pszValue, | 143 const FX_WCHAR* pszValue, |
| 145 int32_t iValueLen); | 144 int32_t iValueLen); |
| 146 void AddPropertyHolder(IFX_MemoryAllocator* pStaticStore, | 145 void AddPropertyHolder(IFX_MemoryAllocator* pStaticStore, |
| 147 FDE_CSSPROPERTY eProperty, | 146 FDE_CSSPROPERTY eProperty, |
| 148 IFDE_CSSValue* pValue, | 147 IFDE_CSSValue* pValue, |
| 149 FX_BOOL bImportant); | 148 bool bImportant); |
| 150 IFDE_CSSPrimitiveValue* NewNumberValue(IFX_MemoryAllocator* pStaticStore, | 149 IFDE_CSSPrimitiveValue* NewNumberValue(IFX_MemoryAllocator* pStaticStore, |
| 151 FDE_CSSPRIMITIVETYPE eUnit, | 150 FDE_CSSPRIMITIVETYPE eUnit, |
| 152 FX_FLOAT fValue) const; | 151 FX_FLOAT fValue) const; |
| 153 IFDE_CSSPrimitiveValue* NewEnumValue(IFX_MemoryAllocator* pStaticStore, | 152 IFDE_CSSPrimitiveValue* NewEnumValue(IFX_MemoryAllocator* pStaticStore, |
| 154 FDE_CSSPROPERTYVALUE eValue) const; | 153 FDE_CSSPROPERTYVALUE eValue) const; |
| 155 | 154 |
| 156 FDE_CSSPropertyHolder* m_pFirstProperty; | 155 FDE_CSSPropertyHolder* m_pFirstProperty; |
| 157 FDE_CSSPropertyHolder* m_pLastProperty; | 156 FDE_CSSPropertyHolder* m_pLastProperty; |
| 158 FDE_CSSCustomProperty* m_pFirstCustom; | 157 FDE_CSSCustomProperty* m_pFirstCustom; |
| 159 FDE_CSSCustomProperty* m_pLastCustom; | 158 FDE_CSSCustomProperty* m_pLastCustom; |
| 160 }; | 159 }; |
| 161 using CFDE_CSSDeclarationArray = CFX_ArrayTemplate<CFDE_CSSDeclaration*>; | 160 using CFDE_CSSDeclarationArray = CFX_ArrayTemplate<CFDE_CSSDeclaration*>; |
| 162 | 161 |
| 163 #endif // XFA_FDE_CSS_FDE_CSSDECLARATION_H_ | 162 #endif // XFA_FDE_CSS_FDE_CSSDECLARATION_H_ |
| OLD | NEW |