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

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

Issue 2727233005: Remove calls to styleForLayoutObject() in LayoutTreeBuilder::style() (Closed)
Patch Set: Created 3 years, 9 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 f33de88828625bc869a80e4e0fb9c2575863396d..f68d32c6ba440f32ca98904da112079f670102eb 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -1739,6 +1739,7 @@ void Element::attachLayoutTree(const AttachContext& context) {
SelectorFilterParentScope filterScope(*this);
StyleSharingDepthScope sharingScope(*this);
+ clearNeedsReattachLayoutTree();
createPseudoElementIfNeeded(PseudoIdBefore);
// When a shadow root exists, it does the work of attaching the children.
@@ -2021,11 +2022,16 @@ StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change,
}
if (localChange == Reattach) {
+ // This mimicks Element::recalcStyleForReattach except it also stores the
+ // nextTextSibling information.
StyleReattachData styleReattachData;
styleReattachData.computedStyle = std::move(newStyle);
styleReattachData.nextTextSibling = nextTextSibling;
document().addStyleReattachData(*this, styleReattachData);
setNeedsReattachLayoutTree();
+ if (layoutObjectIsNeeded(*styleReattachData.computedStyle)) {
+ recalcContainedStyleForReattach();
+ }
return Reattach;
}
@@ -2070,6 +2076,35 @@ StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change,
return localChange;
}
+void Element::recalcStyleForReattach() {
+ StyleReattachData styleReattachData;
+ styleReattachData.computedStyle = styleForLayoutObject();
+ document().addStyleReattachData(*this, styleReattachData);
+ setNeedsReattachLayoutTree();
+ if (layoutObjectIsNeeded(*styleReattachData.computedStyle.get())) {
+ recalcContainedStyleForReattach();
+ }
+}
+
+void Element::recalcContainedStyleForReattach() {
+ if (!childrenCanHaveStyle())
+ return;
+ if (hasCustomStyleCallbacks())
+ return;
+
+ SelectorFilterParentScope filterScope(*this);
+ StyleSharingDepthScope sharingScope(*this);
+ recalcShadowRootStylesForReattach();
+ recalcDescendantStylesForReattach();
+}
+
+void Element::recalcShadowRootStylesForReattach() {
+ for (ShadowRoot* root = youngestShadowRoot(); root;
+ root = root->olderShadowRoot()) {
+ root->recalcDescendantStylesForReattach();
+ }
+}
+
void Element::rebuildLayoutTree() {
DCHECK(inActiveDocument());
DCHECK(parentNode());
@@ -3240,6 +3275,9 @@ const ComputedStyle* Element::ensureComputedStyle(
}
const ComputedStyle* Element::nonLayoutObjectComputedStyle() const {
+ if (needsReattachLayoutTree())
+ return document().getStyleReattachData(*this).computedStyle.get();
+
if (layoutObject() || !hasRareData())
return nullptr;
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/dom/LayoutTreeBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698