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 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 { | 1221 { |
1222 if (!refNode) { | 1222 if (!refNode) { |
1223 exceptionState.throwDOMException(NotFoundError, "The node provided is nu
ll."); | 1223 exceptionState.throwDOMException(NotFoundError, "The node provided is nu
ll."); |
1224 return; | 1224 return; |
1225 } | 1225 } |
1226 | 1226 |
1227 // InvalidNodeTypeError: Raised if refNode or an ancestor of refNode is an E
ntity, Notation | 1227 // InvalidNodeTypeError: Raised if refNode or an ancestor of refNode is an E
ntity, Notation |
1228 // or DocumentType node. | 1228 // or DocumentType node. |
1229 for (Node* n = refNode; n; n = n->parentNode()) { | 1229 for (Node* n = refNode; n; n = n->parentNode()) { |
1230 switch (n->nodeType()) { | 1230 switch (n->nodeType()) { |
1231 case Node::ATTRIBUTE_NODE: | 1231 case Node::ATTRIBUTE_NODE: |
1232 case Node::CDATA_SECTION_NODE: | 1232 case Node::CDATA_SECTION_NODE: |
1233 case Node::COMMENT_NODE: | 1233 case Node::COMMENT_NODE: |
1234 case Node::DOCUMENT_FRAGMENT_NODE: | 1234 case Node::DOCUMENT_FRAGMENT_NODE: |
1235 case Node::DOCUMENT_NODE: | 1235 case Node::DOCUMENT_NODE: |
1236 case Node::ELEMENT_NODE: | 1236 case Node::ELEMENT_NODE: |
1237 case Node::PROCESSING_INSTRUCTION_NODE: | 1237 case Node::PROCESSING_INSTRUCTION_NODE: |
1238 case Node::TEXT_NODE: | 1238 case Node::TEXT_NODE: |
1239 break; | 1239 break; |
1240 case Node::DOCUMENT_TYPE_NODE: | 1240 case Node::DOCUMENT_TYPE_NODE: |
1241 exceptionState.throwDOMException(InvalidNodeTypeError, "The node
provided is of type '" + refNode->nodeName() + "'."); | 1241 exceptionState.throwDOMException(InvalidNodeTypeError, "The node pro
vided is of type '" + refNode->nodeName() + "'."); |
1242 return; | 1242 return; |
1243 } | 1243 } |
1244 } | 1244 } |
1245 | 1245 |
1246 if (m_ownerDocument != refNode->document()) | 1246 if (m_ownerDocument != refNode->document()) |
1247 setDocument(refNode->document()); | 1247 setDocument(refNode->document()); |
1248 | 1248 |
1249 m_start.setToStartOfNode(*refNode); | 1249 m_start.setToStartOfNode(*refNode); |
1250 m_end.setToEndOfNode(*refNode); | 1250 m_end.setToEndOfNode(*refNode); |
1251 } | 1251 } |
1252 | 1252 |
| 1253 bool Range::selectNodeContents(Node* refNode, Position& start, Position& end) |
| 1254 { |
| 1255 if (!refNode) { |
| 1256 return false; |
| 1257 } |
| 1258 |
| 1259 for (Node* n = refNode; n; n = n->parentNode()) { |
| 1260 switch (n->nodeType()) { |
| 1261 case Node::ATTRIBUTE_NODE: |
| 1262 case Node::CDATA_SECTION_NODE: |
| 1263 case Node::COMMENT_NODE: |
| 1264 case Node::DOCUMENT_FRAGMENT_NODE: |
| 1265 case Node::DOCUMENT_NODE: |
| 1266 case Node::ELEMENT_NODE: |
| 1267 case Node::PROCESSING_INSTRUCTION_NODE: |
| 1268 case Node::TEXT_NODE: |
| 1269 break; |
| 1270 case Node::DOCUMENT_TYPE_NODE: |
| 1271 return false; |
| 1272 } |
| 1273 } |
| 1274 |
| 1275 RangeBoundaryPoint startBoundaryPoint(refNode); |
| 1276 startBoundaryPoint.setToStartOfNode(*refNode); |
| 1277 start = startBoundaryPoint.toPosition(); |
| 1278 RangeBoundaryPoint endBoundaryPoint(refNode); |
| 1279 endBoundaryPoint.setToEndOfNode(*refNode); |
| 1280 end = endBoundaryPoint.toPosition(); |
| 1281 return true; |
| 1282 } |
| 1283 |
1253 void Range::surroundContents(PassRefPtrWillBeRawPtr<Node> passNewParent, Excepti
onState& exceptionState) | 1284 void Range::surroundContents(PassRefPtrWillBeRawPtr<Node> passNewParent, Excepti
onState& exceptionState) |
1254 { | 1285 { |
1255 RefPtrWillBeRawPtr<Node> newParent = passNewParent; | 1286 RefPtrWillBeRawPtr<Node> newParent = passNewParent; |
1256 if (!newParent) { | 1287 if (!newParent) { |
1257 exceptionState.throwDOMException(NotFoundError, "The node provided is nu
ll."); | 1288 exceptionState.throwDOMException(NotFoundError, "The node provided is nu
ll."); |
1258 return; | 1289 return; |
1259 } | 1290 } |
1260 | 1291 |
1261 // InvalidStateError: Raised if the Range partially selects a non-Text node. | 1292 // InvalidStateError: Raised if the Range partially selects a non-Text node. |
1262 Node* startNonTextContainer = m_start.container(); | 1293 Node* startNonTextContainer = m_start.container(); |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1752 | 1783 |
1753 void showTree(const blink::Range* range) | 1784 void showTree(const blink::Range* range) |
1754 { | 1785 { |
1755 if (range && range->boundaryPointsValid()) { | 1786 if (range && range->boundaryPointsValid()) { |
1756 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); | 1787 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); |
1757 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); | 1788 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); |
1758 } | 1789 } |
1759 } | 1790 } |
1760 | 1791 |
1761 #endif | 1792 #endif |
OLD | NEW |