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..067aea341e9b9a905135a0db6b17250ceeabd8c6 100644 |
--- a/Source/core/css/resolver/MatchedPropertiesCache.h |
+++ b/Source/core/css/StyleSheetContentsCache.h |
@@ -20,54 +20,52 @@ |
* |
*/ |
-#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 StyleSheetContentsCacheItem : public RefCounted<StyleSheetContentsCacheItem> { |
+public: |
+ static PassRefPtr<StyleSheetContentsCacheItem> create(StyleSheetContents*); |
-struct CachedMatchedProperties { |
- Vector<MatchedProperties> matchedProperties; |
- MatchRanges ranges; |
- RefPtr<RenderStyle> renderStyle; |
- RefPtr<RenderStyle> parentRenderStyle; |
+ StyleSheetContents* contents() { return m_contents.get(); } |
- void set(const RenderStyle*, const RenderStyle* parentStyle, const MatchResult&); |
- void clear(); |
+private: |
+ StyleSheetContentsCacheItem(PassRefPtr<StyleSheetContents> contents) : m_contents(contents) { } |
+ |
+ 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, RefPtr<StyleSheetContentsCacheItem> > Cache; |
Cache m_cache; |
- Timer<MatchedPropertiesCache> m_sweepTimer; |
+ Timer<StyleSheetContentsCache> m_sweepTimer; |
}; |
} |