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

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

Issue 2519393002: Force adding sheets and recalc for html import re-ordering. (Closed)
Patch Set: Missing reset in resetAuthorStyle() Created 4 years, 1 month 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/StyleEngine.cpp
diff --git a/third_party/WebKit/Source/core/dom/StyleEngine.cpp b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
index 00b7648b4e1a7bca2d65b40d050a4bec99821368..765285c1118ab89fc3c152938c590a75b76a0d3a 100644
--- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp
+++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
@@ -1036,6 +1036,29 @@ void StyleEngine::viewportRulesChanged() {
m_viewportResolver->setNeedsCollectRules();
}
+void StyleEngine::importRemoved() {
+ if (document().importLoader()) {
+ document().importsController()->master()->styleEngine().importRemoved();
+ return;
+ }
+
+ // When we remove an import link and re-insert it into the document, the
+ // import Document and CSSStyleSheet pointers are persisted. That means the
+ // comparison of active stylesheets is not able to figure out that the order
+ // of the stylesheets have changed after insertion.
+ //
+ // Fall back to re-add all sheets to the scoped resolver and recalculate style
+ // for the whole document if we remove an import in case it is re-inserted
+ // into the document. The assumption is that removing html imports is very
+ // rare.
+ if (ScopedStyleResolver* resolver = document().scopedStyleResolver()) {
+ resolver->setNeedsAppendAllSheets();
+ document().setNeedsStyleRecalc(
+ SubtreeStyleChange, StyleChangeReasonForTracing::create(
+ StyleChangeReason::ActiveStylesheetsUpdate));
+ }
+}
+
PassRefPtr<ComputedStyle> StyleEngine::findSharedStyle(
const ElementResolveContext& elementResolveContext) {
DCHECK(m_resolver);
@@ -1075,9 +1098,13 @@ void StyleEngine::applyRuleSetChanges(
const ActiveStyleSheetVector& newStyleSheets) {
HeapVector<Member<RuleSet>> changedRuleSets;
+ ScopedStyleResolver* scopedResolver = treeScope.scopedStyleResolver();
+ bool appendAllSheets =
+ scopedResolver && scopedResolver->needsAppendAllSheets();
+
ActiveSheetsChange change =
compareActiveStyleSheets(oldStyleSheets, newStyleSheets, changedRuleSets);
- if (change == NoActiveSheetsChanged)
+ if (change == NoActiveSheetsChanged && !appendAllSheets)
return;
// With rules added or removed, we need to re-aggregate rule meta data.
@@ -1100,7 +1127,7 @@ void StyleEngine::applyRuleSetChanges(
if (treeScope.scopedStyleResolver()) {
if (newStyleSheets.isEmpty())
resetAuthorStyle(treeScope);
- else if (change == ActiveSheetsAppended)
+ else if (change == ActiveSheetsAppended && !appendAllSheets)
appendStartIndex = oldStyleSheets.size();
else
treeScope.scopedStyleResolver()->resetAuthorStyle();
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.h ('k') | third_party/WebKit/Source/core/html/imports/LinkImport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698