| 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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 while (thisTop->parentNode()) | 355 while (thisTop->parentNode()) |
| 356 thisTop = thisTop->parentNode(); | 356 thisTop = thisTop->parentNode(); |
| 357 while (sourceTop->parentNode()) | 357 while (sourceTop->parentNode()) |
| 358 sourceTop = sourceTop->parentNode(); | 358 sourceTop = sourceTop->parentNode(); |
| 359 if (thisTop != sourceTop) { // in different DocumentFragments | 359 if (thisTop != sourceTop) { // in different DocumentFragments |
| 360 exceptionState.throwDOMException(WrongDocumentError, "The source range i
s in a different document than this range."); | 360 exceptionState.throwDOMException(WrongDocumentError, "The source range i
s in a different document than this range."); |
| 361 return 0; | 361 return 0; |
| 362 } | 362 } |
| 363 | 363 |
| 364 switch (how) { | 364 switch (how) { |
| 365 case START_TO_START: | 365 case START_TO_START: |
| 366 return compareBoundaryPoints(m_start, sourceRange->m_start, exceptio
nState); | 366 return compareBoundaryPoints(m_start, sourceRange->m_start, exceptionSta
te); |
| 367 case START_TO_END: | 367 case START_TO_END: |
| 368 return compareBoundaryPoints(m_end, sourceRange->m_start, exceptionS
tate); | 368 return compareBoundaryPoints(m_end, sourceRange->m_start, exceptionState
); |
| 369 case END_TO_END: | 369 case END_TO_END: |
| 370 return compareBoundaryPoints(m_end, sourceRange->m_end, exceptionSta
te); | 370 return compareBoundaryPoints(m_end, sourceRange->m_end, exceptionState); |
| 371 case END_TO_START: | 371 case END_TO_START: |
| 372 return compareBoundaryPoints(m_start, sourceRange->m_end, exceptionS
tate); | 372 return compareBoundaryPoints(m_start, sourceRange->m_end, exceptionState
); |
| 373 } | 373 } |
| 374 | 374 |
| 375 ASSERT_NOT_REACHED(); | 375 ASSERT_NOT_REACHED(); |
| 376 return 0; | 376 return 0; |
| 377 } | 377 } |
| 378 | 378 |
| 379 short Range::compareBoundaryPoints(Node* containerA, int offsetA, Node* containe
rB, int offsetB, ExceptionState& exceptionState) | 379 short Range::compareBoundaryPoints(Node* containerA, int offsetA, Node* containe
rB, int offsetB, ExceptionState& exceptionState) |
| 380 { | 380 { |
| 381 bool disconnected = false; | 381 bool disconnected = false; |
| 382 short result = EditingStrategy::comparePositions(containerA, offsetA, contai
nerB, offsetB, &disconnected); | 382 short result = EditingStrategy::comparePositions(containerA, offsetA, contai
nerB, offsetB, &disconnected); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 case Node::TEXT_NODE: | 648 case Node::TEXT_NODE: |
| 649 case Node::CDATA_SECTION_NODE: | 649 case Node::CDATA_SECTION_NODE: |
| 650 case Node::COMMENT_NODE: | 650 case Node::COMMENT_NODE: |
| 651 endOffset = std::min(endOffset, toCharacterData(container)->length()); | 651 endOffset = std::min(endOffset, toCharacterData(container)->length()); |
| 652 if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) { | 652 if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) { |
| 653 RefPtrWillBeRawPtr<CharacterData> c = static_pointer_cast<CharacterD
ata>(container->cloneNode(true)); | 653 RefPtrWillBeRawPtr<CharacterData> c = static_pointer_cast<CharacterD
ata>(container->cloneNode(true)); |
| 654 deleteCharacterData(c, startOffset, endOffset, exceptionState); | 654 deleteCharacterData(c, startOffset, endOffset, exceptionState); |
| 655 if (fragment) { | 655 if (fragment) { |
| 656 result = fragment; | 656 result = fragment; |
| 657 result->appendChild(c.release(), exceptionState); | 657 result->appendChild(c.release(), exceptionState); |
| 658 } else | 658 } else { |
| 659 result = c.release(); | 659 result = c.release(); |
| 660 } |
| 660 } | 661 } |
| 661 if (action == EXTRACT_CONTENTS || action == DELETE_CONTENTS) | 662 if (action == EXTRACT_CONTENTS || action == DELETE_CONTENTS) |
| 662 toCharacterData(container)->deleteData(startOffset, endOffset - star
tOffset, exceptionState); | 663 toCharacterData(container)->deleteData(startOffset, endOffset - star
tOffset, exceptionState); |
| 663 break; | 664 break; |
| 664 case Node::PROCESSING_INSTRUCTION_NODE: | 665 case Node::PROCESSING_INSTRUCTION_NODE: |
| 665 endOffset = std::min(endOffset, toProcessingInstruction(container)->data
().length()); | 666 endOffset = std::min(endOffset, toProcessingInstruction(container)->data
().length()); |
| 666 if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) { | 667 if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) { |
| 667 RefPtrWillBeRawPtr<ProcessingInstruction> c = static_pointer_cast<Pr
ocessingInstruction>(container->cloneNode(true)); | 668 RefPtrWillBeRawPtr<ProcessingInstruction> c = static_pointer_cast<Pr
ocessingInstruction>(container->cloneNode(true)); |
| 668 c->setData(c->data().substring(startOffset, endOffset - startOffset)
); | 669 c->setData(c->data().substring(startOffset, endOffset - startOffset)
); |
| 669 if (fragment) { | 670 if (fragment) { |
| 670 result = fragment; | 671 result = fragment; |
| 671 result->appendChild(c.release(), exceptionState); | 672 result->appendChild(c.release(), exceptionState); |
| 672 } else | 673 } else { |
| 673 result = c.release(); | 674 result = c.release(); |
| 675 } |
| 674 } | 676 } |
| 675 if (action == EXTRACT_CONTENTS || action == DELETE_CONTENTS) { | 677 if (action == EXTRACT_CONTENTS || action == DELETE_CONTENTS) { |
| 676 ProcessingInstruction* pi = toProcessingInstruction(container); | 678 ProcessingInstruction* pi = toProcessingInstruction(container); |
| 677 String data(pi->data()); | 679 String data(pi->data()); |
| 678 data.remove(startOffset, endOffset - startOffset); | 680 data.remove(startOffset, endOffset - startOffset); |
| 679 pi->setData(data); | 681 pi->setData(data); |
| 680 } | 682 } |
| 681 break; | 683 break; |
| 682 case Node::ELEMENT_NODE: | 684 case Node::ELEMENT_NODE: |
| 683 case Node::ATTRIBUTE_NODE: | 685 case Node::ATTRIBUTE_NODE: |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 | 982 |
| 981 | 983 |
| 982 void Range::detach() | 984 void Range::detach() |
| 983 { | 985 { |
| 984 // This is now a no-op as per the DOM specification. | 986 // This is now a no-op as per the DOM specification. |
| 985 } | 987 } |
| 986 | 988 |
| 987 Node* Range::checkNodeWOffset(Node* n, int offset, ExceptionState& exceptionStat
e) const | 989 Node* Range::checkNodeWOffset(Node* n, int offset, ExceptionState& exceptionStat
e) const |
| 988 { | 990 { |
| 989 switch (n->nodeType()) { | 991 switch (n->nodeType()) { |
| 990 case Node::DOCUMENT_TYPE_NODE: | 992 case Node::DOCUMENT_TYPE_NODE: |
| 991 exceptionState.throwDOMException(InvalidNodeTypeError, "The node pro
vided is of type '" + n->nodeName() + "'."); | 993 exceptionState.throwDOMException(InvalidNodeTypeError, "The node provide
d is of type '" + n->nodeName() + "'."); |
| 994 return nullptr; |
| 995 case Node::CDATA_SECTION_NODE: |
| 996 case Node::COMMENT_NODE: |
| 997 case Node::TEXT_NODE: |
| 998 if (static_cast<unsigned>(offset) > toCharacterData(n)->length()) |
| 999 exceptionState.throwDOMException(IndexSizeError, "The offset " + Str
ing::number(offset) + " is larger than or equal to the node's length (" + String
::number(toCharacterData(n)->length()) + ")."); |
| 1000 return nullptr; |
| 1001 case Node::PROCESSING_INSTRUCTION_NODE: |
| 1002 if (static_cast<unsigned>(offset) > toProcessingInstruction(n)->data().l
ength()) |
| 1003 exceptionState.throwDOMException(IndexSizeError, "The offset " + Str
ing::number(offset) + " is larger than or equal to than the node's length (" + S
tring::number(toProcessingInstruction(n)->data().length()) + ")."); |
| 1004 return nullptr; |
| 1005 case Node::ATTRIBUTE_NODE: |
| 1006 case Node::DOCUMENT_FRAGMENT_NODE: |
| 1007 case Node::DOCUMENT_NODE: |
| 1008 case Node::ELEMENT_NODE: { |
| 1009 if (!offset) |
| 992 return nullptr; | 1010 return nullptr; |
| 993 case Node::CDATA_SECTION_NODE: | 1011 Node* childBefore = NodeTraversal::childAt(*n, offset - 1); |
| 994 case Node::COMMENT_NODE: | 1012 if (!childBefore) |
| 995 case Node::TEXT_NODE: | 1013 exceptionState.throwDOMException(IndexSizeError, "There is no child
at offset " + String::number(offset) + "."); |
| 996 if (static_cast<unsigned>(offset) > toCharacterData(n)->length()) | 1014 return childBefore; |
| 997 exceptionState.throwDOMException(IndexSizeError, "The offset " +
String::number(offset) + " is larger than or equal to the node's length (" + St
ring::number(toCharacterData(n)->length()) + ")."); | 1015 } |
| 998 return nullptr; | |
| 999 case Node::PROCESSING_INSTRUCTION_NODE: | |
| 1000 if (static_cast<unsigned>(offset) > toProcessingInstruction(n)->data
().length()) | |
| 1001 exceptionState.throwDOMException(IndexSizeError, "The offset " +
String::number(offset) + " is larger than or equal to than the node's length ("
+ String::number(toProcessingInstruction(n)->data().length()) + ")."); | |
| 1002 return nullptr; | |
| 1003 case Node::ATTRIBUTE_NODE: | |
| 1004 case Node::DOCUMENT_FRAGMENT_NODE: | |
| 1005 case Node::DOCUMENT_NODE: | |
| 1006 case Node::ELEMENT_NODE: { | |
| 1007 if (!offset) | |
| 1008 return nullptr; | |
| 1009 Node* childBefore = NodeTraversal::childAt(*n, offset - 1); | |
| 1010 if (!childBefore) | |
| 1011 exceptionState.throwDOMException(IndexSizeError, "There is no ch
ild at offset " + String::number(offset) + "."); | |
| 1012 return childBefore; | |
| 1013 } | |
| 1014 } | 1016 } |
| 1015 ASSERT_NOT_REACHED(); | 1017 ASSERT_NOT_REACHED(); |
| 1016 return nullptr; | 1018 return nullptr; |
| 1017 } | 1019 } |
| 1018 | 1020 |
| 1019 void Range::checkNodeBA(Node* n, ExceptionState& exceptionState) const | 1021 void Range::checkNodeBA(Node* n, ExceptionState& exceptionState) const |
| 1020 { | 1022 { |
| 1021 if (!n) { | 1023 if (!n) { |
| 1022 // FIXME: Generated bindings code never calls with null, and neither sho
uld other callers! | 1024 // FIXME: Generated bindings code never calls with null, and neither sho
uld other callers! |
| 1023 exceptionState.throwTypeError("The node provided is null."); | 1025 exceptionState.throwTypeError("The node provided is null."); |
| 1024 return; | 1026 return; |
| 1025 } | 1027 } |
| 1026 | 1028 |
| 1027 // InvalidNodeTypeError: Raised if the root container of refNode is not an | 1029 // InvalidNodeTypeError: Raised if the root container of refNode is not an |
| 1028 // Attr, Document, DocumentFragment or ShadowRoot node, or part of a SVG sha
dow DOM tree, | 1030 // Attr, Document, DocumentFragment or ShadowRoot node, or part of a SVG sha
dow DOM tree, |
| 1029 // or if refNode is a Document, DocumentFragment, ShadowRoot, Attr, Entity,
or Notation node. | 1031 // or if refNode is a Document, DocumentFragment, ShadowRoot, Attr, Entity,
or Notation node. |
| 1030 | 1032 |
| 1031 if (!n->parentNode()) { | 1033 if (!n->parentNode()) { |
| 1032 exceptionState.throwDOMException(InvalidNodeTypeError, "the given Node h
as no parent."); | 1034 exceptionState.throwDOMException(InvalidNodeTypeError, "the given Node h
as no parent."); |
| 1033 return; | 1035 return; |
| 1034 } | 1036 } |
| 1035 | 1037 |
| 1036 switch (n->nodeType()) { | 1038 switch (n->nodeType()) { |
| 1037 case Node::ATTRIBUTE_NODE: | 1039 case Node::ATTRIBUTE_NODE: |
| 1038 case Node::DOCUMENT_FRAGMENT_NODE: | 1040 case Node::DOCUMENT_FRAGMENT_NODE: |
| 1039 case Node::DOCUMENT_NODE: | 1041 case Node::DOCUMENT_NODE: |
| 1040 exceptionState.throwDOMException(InvalidNodeTypeError, "The node pro
vided is of type '" + n->nodeName() + "'."); | 1042 exceptionState.throwDOMException(InvalidNodeTypeError, "The node provide
d is of type '" + n->nodeName() + "'."); |
| 1041 return; | 1043 return; |
| 1042 case Node::CDATA_SECTION_NODE: | 1044 case Node::CDATA_SECTION_NODE: |
| 1043 case Node::COMMENT_NODE: | 1045 case Node::COMMENT_NODE: |
| 1044 case Node::DOCUMENT_TYPE_NODE: | 1046 case Node::DOCUMENT_TYPE_NODE: |
| 1045 case Node::ELEMENT_NODE: | 1047 case Node::ELEMENT_NODE: |
| 1046 case Node::PROCESSING_INSTRUCTION_NODE: | 1048 case Node::PROCESSING_INSTRUCTION_NODE: |
| 1047 case Node::TEXT_NODE: | 1049 case Node::TEXT_NODE: |
| 1048 break; | 1050 break; |
| 1049 } | 1051 } |
| 1050 | 1052 |
| 1051 Node* root = n; | 1053 Node* root = n; |
| 1052 while (ContainerNode* parent = root->parentNode()) | 1054 while (ContainerNode* parent = root->parentNode()) |
| 1053 root = parent; | 1055 root = parent; |
| 1054 | 1056 |
| 1055 switch (root->nodeType()) { | 1057 switch (root->nodeType()) { |
| 1056 case Node::ATTRIBUTE_NODE: | 1058 case Node::ATTRIBUTE_NODE: |
| 1057 case Node::DOCUMENT_NODE: | 1059 case Node::DOCUMENT_NODE: |
| 1058 case Node::DOCUMENT_FRAGMENT_NODE: | 1060 case Node::DOCUMENT_FRAGMENT_NODE: |
| 1059 case Node::ELEMENT_NODE: | 1061 case Node::ELEMENT_NODE: |
| 1060 break; | 1062 break; |
| 1061 case Node::CDATA_SECTION_NODE: | 1063 case Node::CDATA_SECTION_NODE: |
| 1062 case Node::COMMENT_NODE: | 1064 case Node::COMMENT_NODE: |
| 1063 case Node::DOCUMENT_TYPE_NODE: | 1065 case Node::DOCUMENT_TYPE_NODE: |
| 1064 case Node::PROCESSING_INSTRUCTION_NODE: | 1066 case Node::PROCESSING_INSTRUCTION_NODE: |
| 1065 case Node::TEXT_NODE: | 1067 case Node::TEXT_NODE: |
| 1066 exceptionState.throwDOMException(InvalidNodeTypeError, "The node pro
vided is of type '" + n->nodeName() + "'."); | 1068 exceptionState.throwDOMException(InvalidNodeTypeError, "The node provide
d is of type '" + n->nodeName() + "'."); |
| 1067 return; | 1069 return; |
| 1068 } | 1070 } |
| 1069 } | 1071 } |
| 1070 | 1072 |
| 1071 PassRefPtrWillBeRawPtr<Range> Range::cloneRange() const | 1073 PassRefPtrWillBeRawPtr<Range> Range::cloneRange() const |
| 1072 { | 1074 { |
| 1073 return Range::create(*m_ownerDocument.get(), m_start.container(), m_start.of
fset(), m_end.container(), m_end.offset()); | 1075 return Range::create(*m_ownerDocument.get(), m_start.container(), m_start.of
fset(), m_end.container(), m_end.offset()); |
| 1074 } | 1076 } |
| 1075 | 1077 |
| 1076 void Range::setStartAfter(Node* refNode, ExceptionState& exceptionState) | 1078 void Range::setStartAfter(Node* refNode, ExceptionState& exceptionState) |
| 1077 { | 1079 { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 if (!refNode->parentNode()) { | 1113 if (!refNode->parentNode()) { |
| 1112 exceptionState.throwDOMException(InvalidNodeTypeError, "the given Node h
as no parent."); | 1114 exceptionState.throwDOMException(InvalidNodeTypeError, "the given Node h
as no parent."); |
| 1113 return; | 1115 return; |
| 1114 } | 1116 } |
| 1115 | 1117 |
| 1116 // InvalidNodeTypeError: Raised if an ancestor of refNode is an Entity, Nota
tion or | 1118 // InvalidNodeTypeError: Raised if an ancestor of refNode is an Entity, Nota
tion or |
| 1117 // DocumentType node or if refNode is a Document, DocumentFragment, ShadowRo
ot, Attr, Entity, or Notation | 1119 // DocumentType node or if refNode is a Document, DocumentFragment, ShadowRo
ot, Attr, Entity, or Notation |
| 1118 // node. | 1120 // node. |
| 1119 for (ContainerNode* anc = refNode->parentNode(); anc; anc = anc->parentNode(
)) { | 1121 for (ContainerNode* anc = refNode->parentNode(); anc; anc = anc->parentNode(
)) { |
| 1120 switch (anc->nodeType()) { | 1122 switch (anc->nodeType()) { |
| 1121 case Node::ATTRIBUTE_NODE: | 1123 case Node::ATTRIBUTE_NODE: |
| 1122 case Node::CDATA_SECTION_NODE: | 1124 case Node::CDATA_SECTION_NODE: |
| 1123 case Node::COMMENT_NODE: | 1125 case Node::COMMENT_NODE: |
| 1124 case Node::DOCUMENT_FRAGMENT_NODE: | 1126 case Node::DOCUMENT_FRAGMENT_NODE: |
| 1125 case Node::DOCUMENT_NODE: | 1127 case Node::DOCUMENT_NODE: |
| 1126 case Node::ELEMENT_NODE: | 1128 case Node::ELEMENT_NODE: |
| 1127 case Node::PROCESSING_INSTRUCTION_NODE: | 1129 case Node::PROCESSING_INSTRUCTION_NODE: |
| 1128 case Node::TEXT_NODE: | 1130 case Node::TEXT_NODE: |
| 1129 break; | 1131 break; |
| 1130 case Node::DOCUMENT_TYPE_NODE: | 1132 case Node::DOCUMENT_TYPE_NODE: |
| 1131 exceptionState.throwDOMException(InvalidNodeTypeError, "The node
provided has an ancestor of type '" + anc->nodeName() + "'."); | 1133 exceptionState.throwDOMException(InvalidNodeTypeError, "The node pro
vided has an ancestor of type '" + anc->nodeName() + "'."); |
| 1132 return; | 1134 return; |
| 1133 } | 1135 } |
| 1134 } | 1136 } |
| 1135 | 1137 |
| 1136 switch (refNode->nodeType()) { | 1138 switch (refNode->nodeType()) { |
| 1137 case Node::CDATA_SECTION_NODE: | 1139 case Node::CDATA_SECTION_NODE: |
| 1138 case Node::COMMENT_NODE: | 1140 case Node::COMMENT_NODE: |
| 1139 case Node::DOCUMENT_TYPE_NODE: | 1141 case Node::DOCUMENT_TYPE_NODE: |
| 1140 case Node::ELEMENT_NODE: | 1142 case Node::ELEMENT_NODE: |
| 1141 case Node::PROCESSING_INSTRUCTION_NODE: | 1143 case Node::PROCESSING_INSTRUCTION_NODE: |
| 1142 case Node::TEXT_NODE: | 1144 case Node::TEXT_NODE: |
| 1143 break; | 1145 break; |
| 1144 case Node::ATTRIBUTE_NODE: | 1146 case Node::ATTRIBUTE_NODE: |
| 1145 case Node::DOCUMENT_FRAGMENT_NODE: | 1147 case Node::DOCUMENT_FRAGMENT_NODE: |
| 1146 case Node::DOCUMENT_NODE: | 1148 case Node::DOCUMENT_NODE: |
| 1147 exceptionState.throwDOMException(InvalidNodeTypeError, "The node pro
vided is of type '" + refNode->nodeName() + "'."); | 1149 exceptionState.throwDOMException(InvalidNodeTypeError, "The node provide
d is of type '" + refNode->nodeName() + "'."); |
| 1148 return; | 1150 return; |
| 1149 } | 1151 } |
| 1150 | 1152 |
| 1151 if (m_ownerDocument != refNode->document()) | 1153 if (m_ownerDocument != refNode->document()) |
| 1152 setDocument(refNode->document()); | 1154 setDocument(refNode->document()); |
| 1153 | 1155 |
| 1154 setStartBefore(refNode); | 1156 setStartBefore(refNode); |
| 1155 setEndAfter(refNode); | 1157 setEndAfter(refNode); |
| 1156 } | 1158 } |
| 1157 | 1159 |
| 1158 void Range::selectNodeContents(Node* refNode, ExceptionState& exceptionState) | 1160 void Range::selectNodeContents(Node* refNode, ExceptionState& exceptionState) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1237 if (endNonTextContainer->nodeType() == Node::TEXT_NODE) | 1239 if (endNonTextContainer->nodeType() == Node::TEXT_NODE) |
| 1238 endNonTextContainer = endNonTextContainer->parentNode(); | 1240 endNonTextContainer = endNonTextContainer->parentNode(); |
| 1239 if (startNonTextContainer != endNonTextContainer) { | 1241 if (startNonTextContainer != endNonTextContainer) { |
| 1240 exceptionState.throwDOMException(InvalidStateError, "The Range has parti
ally selected a non-Text node."); | 1242 exceptionState.throwDOMException(InvalidStateError, "The Range has parti
ally selected a non-Text node."); |
| 1241 return; | 1243 return; |
| 1242 } | 1244 } |
| 1243 | 1245 |
| 1244 // InvalidNodeTypeError: Raised if node is an Attr, Entity, DocumentType, No
tation, | 1246 // InvalidNodeTypeError: Raised if node is an Attr, Entity, DocumentType, No
tation, |
| 1245 // Document, or DocumentFragment node. | 1247 // Document, or DocumentFragment node. |
| 1246 switch (newParent->nodeType()) { | 1248 switch (newParent->nodeType()) { |
| 1247 case Node::ATTRIBUTE_NODE: | 1249 case Node::ATTRIBUTE_NODE: |
| 1248 case Node::DOCUMENT_FRAGMENT_NODE: | 1250 case Node::DOCUMENT_FRAGMENT_NODE: |
| 1249 case Node::DOCUMENT_NODE: | 1251 case Node::DOCUMENT_NODE: |
| 1250 case Node::DOCUMENT_TYPE_NODE: | 1252 case Node::DOCUMENT_TYPE_NODE: |
| 1251 exceptionState.throwDOMException(InvalidNodeTypeError, "The node pro
vided is of type '" + newParent->nodeName() + "'."); | 1253 exceptionState.throwDOMException(InvalidNodeTypeError, "The node provide
d is of type '" + newParent->nodeName() + "'."); |
| 1252 return; | 1254 return; |
| 1253 case Node::CDATA_SECTION_NODE: | 1255 case Node::CDATA_SECTION_NODE: |
| 1254 case Node::COMMENT_NODE: | 1256 case Node::COMMENT_NODE: |
| 1255 case Node::ELEMENT_NODE: | 1257 case Node::ELEMENT_NODE: |
| 1256 case Node::PROCESSING_INSTRUCTION_NODE: | 1258 case Node::PROCESSING_INSTRUCTION_NODE: |
| 1257 case Node::TEXT_NODE: | 1259 case Node::TEXT_NODE: |
| 1258 break; | 1260 break; |
| 1259 } | 1261 } |
| 1260 | 1262 |
| 1261 // Raise a HierarchyRequestError if m_start.container() doesn't accept child
ren like newParent. | 1263 // Raise a HierarchyRequestError if m_start.container() doesn't accept child
ren like newParent. |
| 1262 Node* parentOfNewParent = m_start.container(); | 1264 Node* parentOfNewParent = m_start.container(); |
| 1263 | 1265 |
| 1264 // If m_start.container() is a character data node, it will be split and it
will be its parent that will | 1266 // If m_start.container() is a character data node, it will be split and it
will be its parent that will |
| 1265 // need to accept newParent (or in the case of a comment, it logically "woul
d" be inserted into the parent, | 1267 // need to accept newParent (or in the case of a comment, it logically "woul
d" be inserted into the parent, |
| 1266 // although this will fail below for another reason). | 1268 // although this will fail below for another reason). |
| 1267 if (parentOfNewParent->isCharacterDataNode()) | 1269 if (parentOfNewParent->isCharacterDataNode()) |
| 1268 parentOfNewParent = parentOfNewParent->parentNode(); | 1270 parentOfNewParent = parentOfNewParent->parentNode(); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1627 end = endOfWord(end); | 1629 end = endOfWord(end); |
| 1628 } else if (unit == "sentence") { | 1630 } else if (unit == "sentence") { |
| 1629 start = startOfSentence(start); | 1631 start = startOfSentence(start); |
| 1630 end = endOfSentence(end); | 1632 end = endOfSentence(end); |
| 1631 } else if (unit == "block") { | 1633 } else if (unit == "block") { |
| 1632 start = startOfParagraph(start); | 1634 start = startOfParagraph(start); |
| 1633 end = endOfParagraph(end); | 1635 end = endOfParagraph(end); |
| 1634 } else if (unit == "document") { | 1636 } else if (unit == "document") { |
| 1635 start = startOfDocument(start); | 1637 start = startOfDocument(start); |
| 1636 end = endOfDocument(end); | 1638 end = endOfDocument(end); |
| 1637 } else | 1639 } else { |
| 1638 return; | 1640 return; |
| 1641 } |
| 1639 setStart(start.deepEquivalent().containerNode(), start.deepEquivalent().comp
uteOffsetInContainerNode(), exceptionState); | 1642 setStart(start.deepEquivalent().containerNode(), start.deepEquivalent().comp
uteOffsetInContainerNode(), exceptionState); |
| 1640 setEnd(end.deepEquivalent().containerNode(), end.deepEquivalent().computeOff
setInContainerNode(), exceptionState); | 1643 setEnd(end.deepEquivalent().containerNode(), end.deepEquivalent().computeOff
setInContainerNode(), exceptionState); |
| 1641 } | 1644 } |
| 1642 | 1645 |
| 1643 ClientRectList* Range::getClientRects() const | 1646 ClientRectList* Range::getClientRects() const |
| 1644 { | 1647 { |
| 1645 m_ownerDocument->updateLayoutIgnorePendingStylesheets(); | 1648 m_ownerDocument->updateLayoutIgnorePendingStylesheets(); |
| 1646 | 1649 |
| 1647 Vector<FloatQuad> quads; | 1650 Vector<FloatQuad> quads; |
| 1648 getBorderAndTextQuads(quads); | 1651 getBorderAndTextQuads(quads); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1722 { | 1725 { |
| 1723 if (range && range->boundaryPointsValid()) { | 1726 if (range && range->boundaryPointsValid()) { |
| 1724 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); | 1727 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); |
| 1725 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); | 1728 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); |
| 1726 } else { | 1729 } else { |
| 1727 fprintf(stderr, "Cannot show tree if range is null, or if boundary point
s are invalid.\n"); | 1730 fprintf(stderr, "Cannot show tree if range is null, or if boundary point
s are invalid.\n"); |
| 1728 } | 1731 } |
| 1729 } | 1732 } |
| 1730 | 1733 |
| 1731 #endif | 1734 #endif |
| OLD | NEW |