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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 240 |
241 CFDE_CSSAccelerator* CFDE_CSSStyleSelector::InitAccelerator() { | 241 CFDE_CSSAccelerator* CFDE_CSSStyleSelector::InitAccelerator() { |
242 if (!m_pAccelerator) | 242 if (!m_pAccelerator) |
243 m_pAccelerator = new CFDE_CSSAccelerator; | 243 m_pAccelerator = new CFDE_CSSAccelerator; |
244 m_pAccelerator->Clear(); | 244 m_pAccelerator->Clear(); |
245 return m_pAccelerator; | 245 return m_pAccelerator; |
246 } | 246 } |
247 | 247 |
248 IFDE_CSSComputedStyle* CFDE_CSSStyleSelector::CreateComputedStyle( | 248 IFDE_CSSComputedStyle* CFDE_CSSStyleSelector::CreateComputedStyle( |
249 IFDE_CSSComputedStyle* pParentStyle) { | 249 IFDE_CSSComputedStyle* pParentStyle) { |
250 if (m_pFixedStyleStore == NULL) { | 250 if (!m_pFixedStyleStore) { |
251 m_pFixedStyleStore = FX_CreateAllocator(FX_ALLOCTYPE_Fixed, 16, | 251 m_pFixedStyleStore = IFX_MemoryAllocator::Create( |
252 sizeof(CFDE_CSSComputedStyle)); | 252 FX_ALLOCTYPE_Fixed, 16, sizeof(CFDE_CSSComputedStyle)); |
253 ASSERT(m_pFixedStyleStore != NULL); | |
254 } | 253 } |
255 CFDE_CSSComputedStyle* pStyle = FXTARGET_NewWith(m_pFixedStyleStore) | 254 CFDE_CSSComputedStyle* pStyle = FXTARGET_NewWith(m_pFixedStyleStore) |
256 CFDE_CSSComputedStyle(m_pFixedStyleStore); | 255 CFDE_CSSComputedStyle(m_pFixedStyleStore); |
257 if (pParentStyle) { | 256 if (pParentStyle) { |
258 pStyle->m_InheritedData = | 257 pStyle->m_InheritedData = |
259 ((CFDE_CSSComputedStyle*)pParentStyle)->m_InheritedData; | 258 ((CFDE_CSSComputedStyle*)pParentStyle)->m_InheritedData; |
260 } else { | 259 } else { |
261 pStyle->m_InheritedData.Reset(); | 260 pStyle->m_InheritedData.Reset(); |
262 } | 261 } |
263 pStyle->m_NonInheritedData.Reset(); | 262 pStyle->m_NonInheritedData.Reset(); |
(...skipping 21 matching lines...) Expand all Loading... |
285 } | 284 } |
286 return TRUE; | 285 return TRUE; |
287 } | 286 } |
288 void CFDE_CSSStyleSelector::SetStylePriority( | 287 void CFDE_CSSStyleSelector::SetStylePriority( |
289 FDE_CSSSTYLESHEETGROUP eType, | 288 FDE_CSSSTYLESHEETGROUP eType, |
290 FDE_CSSSTYLESHEETPRIORITY ePriority) { | 289 FDE_CSSSTYLESHEETPRIORITY ePriority) { |
291 m_ePriorities[ePriority] = eType; | 290 m_ePriorities[ePriority] = eType; |
292 } | 291 } |
293 void CFDE_CSSStyleSelector::UpdateStyleIndex(uint32_t dwMediaList) { | 292 void CFDE_CSSStyleSelector::UpdateStyleIndex(uint32_t dwMediaList) { |
294 Reset(); | 293 Reset(); |
295 m_pRuleDataStore = FX_CreateAllocator(FX_ALLOCTYPE_Static, 1024, 0); | 294 m_pRuleDataStore = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 1024, 0); |
296 ASSERT(m_pRuleDataStore != NULL); | |
297 for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) { | 295 for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) { |
298 CFDE_CSSRuleCollection& rules = m_RuleCollection[iGroup]; | 296 CFDE_CSSRuleCollection& rules = m_RuleCollection[iGroup]; |
299 rules.m_pStaticStore = m_pRuleDataStore; | 297 rules.m_pStaticStore = m_pRuleDataStore; |
300 rules.AddRulesFrom(m_SheetGroups[iGroup], dwMediaList, m_pFontMgr); | 298 rules.AddRulesFrom(m_SheetGroups[iGroup], dwMediaList, m_pFontMgr); |
301 } | 299 } |
302 } | 300 } |
303 void CFDE_CSSStyleSelector::Reset() { | 301 void CFDE_CSSStyleSelector::Reset() { |
304 for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) { | 302 for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) { |
305 m_RuleCollection[iGroup].Clear(); | 303 m_RuleCollection[iGroup].Clear(); |
306 } | 304 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 const CFDE_CSSDeclaration** ppDeclArray, | 416 const CFDE_CSSDeclaration** ppDeclArray, |
419 int32_t iDeclCount, | 417 int32_t iDeclCount, |
420 IFDE_CSSComputedStyle* pDestStyle) { | 418 IFDE_CSSComputedStyle* pDestStyle) { |
421 ASSERT(iDeclCount >= 0); | 419 ASSERT(iDeclCount >= 0); |
422 ASSERT(pDestStyle); | 420 ASSERT(pDestStyle); |
423 | 421 |
424 static const uint32_t s_dwStyleHash = FX_HashCode_GetW(L"style", true); | 422 static const uint32_t s_dwStyleHash = FX_HashCode_GetW(L"style", true); |
425 static const uint32_t s_dwAlignHash = FX_HashCode_GetW(L"align", true); | 423 static const uint32_t s_dwAlignHash = FX_HashCode_GetW(L"align", true); |
426 | 424 |
427 if (!pTag->empty()) { | 425 if (!pTag->empty()) { |
428 if (!m_pInlineStyleStore) | 426 if (!m_pInlineStyleStore) { |
429 m_pInlineStyleStore = FX_CreateAllocator(FX_ALLOCTYPE_Static, 2048, 0); | 427 m_pInlineStyleStore = |
430 | 428 IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 2048, 0); |
| 429 } |
431 CFDE_CSSDeclaration* pDecl = nullptr; | 430 CFDE_CSSDeclaration* pDecl = nullptr; |
432 for (auto it : *pTag) { | 431 for (auto it : *pTag) { |
433 CFX_WideString wsAttri = it.first; | 432 CFX_WideString wsAttri = it.first; |
434 CFX_WideString wsValue = it.second; | 433 CFX_WideString wsValue = it.second; |
435 uint32_t dwAttriHash = FX_HashCode_GetW(wsAttri.AsStringC(), true); | 434 uint32_t dwAttriHash = FX_HashCode_GetW(wsAttri.AsStringC(), true); |
436 if (dwAttriHash == s_dwStyleHash) { | 435 if (dwAttriHash == s_dwStyleHash) { |
437 if (!pDecl) | 436 if (!pDecl) |
438 pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration; | 437 pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration; |
439 | 438 |
440 AppendInlineStyle(pDecl, wsValue.c_str(), wsValue.GetLength()); | 439 AppendInlineStyle(pDecl, wsValue.c_str(), wsValue.GetLength()); |
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1780 return FDE_CSSTEXTTRANSFORM_LowerCase; | 1779 return FDE_CSSTEXTTRANSFORM_LowerCase; |
1781 default: | 1780 default: |
1782 return FDE_CSSTEXTTRANSFORM_None; | 1781 return FDE_CSSTEXTTRANSFORM_None; |
1783 } | 1782 } |
1784 } | 1783 } |
1785 FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant( | 1784 FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant( |
1786 FDE_CSSPROPERTYVALUE eValue) { | 1785 FDE_CSSPROPERTYVALUE eValue) { |
1787 return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps | 1786 return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps |
1788 : FDE_CSSFONTVARIANT_Normal; | 1787 : FDE_CSSFONTVARIANT_Normal; |
1789 } | 1788 } |
OLD | NEW |