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

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

Issue 192473003: Move CSSRuleList to the garbage collected heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ager feedback Created 6 years, 9 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/dom/StyleEngine.h ('k') | Source/core/dom/StyleSheetCollection.h » ('j') | 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 2de67f7ad04984c5061f54ba1091979247803928..ecfca69f3f40463fc03afb98bd5dbaef30a77d40 100644
--- a/Source/core/dom/StyleEngine.cpp
+++ b/Source/core/dom/StyleEngine.cpp
@@ -101,6 +101,13 @@ StyleEngine::StyleEngine(Document& document)
StyleEngine::~StyleEngine()
{
+}
+
+void StyleEngine::detachFromDocument()
+{
+ // Cleanup is performed eagerly when the StyleEngine is removed from the
+ // document. The StyleEngine is unreachable after this, since only the
+ // document has a reference to it.
for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i)
m_injectedAuthorStyleSheets[i]->clearOwnerNode();
for (unsigned i = 0; i < m_authorStyleSheets.size(); ++i)
@@ -111,6 +118,11 @@ StyleEngine::~StyleEngine()
if (m_resolver)
m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get());
}
+
+ // Decrement reference counts for things we could be keeping alive.
+ m_fontSelector.clear();
+ m_resolver.clear();
+ m_styleSheetCollectionMap.clear();
}
inline Document* StyleEngine::master()
@@ -172,7 +184,7 @@ TreeScopeStyleSheetCollection* StyleEngine::styleSheetCollectionFor(TreeScope& t
return it->value.get();
}
-const Vector<RefPtr<StyleSheet> >& StyleEngine::styleSheetsForStyleSheetList(TreeScope& treeScope)
+const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> >& StyleEngine::styleSheetsForStyleSheetList(TreeScope& treeScope)
{
if (treeScope == m_document)
return m_documentStyleSheetCollection.styleSheetsForStyleSheetList();
@@ -180,7 +192,7 @@ const Vector<RefPtr<StyleSheet> >& StyleEngine::styleSheetsForStyleSheetList(Tre
return ensureStyleSheetCollectionFor(treeScope)->styleSheetsForStyleSheetList();
}
-const Vector<RefPtr<CSSStyleSheet> >& StyleEngine::activeAuthorStyleSheets() const
+const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& StyleEngine::activeAuthorStyleSheets() const
{
return m_documentStyleSheetCollection.activeAuthorStyleSheets();
}
@@ -200,7 +212,7 @@ void StyleEngine::resetCSSFeatureFlags(const RuleFeatureSet& features)
m_maxDirectAdjacentSelectors = features.maxDirectAdjacentSelectors();
}
-const Vector<RefPtr<CSSStyleSheet> >& StyleEngine::injectedAuthorStyleSheets() const
+const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& StyleEngine::injectedAuthorStyleSheets() const
{
updateInjectedStyleSheetCache();
return m_injectedAuthorStyleSheets;
@@ -224,7 +236,7 @@ void StyleEngine::updateInjectedStyleSheetCache() const
continue;
if (!URLPatternMatcher::matchesPatterns(m_document.url(), entry->whitelist()))
continue;
- RefPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInline(const_cast<Document*>(&m_document), KURL());
+ RefPtrWillBeRawPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInline(const_cast<Document*>(&m_document), KURL());
m_injectedAuthorStyleSheets.append(groupSheet);
groupSheet->contents()->parseString(entry->source());
}
@@ -366,7 +378,7 @@ void StyleEngine::clearMediaQueryRuleSetStyleSheets()
void StyleEngine::updateStyleSheetsInImport(DocumentStyleSheetCollector& parentCollector)
{
ASSERT(!isMaster());
- Vector<RefPtr<StyleSheet> > sheetsForList;
+ WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > sheetsForList;
ImportedDocumentStyleSheetCollector subcollector(parentCollector, sheetsForList);
m_documentStyleSheetCollection.collectStyleSheets(this, subcollector);
m_documentStyleSheetCollection.swapSheetsForSheetList(sheetsForList);
@@ -411,12 +423,12 @@ bool StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode)
return requiresFullStyleRecalc;
}
-const Vector<RefPtr<StyleSheet> > StyleEngine::activeStyleSheetsForInspector() const
+const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > StyleEngine::activeStyleSheetsForInspector() const
{
if (m_activeTreeScopes.isEmpty())
return m_documentStyleSheetCollection.styleSheetsForStyleSheetList();
- Vector<RefPtr<StyleSheet> > activeStyleSheets;
+ WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > activeStyleSheets;
activeStyleSheets.appendVector(m_documentStyleSheetCollection.styleSheetsForStyleSheetList());
@@ -628,4 +640,10 @@ void StyleEngine::removeSheet(StyleSheetContents* contents)
sheetToTextCache().remove(contents);
}
+void StyleEngine::trace(Visitor* visitor)
+{
+ visitor->trace(m_injectedAuthorStyleSheets);
+ visitor->trace(m_authorStyleSheets);
+}
+
}
« no previous file with comments | « Source/core/dom/StyleEngine.h ('k') | Source/core/dom/StyleSheetCollection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698