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

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: Rebased 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
« 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 741ab09deb5911caef748d874430ff864557ec97..b7cc35fd88b08689c815799321c8a9e47c565e40 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -1833,7 +1833,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());
@@ -1854,7 +1854,7 @@ void Element::recalcStyle(StyleRecalcChange change) {
}
}
if (parentComputedStyle())
- change = recalcOwnStyle(change);
+ change = recalcOwnStyle(change, nextTextSibling);
clearNeedsStyleRecalc();
clearNeedsReattachLayoutTree();
}
@@ -1917,7 +1917,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());
@@ -1942,7 +1943,10 @@ StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) {
}
if (localChange == Reattach) {
- document().addNonAttachedStyle(*this, std::move(newStyle));
+ StyleReattachData styleReattachData;
+ styleReattachData.computedStyle = std::move(newStyle);
+ styleReattachData.nextTextSibling = nextTextSibling;
+ document().addStyleReattachData(*this, styleReattachData);
setNeedsReattachLayoutTree();
return rebuildLayoutTree();
}
@@ -1987,8 +1991,9 @@ StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) {
StyleRecalcChange Element::rebuildLayoutTree() {
DCHECK(inActiveDocument());
+ StyleReattachData styleReattachData = document().getStyleReattachData(*this);
AttachContext reattachContext;
- reattachContext.resolvedStyle = document().getNonAttachedStyle(*this);
+ reattachContext.resolvedStyle = styleReattachData.computedStyle.get();
bool layoutObjectWillChange = needsAttach() || layoutObject();
// We are calling Element::rebuildLayoutTree() from inside
@@ -2008,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(styleReattachData.nextTextSibling);
return Reattach;
}
return ReattachNoLayoutObject;
« 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