| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) | 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) |
| 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) | 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) |
| 5 * (C) 2001 Peter Kelly (pmk@post.com) | 5 * (C) 2001 Peter Kelly (pmk@post.com) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
| 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 break; | 648 break; |
| 649 } | 649 } |
| 650 } | 650 } |
| 651 } | 651 } |
| 652 | 652 |
| 653 Node* Range::processAncestorsAndTheirSiblings(ActionType action, Node* container
, ContentsProcessDirection direction, Node* clonedContainer, Node* commonRoot, E
xceptionState& exceptionState) | 653 Node* Range::processAncestorsAndTheirSiblings(ActionType action, Node* container
, ContentsProcessDirection direction, Node* clonedContainer, Node* commonRoot, E
xceptionState& exceptionState) |
| 654 { | 654 { |
| 655 typedef HeapVector<Member<Node>> NodeVector; | 655 typedef HeapVector<Member<Node>> NodeVector; |
| 656 | 656 |
| 657 NodeVector ancestors; | 657 NodeVector ancestors; |
| 658 for (ContainerNode* n = container->parentNode(); n && n != commonRoot; n = n
->parentNode()) | 658 for (Node& runner : NodeTraversal::ancestorsOf(*container)) { |
| 659 ancestors.append(n); | 659 if (runner == commonRoot) |
| 660 break; |
| 661 ancestors.append(runner); |
| 662 } |
| 660 | 663 |
| 661 Node* firstChildInAncestorToProcess = direction == ProcessContentsForward ?
container->nextSibling() : container->previousSibling(); | 664 Node* firstChildInAncestorToProcess = direction == ProcessContentsForward ?
container->nextSibling() : container->previousSibling(); |
| 662 for (const auto& ancestor : ancestors) { | 665 for (const auto& ancestor : ancestors) { |
| 663 if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) { | 666 if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) { |
| 664 if (Node* clonedAncestor = ancestor->cloneNode(false)) { // Might ha
ve been removed already during mutation event. | 667 if (Node* clonedAncestor = ancestor->cloneNode(false)) { // Might ha
ve been removed already during mutation event. |
| 665 clonedAncestor->appendChild(clonedContainer, exceptionState); | 668 clonedAncestor->appendChild(clonedContainer, exceptionState); |
| 666 clonedContainer = clonedAncestor; | 669 clonedContainer = clonedAncestor; |
| 667 } | 670 } |
| 668 } | 671 } |
| 669 | 672 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 ++numNewChildren; | 762 ++numNewChildren; |
| 760 } | 763 } |
| 761 } else { | 764 } else { |
| 762 numNewChildren = 1; | 765 numNewChildren = 1; |
| 763 if (!checkAgainst->childTypeAllowed(newNodeType)) { | 766 if (!checkAgainst->childTypeAllowed(newNodeType)) { |
| 764 exceptionState.throwDOMException(HierarchyRequestError, "The node to
be inserted is a '" + newNode->nodeName() + "' node, which may not be inserted
here."); | 767 exceptionState.throwDOMException(HierarchyRequestError, "The node to
be inserted is a '" + newNode->nodeName() + "' node, which may not be inserted
here."); |
| 765 return; | 768 return; |
| 766 } | 769 } |
| 767 } | 770 } |
| 768 | 771 |
| 769 for (Node* n = m_start.container(); n; n = n->parentNode()) { | 772 for (Node& node : NodeTraversal::inclusiveAncestorsOf(*m_start.container()))
{ |
| 770 if (n == newNode) { | 773 if (node == newNode) { |
| 771 exceptionState.throwDOMException(HierarchyRequestError, "The node to
be inserted contains the insertion point; it may not be inserted into itself.")
; | 774 exceptionState.throwDOMException(HierarchyRequestError, "The node to
be inserted contains the insertion point; it may not be inserted into itself.")
; |
| 772 return; | 775 return; |
| 773 } | 776 } |
| 774 } | 777 } |
| 775 | 778 |
| 776 // InvalidNodeTypeError: Raised if newNode is an Attr, Entity, Notation, Sha
dowRoot or Document node. | 779 // InvalidNodeTypeError: Raised if newNode is an Attr, Entity, Notation, Sha
dowRoot or Document node. |
| 777 switch (newNodeType) { | 780 switch (newNodeType) { |
| 778 case Node::ATTRIBUTE_NODE: | 781 case Node::ATTRIBUTE_NODE: |
| 779 case Node::DOCUMENT_NODE: | 782 case Node::DOCUMENT_NODE: |
| 780 exceptionState.throwDOMException(InvalidNodeTypeError, "The node to be i
nserted is a '" + newNode->nodeName() + "' node, which may not be inserted here.
"); | 783 exceptionState.throwDOMException(InvalidNodeTypeError, "The node to be i
nserted is a '" + newNode->nodeName() + "' node, which may not be inserted here.
"); |
| (...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1608 { | 1611 { |
| 1609 if (range && range->boundaryPointsValid()) { | 1612 if (range && range->boundaryPointsValid()) { |
| 1610 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); | 1613 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); |
| 1611 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); | 1614 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); |
| 1612 } else { | 1615 } else { |
| 1613 fprintf(stderr, "Cannot show tree if range is null, or if boundary point
s are invalid.\n"); | 1616 fprintf(stderr, "Cannot show tree if range is null, or if boundary point
s are invalid.\n"); |
| 1614 } | 1617 } |
| 1615 } | 1618 } |
| 1616 | 1619 |
| 1617 #endif | 1620 #endif |
| OLD | NEW |