| 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 67e29c95e205616ad139015f196de9e2d76be911..8941173e1e8606d1a9b31d03bd2d40299f39762d 100644
|
| --- a/third_party/WebKit/Source/core/dom/Element.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/Element.cpp
|
| @@ -1703,12 +1703,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);
|
| }
|
| @@ -1752,15 +1753,37 @@ void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling)
|
| reattachWhitespaceSiblingsIfNeeded(nextTextSibling);
|
| }
|
|
|
| +bool Element::canPropagateInheritedProperties(StyleRecalcChange change)
|
| +{
|
| + return change == IndependentInherit
|
| + && !needsStyleRecalc()
|
| + && computedStyle()
|
| + && 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());
|
| + ComputedStyle::propagateIndependentInheritedProperties(*parentComputedStyle(), *newStyle);
|
| + INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), independentInheritedStylesPropagated, 1);
|
| + } else {
|
| + newStyle = styleForLayoutObject();
|
| + }
|
| DCHECK(newStyle);
|
|
|
| StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get());
|
| @@ -1800,7 +1823,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;
|
|
|