| 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 #ifndef XFA_FDE_CSS_FDE_CSSCACHE_H_ | 7 #ifndef XFA_FDE_CSS_FDE_CSSCACHE_H_ |
| 8 #define XFA_FDE_CSS_FDE_CSSCACHE_H_ | 8 #define XFA_FDE_CSS_FDE_CSSCACHE_H_ |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 | 11 |
| 12 #include "xfa/fde/css/fde_css.h" | 12 #include "xfa/fde/css/fde_css.h" |
| 13 #include "xfa/fgas/crt/fgas_memory.h" | 13 #include "xfa/fgas/crt/fgas_memory.h" |
| 14 | 14 |
| 15 class FDE_CSSCacheItem : public CFX_Target { | 15 class FDE_CSSCacheItem : public CFX_Target { |
| 16 public: | 16 public: |
| 17 explicit FDE_CSSCacheItem(IFDE_CSSStyleSheet* p); | 17 explicit FDE_CSSCacheItem(IFDE_CSSStyleSheet* p); |
| 18 ~FDE_CSSCacheItem(); | 18 ~FDE_CSSCacheItem(); |
| 19 | 19 |
| 20 IFDE_CSSStyleSheet* pStylesheet; | 20 IFDE_CSSStyleSheet* pStylesheet; |
| 21 uint32_t dwActivity; | 21 uint32_t dwActivity; |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 class CFDE_CSSStyleSheetCache : public IFDE_CSSStyleSheetCache, | |
| 25 public CFX_Target { | |
| 26 public: | |
| 27 CFDE_CSSStyleSheetCache(); | |
| 28 ~CFDE_CSSStyleSheetCache(); | |
| 29 virtual void Release() { delete this; } | |
| 30 | |
| 31 virtual void SetMaxItems(int32_t iMaxCount = 5) { | |
| 32 FXSYS_assert(iMaxCount >= 3); | |
| 33 m_iMaxItems = iMaxCount; | |
| 34 } | |
| 35 | |
| 36 virtual void AddStyleSheet(const CFX_ByteStringC& szKey, | |
| 37 IFDE_CSSStyleSheet* pStyleSheet); | |
| 38 virtual IFDE_CSSStyleSheet* GetStyleSheet(const CFX_ByteStringC& szKey) const; | |
| 39 virtual void RemoveStyleSheet(const CFX_ByteStringC& szKey); | |
| 40 | |
| 41 protected: | |
| 42 void RemoveLowestActivityItem(); | |
| 43 std::map<CFX_ByteString, FDE_CSSCacheItem*> m_Stylesheets; | |
| 44 IFX_MEMAllocator* m_pFixedStore; | |
| 45 int32_t m_iMaxItems; | |
| 46 }; | |
| 47 | |
| 48 class FDE_CSSTagCache : public CFX_Target { | 24 class FDE_CSSTagCache : public CFX_Target { |
| 49 public: | 25 public: |
| 50 FDE_CSSTagCache(FDE_CSSTagCache* parent, IFDE_CSSTagProvider* tag); | 26 FDE_CSSTagCache(FDE_CSSTagCache* parent, IFDE_CSSTagProvider* tag); |
| 51 FDE_CSSTagCache(const FDE_CSSTagCache& it); | 27 FDE_CSSTagCache(const FDE_CSSTagCache& it); |
| 52 FDE_CSSTagCache* GetParent() const { return pParent; } | 28 FDE_CSSTagCache* GetParent() const { return pParent; } |
| 53 IFDE_CSSTagProvider* GetTag() const { return pTag; } | 29 IFDE_CSSTagProvider* GetTag() const { return pTag; } |
| 54 uint32_t HashID() const { return dwIDHash; } | 30 uint32_t HashID() const { return dwIDHash; } |
| 55 uint32_t HashTag() const { return dwTagHash; } | 31 uint32_t HashTag() const { return dwTagHash; } |
| 56 int32_t CountHashClass() const { return dwClassHashs.GetSize(); } | 32 int32_t CountHashClass() const { return dwClassHashs.GetSize(); } |
| 57 void SetClassIndex(int32_t index) { iClassIndex = index; } | 33 void SetClassIndex(int32_t index) { iClassIndex = index; } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 78 | 54 |
| 79 void Clear() { m_Stack.RemoveAll(); } | 55 void Clear() { m_Stack.RemoveAll(); } |
| 80 | 56 |
| 81 FDE_CSSTagCache* GetTopElement() const { return m_Stack.GetTopElement(); } | 57 FDE_CSSTagCache* GetTopElement() const { return m_Stack.GetTopElement(); } |
| 82 | 58 |
| 83 protected: | 59 protected: |
| 84 CFDE_CSSTagStack m_Stack; | 60 CFDE_CSSTagStack m_Stack; |
| 85 }; | 61 }; |
| 86 | 62 |
| 87 #endif // XFA_FDE_CSS_FDE_CSSCACHE_H_ | 63 #endif // XFA_FDE_CSS_FDE_CSSCACHE_H_ |
| OLD | NEW |