Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Unified Diff: Source/core/dom/StyleEngine.cpp

Issue 28553005: Avoid parsing css text if there are identical inline style blocks. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« Source/core/dom/StyleEngine.h ('K') | « Source/core/dom/StyleEngine.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+}
+
}
« Source/core/dom/StyleEngine.h ('K') | « Source/core/dom/StyleEngine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698