Index: Source/core/css/StyleSheetContentsCache.h |
diff --git a/Source/core/css/resolver/MatchedPropertiesCache.h b/Source/core/css/StyleSheetContentsCache.h |
similarity index 51% |
copy from Source/core/css/resolver/MatchedPropertiesCache.h |
copy to Source/core/css/StyleSheetContentsCache.h |
index 2e5297d5acd3c4bf14d2ca3cf161c2e593370ba6..054e8a679c660db77bfb700f4dd698a789b6cc10 100644 |
--- a/Source/core/css/resolver/MatchedPropertiesCache.h |
+++ b/Source/core/css/StyleSheetContentsCache.h |
@@ -20,54 +20,56 @@ |
* |
*/ |
-#ifndef MatchedPropertiesCache_h |
-#define MatchedPropertiesCache_h |
- |
-#include "core/css/resolver/MatchResult.h" |
+#ifndef StyleSheetContentsCache_h |
+#define StyleSheetContentsCache_h |
+#include "core/css/StyleSheetContents.h" |
#include "platform/Timer.h" |
#include "wtf/Forward.h" |
#include "wtf/HashMap.h" |
#include "wtf/Noncopyable.h" |
+#include "wtf/RefPtr.h" |
+#include "wtf/text/AtomicString.h" |
namespace WebCore { |
-class RenderStyle; |
-class StyleResolverState; |
+class StyleSheetContents; |
+ |
+class CachedStyleSheetContents { |
dglazkov
2013/10/21 18:24:10
StyleSheetContentsCacheItem?
tasak
2013/10/25 05:23:13
Done.
|
+public: |
+ static PassOwnPtr<CachedStyleSheetContents> create(StyleSheetContents*); |
-struct CachedMatchedProperties { |
- Vector<MatchedProperties> matchedProperties; |
- MatchRanges ranges; |
- RefPtr<RenderStyle> renderStyle; |
- RefPtr<RenderStyle> parentRenderStyle; |
+ unsigned addref() { return ++m_refCount; } |
+ unsigned deref() { return --m_refCount; } |
+ bool hasOneRef() { return m_refCount == 1; } |
dglazkov
2013/10/21 18:24:10
Whoa! Why did you reinvent RefPtr here? :)
tasak
2013/10/25 05:23:13
I see.
I re-implemented RefPtr...
I made StyleShee
|
+ StyleSheetContents* contents() { return m_contents.get(); } |
- void set(const RenderStyle*, const RenderStyle* parentStyle, const MatchResult&); |
- void clear(); |
+private: |
+ CachedStyleSheetContents(PassRefPtr<StyleSheetContents> contents) : m_refCount(0), m_contents(contents) { } |
+ |
+ unsigned m_refCount; |
+ RefPtr<StyleSheetContents> m_contents; |
}; |
-class MatchedPropertiesCache { |
- WTF_MAKE_NONCOPYABLE(MatchedPropertiesCache); |
+class StyleSheetContentsCache { |
+ WTF_MAKE_NONCOPYABLE(StyleSheetContentsCache); |
public: |
- MatchedPropertiesCache(); |
- |
- const CachedMatchedProperties* find(unsigned hash, const StyleResolverState&, const MatchResult&); |
- void add(const RenderStyle*, const RenderStyle* parentStyle, unsigned hash, const MatchResult&); |
+ StyleSheetContentsCache(); |
+ StyleSheetContents* find(const AtomicString& sheetText); |
+ void add(const AtomicString& sheetText, StyleSheetContents*); |
+ void remove(const AtomicString& sheetText); |
void clear(); |
- static bool isCacheable(const Element*, const RenderStyle*, const RenderStyle* parentStyle); |
- |
private: |
- // Every N additions to the matched declaration cache trigger a sweep where entries holding |
- // the last reference to a style declaration are garbage collected. |
- void sweep(Timer<MatchedPropertiesCache>*); |
+ void sweep(Timer<StyleSheetContentsCache>*); |
unsigned m_additionsSinceLastSweep; |
- typedef HashMap<unsigned, OwnPtr<CachedMatchedProperties> > Cache; |
+ typedef HashMap<AtomicString, OwnPtr<CachedStyleSheetContents> > Cache; |
Cache m_cache; |
- Timer<MatchedPropertiesCache> m_sweepTimer; |
+ Timer<StyleSheetContentsCache> m_sweepTimer; |
}; |
} |