| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 endRootContainer = endRootContainer->parentNode(); | 149 endRootContainer = endRootContainer->parentNode(); |
| 150 Node* startRootContainer = start.container(); | 150 Node* startRootContainer = start.container(); |
| 151 while (startRootContainer->parentNode()) | 151 while (startRootContainer->parentNode()) |
| 152 startRootContainer = startRootContainer->parentNode(); | 152 startRootContainer = startRootContainer->parentNode(); |
| 153 | 153 |
| 154 return startRootContainer != endRootContainer || (Range::compareBoundaryPoin
ts(start, end, ASSERT_NO_EXCEPTION) > 0); | 154 return startRootContainer != endRootContainer || (Range::compareBoundaryPoin
ts(start, end, ASSERT_NO_EXCEPTION) > 0); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void Range::setStart(PassRefPtrWillBeRawPtr<Node> refNode, int offset, Exception
State& exceptionState) | 157 void Range::setStart(PassRefPtrWillBeRawPtr<Node> refNode, int offset, Exception
State& exceptionState) |
| 158 { | 158 { |
| 159 if (!refNode) { |
| 160 exceptionState.throwDOMException(NotFoundError, "The node provided was n
ull."); |
| 161 return; |
| 162 } |
| 163 |
| 159 bool didMoveDocument = false; | 164 bool didMoveDocument = false; |
| 160 if (refNode->document() != m_ownerDocument) { | 165 if (refNode->document() != m_ownerDocument) { |
| 161 setDocument(refNode->document()); | 166 setDocument(refNode->document()); |
| 162 didMoveDocument = true; | 167 didMoveDocument = true; |
| 163 } | 168 } |
| 164 | 169 |
| 165 Node* childNode = checkNodeWOffset(refNode.get(), offset, exceptionState); | 170 Node* childNode = checkNodeWOffset(refNode.get(), offset, exceptionState); |
| 166 if (exceptionState.hadException()) | 171 if (exceptionState.hadException()) |
| 167 return; | 172 return; |
| 168 | 173 |
| 169 m_start.set(refNode, offset, childNode); | 174 m_start.set(refNode, offset, childNode); |
| 170 | 175 |
| 171 if (didMoveDocument || checkForDifferentRootContainer(m_start, m_end)) | 176 if (didMoveDocument || checkForDifferentRootContainer(m_start, m_end)) |
| 172 collapse(true); | 177 collapse(true); |
| 173 } | 178 } |
| 174 | 179 |
| 175 void Range::setEnd(PassRefPtrWillBeRawPtr<Node> refNode, int offset, ExceptionSt
ate& exceptionState) | 180 void Range::setEnd(PassRefPtrWillBeRawPtr<Node> refNode, int offset, ExceptionSt
ate& exceptionState) |
| 176 { | 181 { |
| 182 if (!refNode) { |
| 183 exceptionState.throwDOMException(NotFoundError, "The node provided was n
ull."); |
| 184 return; |
| 185 } |
| 186 |
| 177 bool didMoveDocument = false; | 187 bool didMoveDocument = false; |
| 178 if (refNode->document() != m_ownerDocument) { | 188 if (refNode->document() != m_ownerDocument) { |
| 179 setDocument(refNode->document()); | 189 setDocument(refNode->document()); |
| 180 didMoveDocument = true; | 190 didMoveDocument = true; |
| 181 } | 191 } |
| 182 | 192 |
| 183 Node* childNode = checkNodeWOffset(refNode.get(), offset, exceptionState); | 193 Node* childNode = checkNodeWOffset(refNode.get(), offset, exceptionState); |
| 184 if (exceptionState.hadException()) | 194 if (exceptionState.hadException()) |
| 185 return; | 195 return; |
| 186 | 196 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 205 void Range::collapse(bool toStart) | 215 void Range::collapse(bool toStart) |
| 206 { | 216 { |
| 207 if (toStart) | 217 if (toStart) |
| 208 m_end = m_start; | 218 m_end = m_start; |
| 209 else | 219 else |
| 210 m_start = m_end; | 220 m_start = m_end; |
| 211 } | 221 } |
| 212 | 222 |
| 213 bool Range::isPointInRange(Node* refNode, int offset, ExceptionState& exceptionS
tate) | 223 bool Range::isPointInRange(Node* refNode, int offset, ExceptionState& exceptionS
tate) |
| 214 { | 224 { |
| 225 if (!refNode) { |
| 226 exceptionState.throwDOMException(HierarchyRequestError, "The node provid
ed was null."); |
| 227 return false; |
| 228 } |
| 229 |
| 215 if (!refNode->inActiveDocument() || refNode->document() != m_ownerDocument)
{ | 230 if (!refNode->inActiveDocument() || refNode->document() != m_ownerDocument)
{ |
| 216 return false; | 231 return false; |
| 217 } | 232 } |
| 218 | 233 |
| 219 checkNodeWOffset(refNode, offset, exceptionState); | 234 checkNodeWOffset(refNode, offset, exceptionState); |
| 220 if (exceptionState.hadException()) | 235 if (exceptionState.hadException()) |
| 221 return false; | 236 return false; |
| 222 | 237 |
| 223 return compareBoundaryPoints(refNode, offset, m_start.container(), m_start.o
ffset(), exceptionState) >= 0 && !exceptionState.hadException() | 238 return compareBoundaryPoints(refNode, offset, m_start.container(), m_start.o
ffset(), exceptionState) >= 0 && !exceptionState.hadException() |
| 224 && compareBoundaryPoints(refNode, offset, m_end.container(), m_end.offse
t(), exceptionState) <= 0 && !exceptionState.hadException(); | 239 && compareBoundaryPoints(refNode, offset, m_end.container(), m_end.offse
t(), exceptionState) <= 0 && !exceptionState.hadException(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 // point is in the middle of this range, or on the boundary points | 273 // point is in the middle of this range, or on the boundary points |
| 259 return 0; | 274 return 0; |
| 260 } | 275 } |
| 261 | 276 |
| 262 Range::CompareResults Range::compareNode(Node* refNode, ExceptionState& exceptio
nState) const | 277 Range::CompareResults Range::compareNode(Node* refNode, ExceptionState& exceptio
nState) const |
| 263 { | 278 { |
| 264 // http://developer.mozilla.org/en/docs/DOM:range.compareNode | 279 // http://developer.mozilla.org/en/docs/DOM:range.compareNode |
| 265 // This method returns 0, 1, 2, or 3 based on if the node is before, after, | 280 // This method returns 0, 1, 2, or 3 based on if the node is before, after, |
| 266 // before and after(surrounds), or inside the range, respectively | 281 // before and after(surrounds), or inside the range, respectively |
| 267 | 282 |
| 283 if (!refNode) { |
| 284 exceptionState.throwDOMException(NotFoundError, "The node provided was n
ull."); |
| 285 return NODE_BEFORE; |
| 286 } |
| 287 |
| 268 if (!refNode->inActiveDocument()) { | 288 if (!refNode->inActiveDocument()) { |
| 269 // Firefox doesn't throw an exception for this case; it returns 0. | 289 // Firefox doesn't throw an exception for this case; it returns 0. |
| 270 return NODE_BEFORE; | 290 return NODE_BEFORE; |
| 271 } | 291 } |
| 272 | 292 |
| 273 if (refNode->document() != m_ownerDocument) { | 293 if (refNode->document() != m_ownerDocument) { |
| 274 // Firefox doesn't throw an exception for this case; it returns 0. | 294 // Firefox doesn't throw an exception for this case; it returns 0. |
| 275 return NODE_BEFORE; | 295 return NODE_BEFORE; |
| 276 } | 296 } |
| 277 | 297 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 void Range::deleteContents(ExceptionState& exceptionState) | 463 void Range::deleteContents(ExceptionState& exceptionState) |
| 444 { | 464 { |
| 445 ASSERT(boundaryPointsValid()); | 465 ASSERT(boundaryPointsValid()); |
| 446 | 466 |
| 447 { | 467 { |
| 448 EventQueueScope eventQueueScope; | 468 EventQueueScope eventQueueScope; |
| 449 processContents(DELETE_CONTENTS, exceptionState); | 469 processContents(DELETE_CONTENTS, exceptionState); |
| 450 } | 470 } |
| 451 } | 471 } |
| 452 | 472 |
| 453 static bool nodeValidForIntersects(Node* refNode, Document* expectedDocument) | 473 static bool nodeValidForIntersects(Node* refNode, Document* expectedDocument, Ex
ceptionState& exceptionState) |
| 454 { | 474 { |
| 475 if (!refNode) { |
| 476 exceptionState.throwDOMException(NotFoundError, "The node provided is nu
ll."); |
| 477 return false; |
| 478 } |
| 479 |
| 455 if (!refNode->inActiveDocument() || refNode->document() != expectedDocument)
{ | 480 if (!refNode->inActiveDocument() || refNode->document() != expectedDocument)
{ |
| 456 // Firefox doesn't throw an exception for these cases; it returns false. | 481 // Firefox doesn't throw an exception for these cases; it returns false. |
| 457 return false; | 482 return false; |
| 458 } | 483 } |
| 459 | 484 |
| 460 return true; | 485 return true; |
| 461 } | 486 } |
| 462 | 487 |
| 463 bool Range::intersectsNode(Node* refNode, ExceptionState& exceptionState) | 488 bool Range::intersectsNode(Node* refNode, ExceptionState& exceptionState) |
| 464 { | 489 { |
| 465 // http://developer.mozilla.org/en/docs/DOM:range.intersectsNode | 490 // http://developer.mozilla.org/en/docs/DOM:range.intersectsNode |
| 466 // Returns a bool if the node intersects the range. | 491 // Returns a bool if the node intersects the range. |
| 467 if (!nodeValidForIntersects(refNode, m_ownerDocument.get())) | 492 if (!nodeValidForIntersects(refNode, m_ownerDocument.get(), exceptionState)) |
| 468 return false; | 493 return false; |
| 469 | 494 |
| 470 ContainerNode* parentNode = refNode->parentNode(); | 495 ContainerNode* parentNode = refNode->parentNode(); |
| 471 int nodeIndex = refNode->nodeIndex(); | 496 int nodeIndex = refNode->nodeIndex(); |
| 472 | 497 |
| 473 if (!parentNode) { | 498 if (!parentNode) { |
| 474 // if the node is the top document we should return NODE_BEFORE_AND_AFTE
R | 499 // if the node is the top document we should return NODE_BEFORE_AND_AFTE
R |
| 475 // but we throw to match firefox behavior | 500 // but we throw to match firefox behavior |
| 476 exceptionState.throwDOMException(NotFoundError, "The node provided has n
o parent."); | 501 exceptionState.throwDOMException(NotFoundError, "The node provided has n
o parent."); |
| 477 return false; | 502 return false; |
| 478 } | 503 } |
| 479 | 504 |
| 480 if (comparePoint(parentNode, nodeIndex, exceptionState) < 0 // starts before
start | 505 if (comparePoint(parentNode, nodeIndex, exceptionState) < 0 // starts before
start |
| 481 && comparePoint(parentNode, nodeIndex + 1, exceptionState) < 0) { // end
s before start | 506 && comparePoint(parentNode, nodeIndex + 1, exceptionState) < 0) { // end
s before start |
| 482 return false; | 507 return false; |
| 483 } | 508 } |
| 484 | 509 |
| 485 if (comparePoint(parentNode, nodeIndex, exceptionState) > 0 // starts after
end | 510 if (comparePoint(parentNode, nodeIndex, exceptionState) > 0 // starts after
end |
| 486 && comparePoint(parentNode, nodeIndex + 1, exceptionState) > 0) { // end
s after end | 511 && comparePoint(parentNode, nodeIndex + 1, exceptionState) > 0) { // end
s after end |
| 487 return false; | 512 return false; |
| 488 } | 513 } |
| 489 | 514 |
| 490 return true; // all other cases | 515 return true; // all other cases |
| 491 } | 516 } |
| 492 | 517 |
| 493 bool Range::intersectsNode(Node* refNode, const Position& start, const Position&
end, ExceptionState& exceptionState) | 518 bool Range::intersectsNode(Node* refNode, const Position& start, const Position&
end, ExceptionState& exceptionState) |
| 494 { | 519 { |
| 495 // http://developer.mozilla.org/en/docs/DOM:range.intersectsNode | 520 // http://developer.mozilla.org/en/docs/DOM:range.intersectsNode |
| 496 // Returns a bool if the node intersects the range. | 521 // Returns a bool if the node intersects the range. |
| 497 if (!nodeValidForIntersects(refNode, start.document())) | 522 if (!nodeValidForIntersects(refNode, start.document(), exceptionState)) |
| 498 return false; | 523 return false; |
| 499 | 524 |
| 500 ContainerNode* parentNode = refNode->parentNode(); | 525 ContainerNode* parentNode = refNode->parentNode(); |
| 501 int nodeIndex = refNode->nodeIndex(); | 526 int nodeIndex = refNode->nodeIndex(); |
| 502 | 527 |
| 503 if (!parentNode) { | 528 if (!parentNode) { |
| 504 // if the node is the top document we should return NODE_BEFORE_AND_AFTE
R | 529 // if the node is the top document we should return NODE_BEFORE_AND_AFTE
R |
| 505 // but we throw to match firefox behavior | 530 // but we throw to match firefox behavior |
| 506 exceptionState.throwDOMException(NotFoundError, "The node provided has n
o parent."); | 531 exceptionState.throwDOMException(NotFoundError, "The node provided has n
o parent."); |
| 507 return false; | 532 return false; |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 | 852 |
| 828 PassRefPtrWillBeRawPtr<DocumentFragment> Range::cloneContents(ExceptionState& ex
ceptionState) | 853 PassRefPtrWillBeRawPtr<DocumentFragment> Range::cloneContents(ExceptionState& ex
ceptionState) |
| 829 { | 854 { |
| 830 return processContents(CLONE_CONTENTS, exceptionState); | 855 return processContents(CLONE_CONTENTS, exceptionState); |
| 831 } | 856 } |
| 832 | 857 |
| 833 void Range::insertNode(PassRefPtrWillBeRawPtr<Node> prpNewNode, ExceptionState&
exceptionState) | 858 void Range::insertNode(PassRefPtrWillBeRawPtr<Node> prpNewNode, ExceptionState&
exceptionState) |
| 834 { | 859 { |
| 835 RefPtrWillBeRawPtr<Node> newNode = prpNewNode; | 860 RefPtrWillBeRawPtr<Node> newNode = prpNewNode; |
| 836 | 861 |
| 862 if (!newNode) { |
| 863 exceptionState.throwDOMException(NotFoundError, "The node provided is nu
ll."); |
| 864 return; |
| 865 } |
| 866 |
| 837 // HierarchyRequestError: Raised if the container of the start of the Range
is of a type that | 867 // HierarchyRequestError: Raised if the container of the start of the Range
is of a type that |
| 838 // does not allow children of the type of newNode or if newNode is an ancest
or of the container. | 868 // does not allow children of the type of newNode or if newNode is an ancest
or of the container. |
| 839 | 869 |
| 840 // an extra one here - if a text node is going to split, it must have a pare
nt to insert into | 870 // an extra one here - if a text node is going to split, it must have a pare
nt to insert into |
| 841 bool startIsText = m_start.container()->isTextNode(); | 871 bool startIsText = m_start.container()->isTextNode(); |
| 842 if (startIsText && !m_start.container()->parentNode()) { | 872 if (startIsText && !m_start.container()->parentNode()) { |
| 843 exceptionState.throwDOMException(HierarchyRequestError, "This operation
would split a text node, but there's no parent into which to insert."); | 873 exceptionState.throwDOMException(HierarchyRequestError, "This operation
would split a text node, but there's no parent into which to insert."); |
| 844 return; | 874 return; |
| 845 } | 875 } |
| 846 | 876 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 exceptionState.throwDOMException(IndexSizeError, "There is no ch
ild at offset " + String::number(offset) + "."); | 1071 exceptionState.throwDOMException(IndexSizeError, "There is no ch
ild at offset " + String::number(offset) + "."); |
| 1042 return childBefore; | 1072 return childBefore; |
| 1043 } | 1073 } |
| 1044 } | 1074 } |
| 1045 ASSERT_NOT_REACHED(); | 1075 ASSERT_NOT_REACHED(); |
| 1046 return nullptr; | 1076 return nullptr; |
| 1047 } | 1077 } |
| 1048 | 1078 |
| 1049 void Range::checkNodeBA(Node* n, ExceptionState& exceptionState) const | 1079 void Range::checkNodeBA(Node* n, ExceptionState& exceptionState) const |
| 1050 { | 1080 { |
| 1081 if (!n) { |
| 1082 exceptionState.throwDOMException(NotFoundError, "The node provided is nu
ll."); |
| 1083 return; |
| 1084 } |
| 1085 |
| 1051 // InvalidNodeTypeError: Raised if the root container of refNode is not an | 1086 // InvalidNodeTypeError: Raised if the root container of refNode is not an |
| 1052 // Attr, Document, DocumentFragment or ShadowRoot node, or part of a SVG sha
dow DOM tree, | 1087 // Attr, Document, DocumentFragment or ShadowRoot node, or part of a SVG sha
dow DOM tree, |
| 1053 // or if refNode is a Document, DocumentFragment, ShadowRoot, Attr, Entity,
or Notation node. | 1088 // or if refNode is a Document, DocumentFragment, ShadowRoot, Attr, Entity,
or Notation node. |
| 1054 | 1089 |
| 1055 if (!n->parentNode()) { | 1090 if (!n->parentNode()) { |
| 1056 exceptionState.throwDOMException(InvalidNodeTypeError, "the given Node h
as no parent."); | 1091 exceptionState.throwDOMException(InvalidNodeTypeError, "the given Node h
as no parent."); |
| 1057 return; | 1092 return; |
| 1058 } | 1093 } |
| 1059 | 1094 |
| 1060 switch (n->nodeType()) { | 1095 switch (n->nodeType()) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 { | 1154 { |
| 1120 checkNodeBA(refNode, exceptionState); | 1155 checkNodeBA(refNode, exceptionState); |
| 1121 if (exceptionState.hadException()) | 1156 if (exceptionState.hadException()) |
| 1122 return; | 1157 return; |
| 1123 | 1158 |
| 1124 setEnd(refNode->parentNode(), refNode->nodeIndex() + 1, exceptionState); | 1159 setEnd(refNode->parentNode(), refNode->nodeIndex() + 1, exceptionState); |
| 1125 } | 1160 } |
| 1126 | 1161 |
| 1127 void Range::selectNode(Node* refNode, ExceptionState& exceptionState) | 1162 void Range::selectNode(Node* refNode, ExceptionState& exceptionState) |
| 1128 { | 1163 { |
| 1164 if (!refNode) { |
| 1165 exceptionState.throwDOMException(NotFoundError, "The node provided is nu
ll."); |
| 1166 return; |
| 1167 } |
| 1168 |
| 1129 if (!refNode->parentNode()) { | 1169 if (!refNode->parentNode()) { |
| 1130 exceptionState.throwDOMException(InvalidNodeTypeError, "the given Node h
as no parent."); | 1170 exceptionState.throwDOMException(InvalidNodeTypeError, "the given Node h
as no parent."); |
| 1131 return; | 1171 return; |
| 1132 } | 1172 } |
| 1133 | 1173 |
| 1134 // InvalidNodeTypeError: Raised if an ancestor of refNode is an Entity, Nota
tion or | 1174 // InvalidNodeTypeError: Raised if an ancestor of refNode is an Entity, Nota
tion or |
| 1135 // DocumentType node or if refNode is a Document, DocumentFragment, ShadowRo
ot, Attr, Entity, or Notation | 1175 // DocumentType node or if refNode is a Document, DocumentFragment, ShadowRo
ot, Attr, Entity, or Notation |
| 1136 // node. | 1176 // node. |
| 1137 for (ContainerNode* anc = refNode->parentNode(); anc; anc = anc->parentNode(
)) { | 1177 for (ContainerNode* anc = refNode->parentNode(); anc; anc = anc->parentNode(
)) { |
| 1138 switch (anc->nodeType()) { | 1178 switch (anc->nodeType()) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1168 | 1208 |
| 1169 if (m_ownerDocument != refNode->document()) | 1209 if (m_ownerDocument != refNode->document()) |
| 1170 setDocument(refNode->document()); | 1210 setDocument(refNode->document()); |
| 1171 | 1211 |
| 1172 setStartBefore(refNode); | 1212 setStartBefore(refNode); |
| 1173 setEndAfter(refNode); | 1213 setEndAfter(refNode); |
| 1174 } | 1214 } |
| 1175 | 1215 |
| 1176 void Range::selectNodeContents(Node* refNode, ExceptionState& exceptionState) | 1216 void Range::selectNodeContents(Node* refNode, ExceptionState& exceptionState) |
| 1177 { | 1217 { |
| 1218 if (!refNode) { |
| 1219 exceptionState.throwDOMException(NotFoundError, "The node provided is nu
ll."); |
| 1220 return; |
| 1221 } |
| 1222 |
| 1178 // InvalidNodeTypeError: Raised if refNode or an ancestor of refNode is an E
ntity, Notation | 1223 // InvalidNodeTypeError: Raised if refNode or an ancestor of refNode is an E
ntity, Notation |
| 1179 // or DocumentType node. | 1224 // or DocumentType node. |
| 1180 for (Node* n = refNode; n; n = n->parentNode()) { | 1225 for (Node* n = refNode; n; n = n->parentNode()) { |
| 1181 switch (n->nodeType()) { | 1226 switch (n->nodeType()) { |
| 1182 case Node::ATTRIBUTE_NODE: | 1227 case Node::ATTRIBUTE_NODE: |
| 1183 case Node::CDATA_SECTION_NODE: | 1228 case Node::CDATA_SECTION_NODE: |
| 1184 case Node::COMMENT_NODE: | 1229 case Node::COMMENT_NODE: |
| 1185 case Node::DOCUMENT_FRAGMENT_NODE: | 1230 case Node::DOCUMENT_FRAGMENT_NODE: |
| 1186 case Node::DOCUMENT_NODE: | 1231 case Node::DOCUMENT_NODE: |
| 1187 case Node::ELEMENT_NODE: | 1232 case Node::ELEMENT_NODE: |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 start = startBoundaryPoint.toPosition(); | 1273 start = startBoundaryPoint.toPosition(); |
| 1229 RangeBoundaryPoint endBoundaryPoint(refNode); | 1274 RangeBoundaryPoint endBoundaryPoint(refNode); |
| 1230 endBoundaryPoint.setToEndOfNode(*refNode); | 1275 endBoundaryPoint.setToEndOfNode(*refNode); |
| 1231 end = endBoundaryPoint.toPosition(); | 1276 end = endBoundaryPoint.toPosition(); |
| 1232 return true; | 1277 return true; |
| 1233 } | 1278 } |
| 1234 | 1279 |
| 1235 void Range::surroundContents(PassRefPtrWillBeRawPtr<Node> passNewParent, Excepti
onState& exceptionState) | 1280 void Range::surroundContents(PassRefPtrWillBeRawPtr<Node> passNewParent, Excepti
onState& exceptionState) |
| 1236 { | 1281 { |
| 1237 RefPtrWillBeRawPtr<Node> newParent = passNewParent; | 1282 RefPtrWillBeRawPtr<Node> newParent = passNewParent; |
| 1283 if (!newParent) { |
| 1284 exceptionState.throwDOMException(NotFoundError, "The node provided is nu
ll."); |
| 1285 return; |
| 1286 } |
| 1238 | 1287 |
| 1239 // InvalidStateError: Raised if the Range partially selects a non-Text node. | 1288 // InvalidStateError: Raised if the Range partially selects a non-Text node. |
| 1240 Node* startNonTextContainer = m_start.container(); | 1289 Node* startNonTextContainer = m_start.container(); |
| 1241 if (startNonTextContainer->nodeType() == Node::TEXT_NODE) | 1290 if (startNonTextContainer->nodeType() == Node::TEXT_NODE) |
| 1242 startNonTextContainer = startNonTextContainer->parentNode(); | 1291 startNonTextContainer = startNonTextContainer->parentNode(); |
| 1243 Node* endNonTextContainer = m_end.container(); | 1292 Node* endNonTextContainer = m_end.container(); |
| 1244 if (endNonTextContainer->nodeType() == Node::TEXT_NODE) | 1293 if (endNonTextContainer->nodeType() == Node::TEXT_NODE) |
| 1245 endNonTextContainer = endNonTextContainer->parentNode(); | 1294 endNonTextContainer = endNonTextContainer->parentNode(); |
| 1246 if (startNonTextContainer != endNonTextContainer) { | 1295 if (startNonTextContainer != endNonTextContainer) { |
| 1247 exceptionState.throwDOMException(InvalidStateError, "The Range has parti
ally selected a non-Text node."); | 1296 exceptionState.throwDOMException(InvalidStateError, "The Range has parti
ally selected a non-Text node."); |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1727 | 1776 |
| 1728 void showTree(const blink::Range* range) | 1777 void showTree(const blink::Range* range) |
| 1729 { | 1778 { |
| 1730 if (range && range->boundaryPointsValid()) { | 1779 if (range && range->boundaryPointsValid()) { |
| 1731 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); | 1780 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); |
| 1732 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); | 1781 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); |
| 1733 } | 1782 } |
| 1734 } | 1783 } |
| 1735 | 1784 |
| 1736 #endif | 1785 #endif |
| OLD | NEW |