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 27d80372c8c18532a0e09e740a25d1d8ed127395..d0ea794f197059fa36be21551eb20e27715b6a35 100644 |
--- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp |
+++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp |
@@ -373,12 +373,6 @@ StyleEngine::activeStyleSheetsForInspector() const { |
return activeStyleSheets; |
} |
-void StyleEngine::didRemoveShadowRoot(ShadowRoot* shadowRoot) { |
- m_styleSheetCollectionMap.remove(shadowRoot); |
- m_activeTreeScopes.remove(shadowRoot); |
- m_dirtyTreeScopes.remove(shadowRoot); |
-} |
- |
void StyleEngine::shadowRootRemovedFromDocument(ShadowRoot* shadowRoot) { |
if (StyleResolver* styleResolver = resolver()) { |
styleResolver->resetRuleFeatures(); |
@@ -445,13 +439,18 @@ void StyleEngine::clearResolver() { |
DCHECK(isMaster() || !m_resolver); |
document().clearScopedStyleResolver(); |
- // StyleEngine::shadowRootRemovedFromDocument removes not-in-document |
- // treescopes from activeTreeScopes. StyleEngine::didRemoveShadowRoot |
- // removes treescopes which are being destroyed from activeTreeScopes. |
- // So we need to clearScopedStyleResolver for treescopes which have been |
- // just removed from document. If document is destroyed before invoking |
- // updateActiveStyleSheets, the treescope has a scopedStyleResolver which |
- // has destroyed StyleSheetContents. |
+ // TODO(rune@opera.com): The clearing of all shadow tree scoped style |
+ // resolvers below should not be necessary. It was introduced to fix a crash |
+ // bug (https://crbug.com/447976) when clearResolver is called from didDetach |
+ // on document destruction. That was pre-oilpan, and removing the for-loop |
+ // below does not re-introduce that crash. If m_activeTreeScopes keeps too |
+ // much memory alive after detach, we should probably clear m_activeTreeScopes |
+ // in didDetach instead. |
+ // |
+ // The current code will clear too much if clearResolver is called from |
+ // clearMasterResolver as a result of a Reconstruct in |
+ // DocumentStyleSheetCollection. Such a reconstruct should not necessarily |
+ // affect scoped resolvers from shadow trees at all. |
for (TreeScope* treeScope : m_activeTreeScopes) |
treeScope->clearScopedStyleResolver(); |