Index: Source/core/dom/StyleEngine.cpp |
diff --git a/Source/core/dom/StyleEngine.cpp b/Source/core/dom/StyleEngine.cpp |
index 8d902cd52e21c44170e669d15f4a279d8e1a9cfc..7730ffdb12fae5b69845ec71ccacf726d45dc2fe 100644 |
--- a/Source/core/dom/StyleEngine.cpp |
+++ b/Source/core/dom/StyleEngine.cpp |
@@ -445,4 +445,41 @@ void StyleEngine::appendActiveAuthorStyleSheets(StyleResolver* styleResolver) |
styleResolver->setBuildScopedStyleTreeInDocumentOrder(false); |
} |
+StyleSheetContents* StyleEngine::findStyleSheetContents(const AtomicString& sheetText) |
+{ |
+ if (sheetText.isEmpty()) |
+ return 0; |
+ |
+ HashMap<AtomicString, std::pair<unsigned, RefPtr<StyleSheetContents> > >::iterator it = m_styleSheetContentsCache.find(sheetText); |
+ if (it == m_styleSheetContentsCache.end()) |
+ return 0; |
+ return it->value.second.get(); |
+} |
+ |
+void StyleEngine::registerStyleSheetContents(const AtomicString& sheetText, StyleSheetContents* contents) |
+{ |
+ ASSERT(contents); |
+ ASSERT(!sheetText.isEmpty()); |
+ HashMap<AtomicString, std::pair<unsigned, RefPtr<StyleSheetContents> > >::AddResult result = m_styleSheetContentsCache.add(sheetText, std::pair<unsigned, RefPtr<StyleSheetContents> >(0, 0)); |
+ if (!result.isNewEntry) { |
+ result.iterator->value.first++; |
+ return; |
+ } |
+ result.iterator->value.first = 1; |
+ result.iterator->value.second = contents->copy(); |
+} |
+ |
+void StyleEngine::unregisterStyleSheetContents(const AtomicString& sheetText) |
+{ |
+ ASSERT(!sheetText.isEmpty()); |
+ HashMap<AtomicString, std::pair<unsigned, RefPtr<StyleSheetContents> > >::iterator it = m_styleSheetContentsCache.find(sheetText); |
+ if (it == m_styleSheetContentsCache.end()) |
+ return; |
+ ASSERT(it->value.first > 0); |
+ it->value.first--; |
+ if (it->value.first) |
+ return; |
+ m_styleSheetContentsCache.remove(sheetText); |
+} |
+ |
} |