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_CSSSTYLESHEET_H_ | 7 #ifndef XFA_FDE_CSS_FDE_CSSSTYLESHEET_H_ |
8 #define XFA_FDE_CSS_FDE_CSSSTYLESHEET_H_ | 8 #define XFA_FDE_CSS_FDE_CSSSTYLESHEET_H_ |
9 | 9 |
10 #include "core/fxcrt/include/fx_ext.h" | 10 #include "core/fxcrt/include/fx_ext.h" |
11 #include "xfa/fde/css/fde_cssdeclaration.h" | 11 #include "xfa/fde/css/fde_cssdeclaration.h" |
12 | 12 |
13 class CFDE_CSSSyntaxParser; | 13 class CFDE_CSSSyntaxParser; |
14 | 14 |
15 class CFDE_CSSSelector : public CFX_Target { | 15 class CFDE_CSSSelector : public CFX_Target { |
16 public: | 16 public: |
17 CFDE_CSSSelector(FDE_CSSSELECTORTYPE eType, | 17 CFDE_CSSSelector(FDE_CSSSELECTORTYPE eType, |
18 const FX_WCHAR* psz, | 18 const FX_WCHAR* psz, |
19 int32_t iLen, | 19 int32_t iLen, |
20 bool bIgnoreCase) | 20 bool bIgnoreCase) |
21 : m_eType(eType), | 21 : m_eType(eType), |
22 m_dwHash(FX_HashCode_GetW(CFX_WideStringC(psz, iLen), bIgnoreCase)), | 22 m_dwHash(FX_HashCode_GetW(CFX_WideStringC(psz, iLen), bIgnoreCase)), |
23 m_pNext(nullptr) {} | 23 m_pNext(nullptr) {} |
24 virtual FDE_CSSSELECTORTYPE GetType() const { return m_eType; } | 24 virtual FDE_CSSSELECTORTYPE GetType() const { return m_eType; } |
25 | 25 |
26 virtual uint32_t GetNameHash() const { return m_dwHash; } | 26 virtual uint32_t GetNameHash() const { return m_dwHash; } |
27 | 27 |
28 virtual CFDE_CSSSelector* GetNextSelector() const { return m_pNext; } | 28 virtual CFDE_CSSSelector* GetNextSelector() const { return m_pNext; } |
29 static CFDE_CSSSelector* FromString(IFX_MEMAllocator* pStaticStore, | 29 static CFDE_CSSSelector* FromString(IFX_MemoryAllocator* pStaticStore, |
30 const FX_WCHAR* psz, | 30 const FX_WCHAR* psz, |
31 int32_t iLen); | 31 int32_t iLen); |
32 void SetNext(CFDE_CSSSelector* pNext) { m_pNext = pNext; } | 32 void SetNext(CFDE_CSSSelector* pNext) { m_pNext = pNext; } |
33 | 33 |
34 protected: | 34 protected: |
35 static CFDE_CSSSelector* ParseSelector(IFX_MEMAllocator* pStaticStore, | 35 static CFDE_CSSSelector* ParseSelector(IFX_MemoryAllocator* pStaticStore, |
36 const FX_WCHAR* psz, | 36 const FX_WCHAR* psz, |
37 int32_t& iOff, | 37 int32_t& iOff, |
38 int32_t iLen, | 38 int32_t iLen, |
39 FDE_CSSSELECTORTYPE eType); | 39 FDE_CSSSELECTORTYPE eType); |
40 void SetType(FDE_CSSSELECTORTYPE eType) { m_eType = eType; } | 40 void SetType(FDE_CSSSELECTORTYPE eType) { m_eType = eType; } |
41 FDE_CSSSELECTORTYPE m_eType; | 41 FDE_CSSSELECTORTYPE m_eType; |
42 uint32_t m_dwHash; | 42 uint32_t m_dwHash; |
43 CFDE_CSSSelector* m_pNext; | 43 CFDE_CSSSelector* m_pNext; |
44 }; | 44 }; |
45 typedef CFX_ArrayTemplate<CFDE_CSSSelector*> CFDE_CSSSelectorArray; | 45 typedef CFX_ArrayTemplate<CFDE_CSSSelector*> CFDE_CSSSelectorArray; |
46 | 46 |
47 class CFDE_CSSStyleRule : public IFDE_CSSStyleRule, public CFX_Target { | 47 class CFDE_CSSStyleRule : public IFDE_CSSStyleRule, public CFX_Target { |
48 public: | 48 public: |
49 CFDE_CSSStyleRule() : m_ppSelector(NULL), m_iSelectors(0) {} | 49 CFDE_CSSStyleRule() : m_ppSelector(NULL), m_iSelectors(0) {} |
50 int32_t CountSelectorLists() const override { return m_iSelectors; } | 50 int32_t CountSelectorLists() const override { return m_iSelectors; } |
51 CFDE_CSSSelector* GetSelectorList(int32_t index) const override { | 51 CFDE_CSSSelector* GetSelectorList(int32_t index) const override { |
52 return m_ppSelector[index]; | 52 return m_ppSelector[index]; |
53 } | 53 } |
54 | 54 |
55 CFDE_CSSDeclaration* GetDeclaration() override { return &m_Declaration; } | 55 CFDE_CSSDeclaration* GetDeclaration() override { return &m_Declaration; } |
56 CFDE_CSSDeclaration& GetDeclImp() { return m_Declaration; } | 56 CFDE_CSSDeclaration& GetDeclImp() { return m_Declaration; } |
57 void SetSelector(IFX_MEMAllocator* pStaticStore, | 57 void SetSelector(IFX_MemoryAllocator* pStaticStore, |
58 const CFDE_CSSSelectorArray& list); | 58 const CFDE_CSSSelectorArray& list); |
59 | 59 |
60 protected: | 60 protected: |
61 CFDE_CSSDeclaration m_Declaration; | 61 CFDE_CSSDeclaration m_Declaration; |
62 CFDE_CSSSelector** m_ppSelector; | 62 CFDE_CSSSelector** m_ppSelector; |
63 int32_t m_iSelectors; | 63 int32_t m_iSelectors; |
64 }; | 64 }; |
65 class CFDE_CSSMediaRule : public IFDE_CSSMediaRule, public CFX_Target { | 65 class CFDE_CSSMediaRule : public IFDE_CSSMediaRule, public CFX_Target { |
66 public: | 66 public: |
67 CFDE_CSSMediaRule(uint32_t dwMediaList) : m_dwMediaList(dwMediaList) {} | 67 CFDE_CSSMediaRule(uint32_t dwMediaList) : m_dwMediaList(dwMediaList) {} |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 CFDE_CSSRuleArray& ruleArray); | 123 CFDE_CSSRuleArray& ruleArray); |
124 FDE_CSSSYNTAXSTATUS LoadImportRule(CFDE_CSSSyntaxParser* pSyntax); | 124 FDE_CSSSYNTAXSTATUS LoadImportRule(CFDE_CSSSyntaxParser* pSyntax); |
125 FDE_CSSSYNTAXSTATUS LoadPageRule(CFDE_CSSSyntaxParser* pSyntax); | 125 FDE_CSSSYNTAXSTATUS LoadPageRule(CFDE_CSSSyntaxParser* pSyntax); |
126 FDE_CSSSYNTAXSTATUS LoadMediaRule(CFDE_CSSSyntaxParser* pSyntax); | 126 FDE_CSSSYNTAXSTATUS LoadMediaRule(CFDE_CSSSyntaxParser* pSyntax); |
127 FDE_CSSSYNTAXSTATUS LoadFontFaceRule(CFDE_CSSSyntaxParser* pSyntax, | 127 FDE_CSSSYNTAXSTATUS LoadFontFaceRule(CFDE_CSSSyntaxParser* pSyntax, |
128 CFDE_CSSRuleArray& ruleArray); | 128 CFDE_CSSRuleArray& ruleArray); |
129 FDE_CSSSYNTAXSTATUS SkipRuleSet(CFDE_CSSSyntaxParser* pSyntax); | 129 FDE_CSSSYNTAXSTATUS SkipRuleSet(CFDE_CSSSyntaxParser* pSyntax); |
130 uint16_t m_wCodePage; | 130 uint16_t m_wCodePage; |
131 uint16_t m_wRefCount; | 131 uint16_t m_wRefCount; |
132 uint32_t m_dwMediaList; | 132 uint32_t m_dwMediaList; |
133 IFX_MEMAllocator* m_pAllocator; | 133 IFX_MemoryAllocator* m_pAllocator; |
134 CFDE_CSSRuleArray m_RuleArray; | 134 CFDE_CSSRuleArray m_RuleArray; |
135 CFX_WideString m_szUrl; | 135 CFX_WideString m_szUrl; |
136 CFDE_CSSSelectorArray m_Selectors; | 136 CFDE_CSSSelectorArray m_Selectors; |
137 CFX_MapPtrToPtr m_StringCache; | 137 CFX_MapPtrToPtr m_StringCache; |
138 }; | 138 }; |
139 | 139 |
140 #endif // XFA_FDE_CSS_FDE_CSSSTYLESHEET_H_ | 140 #endif // XFA_FDE_CSS_FDE_CSSSTYLESHEET_H_ |
OLD | NEW |