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 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 checkAgainst = m_start.container()->parentNode(); | 809 checkAgainst = m_start.container()->parentNode(); |
810 else | 810 else |
811 checkAgainst = m_start.container(); | 811 checkAgainst = m_start.container(); |
812 | 812 |
813 Node::NodeType newNodeType = newNode->nodeType(); | 813 Node::NodeType newNodeType = newNode->nodeType(); |
814 int numNewChildren; | 814 int numNewChildren; |
815 if (newNodeType == Node::DOCUMENT_FRAGMENT_NODE && !newNode->isShadowRoot())
{ | 815 if (newNodeType == Node::DOCUMENT_FRAGMENT_NODE && !newNode->isShadowRoot())
{ |
816 // check each child node, not the DocumentFragment itself | 816 // check each child node, not the DocumentFragment itself |
817 numNewChildren = 0; | 817 numNewChildren = 0; |
818 for (Node* c = toDocumentFragment(newNode)->firstChild(); c; c = c->next
Sibling()) { | 818 for (Node* c = toDocumentFragment(newNode)->firstChild(); c; c = c->next
Sibling()) { |
819 if (!checkAgainst->childTypeAllowed(c->nodeType())) { | |
820 exceptionState.throwDOMException(HierarchyRequestError, "The nod
e to be inserted contains a '" + c->nodeName() + "' node, which may not be inser
ted here."); | |
821 return; | |
822 } | |
823 ++numNewChildren; | 819 ++numNewChildren; |
824 } | 820 } |
825 } else { | 821 } else { |
826 numNewChildren = 1; | 822 numNewChildren = 1; |
827 if (!checkAgainst->childTypeAllowed(newNodeType)) { | |
828 exceptionState.throwDOMException(HierarchyRequestError, "The node to
be inserted is a '" + newNode->nodeName() + "' node, which may not be inserted
here."); | |
829 return; | |
830 } | |
831 } | 823 } |
832 | 824 |
833 for (Node* n = m_start.container(); n; n = n->parentNode()) { | 825 for (Node* n = m_start.container(); n; n = n->parentNode()) { |
834 if (n == newNode) { | 826 if (n == newNode) { |
835 exceptionState.throwDOMException(HierarchyRequestError, "The node to
be inserted contains the insertion point; it may not be inserted into itself.")
; | 827 exceptionState.throwDOMException(HierarchyRequestError, "The node to
be inserted contains the insertion point; it may not be inserted into itself.")
; |
836 return; | 828 return; |
837 } | 829 } |
838 } | 830 } |
839 | 831 |
840 // InvalidNodeTypeError: Raised if newNode is an Attr, Entity, Notation, Sha
dowRoot or Document node. | 832 // InvalidNodeTypeError: Raised if newNode is an Attr, Entity, Notation, Sha
dowRoot or Document node. |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 // need to accept newParent (or in the case of a comment, it logically "woul
d" be inserted into the parent, | 1103 // need to accept newParent (or in the case of a comment, it logically "woul
d" be inserted into the parent, |
1112 // although this will fail below for another reason). | 1104 // although this will fail below for another reason). |
1113 if (parentOfNewParent->isCharacterDataNode()) | 1105 if (parentOfNewParent->isCharacterDataNode()) |
1114 parentOfNewParent = parentOfNewParent->parentNode(); | 1106 parentOfNewParent = parentOfNewParent->parentNode(); |
1115 | 1107 |
1116 if (!parentOfNewParent) { | 1108 if (!parentOfNewParent) { |
1117 exceptionState.throwDOMException(HierarchyRequestError, "The container n
ode is a detached character data node; no parent node is available for insertion
."); | 1109 exceptionState.throwDOMException(HierarchyRequestError, "The container n
ode is a detached character data node; no parent node is available for insertion
."); |
1118 return; | 1110 return; |
1119 } | 1111 } |
1120 | 1112 |
1121 if (!parentOfNewParent->childTypeAllowed(newParent->nodeType())) { | |
1122 exceptionState.throwDOMException(HierarchyRequestError, "The node provid
ed is of type '" + newParent->nodeName() + "', which may not be inserted here.")
; | |
1123 return; | |
1124 } | |
1125 | |
1126 if (newParent->contains(m_start.container())) { | 1113 if (newParent->contains(m_start.container())) { |
1127 exceptionState.throwDOMException(HierarchyRequestError, "The node provid
ed contains the insertion point; it may not be inserted into itself."); | 1114 exceptionState.throwDOMException(HierarchyRequestError, "The node provid
ed contains the insertion point; it may not be inserted into itself."); |
1128 return; | 1115 return; |
1129 } | 1116 } |
1130 | 1117 |
1131 // FIXME: Do we need a check if the node would end up with a child node of a
type not | 1118 // FIXME: Do we need a check if the node would end up with a child node of a
type not |
1132 // allowed by the type of node? | 1119 // allowed by the type of node? |
1133 | 1120 |
1134 while (Node* n = newParent->firstChild()) { | 1121 while (Node* n = newParent->firstChild()) { |
1135 toContainerNode(newParent)->removeChild(n, exceptionState); | 1122 toContainerNode(newParent)->removeChild(n, exceptionState); |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 | 1520 |
1534 void showTree(const blink::Range* range) | 1521 void showTree(const blink::Range* range) |
1535 { | 1522 { |
1536 if (range && range->boundaryPointsValid()) { | 1523 if (range && range->boundaryPointsValid()) { |
1537 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); | 1524 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); |
1538 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); | 1525 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); |
1539 } | 1526 } |
1540 } | 1527 } |
1541 | 1528 |
1542 #endif | 1529 #endif |
OLD | NEW |