| 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 308f92d8343a6f3d013954d9029aa2220f951b3c..03583eda3b36d35f71497a02778a6aaf8280ea5a 100644
|
| --- a/third_party/WebKit/Source/core/dom/Element.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/Element.cpp
|
| @@ -1903,17 +1903,14 @@
|
| }
|
| if (parentComputedStyle())
|
| change = recalcOwnStyle(change, nextTextSibling);
|
| - // Needed because the rebuildLayoutTree code needs to see what the
|
| - // styleChangeType() was on reattach roots. See Node::reattachLayoutTree()
|
| - // for an example.
|
| - if (change != Reattach)
|
| - clearNeedsStyleRecalc();
|
| - }
|
| -
|
| - // If we are going to reattach we don't need to recalc the style of
|
| - // our descendants anymore.
|
| - if (change < Reattach &&
|
| - (change >= UpdatePseudoElements || childNeedsStyleRecalc())) {
|
| + clearNeedsStyleRecalc();
|
| + clearNeedsReattachLayoutTree();
|
| + }
|
| +
|
| + // If we reattached we don't need to recalc the style of our descendants
|
| + // anymore.
|
| + if ((change >= UpdatePseudoElements && change < Reattach) ||
|
| + childNeedsStyleRecalc()) {
|
| SelectorFilterParentScope filterScope(*this);
|
| StyleSharingDepthScope sharingScope(*this);
|
|
|
| @@ -1939,6 +1936,7 @@
|
| childNeedsStyleRecalc() ? Force : change);
|
|
|
| clearChildNeedsStyleRecalc();
|
| + clearChildNeedsReattachLayoutTree();
|
| }
|
|
|
| if (hasCustomStyleCallbacks())
|
| @@ -1998,7 +1996,7 @@
|
| styleReattachData.nextTextSibling = nextTextSibling;
|
| document().addStyleReattachData(*this, styleReattachData);
|
| setNeedsReattachLayoutTree();
|
| - return Reattach;
|
| + return rebuildLayoutTree();
|
| }
|
|
|
| DCHECK(oldStyle);
|
| @@ -2039,58 +2037,34 @@
|
| return localChange;
|
| }
|
|
|
| -void Element::rebuildLayoutTree() {
|
| +StyleRecalcChange Element::rebuildLayoutTree() {
|
| DCHECK(inActiveDocument());
|
| + StyleReattachData styleReattachData = document().getStyleReattachData(*this);
|
| + AttachContext reattachContext;
|
| + reattachContext.resolvedStyle = styleReattachData.computedStyle.get();
|
| + bool layoutObjectWillChange = needsAttach() || layoutObject();
|
| +
|
| + // We are calling Element::rebuildLayoutTree() from inside
|
| + // Element::recalcOwnStyle where we set the NeedsReattachLayoutTree
|
| + // flag - so needsReattachLayoutTree() should always be true.
|
| DCHECK(parentNode());
|
| -
|
| - if (needsReattachLayoutTree()) {
|
| - StyleReattachData styleReattachData =
|
| - document().getStyleReattachData(*this);
|
| - AttachContext reattachContext;
|
| - reattachContext.resolvedStyle = styleReattachData.computedStyle.get();
|
| - bool layoutObjectWillChange =
|
| - getStyleChangeType() == NeedsReattachStyleChange || layoutObject();
|
| - reattachLayoutTree(reattachContext);
|
| - if (layoutObjectWillChange || layoutObject()) {
|
| - // nextTextSibling is passed on to recalcStyle from recalcDescendantStyles
|
| - // we can either traverse the current subtree from this node onwards
|
| - // or store it.
|
| - // The choice is between increased time and increased memory complexity.
|
| - reattachWhitespaceSiblingsIfNeeded(styleReattachData.nextTextSibling);
|
| - }
|
| - } else if (childNeedsReattachLayoutTree()) {
|
| - DCHECK(!needsReattachLayoutTree());
|
| - SelectorFilterParentScope filterScope(*this);
|
| - StyleSharingDepthScope sharingScope(*this);
|
| - reattachPseudoElementLayoutTree(PseudoIdBefore);
|
| - rebuildShadowRootLayoutTree();
|
| - rebuildChildrenLayoutTrees();
|
| - reattachPseudoElementLayoutTree(PseudoIdAfter);
|
| - reattachPseudoElementLayoutTree(PseudoIdBackdrop);
|
| - reattachPseudoElementLayoutTree(PseudoIdFirstLetter);
|
| - }
|
| - DCHECK(!needsStyleRecalc());
|
| - DCHECK(!childNeedsStyleRecalc());
|
| - DCHECK(!needsReattachLayoutTree());
|
| + DCHECK(parentNode()->childNeedsReattachLayoutTree());
|
| + DCHECK(needsReattachLayoutTree());
|
| + reattachLayoutTree(reattachContext);
|
| + // Since needsReattachLayoutTree() is always true we go into
|
| + // reattachLayoutTree() which reattaches all the descendant
|
| + // sub-trees. At this point no child should need reattaching.
|
| DCHECK(!childNeedsReattachLayoutTree());
|
| -}
|
| -
|
| -void Element::rebuildShadowRootLayoutTree() {
|
| - for (ShadowRoot* root = youngestShadowRoot(); root;
|
| - root = root->olderShadowRoot()) {
|
| - if (root->needsReattachLayoutTree() || root->childNeedsReattachLayoutTree())
|
| - root->rebuildLayoutTree();
|
| - }
|
| -}
|
| -
|
| -void Element::reattachPseudoElementLayoutTree(PseudoId pseudoId) {
|
| - if (PseudoElement* element = pseudoElement(pseudoId)) {
|
| - if (element->needsReattachLayoutTree() ||
|
| - element->childNeedsReattachLayoutTree())
|
| - element->rebuildLayoutTree();
|
| - } else {
|
| - createPseudoElementIfNeeded(pseudoId);
|
| - }
|
| +
|
| + if (layoutObjectWillChange || layoutObject()) {
|
| + // nextTextSibling is passed on to recalcStyle from recalcDescendantStyles
|
| + // we can either traverse the current subtree from this node onwards
|
| + // or store it.
|
| + // The choice is between increased time and increased memory complexity.
|
| + reattachWhitespaceSiblingsIfNeeded(styleReattachData.nextTextSibling);
|
| + return Reattach;
|
| + }
|
| + return ReattachNoLayoutObject;
|
| }
|
|
|
| void Element::updateCallbackSelectors(const ComputedStyle* oldStyle,
|
|
|