Chromium Code Reviews| 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..75ec9446f6fd349cf5b75d86b34052a93ddd7fdd 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); |
|
esprehn
2017/03/28 20:56:51
Why do we only need this for ::before?
rune
2017/03/29 10:39:47
We always evaluate the need for a whitespace layou
|
| + rebuildPseudoElementLayoutTree(PseudoIdBackdrop); |
| + rebuildPseudoElementLayoutTree(PseudoIdFirstLetter); |
| } |
| DCHECK(!needsStyleRecalc()); |
| DCHECK(!childNeedsStyleRecalc()); |
| @@ -2050,19 +2051,31 @@ void Element::rebuildLayoutTree(Text* nextTextSibling) { |
| DCHECK(!childNeedsReattachLayoutTree()); |
| } |
| -void Element::rebuildShadowRootLayoutTree() { |
| +void Element::rebuildShadowRootLayoutTree(Text*& nextTextSibling) { |
| for (ShadowRoot* root = youngestShadowRoot(); root; |
| root = root->olderShadowRoot()) { |
| + // 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). |
| + // |
| + // When we call this method and neither this, nor our child nodes are marked |
| + // for re-attachment, it means one or more pseudo elements needs re- |
| + // attachment. In that case, find the first text node sibling not preceeded |
| + // by any in-flow children as the nextTextSibling to allow correct |
| + // whitespace re-attachment if the ::before element display changes. |
| if (root->needsReattachLayoutTree() || root->childNeedsReattachLayoutTree()) |
| - root->rebuildLayoutTree(); |
| + root->rebuildLayoutTree(nextTextSibling); |
| + else |
| + nextTextSibling = root->findNextTextSibling(); |
|
esprehn
2017/03/28 20:56:51
ShadowRoot can't have siblings so this doesn't mak
rune
2017/03/29 10:39:47
Rewrote this for PS2.
|
| } |
| } |
| -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); |
| } |