Chromium Code Reviews| 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 ef260adf32dc31fb8e8c0d0dfbfbde675c104369..1890dfee27fdd442e73cf3f4a157520093e8a523 100644 |
| --- a/third_party/WebKit/Source/core/dom/Element.cpp |
| +++ b/third_party/WebKit/Source/core/dom/Element.cpp |
| @@ -1710,12 +1710,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); |
| } |
| @@ -1759,15 +1760,40 @@ void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) |
| reattachWhitespaceSiblingsIfNeeded(nextTextSibling); |
| } |
| +PassRefPtr<ComputedStyle> Element::propagateInheritedProperties(StyleRecalcChange change) |
| +{ |
| + if (change != IndependentInherit) |
| + return nullptr; |
| + if (needsStyleRecalc()) |
| + return nullptr; |
| + if (hasAnimations()) |
| + return nullptr; |
| + const ComputedStyle* parentStyle = parentComputedStyle(); |
| + DCHECK(parentStyle); |
| + const ComputedStyle* style = computedStyle(); |
| + if (!style || style->animations() || style->transitions()) |
| + return nullptr; |
| + RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*style); |
| + newStyle->propagateIndependentInheritedProperties(*parentStyle); |
| + INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), independentInheritedStylesPropagated, 1); |
| + return newStyle; |
| +} |
| + |
| 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; |
|
esprehn
2016/08/02 02:34:58
can we do:
newStyle = propagateInheritedPropertie
sashab
2016/08/15 07:19:04
Yup, sg!
|
| + |
| + // 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 (!(newStyle = propagateInheritedProperties(change))) |
| + newStyle = styleForLayoutObject(); |
| DCHECK(newStyle); |
| StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get()); |
| @@ -1807,7 +1833,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; |