Chromium Code Reviews| 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) |