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 a403176069c3b352a8a11cbf448a268666686e72..f040578077ee87dd16ef8915aa011ba73ccbfbf2 100644 |
--- a/third_party/WebKit/Source/core/dom/Element.cpp |
+++ b/third_party/WebKit/Source/core/dom/Element.cpp |
@@ -2037,12 +2037,13 @@ void Element::rebuildLayoutTree(Text* nextTextSibling) { |
DCHECK(!needsReattachLayoutTree()); |
SelectorFilterParentScope filterScope(*this); |
StyleSharingDepthScope sharingScope(*this); |
- reattachPseudoElementLayoutTree(PseudoIdBefore); |
- rebuildShadowRootLayoutTree(); |
- rebuildChildrenLayoutTrees(); |
- reattachPseudoElementLayoutTree(PseudoIdAfter); |
- reattachPseudoElementLayoutTree(PseudoIdBackdrop); |
- reattachPseudoElementLayoutTree(PseudoIdFirstLetter); |
+ Text* nextTextSibling = nullptr; |
+ rebuildPseudoElementLayoutTree(PseudoIdAfter); |
+ rebuildShadowRootLayoutTree(nextTextSibling); |
+ rebuildChildrenLayoutTrees(nextTextSibling); |
+ rebuildPseudoElementLayoutTree(PseudoIdBefore, nextTextSibling); |
+ rebuildPseudoElementLayoutTree(PseudoIdBackdrop); |
+ rebuildPseudoElementLayoutTree(PseudoIdFirstLetter); |
} |
DCHECK(!needsStyleRecalc()); |
DCHECK(!childNeedsStyleRecalc()); |
@@ -2050,19 +2051,22 @@ void Element::rebuildLayoutTree(Text* nextTextSibling) { |
DCHECK(!childNeedsReattachLayoutTree()); |
} |
-void Element::rebuildShadowRootLayoutTree() { |
+void Element::rebuildShadowRootLayoutTree(Text*& nextTextSibling) { |
for (ShadowRoot* root = youngestShadowRoot(); root; |
root = root->olderShadowRoot()) { |
- if (root->needsReattachLayoutTree() || root->childNeedsReattachLayoutTree()) |
- root->rebuildLayoutTree(); |
+ // TODO(rune@opera.com): nextTextSibling is not set correctly when we have |
+ // slotted nodes (crbug.com/648931). Also, it may be incorrect when we have |
+ // multiple shadow roots (for V0 shadow hosts). |
+ root->rebuildLayoutTree(nextTextSibling); |
} |
} |
-void Element::reattachPseudoElementLayoutTree(PseudoId pseudoId) { |
+void Element::rebuildPseudoElementLayoutTree(PseudoId pseudoId, |
+ Text* nextTextSibling) { |
if (PseudoElement* element = pseudoElement(pseudoId)) { |
if (element->needsReattachLayoutTree() || |
element->childNeedsReattachLayoutTree()) |
- element->rebuildLayoutTree(); |
+ element->rebuildLayoutTree(nextTextSibling); |
} else { |
createPseudoElementIfNeeded(pseudoId); |
} |