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

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

Issue 185403016: Oilpan: Use weak pointers in StyleSheetContents caches. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix compilation Created 6 years, 10 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
« no previous file with comments | « Source/core/css/StyleSheetContents.cpp ('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 f59a38e203d880478af6b41ac56e4eeaad749b46..2de67f7ad04984c5061f54ba1091979247803928 100644
--- a/Source/core/dom/StyleEngine.cpp
+++ b/Source/core/dom/StyleEngine.cpp
@@ -54,18 +54,28 @@ namespace WebCore {
using namespace HTMLNames;
-static HashMap<AtomicString, StyleSheetContents*>& textToSheetCache()
+static WillBeHeapHashMap<AtomicString, RawPtrWillBeWeakMember<StyleSheetContents> >& textToSheetCache()
{
- typedef HashMap<AtomicString, StyleSheetContents*> TextToSheetCache;
+ typedef WillBeHeapHashMap<AtomicString, RawPtrWillBeWeakMember<StyleSheetContents> > TextToSheetCache;
+#if ENABLE(OILPAN)
+ DEFINE_STATIC_LOCAL(Persistent<TextToSheetCache>, cache, (new TextToSheetCache));
+ return *cache;
+#else
DEFINE_STATIC_LOCAL(TextToSheetCache, cache, ());
return cache;
+#endif
}
-static HashMap<StyleSheetContents*, AtomicString>& sheetToTextCache()
+static WillBeHeapHashMap<RawPtrWillBeWeakMember<StyleSheetContents>, AtomicString>& sheetToTextCache()
{
- typedef HashMap<StyleSheetContents*, AtomicString> SheetToTextCache;
+ typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<StyleSheetContents>, AtomicString> SheetToTextCache;
+#if ENABLE(OILPAN)
+ DEFINE_STATIC_LOCAL(Persistent<SheetToTextCache>, cache, (new SheetToTextCache));
+ return *cache;
+#else
DEFINE_STATIC_LOCAL(SheetToTextCache, cache, ());
return cache;
+#endif
}
StyleEngine::StyleEngine(Document& document)
@@ -579,7 +589,7 @@ PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex
if (!e->document().inQuirksMode()) {
AtomicString textContent(text);
- HashMap<AtomicString, StyleSheetContents*>::AddResult result = textToSheetCache().add(textContent, 0);
+ WillBeHeapHashMap<AtomicString, RawPtrWillBeWeakMember<StyleSheetContents> >::AddResult result = textToSheetCache().add(textContent, RawPtrWillBeWeakMember<StyleSheetContents>(nullptr));
if (result.isNewEntry || !result.storedValue->value) {
styleSheet = StyleEngine::parseSheet(e, text, startPosition, createdByParser);
if (result.isNewEntry && styleSheet->contents()->maybeCacheable()) {
@@ -610,7 +620,7 @@ PassRefPtr<CSSStyleSheet> StyleEngine::parseSheet(Element* e, const String& text
void StyleEngine::removeSheet(StyleSheetContents* contents)
{
- HashMap<StyleSheetContents*, AtomicString>::iterator it = sheetToTextCache().find(contents);
+ WillBeHeapHashMap<RawPtrWillBeWeakMember<StyleSheetContents>, AtomicString>::iterator it = sheetToTextCache().find(contents);
if (it == sheetToTextCache().end())
return;
« no previous file with comments | « Source/core/css/StyleSheetContents.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698