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 | |
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')
-rw-r--r-- | xfa/src/fde/css/fde_csscache.cpp | 26 | ||||
-rw-r--r-- | xfa/src/fde/css/fde_csscache.h | 23 | ||||
-rw-r--r-- | xfa/src/fde/css/fde_cssdeclaration.cpp | 14 | ||||
-rw-r--r-- | xfa/src/fde/css/fde_cssdeclaration.h | 20 | ||||
-rw-r--r-- | xfa/src/fde/css/fde_cssstyleselector.cpp | 28 | ||||
-rw-r--r-- | xfa/src/fde/css/fde_cssstyleselector.h | 38 | ||||
-rw-r--r-- | xfa/src/fde/fde_iterator.h | 2 | ||||
-rw-r--r-- | xfa/src/fxfa/app/xfa_fftext.cpp | 2 | ||||
-rw-r--r-- | xfa/src/fxfa/app/xfa_textlayout.cpp | 21 | ||||
-rw-r--r-- | xfa/src/fxfa/app/xfa_textlayout.h | 13 |
10 files changed, 95 insertions, 92 deletions
diff --git a/xfa/src/fde/css/fde_csscache.cpp b/xfa/src/fde/css/fde_csscache.cpp index 3fee9f862f..012585bfd0 100644 --- a/xfa/src/fde/css/fde_csscache.cpp +++ b/xfa/src/fde/css/fde_csscache.cpp @@ -10,12 +10,12 @@ #include "core/include/fxcrt/fx_ext.h" -FDE_CSSCACHEITEM::FDE_CSSCACHEITEM(IFDE_CSSStyleSheet* p) +FDE_CSSCacheItem::FDE_CSSCacheItem(IFDE_CSSStyleSheet* p) : pStylesheet(p), dwActivity(0) { FXSYS_assert(pStylesheet); pStylesheet->AddRef(); } -FDE_CSSCACHEITEM::~FDE_CSSCACHEITEM() { +FDE_CSSCacheItem::~FDE_CSSCacheItem() { pStylesheet->Release(); } IFDE_CSSStyleSheetCache* IFDE_CSSStyleSheetCache::Create() { @@ -27,7 +27,7 @@ CFDE_CSSStyleSheetCache::CFDE_CSSStyleSheetCache() CFDE_CSSStyleSheetCache::~CFDE_CSSStyleSheetCache() { for (const auto& pair : m_Stylesheets) { - FXTARGET_DeleteWith(FDE_CSSCACHEITEM, m_pFixedStore, pair.second); + FXTARGET_DeleteWith(FDE_CSSCacheItem, m_pFixedStore, pair.second); } m_Stylesheets.clear(); if (m_pFixedStore) { @@ -40,12 +40,12 @@ void CFDE_CSSStyleSheetCache::AddStyleSheet(const CFX_ByteStringC& szKey, if (m_pFixedStore == NULL) { m_pFixedStore = FX_CreateAllocator(FX_ALLOCTYPE_Fixed, std::max(10, m_iMaxItems), - sizeof(FDE_CSSCACHEITEM)); + sizeof(FDE_CSSCacheItem)); FXSYS_assert(m_pFixedStore != NULL); } auto it = m_Stylesheets.find(szKey); if (it != m_Stylesheets.end()) { - FDE_CSSCACHEITEM* pItem = it->second; + FDE_CSSCacheItem* pItem = it->second; if (pItem->pStylesheet != pStyleSheet) { pItem->pStylesheet->Release(); pItem->pStylesheet = pStyleSheet; @@ -57,7 +57,7 @@ void CFDE_CSSStyleSheetCache::AddStyleSheet(const CFX_ByteStringC& szKey, RemoveLowestActivityItem(); } m_Stylesheets[szKey] = - FXTARGET_NewWith(m_pFixedStore) FDE_CSSCACHEITEM(pStyleSheet); + FXTARGET_NewWith(m_pFixedStore) FDE_CSSCacheItem(pStyleSheet); } } IFDE_CSSStyleSheet* CFDE_CSSStyleSheetCache::GetStyleSheet( @@ -66,7 +66,7 @@ IFDE_CSSStyleSheet* CFDE_CSSStyleSheetCache::GetStyleSheet( if (it == m_Stylesheets.end()) { return nullptr; } - FDE_CSSCACHEITEM* pItem = it->second; + FDE_CSSCacheItem* pItem = it->second; pItem->dwActivity++; pItem->pStylesheet->AddRef(); return pItem->pStylesheet; @@ -76,7 +76,7 @@ void CFDE_CSSStyleSheetCache::RemoveStyleSheet(const CFX_ByteStringC& szKey) { if (it == m_Stylesheets.end()) { return; } - FXTARGET_DeleteWith(FDE_CSSCACHEITEM, m_pFixedStore, it->second); + FXTARGET_DeleteWith(FDE_CSSCacheItem, m_pFixedStore, it->second); m_Stylesheets.erase(it); } void CFDE_CSSStyleSheetCache::RemoveLowestActivityItem() { @@ -93,11 +93,11 @@ void CFDE_CSSStyleSheetCache::RemoveLowestActivityItem() { } } if (found != m_Stylesheets.end()) { - FXTARGET_DeleteWith(FDE_CSSCACHEITEM, m_pFixedStore, found->second); + FXTARGET_DeleteWith(FDE_CSSCacheItem, m_pFixedStore, found->second); m_Stylesheets.erase(found); } } -FDE_CSSTAGCACHE::FDE_CSSTAGCACHE(FDE_CSSTAGCACHE* parent, +FDE_CSSTagCache::FDE_CSSTagCache(FDE_CSSTagCache* parent, IFDE_CSSTagProvider* tag) : pTag(tag), pParent(parent), @@ -126,7 +126,7 @@ FDE_CSSTAGCACHE::FDE_CSSTAGCACHE(FDE_CSSTAGCACHE* parent, } } } -FDE_CSSTAGCACHE::FDE_CSSTAGCACHE(const FDE_CSSTAGCACHE& it) +FDE_CSSTagCache::FDE_CSSTagCache(const FDE_CSSTagCache& it) : pTag(it.pTag), pParent(it.pParent), dwIDHash(it.dwIDHash), @@ -138,8 +138,8 @@ FDE_CSSTAGCACHE::FDE_CSSTAGCACHE(const FDE_CSSTAGCACHE& it) } } void CFDE_CSSAccelerator::OnEnterTag(IFDE_CSSTagProvider* pTag) { - FDE_CSSTAGCACHE* pTop = GetTopElement(); - FDE_CSSTAGCACHE item(pTop, pTag); + FDE_CSSTagCache* pTop = GetTopElement(); + FDE_CSSTagCache item(pTop, pTag); m_Stack.Push(item); } void CFDE_CSSAccelerator::OnLeaveTag(IFDE_CSSTagProvider* pTag) { diff --git a/xfa/src/fde/css/fde_csscache.h b/xfa/src/fde/css/fde_csscache.h index ac3d68c071..e10bea77f5 100644 --- a/xfa/src/fde/css/fde_csscache.h +++ b/xfa/src/fde/css/fde_csscache.h @@ -12,9 +12,10 @@ #include "xfa/src/fde/css/fde_css.h" #include "xfa/src/fgas/crt/fgas_memory.h" -struct FDE_CSSCACHEITEM : public CFX_Target { - FDE_CSSCACHEITEM(IFDE_CSSStyleSheet* p); - ~FDE_CSSCACHEITEM(); +class FDE_CSSCacheItem : public CFX_Target { + public: + explicit FDE_CSSCacheItem(IFDE_CSSStyleSheet* p); + ~FDE_CSSCacheItem(); IFDE_CSSStyleSheet* pStylesheet; FX_DWORD dwActivity; @@ -39,16 +40,16 @@ class CFDE_CSSStyleSheetCache : public IFDE_CSSStyleSheetCache, protected: void RemoveLowestActivityItem(); - std::map<CFX_ByteString, FDE_CSSCACHEITEM*> m_Stylesheets; + std::map<CFX_ByteString, FDE_CSSCacheItem*> m_Stylesheets; IFX_MEMAllocator* m_pFixedStore; int32_t m_iMaxItems; }; -struct FDE_CSSTAGCACHE : public CFX_Target { +class FDE_CSSTagCache : public CFX_Target { public: - FDE_CSSTAGCACHE(FDE_CSSTAGCACHE* parent, IFDE_CSSTagProvider* tag); - FDE_CSSTAGCACHE(const FDE_CSSTAGCACHE& it); - FDE_CSSTAGCACHE* GetParent() const { return pParent; } + FDE_CSSTagCache(FDE_CSSTagCache* parent, IFDE_CSSTagProvider* tag); + FDE_CSSTagCache(const FDE_CSSTagCache& it); + FDE_CSSTagCache* GetParent() const { return pParent; } IFDE_CSSTagProvider* GetTag() const { return pTag; } FX_DWORD HashID() const { return dwIDHash; } FX_DWORD HashTag() const { return dwTagHash; } @@ -62,20 +63,20 @@ struct FDE_CSSTAGCACHE : public CFX_Target { protected: IFDE_CSSTagProvider* pTag; - FDE_CSSTAGCACHE* pParent; + FDE_CSSTagCache* pParent; FX_DWORD dwIDHash; FX_DWORD dwTagHash; int32_t iClassIndex; CFDE_DWordArray dwClassHashs; }; -typedef CFX_ObjectStackTemplate<FDE_CSSTAGCACHE> CFDE_CSSTagStack; +typedef CFX_ObjectStackTemplate<FDE_CSSTagCache> CFDE_CSSTagStack; class CFDE_CSSAccelerator : public IFDE_CSSAccelerator, public CFX_Target { public: virtual void OnEnterTag(IFDE_CSSTagProvider* pTag); virtual void OnLeaveTag(IFDE_CSSTagProvider* pTag); void Clear() { m_Stack.RemoveAll(); } - FDE_CSSTAGCACHE* GetTopElement() const { return m_Stack.GetTopElement(); } + FDE_CSSTagCache* GetTopElement() const { return m_Stack.GetTopElement(); } protected: CFDE_CSSTagStack m_Stack; diff --git a/xfa/src/fde/css/fde_cssdeclaration.cpp b/xfa/src/fde/css/fde_cssdeclaration.cpp index 1a43b8beb2..073c14d414 100644 --- a/xfa/src/fde/css/fde_cssdeclaration.cpp +++ b/xfa/src/fde/css/fde_cssdeclaration.cpp @@ -11,7 +11,7 @@ IFDE_CSSValue* CFDE_CSSDeclaration::GetProperty(FDE_CSSPROPERTY eProperty, FX_BOOL& bImportant) const { - for (const FDE_CSSPROPERTYHOLDER* pHolder = m_pFirstProperty; pHolder; + for (const FDE_CSSPropertyHolder* pHolder = m_pFirstProperty; pHolder; pHolder = pHolder->pNext) { if (pHolder->eProperty == eProperty) { bImportant = pHolder->bImportant; @@ -27,7 +27,7 @@ void CFDE_CSSDeclaration::GetNextProperty(FX_POSITION& pos, FDE_CSSPROPERTY& eProperty, IFDE_CSSValue*& pValue, FX_BOOL& bImportant) const { - const FDE_CSSPROPERTYHOLDER* pHolder = (const FDE_CSSPROPERTYHOLDER*)pos; + const FDE_CSSPropertyHolder* pHolder = (const FDE_CSSPropertyHolder*)pos; FXSYS_assert(pHolder != NULL); bImportant = pHolder->bImportant; eProperty = (FDE_CSSPROPERTY)pHolder->eProperty; @@ -40,7 +40,7 @@ FX_POSITION CFDE_CSSDeclaration::GetStartCustom() const { void CFDE_CSSDeclaration::GetNextCustom(FX_POSITION& pos, CFX_WideString& wsName, CFX_WideString& wsValue) const { - const FDE_CSSCUSTOMPROPERTY* pProperty = (const FDE_CSSCUSTOMPROPERTY*)pos; + const FDE_CSSCustomProperty* pProperty = (const FDE_CSSCustomProperty*)pos; if (pProperty == NULL) { return; } @@ -94,8 +94,8 @@ void CFDE_CSSDeclaration::AddPropertyHolder(IFX_MEMAllocator* pStaticStore, FDE_CSSPROPERTY eProperty, IFDE_CSSValue* pValue, FX_BOOL bImportant) { - FDE_CSSPROPERTYHOLDER* pHolder = - FXTARGET_NewWith(pStaticStore) FDE_CSSPROPERTYHOLDER; + FDE_CSSPropertyHolder* pHolder = + FXTARGET_NewWith(pStaticStore) FDE_CSSPropertyHolder; pHolder->bImportant = bImportant; pHolder->eProperty = eProperty; pHolder->pValue = pValue; @@ -270,8 +270,8 @@ FX_BOOL CFDE_CSSDeclaration::AddProperty(const FDE_CSSPROPERTYARGS* pArgs, int32_t iNameLen, const FX_WCHAR* pszValue, int32_t iValueLen) { - FDE_CSSCUSTOMPROPERTY* pProperty = - FXTARGET_NewWith(pArgs->pStaticStore) FDE_CSSCUSTOMPROPERTY; + FDE_CSSCustomProperty* pProperty = + FXTARGET_NewWith(pArgs->pStaticStore) FDE_CSSCustomProperty; pProperty->pwsName = CopyToLocal(pArgs, pszName, iNameLen); pProperty->pwsValue = CopyToLocal(pArgs, pszValue, iValueLen); pProperty->pNext = NULL; diff --git a/xfa/src/fde/css/fde_cssdeclaration.h b/xfa/src/fde/css/fde_cssdeclaration.h index 42aee9ea13..9866b20f4c 100644 --- a/xfa/src/fde/css/fde_cssdeclaration.h +++ b/xfa/src/fde/css/fde_cssdeclaration.h @@ -9,20 +9,22 @@ #include "xfa/src/fde/css/fde_cssdatatable.h" -struct FDE_CSSPROPERTYHOLDER : public CFX_Target { +class FDE_CSSPropertyHolder : public CFX_Target { + public: int16_t eProperty; int16_t bImportant; IFDE_CSSValue* pValue; - FDE_CSSPROPERTYHOLDER* pNext; + FDE_CSSPropertyHolder* pNext; }; -struct FDE_CSSCUSTOMPROPERTY : public CFX_Target { +class FDE_CSSCustomProperty : public CFX_Target { + public: const FX_WCHAR* pwsName; const FX_WCHAR* pwsValue; - FDE_CSSCUSTOMPROPERTY* pNext; + FDE_CSSCustomProperty* pNext; }; -struct FDE_CSSPROPERTYARGS : public CFX_Target { +struct FDE_CSSPROPERTYARGS { IFX_MEMAllocator* pStaticStore; CFX_MapPtrToPtr* pStringCache; FDE_LPCCSSPROPERTYTABLE pProperty; @@ -147,10 +149,10 @@ class CFDE_CSSDeclaration : public IFDE_CSSDeclaration, public CFX_Target { FX_FLOAT fValue) const; IFDE_CSSPrimitiveValue* NewEnumValue(IFX_MEMAllocator* pStaticStore, FDE_CSSPROPERTYVALUE eValue) const; - FDE_CSSPROPERTYHOLDER* m_pFirstProperty; - FDE_CSSPROPERTYHOLDER* m_pLastProperty; - FDE_CSSCUSTOMPROPERTY* m_pFirstCustom; - FDE_CSSCUSTOMPROPERTY* m_pLastCustom; + FDE_CSSPropertyHolder* m_pFirstProperty; + FDE_CSSPropertyHolder* m_pLastProperty; + FDE_CSSCustomProperty* m_pFirstCustom; + FDE_CSSCustomProperty* m_pLastCustom; }; #endif // XFA_SRC_FDE_CSS_FDE_CSSDECLARATION_H_ 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; diff --git a/xfa/src/fde/css/fde_cssstyleselector.h b/xfa/src/fde/css/fde_cssstyleselector.h index 6ac3f0b7c5..5f5ee095be 100644 --- a/xfa/src/fde/css/fde_cssstyleselector.h +++ b/xfa/src/fde/css/fde_cssstyleselector.h @@ -18,16 +18,16 @@ #define FDE_CSSUNIVERSALHASH ('*') -struct FDE_CSSRULEDATA : public CFX_Target { +class FDE_CSSRuleData : public CFX_Target { public: - FDE_CSSRULEDATA(IFDE_CSSSelector* pSel, + FDE_CSSRuleData(IFDE_CSSSelector* pSel, IFDE_CSSDeclaration* pDecl, FX_DWORD dwPos); IFDE_CSSSelector* pSelector; IFDE_CSSDeclaration* pDeclaration; FX_DWORD dwPriority; - FDE_CSSRULEDATA* pNext; + FDE_CSSRuleData* pNext; }; class CFDE_CSSRuleCollection : public CFX_Target { @@ -44,26 +44,26 @@ class CFDE_CSSRuleCollection : public CFX_Target { void Clear(); int32_t CountSelectors() const { return m_iSelectors; } - FDE_CSSRULEDATA* GetIDRuleData(FX_DWORD dwIDHash) { + FDE_CSSRuleData* GetIDRuleData(FX_DWORD dwIDHash) { void* pData; return m_IDRules.Lookup((void*)(uintptr_t)dwIDHash, pData) - ? (FDE_CSSRULEDATA*)pData + ? (FDE_CSSRuleData*)pData : NULL; } - FDE_CSSRULEDATA* GetTagRuleData(FX_DWORD dwTagHasn) { + FDE_CSSRuleData* GetTagRuleData(FX_DWORD dwTagHasn) { void* pData; return m_TagRules.Lookup((void*)(uintptr_t)dwTagHasn, pData) - ? (FDE_CSSRULEDATA*)pData + ? (FDE_CSSRuleData*)pData : NULL; } - FDE_CSSRULEDATA* GetClassRuleData(FX_DWORD dwIDHash) { + FDE_CSSRuleData* GetClassRuleData(FX_DWORD dwIDHash) { void* pData; return m_ClassRules.Lookup((void*)(uintptr_t)dwIDHash, pData) - ? (FDE_CSSRULEDATA*)pData + ? (FDE_CSSRuleData*)pData : NULL; } - FDE_CSSRULEDATA* GetUniversalRuleData() { return m_pUniversalRules; } - FDE_CSSRULEDATA* GetPersudoRuleData() { return m_pPersudoRules; } + FDE_CSSRuleData* GetUniversalRuleData() { return m_pUniversalRules; } + FDE_CSSRuleData* GetPersudoRuleData() { return m_pPersudoRules; } IFX_MEMAllocator* m_pStaticStore; protected: @@ -75,14 +75,14 @@ class CFDE_CSSRuleCollection : public CFX_Target { FX_DWORD dwKey, IFDE_CSSSelector* pSel, IFDE_CSSDeclaration* pDecl); - FX_BOOL AddRuleTo(FDE_CSSRULEDATA*& pList, FDE_CSSRULEDATA* pData); - FDE_CSSRULEDATA* NewRuleData(IFDE_CSSSelector* pSel, + FX_BOOL AddRuleTo(FDE_CSSRuleData*& pList, FDE_CSSRuleData* pData); + FDE_CSSRuleData* NewRuleData(IFDE_CSSSelector* pSel, IFDE_CSSDeclaration* pDecl); CFX_MapPtrToPtr m_IDRules; CFX_MapPtrToPtr m_TagRules; CFX_MapPtrToPtr m_ClassRules; - FDE_CSSRULEDATA* m_pUniversalRules; - FDE_CSSRULEDATA* m_pPersudoRules; + FDE_CSSRuleData* m_pUniversalRules; + FDE_CSSRuleData* m_pPersudoRules; int32_t m_iSelectors; }; class CFDE_CSSAccelerator; @@ -117,10 +117,10 @@ class CFDE_CSSStyleSelector : public IFDE_CSSStyleSelector, public CFX_Target { protected: void Reset(); - void MatchRules(FDE_CSSTAGCACHE* pCache, - FDE_CSSRULEDATA* pList, + void MatchRules(FDE_CSSTagCache* pCache, + FDE_CSSRuleData* pList, FDE_CSSPERSUDO ePersudoType); - FX_BOOL MatchSelector(FDE_CSSTAGCACHE* pCache, + FX_BOOL MatchSelector(FDE_CSSTagCache* pCache, IFDE_CSSSelector* pSel, FDE_CSSPERSUDO ePersudoType); void AppendInlineStyle(CFDE_CSSDeclaration* pDecl, @@ -185,7 +185,7 @@ class CFDE_CSSStyleSelector : public IFDE_CSSStyleSelector, public CFX_Target { IFX_MEMAllocator* m_pInlineStyleStore; IFX_MEMAllocator* m_pFixedStyleStore; CFDE_CSSAccelerator* m_pAccelerator; - std::vector<FDE_CSSRULEDATA*> m_MatchedRules; + std::vector<FDE_CSSRuleData*> m_MatchedRules; }; struct FDE_CSSCOUNTERDATA { diff --git a/xfa/src/fde/fde_iterator.h b/xfa/src/fde/fde_iterator.h index eadff97508..2bb4c1a19f 100644 --- a/xfa/src/fde/fde_iterator.h +++ b/xfa/src/fde/fde_iterator.h @@ -10,7 +10,7 @@ #include "xfa/src/fde/fde_visualset.h" #include "xfa/src/fgas/crt/fgas_memory.h" -struct FDE_CANVASITEM : public CFX_Target { +struct FDE_CANVASITEM { IFDE_CanvasSet* pCanvas; FDE_HVISUALOBJ hCanvas; FX_POSITION hPos; diff --git a/xfa/src/fxfa/app/xfa_fftext.cpp b/xfa/src/fxfa/app/xfa_fftext.cpp index 2e9abb9f81..95d408ce71 100644 --- a/xfa/src/fxfa/app/xfa_fftext.cpp +++ b/xfa/src/fxfa/app/xfa_fftext.cpp @@ -163,7 +163,7 @@ const FX_WCHAR* CXFA_FFText::GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy) { CXFA_PieceLine* pPieceLine = pPieceLines->GetAt(i); int32_t iPieces = pPieceLine->m_textPieces.GetSize(); for (int32_t j = 0; j < iPieces; j++) { - XFA_TEXTPIECE* pPiece = pPieceLine->m_textPieces.GetAt(j); + XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); if (pPiece->pLinkData && pPiece->rtPiece.Contains(x, y)) { return pPiece->pLinkData->GetLinkURL(); } diff --git a/xfa/src/fxfa/app/xfa_textlayout.cpp b/xfa/src/fxfa/app/xfa_textlayout.cpp index e8a23b1523..b8a9ec433e 100644 --- a/xfa/src/fxfa/app/xfa_textlayout.cpp +++ b/xfa/src/fxfa/app/xfa_textlayout.cpp @@ -1256,7 +1256,7 @@ FX_BOOL CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, int32_t iPieces = pPieceLine->m_textPieces.GetSize(); int32_t j = 0; for (j = 0; j < iPieces; j++) { - const XFA_TEXTPIECE* pPiece = pPieceLine->m_textPieces.GetAt(j); + const XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); int32_t iChars = pPiece->iChars; if (iCharCount < iChars) { FX_Free(pCharPos); @@ -1296,7 +1296,7 @@ void CXFA_TextLayout::UpdateAlign(FX_FLOAT fHeight, FX_FLOAT fBottom) { CXFA_PieceLine* pPieceLine = m_pieceLines.GetAt(i); int32_t iPieces = pPieceLine->m_textPieces.GetSize(); for (int32_t j = 0; j < iPieces; j++) { - XFA_TEXTPIECE* pPiece = pPieceLine->m_textPieces.GetAt(j); + XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); CFX_RectF& rect = pPiece->rtPiece; rect.top += fHeight; } @@ -1651,7 +1651,7 @@ void CXFA_TextLayout::DoTabstops(IFDE_CSSComputedStyle* pStyle, if (iPieces == 0) { return; } - XFA_TEXTPIECE* pPiece = pPieceLine->m_textPieces.GetAt(iPieces - 1); + XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPieces - 1); int32_t& iTabstopsIndex = m_pTabstopContext->m_iTabIndex; int32_t iCount = m_textParser.CountTabs(pStyle); if (iTabstopsIndex > m_pTabstopContext->m_iTabCount - 1) { @@ -1662,7 +1662,7 @@ void CXFA_TextLayout::DoTabstops(IFDE_CSSComputedStyle* pStyle, m_pTabstopContext->m_bTabstops = TRUE; FX_FLOAT fRight = 0; if (iPieces > 1) { - XFA_TEXTPIECE* p = pPieceLine->m_textPieces.GetAt(iPieces - 2); + XFA_TextPiece* p = pPieceLine->m_textPieces.GetAt(iPieces - 2); fRight = p->rtPiece.right(); } m_pTabstopContext->m_fTabWidth = @@ -1718,8 +1718,7 @@ void CXFA_TextLayout::AppendTextLine(FX_DWORD dwStatus, if (pUserData) pStyle = pUserData->m_pStyle; FX_FLOAT fVerScale = pPiece->m_iVerticalScale / 100.0f; - XFA_TEXTPIECE* pTP = - (XFA_TEXTPIECE*)m_pAllocator->Alloc(sizeof(XFA_TEXTPIECE)); + XFA_TextPiece* pTP = FXTARGET_NewWith(m_pAllocator) XFA_TextPiece(); pTP->pszText = (FX_WCHAR*)m_pAllocator->Alloc(pPiece->m_iChars * sizeof(FX_WCHAR)); pTP->pWidths = @@ -1765,7 +1764,7 @@ void CXFA_TextLayout::AppendTextLine(FX_DWORD dwStatus, DoTabstops(pStyle, pPieceLine); } for (i = 0; i < iPieces; i++) { - XFA_TEXTPIECE* pTP = pPieceLine->m_textPieces.GetAt(i); + XFA_TextPiece* pTP = pPieceLine->m_textPieces.GetAt(i); FX_FLOAT& fTop = pTP->rtPiece.top; FX_FLOAT fBaseLineTemp = fTop; fTop = fLinePos + fLineStep - pTP->rtPiece.height - fBaseLineTemp; @@ -1847,7 +1846,7 @@ void CXFA_TextLayout::RenderString(IFDE_RenderDevice* pDevice, int32_t iPiece, FXTEXT_CHARPOS* pCharPos, const CFX_Matrix& tmDoc2Device) { - const XFA_TEXTPIECE* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); + const XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); int32_t iCount = GetDisplayPos(pPiece, pCharPos); if (iCount > 0) { pBrush->SetColor(pPiece->dwColor); @@ -1862,7 +1861,7 @@ void CXFA_TextLayout::RenderPath(IFDE_RenderDevice* pDevice, int32_t iPiece, FXTEXT_CHARPOS* pCharPos, const CFX_Matrix& tmDoc2Device) { - XFA_TEXTPIECE* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); + XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPiece); FX_BOOL bNoUnderline = pPiece->iUnderline < 1 || pPiece->iUnderline > 2; FX_BOOL bNoLineThrough = pPiece->iLineThrough < 1 || pPiece->iLineThrough > 2; if (bNoUnderline && bNoLineThrough) { @@ -1969,7 +1968,7 @@ void CXFA_TextLayout::RenderPath(IFDE_RenderDevice* pDevice, XFA_RenderPathRet: pPath->Release(); } -int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TEXTPIECE* pPiece, +int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TextPiece* pPiece, FXTEXT_CHARPOS* pCharPos, FX_BOOL bCharCode) { if (pPiece == NULL) { @@ -1981,7 +1980,7 @@ int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TEXTPIECE* pPiece, } return m_pBreak->GetDisplayPos(&tr, pCharPos, bCharCode); } -FX_BOOL CXFA_TextLayout::ToRun(const XFA_TEXTPIECE* pPiece, FX_RTFTEXTOBJ& tr) { +FX_BOOL CXFA_TextLayout::ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr) { int32_t iLength = pPiece->iChars; if (iLength < 1) { return FALSE; diff --git a/xfa/src/fxfa/app/xfa_textlayout.h b/xfa/src/fxfa/app/xfa_textlayout.h index bcace9d9d6..2d8d1bf15e 100644 --- a/xfa/src/fxfa/app/xfa_textlayout.h +++ b/xfa/src/fxfa/app/xfa_textlayout.h @@ -243,9 +243,10 @@ class CXFA_TextUserData : public IFX_Unknown, public CFX_Target { FX_DWORD m_dwRefCount; }; -struct XFA_TEXTPIECE : public CFX_Target { - XFA_TEXTPIECE() : pszText(nullptr), pFont(nullptr), pLinkData(nullptr) {} - ~XFA_TEXTPIECE() { +class XFA_TextPiece : public CFX_Target { + public: + XFA_TextPiece() : pszText(nullptr), pFont(nullptr), pLinkData(nullptr) {} + ~XFA_TextPiece() { if (pLinkData) pLinkData->Release(); } @@ -265,7 +266,7 @@ struct XFA_TEXTPIECE : public CFX_Target { CFX_RectF rtPiece; CXFA_LinkUserData* pLinkData; }; -typedef CFX_ArrayTemplate<XFA_TEXTPIECE*> CXFA_PieceArray; +typedef CFX_ArrayTemplate<XFA_TextPiece*> CXFA_PieceArray; class CXFA_PieceLine : public CFX_Target { public: @@ -399,10 +400,10 @@ class CXFA_TextLayout { int32_t iPiece, FXTEXT_CHARPOS* pCharPos, const CFX_Matrix& tmDoc2Device); - int32_t GetDisplayPos(const XFA_TEXTPIECE* pPiece, + int32_t GetDisplayPos(const XFA_TextPiece* pPiece, FXTEXT_CHARPOS* pCharPos, FX_BOOL bCharCode = FALSE); - FX_BOOL ToRun(const XFA_TEXTPIECE* pPiece, FX_RTFTEXTOBJ& tr); + FX_BOOL ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr); void DoTabstops(IFDE_CSSComputedStyle* pStyle, CXFA_PieceLine* pPieceLine); FX_BOOL Layout(int32_t iBlock); int32_t CountBlocks() const; |