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 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 PassRefPtr<Node> Range::processAncestorsAndTheirSiblings(ActionType action, Node
* container, ContentsProcessDirection direction, PassRefPtr<Node> passedClonedCo
ntainer, Node* commonRoot, ExceptionState& exceptionState) | 870 PassRefPtr<Node> Range::processAncestorsAndTheirSiblings(ActionType action, Node
* container, ContentsProcessDirection direction, PassRefPtr<Node> passedClonedCo
ntainer, Node* commonRoot, ExceptionState& exceptionState) |
871 { | 871 { |
872 typedef Vector<RefPtr<Node> > NodeVector; | 872 typedef Vector<RefPtr<Node> > NodeVector; |
873 | 873 |
874 RefPtr<Node> clonedContainer = passedClonedContainer; | 874 RefPtr<Node> clonedContainer = passedClonedContainer; |
875 Vector<RefPtr<Node> > ancestors; | 875 Vector<RefPtr<Node> > ancestors; |
876 for (ContainerNode* n = container->parentNode(); n && n != commonRoot; n = n
->parentNode()) | 876 for (ContainerNode* n = container->parentNode(); n && n != commonRoot; n = n
->parentNode()) |
877 ancestors.append(n); | 877 ancestors.append(n); |
878 | 878 |
879 RefPtr<Node> firstChildInAncestorToProcess = direction == ProcessContentsFor
ward ? container->nextSibling() : container->previousSibling(); | 879 RefPtr<Node> firstChildInAncestorToProcess = direction == ProcessContentsFor
ward ? container->nextSibling() : container->previousSibling(); |
880 for (Vector<RefPtr<Node> >::const_iterator it = ancestors.begin(); it != anc
estors.end(); it++) { | 880 for (Vector<RefPtr<Node> >::const_iterator it = ancestors.begin(); it != anc
estors.end(); ++it) { |
881 RefPtr<Node> ancestor = *it; | 881 RefPtr<Node> ancestor = *it; |
882 if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) { | 882 if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) { |
883 if (RefPtr<Node> clonedAncestor = ancestor->cloneNode(false)) { // M
ight have been removed already during mutation event. | 883 if (RefPtr<Node> clonedAncestor = ancestor->cloneNode(false)) { // M
ight have been removed already during mutation event. |
884 clonedAncestor->appendChild(clonedContainer, exceptionState); | 884 clonedAncestor->appendChild(clonedContainer, exceptionState); |
885 clonedContainer = clonedAncestor; | 885 clonedContainer = clonedAncestor; |
886 } | 886 } |
887 } | 887 } |
888 | 888 |
889 // Copy siblings of an ancestor of start/end containers | 889 // Copy siblings of an ancestor of start/end containers |
890 // FIXME: This assertion may fail if DOM is modified during mutation eve
nt | 890 // FIXME: This assertion may fail if DOM is modified during mutation eve
nt |
891 // FIXME: Share code with Range::processNodes | 891 // FIXME: Share code with Range::processNodes |
892 ASSERT(!firstChildInAncestorToProcess || firstChildInAncestorToProcess->
parentNode() == ancestor); | 892 ASSERT(!firstChildInAncestorToProcess || firstChildInAncestorToProcess->
parentNode() == ancestor); |
893 | 893 |
894 NodeVector nodes; | 894 NodeVector nodes; |
895 for (Node* child = firstChildInAncestorToProcess.get(); child; | 895 for (Node* child = firstChildInAncestorToProcess.get(); child; |
896 child = (direction == ProcessContentsForward) ? child->nextSibling()
: child->previousSibling()) | 896 child = (direction == ProcessContentsForward) ? child->nextSibling()
: child->previousSibling()) |
897 nodes.append(child); | 897 nodes.append(child); |
898 | 898 |
899 for (NodeVector::const_iterator it = nodes.begin(); it != nodes.end(); i
t++) { | 899 for (NodeVector::const_iterator it = nodes.begin(); it != nodes.end(); +
+it) { |
900 Node* child = it->get(); | 900 Node* child = it->get(); |
901 switch (action) { | 901 switch (action) { |
902 case DELETE_CONTENTS: | 902 case DELETE_CONTENTS: |
903 ancestor->removeChild(child, exceptionState); | 903 ancestor->removeChild(child, exceptionState); |
904 break; | 904 break; |
905 case EXTRACT_CONTENTS: // will remove child from ancestor | 905 case EXTRACT_CONTENTS: // will remove child from ancestor |
906 if (direction == ProcessContentsForward) | 906 if (direction == ProcessContentsForward) |
907 clonedContainer->appendChild(child, exceptionState); | 907 clonedContainer->appendChild(child, exceptionState); |
908 else | 908 else |
909 clonedContainer->insertBefore(child, clonedContainer->firstC
hild(), exceptionState); | 909 clonedContainer->insertBefore(child, clonedContainer->firstC
hild(), exceptionState); |
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 | 1886 |
1887 void showTree(const WebCore::Range* range) | 1887 void showTree(const WebCore::Range* range) |
1888 { | 1888 { |
1889 if (range && range->boundaryPointsValid()) { | 1889 if (range && range->boundaryPointsValid()) { |
1890 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); | 1890 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); |
1891 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); | 1891 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); |
1892 } | 1892 } |
1893 } | 1893 } |
1894 | 1894 |
1895 #endif | 1895 #endif |
OLD | NEW |