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 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 if (startIsText) | 865 if (startIsText) |
866 checkAgainst = m_start.container()->parentNode(); | 866 checkAgainst = m_start.container()->parentNode(); |
867 else | 867 else |
868 checkAgainst = m_start.container(); | 868 checkAgainst = m_start.container(); |
869 | 869 |
870 Node::NodeType newNodeType = newNode->nodeType(); | 870 Node::NodeType newNodeType = newNode->nodeType(); |
871 int numNewChildren; | 871 int numNewChildren; |
872 if (newNodeType == Node::DOCUMENT_FRAGMENT_NODE && !newNode->isShadowRoot())
{ | 872 if (newNodeType == Node::DOCUMENT_FRAGMENT_NODE && !newNode->isShadowRoot())
{ |
873 // check each child node, not the DocumentFragment itself | 873 // check each child node, not the DocumentFragment itself |
874 numNewChildren = 0; | 874 numNewChildren = 0; |
875 for (Node* c = newNode->firstChild(); c; c = c->nextSibling()) { | 875 for (Node* c = toDocumentFragment(newNode)->firstChild(); c; c = c->next
Sibling()) { |
876 if (!checkAgainst->childTypeAllowed(c->nodeType())) { | 876 if (!checkAgainst->childTypeAllowed(c->nodeType())) { |
877 exceptionState.throwDOMException(HierarchyRequestError, "The nod
e to be inserted contains a '" + c->nodeName() + "' node, which may not be inser
ted here."); | 877 exceptionState.throwDOMException(HierarchyRequestError, "The nod
e to be inserted contains a '" + c->nodeName() + "' node, which may not be inser
ted here."); |
878 return; | 878 return; |
879 } | 879 } |
880 ++numNewChildren; | 880 ++numNewChildren; |
881 } | 881 } |
882 } else { | 882 } else { |
883 numNewChildren = 1; | 883 numNewChildren = 1; |
884 if (!checkAgainst->childTypeAllowed(newNodeType)) { | 884 if (!checkAgainst->childTypeAllowed(newNodeType)) { |
885 exceptionState.throwDOMException(HierarchyRequestError, "The node to
be inserted is a '" + newNode->nodeName() + "' node, which may not be inserted
here."); | 885 exceptionState.throwDOMException(HierarchyRequestError, "The node to
be inserted is a '" + newNode->nodeName() + "' node, which may not be inserted
here."); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 return; | 918 return; |
919 | 919 |
920 container = m_start.container(); | 920 container = m_start.container(); |
921 container->parentNode()->insertBefore(newNode.release(), newText.get(),
exceptionState); | 921 container->parentNode()->insertBefore(newNode.release(), newText.get(),
exceptionState); |
922 if (exceptionState.hadException()) | 922 if (exceptionState.hadException()) |
923 return; | 923 return; |
924 | 924 |
925 if (collapsed) | 925 if (collapsed) |
926 m_end.setToBeforeChild(*newText); | 926 m_end.setToBeforeChild(*newText); |
927 } else { | 927 } else { |
928 RefPtrWillBeRawPtr<Node> lastChild = (newNodeType == Node::DOCUMENT_FRAG
MENT_NODE) ? newNode->lastChild() : newNode.get(); | 928 RefPtrWillBeRawPtr<Node> lastChild = (newNodeType == Node::DOCUMENT_FRAG
MENT_NODE) ? toDocumentFragment(newNode)->lastChild() : newNode.get(); |
929 if (lastChild && lastChild == m_start.childBefore()) { | 929 if (lastChild && lastChild == m_start.childBefore()) { |
930 // The insertion will do nothing, but we need to extend the range to
include | 930 // The insertion will do nothing, but we need to extend the range to
include |
931 // the inserted nodes. | 931 // the inserted nodes. |
932 Node* firstChild = (newNodeType == Node::DOCUMENT_FRAGMENT_NODE) ? n
ewNode->firstChild() : newNode.get(); | 932 Node* firstChild = (newNodeType == Node::DOCUMENT_FRAGMENT_NODE) ? t
oDocumentFragment(newNode)->firstChild() : newNode.get(); |
933 ASSERT(firstChild); | 933 ASSERT(firstChild); |
934 m_start.setToBeforeChild(*firstChild); | 934 m_start.setToBeforeChild(*firstChild); |
935 return; | 935 return; |
936 } | 936 } |
937 | 937 |
938 container = m_start.container(); | 938 container = m_start.container(); |
939 container->insertBefore(newNode.release(), container->traverseToChildAt(
m_start.offset()), exceptionState); | 939 container->insertBefore(newNode.release(), container->traverseToChildAt(
m_start.offset()), exceptionState); |
940 if (exceptionState.hadException()) | 940 if (exceptionState.hadException()) |
941 return; | 941 return; |
942 | 942 |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1694 | 1694 |
1695 void showTree(const WebCore::Range* range) | 1695 void showTree(const WebCore::Range* range) |
1696 { | 1696 { |
1697 if (range && range->boundaryPointsValid()) { | 1697 if (range && range->boundaryPointsValid()) { |
1698 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); | 1698 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); |
1699 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); | 1699 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); |
1700 } | 1700 } |
1701 } | 1701 } |
1702 | 1702 |
1703 #endif | 1703 #endif |
OLD | NEW |