OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "xfa/fde/css/fde_cssstyleselector.h" | 7 #include "xfa/fde/css/fde_cssstyleselector.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 21 matching lines...) Expand all Loading... |
32 m_pUniversalRules(nullptr), | 32 m_pUniversalRules(nullptr), |
33 m_pPersudoRules(nullptr), | 33 m_pPersudoRules(nullptr), |
34 m_iSelectors(0) {} | 34 m_iSelectors(0) {} |
35 | 35 |
36 CFDE_CSSRuleCollection::~CFDE_CSSRuleCollection() { | 36 CFDE_CSSRuleCollection::~CFDE_CSSRuleCollection() { |
37 Clear(); | 37 Clear(); |
38 } | 38 } |
39 | 39 |
40 void CFDE_CSSRuleCollection::AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets, | 40 void CFDE_CSSRuleCollection::AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets, |
41 uint32_t dwMediaList, | 41 uint32_t dwMediaList, |
42 IFGAS_FontMgr* pFontMgr) { | 42 CFGAS_FontMgr* pFontMgr) { |
43 int32_t iSheets = sheets.GetSize(); | 43 int32_t iSheets = sheets.GetSize(); |
44 for (int32_t i = 0; i < iSheets; ++i) { | 44 for (int32_t i = 0; i < iSheets; ++i) { |
45 IFDE_CSSStyleSheet* pSheet = sheets.GetAt(i); | 45 IFDE_CSSStyleSheet* pSheet = sheets.GetAt(i); |
46 if (uint32_t dwMatchMedia = pSheet->GetMediaList() & dwMediaList) { | 46 if (uint32_t dwMatchMedia = pSheet->GetMediaList() & dwMediaList) { |
47 int32_t iRules = pSheet->CountRules(); | 47 int32_t iRules = pSheet->CountRules(); |
48 for (int32_t j = 0; j < iRules; j++) { | 48 for (int32_t j = 0; j < iRules; j++) { |
49 AddRulesFrom(pSheet, pSheet->GetRule(j), dwMatchMedia, pFontMgr); | 49 AddRulesFrom(pSheet, pSheet->GetRule(j), dwMatchMedia, pFontMgr); |
50 } | 50 } |
51 } | 51 } |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet, | 55 void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet, |
56 IFDE_CSSRule* pRule, | 56 IFDE_CSSRule* pRule, |
57 uint32_t dwMediaList, | 57 uint32_t dwMediaList, |
58 IFGAS_FontMgr* pFontMgr) { | 58 CFGAS_FontMgr* pFontMgr) { |
59 switch (pRule->GetType()) { | 59 switch (pRule->GetType()) { |
60 case FDE_CSSRULETYPE_Style: { | 60 case FDE_CSSRULETYPE_Style: { |
61 IFDE_CSSStyleRule* pStyleRule = static_cast<IFDE_CSSStyleRule*>(pRule); | 61 IFDE_CSSStyleRule* pStyleRule = static_cast<IFDE_CSSStyleRule*>(pRule); |
62 CFDE_CSSDeclaration* pDeclaration = pStyleRule->GetDeclaration(); | 62 CFDE_CSSDeclaration* pDeclaration = pStyleRule->GetDeclaration(); |
63 int32_t iSelectors = pStyleRule->CountSelectorLists(); | 63 int32_t iSelectors = pStyleRule->CountSelectorLists(); |
64 for (int32_t i = 0; i < iSelectors; ++i) { | 64 for (int32_t i = 0; i < iSelectors; ++i) { |
65 CFDE_CSSSelector* pSelector = pStyleRule->GetSelectorList(i); | 65 CFDE_CSSSelector* pSelector = pStyleRule->GetSelectorList(i); |
66 if (pSelector->GetType() == FDE_CSSSELECTORTYPE_Persudo) { | 66 if (pSelector->GetType() == FDE_CSSSELECTORTYPE_Persudo) { |
67 FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration); | 67 FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration); |
68 AddRuleTo(m_pPersudoRules, pData); | 68 AddRuleTo(m_pPersudoRules, pData); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 pList = pData; | 137 pList = pData; |
138 return true; | 138 return true; |
139 } | 139 } |
140 | 140 |
141 FDE_CSSRuleData* CFDE_CSSRuleCollection::NewRuleData( | 141 FDE_CSSRuleData* CFDE_CSSRuleCollection::NewRuleData( |
142 CFDE_CSSSelector* pSel, | 142 CFDE_CSSSelector* pSel, |
143 CFDE_CSSDeclaration* pDecl) { | 143 CFDE_CSSDeclaration* pDecl) { |
144 return FXTARGET_NewWith(m_pStaticStore) | 144 return FXTARGET_NewWith(m_pStaticStore) |
145 FDE_CSSRuleData(pSel, pDecl, ++m_iSelectors); | 145 FDE_CSSRuleData(pSel, pDecl, ++m_iSelectors); |
146 } | 146 } |
OLD | NEW |