Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Unified Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 2729453002: Revert of Call Element::rebuildLayoutTree from Document::updateStyle directly (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/dom/Node.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/dom/Node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698