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

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

Issue 2476163002: Fixed perf regression by removing tree traversal for text sibling. (Closed)
Patch Set: Created 4 years, 1 month 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 469bc7a952c742e9449d340a4b81df0a039a8166..c78ef3cae1563bb80a6aed761b58502d9a8dad73 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -1836,7 +1836,7 @@ PassRefPtr<ComputedStyle> Element::originalStyleForLayoutObject() {
return document().ensureStyleResolver().styleForElement(this);
}
-void Element::recalcStyle(StyleRecalcChange change) {
+void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) {
DCHECK(document().inStyleRecalc());
DCHECK(!document().lifecycle().inDetach());
DCHECK(!parentOrShadowHostNode()->needsStyleRecalc());
@@ -1857,7 +1857,7 @@ void Element::recalcStyle(StyleRecalcChange change) {
}
}
if (parentComputedStyle())
- change = recalcOwnStyle(change);
+ change = recalcOwnStyle(change, nextTextSibling);
clearNeedsStyleRecalc();
clearNeedsReattachLayoutTree();
}
@@ -1918,7 +1918,8 @@ PassRefPtr<ComputedStyle> Element::propagateInheritedProperties(
return newStyle;
}
-StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) {
+StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change,
+ Text* nextTextSibling) {
DCHECK(document().inStyleRecalc());
DCHECK(!parentOrShadowHostNode()->needsStyleRecalc());
DCHECK(change >= IndependentInherit || needsStyleRecalc());
@@ -1943,7 +1944,8 @@ StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) {
}
if (localChange == Reattach) {
- document().addNonAttachedStyle(*this, std::move(newStyle));
+ document().addStyleRecalcData(
+ *this, new StyleRecalcData(std::move(newStyle), nextTextSibling));
setNeedsReattachLayoutTree();
return rebuildLayoutTree();
}
@@ -1989,8 +1991,9 @@ StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) {
StyleRecalcChange Element::rebuildLayoutTree() {
DCHECK(inActiveDocument());
+ StyleRecalcData* styleRecalcData = document().getStyleRecalcData(*this);
AttachContext reattachContext;
- reattachContext.resolvedStyle = document().getNonAttachedStyle(*this);
+ reattachContext.resolvedStyle = styleRecalcData->computedStyle.get();
bool layoutObjectWillChange = needsAttach() || layoutObject();
// We are calling Element::rebuildLayoutTree() from inside
@@ -2010,7 +2013,7 @@ StyleRecalcChange Element::rebuildLayoutTree() {
// 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());
+ reattachWhitespaceSiblingsIfNeeded(styleRecalcData->nextTextSibling);
return Reattach;
}
return ReattachNoLayoutObject;

Powered by Google App Engine
This is Rietveld 408576698