summaryrefslogtreecommitdiff
path: root/xfa/fde/css
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-04-15 14:44:20 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-15 14:44:20 -0700
commitdb152695e49c24083874a5e3639a5f967b69b0f3 (patch)
treea2891a0dc380b15f4313be465112805bef83d550 /xfa/fde/css
parente0ad6a4af5d9c5f5671a9ecd0aa437dedae52b16 (diff)
downloadpdfium-db152695e49c24083874a5e3639a5f967b69b0f3.tar.xz
Remove unused IFDE_CSSStyleSheetCache/CFDE_CSSStyleSheetCache.
Review URL: https://codereview.chromium.org/1896553004
Diffstat (limited to 'xfa/fde/css')
-rw-r--r--xfa/fde/css/fde_css.h13
-rw-r--r--xfa/fde/css/fde_csscache.cpp78
-rw-r--r--xfa/fde/css/fde_csscache.h24
3 files changed, 0 insertions, 115 deletions
diff --git a/xfa/fde/css/fde_css.h b/xfa/fde/css/fde_css.h
index f1a8ee93c9..566a94710c 100644
--- a/xfa/fde/css/fde_css.h
+++ b/xfa/fde/css/fde_css.h
@@ -23,7 +23,6 @@ class IFDE_CSSRule;
class IFDE_CSSSelector;
class IFDE_CSSStyleSelector;
class IFDE_CSSStyleSheet;
-class IFDE_CSSStyleSheetCache;
class IFDE_CSSSyntaxParser;
class IFDE_CSSTagProvider;
class IFDE_CSSValue;
@@ -453,18 +452,6 @@ class IFDE_CSSStyleSheet : public IFX_Unknown {
};
typedef CFX_ArrayTemplate<IFDE_CSSStyleSheet*> CFDE_CSSStyleSheetArray;
-class IFDE_CSSStyleSheetCache {
- public:
- static IFDE_CSSStyleSheetCache* Create();
- virtual ~IFDE_CSSStyleSheetCache() {}
- virtual void Release() = 0;
- virtual void SetMaxItems(int32_t iMaxCount = 5) = 0;
- virtual void AddStyleSheet(const CFX_ByteStringC& szKey,
- IFDE_CSSStyleSheet* pStyleSheet) = 0;
- virtual IFDE_CSSStyleSheet* GetStyleSheet(
- const CFX_ByteStringC& szKey) const = 0;
- virtual void RemoveStyleSheet(const CFX_ByteStringC& szKey) = 0;
-};
enum FDE_CSSSYNTAXSTATUS {
FDE_CSSSYNTAXSTATUS_Error,
FDE_CSSSYNTAXSTATUS_EOS,
diff --git a/xfa/fde/css/fde_csscache.cpp b/xfa/fde/css/fde_csscache.cpp
index c68d4ddb49..511c69798b 100644
--- a/xfa/fde/css/fde_csscache.cpp
+++ b/xfa/fde/css/fde_csscache.cpp
@@ -18,85 +18,7 @@ FDE_CSSCacheItem::FDE_CSSCacheItem(IFDE_CSSStyleSheet* p)
FDE_CSSCacheItem::~FDE_CSSCacheItem() {
pStylesheet->Release();
}
-IFDE_CSSStyleSheetCache* IFDE_CSSStyleSheetCache::Create() {
- return new CFDE_CSSStyleSheetCache;
-}
-
-CFDE_CSSStyleSheetCache::CFDE_CSSStyleSheetCache()
- : m_pFixedStore(NULL), m_iMaxItems(5) {}
-CFDE_CSSStyleSheetCache::~CFDE_CSSStyleSheetCache() {
- for (const auto& pair : m_Stylesheets) {
- FXTARGET_DeleteWith(FDE_CSSCacheItem, m_pFixedStore, pair.second);
- }
- m_Stylesheets.clear();
- if (m_pFixedStore) {
- m_pFixedStore->Release();
- }
-}
-void CFDE_CSSStyleSheetCache::AddStyleSheet(const CFX_ByteStringC& szKey,
- IFDE_CSSStyleSheet* pStyleSheet) {
- FXSYS_assert(pStyleSheet != NULL);
- if (m_pFixedStore == NULL) {
- m_pFixedStore =
- FX_CreateAllocator(FX_ALLOCTYPE_Fixed, std::max(10, m_iMaxItems),
- sizeof(FDE_CSSCacheItem));
- FXSYS_assert(m_pFixedStore != NULL);
- }
- auto it = m_Stylesheets.find(szKey);
- if (it != m_Stylesheets.end()) {
- FDE_CSSCacheItem* pItem = it->second;
- if (pItem->pStylesheet != pStyleSheet) {
- pItem->pStylesheet->Release();
- pItem->pStylesheet = pStyleSheet;
- pItem->pStylesheet->AddRef();
- pItem->dwActivity = 0;
- }
- } else {
- while (static_cast<int32_t>(m_Stylesheets.size()) >= m_iMaxItems) {
- RemoveLowestActivityItem();
- }
- m_Stylesheets[szKey] =
- FXTARGET_NewWith(m_pFixedStore) FDE_CSSCacheItem(pStyleSheet);
- }
-}
-IFDE_CSSStyleSheet* CFDE_CSSStyleSheetCache::GetStyleSheet(
- const CFX_ByteStringC& szKey) const {
- auto it = m_Stylesheets.find(szKey);
- if (it == m_Stylesheets.end()) {
- return nullptr;
- }
- FDE_CSSCacheItem* pItem = it->second;
- pItem->dwActivity++;
- pItem->pStylesheet->AddRef();
- return pItem->pStylesheet;
-}
-void CFDE_CSSStyleSheetCache::RemoveStyleSheet(const CFX_ByteStringC& szKey) {
- auto it = m_Stylesheets.find(szKey);
- if (it == m_Stylesheets.end()) {
- return;
- }
- FXTARGET_DeleteWith(FDE_CSSCacheItem, m_pFixedStore, it->second);
- m_Stylesheets.erase(it);
-}
-void CFDE_CSSStyleSheetCache::RemoveLowestActivityItem() {
- auto found = m_Stylesheets.end();
- for (auto it = m_Stylesheets.begin(); it != m_Stylesheets.end(); ++it) {
- switch (it->first.GetID()) {
- case FXBSTR_ID('#', 'U', 'S', 'E'):
- case FXBSTR_ID('#', 'A', 'G', 'E'):
- continue;
- }
- if (found == m_Stylesheets.end() ||
- it->second->dwActivity > found->second->dwActivity) {
- found = it;
- }
- }
- if (found != m_Stylesheets.end()) {
- FXTARGET_DeleteWith(FDE_CSSCacheItem, m_pFixedStore, found->second);
- m_Stylesheets.erase(found);
- }
-}
FDE_CSSTagCache::FDE_CSSTagCache(FDE_CSSTagCache* parent,
IFDE_CSSTagProvider* tag)
: pTag(tag),
diff --git a/xfa/fde/css/fde_csscache.h b/xfa/fde/css/fde_csscache.h
index 7d1ace8ac1..41908c1c6c 100644
--- a/xfa/fde/css/fde_csscache.h
+++ b/xfa/fde/css/fde_csscache.h
@@ -21,30 +21,6 @@ class FDE_CSSCacheItem : public CFX_Target {
uint32_t dwActivity;
};
-class CFDE_CSSStyleSheetCache : public IFDE_CSSStyleSheetCache,
- public CFX_Target {
- public:
- CFDE_CSSStyleSheetCache();
- ~CFDE_CSSStyleSheetCache();
- virtual void Release() { delete this; }
-
- virtual void SetMaxItems(int32_t iMaxCount = 5) {
- FXSYS_assert(iMaxCount >= 3);
- m_iMaxItems = iMaxCount;
- }
-
- virtual void AddStyleSheet(const CFX_ByteStringC& szKey,
- IFDE_CSSStyleSheet* pStyleSheet);
- virtual IFDE_CSSStyleSheet* GetStyleSheet(const CFX_ByteStringC& szKey) const;
- virtual void RemoveStyleSheet(const CFX_ByteStringC& szKey);
-
- protected:
- void RemoveLowestActivityItem();
- std::map<CFX_ByteString, FDE_CSSCacheItem*> m_Stylesheets;
- IFX_MEMAllocator* m_pFixedStore;
- int32_t m_iMaxItems;
-};
-
class FDE_CSSTagCache : public CFX_Target {
public:
FDE_CSSTagCache(FDE_CSSTagCache* parent, IFDE_CSSTagProvider* tag);