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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 break; | 85 break; |
86 case FDE_CSSSELECTORTYPE_Class: | 86 case FDE_CSSSELECTORTYPE_Class: |
87 AddRuleTo(m_ClassRules, pNext->GetNameHash(), pSelector, | 87 AddRuleTo(m_ClassRules, pNext->GetNameHash(), pSelector, |
88 pDeclaration); | 88 pDeclaration); |
89 break; | 89 break; |
90 case FDE_CSSSELECTORTYPE_Descendant: | 90 case FDE_CSSSELECTORTYPE_Descendant: |
91 case FDE_CSSSELECTORTYPE_Element: | 91 case FDE_CSSSELECTORTYPE_Element: |
92 AddRuleTo(m_pUniversalRules, NewRuleData(pSelector, pDeclaration)); | 92 AddRuleTo(m_pUniversalRules, NewRuleData(pSelector, pDeclaration)); |
93 break; | 93 break; |
94 default: | 94 default: |
95 ASSERT(FALSE); | 95 ASSERT(false); |
96 break; | 96 break; |
97 } | 97 } |
98 } | 98 } |
99 } break; | 99 } break; |
100 case FDE_CSSRULETYPE_Media: { | 100 case FDE_CSSRULETYPE_Media: { |
101 IFDE_CSSMediaRule* pMediaRule = static_cast<IFDE_CSSMediaRule*>(pRule); | 101 IFDE_CSSMediaRule* pMediaRule = static_cast<IFDE_CSSMediaRule*>(pRule); |
102 if (pMediaRule->GetMediaList() & dwMediaList) { | 102 if (pMediaRule->GetMediaList() & dwMediaList) { |
103 int32_t iRules = pMediaRule->CountRules(); | 103 int32_t iRules = pMediaRule->CountRules(); |
104 for (int32_t i = 0; i < iRules; ++i) { | 104 for (int32_t i = 0; i < iRules; ++i) { |
105 AddRulesFrom(pStyleSheet, pMediaRule->GetRule(i), dwMediaList, | 105 AddRulesFrom(pStyleSheet, pMediaRule->GetRule(i), dwMediaList, |
(...skipping 13 matching lines...) Expand all Loading... |
119 void* pKey = (void*)(uintptr_t)dwKey; | 119 void* pKey = (void*)(uintptr_t)dwKey; |
120 FDE_CSSRuleData* pData = NewRuleData(pSel, pDecl); | 120 FDE_CSSRuleData* pData = NewRuleData(pSel, pDecl); |
121 FDE_CSSRuleData* pList = nullptr; | 121 FDE_CSSRuleData* pList = nullptr; |
122 if (!map.Lookup(pKey, (void*&)pList)) { | 122 if (!map.Lookup(pKey, (void*&)pList)) { |
123 map.SetAt(pKey, pData); | 123 map.SetAt(pKey, pData); |
124 } else if (AddRuleTo(pList, pData)) { | 124 } else if (AddRuleTo(pList, pData)) { |
125 map.SetAt(pKey, pList); | 125 map.SetAt(pKey, pList); |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 FX_BOOL CFDE_CSSRuleCollection::AddRuleTo(FDE_CSSRuleData*& pList, | 129 bool CFDE_CSSRuleCollection::AddRuleTo(FDE_CSSRuleData*& pList, |
130 FDE_CSSRuleData* pData) { | 130 FDE_CSSRuleData* pData) { |
131 if (pList) { | 131 if (pList) { |
132 pData->pNext = pList->pNext; | 132 pData->pNext = pList->pNext; |
133 pList->pNext = pData; | 133 pList->pNext = pData; |
134 return FALSE; | 134 return false; |
135 } | 135 } |
136 | 136 |
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 |