| 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 f33de88828625bc869a80e4e0fb9c2575863396d..f68d32c6ba440f32ca98904da112079f670102eb 100644
|
| --- a/third_party/WebKit/Source/core/dom/Element.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/Element.cpp
|
| @@ -1739,6 +1739,7 @@ void Element::attachLayoutTree(const AttachContext& context) {
|
| SelectorFilterParentScope filterScope(*this);
|
| StyleSharingDepthScope sharingScope(*this);
|
|
|
| + clearNeedsReattachLayoutTree();
|
| createPseudoElementIfNeeded(PseudoIdBefore);
|
|
|
| // When a shadow root exists, it does the work of attaching the children.
|
| @@ -2021,11 +2022,16 @@ StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change,
|
| }
|
|
|
| if (localChange == Reattach) {
|
| + // This mimicks Element::recalcStyleForReattach except it also stores the
|
| + // nextTextSibling information.
|
| StyleReattachData styleReattachData;
|
| styleReattachData.computedStyle = std::move(newStyle);
|
| styleReattachData.nextTextSibling = nextTextSibling;
|
| document().addStyleReattachData(*this, styleReattachData);
|
| setNeedsReattachLayoutTree();
|
| + if (layoutObjectIsNeeded(*styleReattachData.computedStyle)) {
|
| + recalcContainedStyleForReattach();
|
| + }
|
| return Reattach;
|
| }
|
|
|
| @@ -2070,6 +2076,35 @@ StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change,
|
| return localChange;
|
| }
|
|
|
| +void Element::recalcStyleForReattach() {
|
| + StyleReattachData styleReattachData;
|
| + styleReattachData.computedStyle = styleForLayoutObject();
|
| + document().addStyleReattachData(*this, styleReattachData);
|
| + setNeedsReattachLayoutTree();
|
| + if (layoutObjectIsNeeded(*styleReattachData.computedStyle.get())) {
|
| + recalcContainedStyleForReattach();
|
| + }
|
| +}
|
| +
|
| +void Element::recalcContainedStyleForReattach() {
|
| + if (!childrenCanHaveStyle())
|
| + return;
|
| + if (hasCustomStyleCallbacks())
|
| + return;
|
| +
|
| + SelectorFilterParentScope filterScope(*this);
|
| + StyleSharingDepthScope sharingScope(*this);
|
| + recalcShadowRootStylesForReattach();
|
| + recalcDescendantStylesForReattach();
|
| +}
|
| +
|
| +void Element::recalcShadowRootStylesForReattach() {
|
| + for (ShadowRoot* root = youngestShadowRoot(); root;
|
| + root = root->olderShadowRoot()) {
|
| + root->recalcDescendantStylesForReattach();
|
| + }
|
| +}
|
| +
|
| void Element::rebuildLayoutTree() {
|
| DCHECK(inActiveDocument());
|
| DCHECK(parentNode());
|
| @@ -3240,6 +3275,9 @@ const ComputedStyle* Element::ensureComputedStyle(
|
| }
|
|
|
| const ComputedStyle* Element::nonLayoutObjectComputedStyle() const {
|
| + if (needsReattachLayoutTree())
|
| + return document().getStyleReattachData(*this).computedStyle.get();
|
| +
|
| if (layoutObject() || !hasRareData())
|
| return nullptr;
|
|
|
|
|