diff options
author | Tom Sepez <tsepez@chromium.org> | 2016-03-09 13:24:25 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2016-03-09 13:24:25 -0800 |
commit | 4f6fdbe6adf0d90886b9deb5666996603cf1207c (patch) | |
tree | 4fee37f0d6711efbfdebbb72e0ba1746c95ad05e /xfa/src/fde/css/fde_cssstyleselector.cpp | |
parent | 2e95951e06bd4d11459fb257c7c2b8fc881854e8 (diff) | |
download | pdfium-4f6fdbe6adf0d90886b9deb5666996603cf1207c.tar.xz |
Structs shouldn't inherit from CFX_Target.
There are some assumptions in the code that CAPS_NAMED
structs are POD, and can be memcpy'd, malloc'd, etc.
CFX_Target adds a virtual dtor, which is not what is
desired for many of these, so resolve by making each
a CAPS_Named class or by removing the inheritence.
In the process XFA_TextPiece was found to be malloc'd
despite having a ctor. Move this to |new|, noting that
the object is never freed (and goes out of existence
when the allocator's pool is destroyed).
BUG=pdfium:432
R=dsinclair@chromium.org
Review URL: https://codereview.chromium.org/1780753002 .
Diffstat (limited to 'xfa/src/fde/css/fde_cssstyleselector.cpp')
-rw-r--r-- | xfa/src/fde/css/fde_cssstyleselector.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/xfa/src/fde/css/fde_cssstyleselector.cpp b/xfa/src/fde/css/fde_cssstyleselector.cpp index ae9a7a5d39..ff82f9d956 100644 --- a/xfa/src/fde/css/fde_cssstyleselector.cpp +++ b/xfa/src/fde/css/fde_cssstyleselector.cpp @@ -83,7 +83,7 @@ FDE_CSSTEXTEMPHASISMARK CFDE_CSSComputedStyle::GetTextEmphasisMark() const { } return FDE_CSSTEXTEMPHASISMARK_Sesame; } -FDE_CSSRULEDATA::FDE_CSSRULEDATA(IFDE_CSSSelector* pSel, +FDE_CSSRuleData::FDE_CSSRuleData(IFDE_CSSSelector* pSel, IFDE_CSSDeclaration* pDecl, FX_DWORD dwPos) : pSelector(pSel), pDeclaration(pDecl), dwPriority(dwPos), pNext(NULL) { @@ -131,7 +131,7 @@ void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet, for (int32_t i = 0; i < iSelectors; ++i) { IFDE_CSSSelector* pSelector = pStyleRule->GetSelectorList(i); if (pSelector->GetType() == FDE_CSSSELECTORTYPE_Persudo) { - FDE_CSSRULEDATA* pData = NewRuleData(pSelector, pDeclaration); + FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration); AddRuleTo(m_pPersudoRules, pData); continue; } @@ -142,7 +142,7 @@ void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet, } IFDE_CSSSelector* pNext = pSelector->GetNextSelector(); if (pNext == NULL) { - FDE_CSSRULEDATA* pData = NewRuleData(pSelector, pDeclaration); + FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration); AddRuleTo(m_pUniversalRules, pData); continue; } @@ -183,8 +183,8 @@ void CFDE_CSSRuleCollection::AddRuleTo(CFX_MapPtrToPtr& map, IFDE_CSSSelector* pSel, IFDE_CSSDeclaration* pDecl) { void* pKey = (void*)(uintptr_t)dwKey; - FDE_CSSRULEDATA* pData = NewRuleData(pSel, pDecl); - FDE_CSSRULEDATA* pList = NULL; + FDE_CSSRuleData* pData = NewRuleData(pSel, pDecl); + FDE_CSSRuleData* pList = NULL; if (!map.Lookup(pKey, (void*&)pList)) { map.SetAt(pKey, pData); } else if (AddRuleTo(pList, pData)) { @@ -192,8 +192,8 @@ void CFDE_CSSRuleCollection::AddRuleTo(CFX_MapPtrToPtr& map, } } -FX_BOOL CFDE_CSSRuleCollection::AddRuleTo(FDE_CSSRULEDATA*& pList, - FDE_CSSRULEDATA* pData) { +FX_BOOL CFDE_CSSRuleCollection::AddRuleTo(FDE_CSSRuleData*& pList, + FDE_CSSRuleData* pData) { if (pList) { pData->pNext = pList->pNext; pList->pNext = pData; @@ -204,11 +204,11 @@ FX_BOOL CFDE_CSSRuleCollection::AddRuleTo(FDE_CSSRULEDATA*& pList, return TRUE; } -FDE_CSSRULEDATA* CFDE_CSSRuleCollection::NewRuleData( +FDE_CSSRuleData* CFDE_CSSRuleCollection::NewRuleData( IFDE_CSSSelector* pSel, IFDE_CSSDeclaration* pDecl) { return FXTARGET_NewWith(m_pStaticStore) - FDE_CSSRULEDATA(pSel, pDecl, ++m_iSelectors); + FDE_CSSRuleData(pSel, pDecl, ++m_iSelectors); } IFDE_CSSStyleSelector* IFDE_CSSStyleSelector::Create() { @@ -322,7 +322,7 @@ int32_t CFDE_CSSStyleSelector::MatchDeclarations( CFDE_CSSDeclarationArray& matchedDecls, FDE_CSSPERSUDO ePersudoType) { FXSYS_assert(m_pAccelerator != NULL && pTag != NULL); - FDE_CSSTAGCACHE* pCache = m_pAccelerator->GetTopElement(); + FDE_CSSTagCache* pCache = m_pAccelerator->GetTopElement(); FXSYS_assert(pCache != NULL && pCache->GetTag() == pTag); matchedDecls.RemoveAt(0, matchedDecls.GetSize()); for (int32_t ePriority = FDE_CSSSTYLESHEETPRIORITY_MAX - 1; ePriority >= 0; @@ -349,7 +349,7 @@ int32_t CFDE_CSSStyleSelector::MatchDeclarations( } std::sort(m_MatchedRules.begin(), m_MatchedRules.end(), - [](const FDE_CSSRULEDATA* p1, const FDE_CSSRULEDATA* p2) { + [](const FDE_CSSRuleData* p1, const FDE_CSSRuleData* p2) { return p1->dwPriority < p2->dwPriority; }); for (const auto& rule : m_MatchedRules) @@ -359,8 +359,8 @@ int32_t CFDE_CSSStyleSelector::MatchDeclarations( return matchedDecls.GetSize(); } -void CFDE_CSSStyleSelector::MatchRules(FDE_CSSTAGCACHE* pCache, - FDE_CSSRULEDATA* pList, +void CFDE_CSSStyleSelector::MatchRules(FDE_CSSTagCache* pCache, + FDE_CSSRuleData* pList, FDE_CSSPERSUDO ePersudoType) { while (pList) { if (MatchSelector(pCache, pList->pSelector, ePersudoType)) @@ -369,7 +369,7 @@ void CFDE_CSSStyleSelector::MatchRules(FDE_CSSTAGCACHE* pCache, } } -FX_BOOL CFDE_CSSStyleSelector::MatchSelector(FDE_CSSTAGCACHE* pCache, +FX_BOOL CFDE_CSSStyleSelector::MatchSelector(FDE_CSSTagCache* pCache, IFDE_CSSSelector* pSel, FDE_CSSPERSUDO ePersudoType) { FX_DWORD dwHash; |