Index: third_party/WebKit/Source/core/dom/StyleEngine.cpp |
diff --git a/third_party/WebKit/Source/core/dom/StyleEngine.cpp b/third_party/WebKit/Source/core/dom/StyleEngine.cpp |
index f739839f9b39e6d90d334df236eb63c7d8c3ba62..a5fb3f8c7d5933fb1afeddb52218f55d312c65da 100644 |
--- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp |
+++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp |
@@ -511,18 +511,20 @@ CSSStyleSheet* StyleEngine::createSheet(Element* e, const String& text, TextPosi |
AtomicString textContent(text); |
- HeapHashMap<AtomicString, Member<StyleSheetContents>>::AddResult result = m_textToSheetCache.add(textContent, nullptr); |
- if (result.isNewEntry || !result.storedValue->value) { |
+ auto result = m_textToSheetCache.add(textContent, nullptr); |
+ StyleSheetContents* contents = result.storedValue->value; |
+ if (result.isNewEntry || !contents || !contents->isCacheableForStyleElement()) { |
+ result.storedValue->value = nullptr; |
styleSheet = StyleEngine::parseSheet(e, text, startPosition); |
- if (result.isNewEntry && styleSheet->contents()->isCacheableForStyleElement()) { |
+ if (styleSheet->contents()->isCacheableForStyleElement()) { |
result.storedValue->value = styleSheet->contents(); |
m_sheetToTextCache.add(styleSheet->contents(), textContent); |
} |
} else { |
- StyleSheetContents* contents = result.storedValue->value; |
DCHECK(contents); |
DCHECK(contents->isCacheableForStyleElement()); |
- DCHECK_EQ(contents->singleOwnerDocument(), e->document()); |
+ DCHECK(contents->hasSingleOwnerDocument()); |
+ contents->setIsUsedFromTextCache(); |
styleSheet = CSSStyleSheet::createInline(contents, e, startPosition); |
} |
@@ -541,16 +543,6 @@ CSSStyleSheet* StyleEngine::parseSheet(Element* e, const String& text, TextPosit |
return styleSheet; |
} |
-void StyleEngine::removeSheet(StyleSheetContents* contents) |
-{ |
- HeapHashMap<Member<StyleSheetContents>, AtomicString>::iterator it = m_sheetToTextCache.find(contents); |
- if (it == m_sheetToTextCache.end()) |
- return; |
- |
- m_textToSheetCache.remove(it->value); |
- m_sheetToTextCache.remove(contents); |
-} |
- |
void StyleEngine::collectScopedStyleFeaturesTo(RuleFeatureSet& features) const |
{ |
HeapHashSet<Member<const StyleSheetContents>> visitedSharedStyleSheetContents; |