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

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

Issue 2106073005: Add fast-path for propagated variable changes (WIP) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@+pointer_events_fastpath_5
Patch Set: Rebase 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/Element.cpp
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp
index b7cc35fd88b08689c815799321c8a9e47c565e40..5f89773399a8113b7c57402448419a37c7cbc2d7 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -1897,7 +1897,7 @@ void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) {
PassRefPtr<ComputedStyle> Element::propagateInheritedProperties(
StyleRecalcChange change) {
- if (change != IndependentInherit)
+ if (change != IndependentInherit && change != IndependentInheritWithVariables)
return nullptr;
if (isPseudoElement())
return nullptr;
@@ -1910,6 +1910,16 @@ PassRefPtr<ComputedStyle> Element::propagateInheritedProperties(
const ComputedStyle* style = computedStyle();
if (!style || style->animations() || style->transitions())
return nullptr;
+ if (change == IndependentInheritWithVariables &&
+ (style->hasVariableReferenceFromInheritedProperty() ||
+ style->hasVariableReferenceFromNonInheritedProperty()
+ // If this element sets any variables, they may refer to other variables.
+ // To be safe, recalc the element's style.
+ // TODO(sashab): Set the hasVariableReferenceFromInheritedProperty flag
+ // on ComputedStyle when a variable references another variable and
+ // remove this additional check.
+ || style->hasAnyNonInheritedVariableDefinitions()))
+ return nullptr;
RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*style);
newStyle->propagateIndependentInheritedProperties(*parentStyle);
INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(),
@@ -1942,6 +1952,13 @@ StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change,
INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1);
}
+ if (change == IndependentInheritWithVariables && localChange == NoChange) {
+ // If we are in a propagation fast-path, but we have changed variables,
+ // there
+ // might still be properties that need to be updated below. Force continue.
+ localChange = IndependentInheritWithVariables;
+ }
+
if (localChange == Reattach) {
StyleReattachData styleReattachData;
styleReattachData.computedStyle = std::move(newStyle);

Powered by Google App Engine
This is Rietveld 408576698