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_csscache.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_csscache.cpp')
-rw-r--r-- | xfa/src/fde/css/fde_csscache.cpp | 26 |
1 files changed, 13 insertions, 13 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) { |