Index: third_party/WebKit/Source/core/dom/ContainerNode.cpp |
diff --git a/third_party/WebKit/Source/core/dom/ContainerNode.cpp b/third_party/WebKit/Source/core/dom/ContainerNode.cpp |
index 46aacf5a09266351f9e34286c481c4bf70ec6f1c..fcd326cb49035a75c0c2afc5156172234dbdcb49 100644 |
--- a/third_party/WebKit/Source/core/dom/ContainerNode.cpp |
+++ b/third_party/WebKit/Source/core/dom/ContainerNode.cpp |
@@ -1298,7 +1298,7 @@ void ContainerNode::recalcDescendantStyles(StyleRecalcChange change) { |
} |
} |
-void ContainerNode::rebuildChildrenLayoutTrees() { |
+void ContainerNode::rebuildChildrenLayoutTrees(Text*& nextTextSibling) { |
DCHECK(!needsReattachLayoutTree()); |
// This loop is deliberately backwards because we use insertBefore in the |
@@ -1306,21 +1306,20 @@ void ContainerNode::rebuildChildrenLayoutTrees() { |
// point while building the layout tree. Having us start from the last child |
// and work our way back means in the common case, we'll find the insertion |
// point in O(1) time. See crbug.com/288225 |
- Text* lastTextNode = nullptr; |
for (Node* child = lastChild(); child; child = child->previousSibling()) { |
bool rebuildChild = child->needsReattachLayoutTree() || |
child->childNeedsReattachLayoutTree(); |
if (child->isTextNode()) { |
Text* textNode = toText(child); |
if (rebuildChild) |
- textNode->rebuildTextLayoutTree(lastTextNode); |
- lastTextNode = textNode; |
+ textNode->rebuildTextLayoutTree(nextTextSibling); |
+ nextTextSibling = textNode; |
} else if (child->isElementNode()) { |
Element* element = toElement(child); |
if (rebuildChild) |
- element->rebuildLayoutTree(lastTextNode); |
+ element->rebuildLayoutTree(nextTextSibling); |
if (element->layoutObject()) |
- lastTextNode = nullptr; |
+ nextTextSibling = nullptr; |
} |
} |
// This is done in ContainerNode::attachLayoutTree but will never be cleared |
@@ -1329,6 +1328,18 @@ void ContainerNode::rebuildChildrenLayoutTrees() { |
clearChildNeedsReattachLayoutTree(); |
} |
+Text* ContainerNode::findNextTextSibling() const { |
esprehn
2017/03/28 20:56:51
This needs a better name, it's doing something ver
rune
2017/03/29 10:39:47
PS2 adds a new method on ShadowRoot instead.
|
+ for (Node* sibling = firstChild(); sibling; |
esprehn
2017/03/28 20:56:51
This is confusing, the function says sibling, but
rune
2017/03/29 10:39:47
Acknowledged.
|
+ sibling = sibling->nextSibling()) { |
+ if (sibling->isTextNode()) |
+ return toText(sibling); |
+ LayoutObject* layoutObject = sibling->layoutObject(); |
+ if (layoutObject && !layoutObject->isFloatingOrOutOfFlowPositioned()) |
esprehn
2017/03/28 20:56:51
Why is it safe to call this here? Wouldn't the sty
rune
2017/03/29 10:39:47
This code should be executed during rebuildLayoutT
|
+ return nullptr; |
+ } |
+ return nullptr; |
+} |
+ |
void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, |
Element* changedElement, |
Node* nodeBeforeChange, |