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

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

Issue 2572473006: Revert of Collect active stylesheets and and apply asynchronously. (Closed)
Patch Set: Created 4 years 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 7f735dd5d9bb6c537f8375d32dcbf24e20def2b5..29dad5ffed2e06abdc62cbe4e4216c7898605a2f 100644
--- a/third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.cpp
+++ b/third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.cpp
@@ -47,6 +47,7 @@
: TreeScopeStyleSheetCollection(shadowRoot) {}
void ShadowTreeStyleSheetCollection::collectStyleSheets(
+ StyleEngine& engine,
StyleSheetCollection& collection) {
for (Node* n : m_styleSheetCandidateNodes) {
StyleSheetCandidate candidate(*n);
@@ -57,19 +58,46 @@
continue;
collection.appendSheetForList(sheet);
- if (candidate.canBeActivated(nullAtom)) {
- CSSStyleSheet* cssSheet = toCSSStyleSheet(sheet);
- collection.appendActiveStyleSheet(std::make_pair(
- cssSheet, document().styleEngine().ruleSetForSheet(*cssSheet)));
- }
+ if (candidate.canBeActivated(nullAtom))
+ collection.appendActiveStyleSheet(toCSSStyleSheet(sheet));
}
}
-void ShadowTreeStyleSheetCollection::updateActiveStyleSheets() {
+void ShadowTreeStyleSheetCollection::updateActiveStyleSheets(
+ StyleEngine& engine,
+ StyleResolverUpdateMode updateMode) {
// StyleSheetCollection is GarbageCollected<>, allocate it on the heap.
StyleSheetCollection* collection = StyleSheetCollection::create();
- collectStyleSheets(*collection);
- applyActiveStyleSheetChanges(*collection);
+ collectStyleSheets(engine, *collection);
+
+ StyleSheetChange change;
+ analyzeStyleSheetChange(updateMode, collection->activeAuthorStyleSheets(),
+ change);
+
+ if (StyleResolver* styleResolver = engine.resolver()) {
+ if (change.styleResolverUpdateType != Additive) {
+ // We should not destroy StyleResolver when we find any stylesheet update
+ // in a shadow tree. In this case, we will reset rulesets created from
+ // style elements in the shadow tree.
+ engine.resetAuthorStyle(treeScope());
+ styleResolver->removePendingAuthorStyleSheets(m_activeAuthorStyleSheets);
+ styleResolver->lazyAppendAuthorStyleSheets(
+ 0, collection->activeAuthorStyleSheets());
+ } else {
+ styleResolver->lazyAppendAuthorStyleSheets(
+ m_activeAuthorStyleSheets.size(),
+ collection->activeAuthorStyleSheets());
+ }
+ }
+ if (change.requiresFullStyleRecalc)
+ toShadowRoot(treeScope().rootNode())
+ .host()
+ .setNeedsStyleRecalc(SubtreeStyleChange,
+ StyleChangeReasonForTracing::create(
+ StyleChangeReason::ActiveStylesheetsUpdate));
+
+ collection->swap(*this);
+ collection->dispose();
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.h ('k') | third_party/WebKit/Source/core/dom/StyleEngine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698