Chromium Code Reviews| Index: Source/core/dom/StyleEngine.cpp |
| diff --git a/Source/core/dom/StyleEngine.cpp b/Source/core/dom/StyleEngine.cpp |
| index f59a38e203d880478af6b41ac56e4eeaad749b46..d6052c671d9917cb8d7efa393386175e331e7955 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() |
|
zerny-chromium
2014/03/04 13:59:46
Nit: use the typedef here too.
Mads Ager (chromium)
2014/03/04 14:03:33
The typedefs are local to the methods. And typedef
|
| { |
| - typedef HashMap<AtomicString, StyleSheetContents*> TextToSheetCache; |
| + typedef WillBeHeapHashMap<AtomicString, RawPtrWillBeWeakMember<StyleSheetContents> > TextToSheetCache; |
| +#if ENABLE(OILPAN) |
| + DEFINE_STATIC_LOCAL(Persistent<TextToSheetCache>, cache, (new TextToSheetCache)); |
|
Erik Corry
2014/03/04 14:09:27
I think in another change we could use WillBePersi
Mads Ager (chromium)
2014/03/04 14:13:36
Yeah, it would be nice if we could do that. Let's
|
| + return *cache; |
| +#else |
| DEFINE_STATIC_LOCAL(TextToSheetCache, cache, ()); |
| return cache; |
| +#endif |
| } |
| -static HashMap<StyleSheetContents*, AtomicString>& sheetToTextCache() |
| +static WillBeHeapHashMap<RawPtrWillBeWeakMember<StyleSheetContents>, AtomicString>& sheetToTextCache() |
|
zerny-chromium
2014/03/04 13:59:46
nit: ditto.
|
| { |
| - 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, 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; |