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 #include "xfa/fde/css/fde_cssstyleselector.h" | 7 #include "xfa/fde/css/fde_cssstyleselector.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 m_pFixedStyleStore(NULL), | 216 m_pFixedStyleStore(NULL), |
217 m_pAccelerator(NULL) { | 217 m_pAccelerator(NULL) { |
218 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_High] = FDE_CSSSTYLESHEETGROUP_Author; | 218 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_High] = FDE_CSSSTYLESHEETGROUP_Author; |
219 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Mid] = FDE_CSSSTYLESHEETGROUP_User; | 219 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Mid] = FDE_CSSSTYLESHEETGROUP_User; |
220 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Low] = | 220 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Low] = |
221 FDE_CSSSTYLESHEETGROUP_UserAgent; | 221 FDE_CSSSTYLESHEETGROUP_UserAgent; |
222 } | 222 } |
223 | 223 |
224 CFDE_CSSStyleSelector::~CFDE_CSSStyleSelector() { | 224 CFDE_CSSStyleSelector::~CFDE_CSSStyleSelector() { |
225 Reset(); | 225 Reset(); |
226 if (m_pInlineStyleStore) | 226 delete m_pInlineStyleStore; |
227 m_pInlineStyleStore->Release(); | 227 delete m_pFixedStyleStore; |
228 if (m_pFixedStyleStore) | |
229 m_pFixedStyleStore->Release(); | |
230 delete m_pAccelerator; | 228 delete m_pAccelerator; |
231 } | 229 } |
232 | 230 |
233 void CFDE_CSSStyleSelector::SetFontMgr(IFX_FontMgr* pFontMgr) { | 231 void CFDE_CSSStyleSelector::SetFontMgr(IFX_FontMgr* pFontMgr) { |
234 m_pFontMgr = pFontMgr; | 232 m_pFontMgr = pFontMgr; |
235 } | 233 } |
236 void CFDE_CSSStyleSelector::SetDefFontSize(FX_FLOAT fFontSize) { | 234 void CFDE_CSSStyleSelector::SetDefFontSize(FX_FLOAT fFontSize) { |
237 ASSERT(fFontSize > 0); | 235 ASSERT(fFontSize > 0); |
238 m_fDefFontSize = fFontSize; | 236 m_fDefFontSize = fFontSize; |
239 } | 237 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) { | 293 for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) { |
296 CFDE_CSSRuleCollection& rules = m_RuleCollection[iGroup]; | 294 CFDE_CSSRuleCollection& rules = m_RuleCollection[iGroup]; |
297 rules.m_pStaticStore = m_pRuleDataStore; | 295 rules.m_pStaticStore = m_pRuleDataStore; |
298 rules.AddRulesFrom(m_SheetGroups[iGroup], dwMediaList, m_pFontMgr); | 296 rules.AddRulesFrom(m_SheetGroups[iGroup], dwMediaList, m_pFontMgr); |
299 } | 297 } |
300 } | 298 } |
301 void CFDE_CSSStyleSelector::Reset() { | 299 void CFDE_CSSStyleSelector::Reset() { |
302 for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) { | 300 for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) { |
303 m_RuleCollection[iGroup].Clear(); | 301 m_RuleCollection[iGroup].Clear(); |
304 } | 302 } |
305 if (m_pRuleDataStore != NULL) { | 303 delete m_pRuleDataStore; |
306 m_pRuleDataStore->Release(); | 304 m_pRuleDataStore = nullptr; |
307 m_pRuleDataStore = NULL; | |
308 } | |
309 } | 305 } |
310 int32_t CFDE_CSSStyleSelector::MatchDeclarations( | 306 int32_t CFDE_CSSStyleSelector::MatchDeclarations( |
311 CXFA_CSSTagProvider* pTag, | 307 CXFA_CSSTagProvider* pTag, |
312 CFDE_CSSDeclarationArray& matchedDecls, | 308 CFDE_CSSDeclarationArray& matchedDecls, |
313 FDE_CSSPERSUDO ePersudoType) { | 309 FDE_CSSPERSUDO ePersudoType) { |
314 ASSERT(m_pAccelerator && pTag); | 310 ASSERT(m_pAccelerator && pTag); |
315 | 311 |
316 FDE_CSSTagCache* pCache = m_pAccelerator->GetTopElement(); | 312 FDE_CSSTagCache* pCache = m_pAccelerator->GetTopElement(); |
317 ASSERT(pCache && pCache->GetTag() == pTag); | 313 ASSERT(pCache && pCache->GetTag() == pTag); |
318 | 314 |
(...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1779 return FDE_CSSTEXTTRANSFORM_LowerCase; | 1775 return FDE_CSSTEXTTRANSFORM_LowerCase; |
1780 default: | 1776 default: |
1781 return FDE_CSSTEXTTRANSFORM_None; | 1777 return FDE_CSSTEXTTRANSFORM_None; |
1782 } | 1778 } |
1783 } | 1779 } |
1784 FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant( | 1780 FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant( |
1785 FDE_CSSPROPERTYVALUE eValue) { | 1781 FDE_CSSPROPERTYVALUE eValue) { |
1786 return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps | 1782 return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps |
1787 : FDE_CSSFONTVARIANT_Normal; | 1783 : FDE_CSSFONTVARIANT_Normal; |
1788 } | 1784 } |
OLD | NEW |