| 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 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include <wtf/text/StringBuilder.h> | 51 #include <wtf/text/StringBuilder.h> |
| 52 | 52 |
| 53 namespace WebCore { | 53 namespace WebCore { |
| 54 | 54 |
| 55 using namespace std; | 55 using namespace std; |
| 56 | 56 |
| 57 #ifndef NDEBUG | 57 #ifndef NDEBUG |
| 58 static WTF::RefCountedLeakCounter rangeCounter("Range"); | 58 static WTF::RefCountedLeakCounter rangeCounter("Range"); |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 typedef Vector<RefPtr<Node> > NodeVector; | |
| 62 | |
| 63 inline Range::Range(PassRefPtr<Document> ownerDocument) | 61 inline Range::Range(PassRefPtr<Document> ownerDocument) |
| 64 : m_ownerDocument(ownerDocument) | 62 : m_ownerDocument(ownerDocument) |
| 65 , m_start(m_ownerDocument) | 63 , m_start(m_ownerDocument) |
| 66 , m_end(m_ownerDocument) | 64 , m_end(m_ownerDocument) |
| 67 { | 65 { |
| 68 #ifndef NDEBUG | 66 #ifndef NDEBUG |
| 69 rangeCounter.increment(); | 67 rangeCounter.increment(); |
| 70 #endif | 68 #endif |
| 71 | 69 |
| 72 m_ownerDocument->attachRange(this); | 70 m_ownerDocument->attachRange(this); |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 case Node::XPATH_NAMESPACE_NODE: | 662 case Node::XPATH_NAMESPACE_NODE: |
| 665 case Node::SHADOW_ROOT_NODE: | 663 case Node::SHADOW_ROOT_NODE: |
| 666 return node->childNodeCount(); | 664 return node->childNodeCount(); |
| 667 } | 665 } |
| 668 ASSERT_NOT_REACHED(); | 666 ASSERT_NOT_REACHED(); |
| 669 return 0; | 667 return 0; |
| 670 } | 668 } |
| 671 | 669 |
| 672 PassRefPtr<DocumentFragment> Range::processContents(ActionType action, Exception
Code& ec) | 670 PassRefPtr<DocumentFragment> Range::processContents(ActionType action, Exception
Code& ec) |
| 673 { | 671 { |
| 672 typedef Vector<RefPtr<Node> > NodeVector; |
| 673 |
| 674 RefPtr<DocumentFragment> fragment; | 674 RefPtr<DocumentFragment> fragment; |
| 675 if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) | 675 if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) |
| 676 fragment = DocumentFragment::create(m_ownerDocument.get()); | 676 fragment = DocumentFragment::create(m_ownerDocument.get()); |
| 677 | 677 |
| 678 ec = 0; | 678 ec = 0; |
| 679 if (collapsed(ec)) | 679 if (collapsed(ec)) |
| 680 return fragment.release(); | 680 return fragment.release(); |
| 681 if (ec) | 681 if (ec) |
| 682 return 0; | 682 return 0; |
| 683 | 683 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 break; | 858 break; |
| 859 case CLONE_CONTENTS: | 859 case CLONE_CONTENTS: |
| 860 newContainer->appendChild(nodes[i]->cloneNode(true), ec); | 860 newContainer->appendChild(nodes[i]->cloneNode(true), ec); |
| 861 break; | 861 break; |
| 862 } | 862 } |
| 863 } | 863 } |
| 864 } | 864 } |
| 865 | 865 |
| 866 PassRefPtr<Node> Range::processAncestorsAndTheirSiblings(ActionType action, Node
* container, ContentsProcessDirection direction, PassRefPtr<Node> passedClonedCo
ntainer, Node* commonRoot, ExceptionCode& ec) | 866 PassRefPtr<Node> Range::processAncestorsAndTheirSiblings(ActionType action, Node
* container, ContentsProcessDirection direction, PassRefPtr<Node> passedClonedCo
ntainer, Node* commonRoot, ExceptionCode& ec) |
| 867 { | 867 { |
| 868 typedef Vector<RefPtr<Node> > NodeVector; |
| 869 |
| 868 RefPtr<Node> clonedContainer = passedClonedContainer; | 870 RefPtr<Node> clonedContainer = passedClonedContainer; |
| 869 Vector<RefPtr<Node> > ancestors; | 871 Vector<RefPtr<Node> > ancestors; |
| 870 for (ContainerNode* n = container->parentNode(); n && n != commonRoot; n = n
->parentNode()) | 872 for (ContainerNode* n = container->parentNode(); n && n != commonRoot; n = n
->parentNode()) |
| 871 ancestors.append(n); | 873 ancestors.append(n); |
| 872 | 874 |
| 873 RefPtr<Node> firstChildInAncestorToProcess = direction == ProcessContentsFor
ward ? container->nextSibling() : container->previousSibling(); | 875 RefPtr<Node> firstChildInAncestorToProcess = direction == ProcessContentsFor
ward ? container->nextSibling() : container->previousSibling(); |
| 874 for (Vector<RefPtr<Node> >::const_iterator it = ancestors.begin(); it != anc
estors.end(); it++) { | 876 for (Vector<RefPtr<Node> >::const_iterator it = ancestors.begin(); it != anc
estors.end(); it++) { |
| 875 RefPtr<Node> ancestor = *it; | 877 RefPtr<Node> ancestor = *it; |
| 876 if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) { | 878 if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) { |
| 877 if (RefPtr<Node> clonedAncestor = ancestor->cloneNode(false)) { // M
ight have been removed already during mutation event. | 879 if (RefPtr<Node> clonedAncestor = ancestor->cloneNode(false)) { // M
ight have been removed already during mutation event. |
| (...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2017 | 2019 |
| 2018 void showTree(const WebCore::Range* range) | 2020 void showTree(const WebCore::Range* range) |
| 2019 { | 2021 { |
| 2020 if (range && range->boundaryPointsValid()) { | 2022 if (range && range->boundaryPointsValid()) { |
| 2021 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); | 2023 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); |
| 2022 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); | 2024 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); |
| 2023 } | 2025 } |
| 2024 } | 2026 } |
| 2025 | 2027 |
| 2026 #endif | 2028 #endif |
| OLD | NEW |