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

Unified Diff: third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.cpp

Issue 2096653004: Avoid stack allocating StyleSheetCollections. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
Index: third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.cpp
diff --git a/third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.cpp b/third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.cpp
index 31aabc718b704256c7345ed3e26bcc5624004a43..0c967faf147f7ce459052e493b6807e36e6e1510 100644
--- a/third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.cpp
+++ b/third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.cpp
@@ -66,11 +66,12 @@ void ShadowTreeStyleSheetCollection::collectStyleSheets(StyleEngine& engine, Sty
void ShadowTreeStyleSheetCollection::updateActiveStyleSheets(StyleEngine& engine, StyleResolverUpdateMode updateMode)
{
- StyleSheetCollection collection;
- collectStyleSheets(engine, collection);
+ // StyleSheetCollection is GarbageCollected<>, allocate it on the heap.
+ StyleSheetCollection* collection = StyleSheetCollection::create();
+ collectStyleSheets(engine, *collection);
StyleSheetChange change;
- analyzeStyleSheetChange(updateMode, collection, change);
+ analyzeStyleSheetChange(updateMode, collection->activeAuthorStyleSheets(), change);
if (StyleResolver* styleResolver = engine.resolver()) {
if (change.styleResolverUpdateType != Additive) {
@@ -78,15 +79,16 @@ void ShadowTreeStyleSheetCollection::updateActiveStyleSheets(StyleEngine& engine
// In this case, we will reset rulesets created from style elements in the shadow tree.
styleResolver->resetAuthorStyle(treeScope());
styleResolver->removePendingAuthorStyleSheets(m_activeAuthorStyleSheets);
- styleResolver->lazyAppendAuthorStyleSheets(0, collection.activeAuthorStyleSheets());
+ styleResolver->lazyAppendAuthorStyleSheets(0, collection->activeAuthorStyleSheets());
} else {
- styleResolver->lazyAppendAuthorStyleSheets(m_activeAuthorStyleSheets.size(), collection.activeAuthorStyleSheets());
+ styleResolver->lazyAppendAuthorStyleSheets(m_activeAuthorStyleSheets.size(), collection->activeAuthorStyleSheets());
}
}
if (change.requiresFullStyleRecalc)
toShadowRoot(treeScope().rootNode()).host().setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::ActiveStylesheetsUpdate));
- collection.swap(*this);
+ collection->swap(*this);
+ collection->dispose();
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698