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 b5af1480b0c2bdb212949ff1d9f2de946d283877..10a0ccb96769e49e0b6be81ff79ce68a4aa012d0 100644 |
--- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp |
+++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp |
@@ -426,28 +426,14 @@ void StyleEngine::createResolver() { |
m_resolver->setRuleUsageTracker(m_tracker); |
} |
-void StyleEngine::clearResolver() { |
+void StyleEngine::clearResolvers() { |
DCHECK(!document().inStyleRecalc()); |
DCHECK(isMaster() || !m_resolver); |
document().clearScopedStyleResolver(); |
- // 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(); |
- m_treeBoundaryCrossingScopes.clear(); |
- |
if (m_resolver) { |
TRACE_EVENT1("blink", "StyleEngine::clearResolver", "frame", |
document().frame()); |
@@ -457,8 +443,11 @@ void StyleEngine::clearResolver() { |
} |
void StyleEngine::didDetach() { |
+ clearResolvers(); |
m_globalRuleSet.dispose(); |
- clearResolver(); |
+ m_treeBoundaryCrossingScopes.clear(); |
+ m_dirtyTreeScopes.clear(); |
+ m_activeTreeScopes.clear(); |
m_viewportResolver = nullptr; |
m_mediaQueryEvaluator = nullptr; |
clearFontCache(); |