| Index: third_party/WebKit/Source/core/dom/Range.cpp
|
| diff --git a/third_party/WebKit/Source/core/dom/Range.cpp b/third_party/WebKit/Source/core/dom/Range.cpp
|
| index 9fd0d868fca088ed527d147653961b2f3b649b1c..b662e2bbdc9d43968c99f0126332ed0825b854e1 100644
|
| --- a/third_party/WebKit/Source/core/dom/Range.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/Range.cpp
|
| @@ -655,8 +655,11 @@ Node* Range::processAncestorsAndTheirSiblings(ActionType action, Node* container
|
| typedef HeapVector<Member<Node>> NodeVector;
|
|
|
| NodeVector ancestors;
|
| - for (ContainerNode* n = container->parentNode(); n && n != commonRoot; n = n->parentNode())
|
| - ancestors.append(n);
|
| + for (Node& runner : NodeTraversal::ancestorsOf(*container)) {
|
| + if (runner == commonRoot)
|
| + break;
|
| + ancestors.append(runner);
|
| + }
|
|
|
| Node* firstChildInAncestorToProcess = direction == ProcessContentsForward ? container->nextSibling() : container->previousSibling();
|
| for (const auto& ancestor : ancestors) {
|
| @@ -766,8 +769,8 @@ void Range::insertNode(Node* newNode, ExceptionState& exceptionState)
|
| }
|
| }
|
|
|
| - for (Node* n = m_start.container(); n; n = n->parentNode()) {
|
| - if (n == newNode) {
|
| + for (Node& node : NodeTraversal::inclusiveAncestorsOf(*m_start.container())) {
|
| + if (node == newNode) {
|
| exceptionState.throwDOMException(HierarchyRequestError, "The node to be inserted contains the insertion point; it may not be inserted into itself.");
|
| return;
|
| }
|
|
|