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

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

Issue 2398293003: Move Layout Tree Construction code into Element::rebuildLayoutTree() (Closed)
Patch Set: Addressing bugsnash@ comments Created 4 years, 2 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
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 7a6688b1a524f0d35371390cd52e2ea488d15955..87358e406672c75765afe1deeaba2bd1bd9836cf 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -1858,6 +1858,7 @@ void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) {
if (parentComputedStyle())
change = recalcOwnStyle(change);
clearNeedsStyleRecalc();
+ clearNeedsReattachLayoutTree();
}
// If we reattached we don't need to recalc the style of our descendants
@@ -1889,13 +1890,11 @@ void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) {
childNeedsStyleRecalc() ? Force : change);
clearChildNeedsStyleRecalc();
+ clearChildNeedsReattachLayoutTree();
esprehn 2016/10/17 21:36:26 Note that once you start walking the tree you're n
nainar 2016/10/18 00:04:41 Done.
}
if (hasCustomStyleCallbacks())
didRecalcStyle(change);
-
- if (change == Reattach)
- reattachWhitespaceSiblingsIfNeeded(nextTextSibling);
}
PassRefPtr<ComputedStyle> Element::propagateInheritedProperties(
@@ -1944,6 +1943,7 @@ StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) {
if (localChange == Reattach) {
document().addNonAttachedStyle(*this, std::move(newStyle));
+ setNeedsReattachLayoutTree();
return rebuildLayoutTree();
}
@@ -1990,9 +1990,25 @@ StyleRecalcChange Element::rebuildLayoutTree() {
AttachContext reattachContext;
esprehn 2016/10/17 21:36:26 DCHECK(inActiveDocument()) in this function
nainar 2016/10/18 00:04:41 Done.
reattachContext.resolvedStyle = document().getNonAttachedStyle(*this);
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(needsReattachLayoutTree());
reattachLayoutTree(reattachContext);
- if (layoutObjectWillChange || layoutObject())
+ // 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());
esprehn 2016/10/17 21:36:26 DCHECK(parentNode()); DCHECK(parentNode()->childNe
nainar 2016/10/18 00:04:41 Done.
+
+ 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(nextTextSibling());
return Reattach;
+ }
return ReattachNoLayoutObject;
}

Powered by Google App Engine
This is Rietveld 408576698