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 1a0e0246e0fa4a97e6dcedc9ff84f8415984e545..c6297a0a6d29138cce8f0a7a944613a363660884 100644 |
--- a/third_party/WebKit/Source/core/dom/Element.cpp |
+++ b/third_party/WebKit/Source/core/dom/Element.cpp |
@@ -1708,12 +1708,13 @@ void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) |
if (hasCustomStyleCallbacks()) |
willRecalcStyle(change); |
- if (change >= Inherit || needsStyleRecalc()) { |
+ if (change >= IndependentInherit || needsStyleRecalc()) { |
if (hasRareData()) { |
ElementRareData* data = elementRareData(); |
- data->clearComputedStyle(); |
+ if (change != IndependentInherit) |
+ data->clearComputedStyle(); |
- if (change >= Inherit) { |
+ if (change >= IndependentInherit) { |
if (ElementAnimations* elementAnimations = data->elementAnimations()) |
elementAnimations->setAnimationStyleChange(false); |
} |
@@ -1757,15 +1758,37 @@ void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) |
reattachWhitespaceSiblingsIfNeeded(nextTextSibling); |
} |
+bool Element::canPropagateInheritedProperties(StyleRecalcChange change) |
+{ |
+ return change == IndependentInherit |
esprehn
2016/07/19 03:46:26
if (change != ...)
return false;
if (!parentComp
sashab
2016/07/19 06:32:38
Nice :) Thanks, done
|
+ && !needsStyleRecalc() |
+ && computedStyle() |
esprehn
2016/07/19 03:46:26
computedStyle() contains a bunch of branches, you
sashab
2016/07/19 06:32:38
Yup nice, thanks
|
+ && parentComputedStyle() |
+ && !computedStyle()->animations() |
+ && !computedStyle()->transitions() |
+ && !hasAnimations(); |
+} |
+ |
StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) |
{ |
DCHECK(document().inStyleRecalc()); |
DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); |
- DCHECK(change >= Inherit || needsStyleRecalc()); |
+ DCHECK(change >= IndependentInherit || needsStyleRecalc()); |
DCHECK(parentComputedStyle()); |
RefPtr<ComputedStyle> oldStyle = mutableComputedStyle(); |
- RefPtr<ComputedStyle> newStyle = styleForLayoutObject(); |
+ RefPtr<ComputedStyle> newStyle; |
+ |
+ // When propagating inherited changes, we don't need to do a full style recalc |
+ // if the only changed properties are independent. In this case, we can simply |
+ // set these directly on the ComputedStyle object. |
+ if (canPropagateInheritedProperties(change)) { |
+ newStyle = ComputedStyle::clone(*computedStyle()); |
Timothy Loh
2016/07/19 01:29:32
clone(oldStyle)?
sashab
2016/07/19 03:31:35
Done
esprehn
2016/07/19 03:46:26
yeah, don't call computedStyle() repeatedly it's g
|
+ ComputedStyle::propagateIndependentInheritedProperties(*parentComputedStyle(), *newStyle); |
esprehn
2016/07/19 03:46:26
parentComputedStyle() isn't free, I think you want
sashab
2016/07/19 06:32:38
Nice!! Done.
Had to pass newStyle because its use
|
+ INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), independentInheritedStylesPropagated, 1); |
+ } else { |
+ newStyle = styleForLayoutObject(); |
+ } |
DCHECK(newStyle); |
StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get()); |
esprehn
2016/07/19 03:46:26
do we even need to run any of this now if we took
sashab
2016/07/19 06:32:38
That's a good question. I've left it this way now
|
@@ -1805,7 +1828,7 @@ StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) |
if (change > Inherit || localChange > Inherit) |
return max(localChange, change); |
- if (localChange < Inherit) { |
+ if (localChange < IndependentInherit) { |
if (oldStyle->hasChildDependentFlags()) { |
if (childNeedsStyleRecalc()) |
return Inherit; |