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

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

Issue 1649983003: Remove the forced layout in getComputedStyle for elements in Shadow DOM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Look at ShadowRoots when walking up the tree in updateLayoutTreeForNodeIfNeeded. Created 4 years, 11 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/Document.cpp
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index 2e5102eb0ff09212e3e4c0f555caa6deed66b926..e776d069457751020fc33a785280746b7bcec18b 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -1902,6 +1902,16 @@ void Document::notifyLayoutTreeOfSubtreeChanges()
m_lifecycle.advanceTo(DocumentLifecycle::LayoutSubtreeChangeClean);
}
+static bool nodeMayNeedStyleRecalc(const ContainerNode& node)
rune 2016/02/01 09:24:23 Should we now use anonymous namespace instead of s
+{
+ return node.needsStyleRecalc() || node.needsStyleInvalidation() || node.needsAdjacentStyleRecalc();
+}
+
+static bool nodeMayNeedStyleRecalc(const ContainerNode* node)
+{
+ return node && nodeMayNeedStyleRecalc(*node);
+}
+
void Document::updateLayoutTreeForNodeIfNeeded(Node* node)
{
ASSERT(node);
@@ -1915,8 +1925,14 @@ void Document::updateLayoutTreeForNodeIfNeeded(Node* node)
bool needsRecalc = needsFullLayoutTreeUpdate() || node->needsStyleRecalc() || node->needsStyleInvalidation();
if (!needsRecalc) {
- for (const ContainerNode* ancestor = LayoutTreeBuilderTraversal::parent(*node); ancestor && !needsRecalc; ancestor = LayoutTreeBuilderTraversal::parent(*ancestor))
- needsRecalc = ancestor->needsStyleRecalc() || ancestor->needsStyleInvalidation() || ancestor->needsAdjacentStyleRecalc();
+ LayoutTreeBuilderTraversal::ParentDetails parentDetails;
+ for (const ContainerNode* ancestor = LayoutTreeBuilderTraversal::parent(*node, &parentDetails); ancestor && !needsRecalc; ancestor = LayoutTreeBuilderTraversal::parent(*ancestor, &parentDetails)) {
+ needsRecalc = nodeMayNeedStyleRecalc(*ancestor) || nodeMayNeedStyleRecalc(parentDetails.shadowRoot());
+ parentDetails.reset();
+ }
+ // We may have bailed out of the loop because there's no ancestor in the
+ // composed tree, but we still need to check the shadow root.
+ needsRecalc = needsRecalc || nodeMayNeedStyleRecalc(parentDetails.shadowRoot());
rune 2016/02/01 09:24:23 How could that happen? Won't every shadow root hav
}
if (needsRecalc)

Powered by Google App Engine
This is Rietveld 408576698