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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 } | 455 } |
456 | 456 |
457 bool Range::boundaryPointsValid() const | 457 bool Range::boundaryPointsValid() const |
458 { | 458 { |
459 TrackExceptionState exceptionState; | 459 TrackExceptionState exceptionState; |
460 return compareBoundaryPoints(m_start, m_end, exceptionState) <= 0 && !except
ionState.hadException(); | 460 return compareBoundaryPoints(m_start, m_end, exceptionState) <= 0 && !except
ionState.hadException(); |
461 } | 461 } |
462 | 462 |
463 void Range::deleteContents(ExceptionState& exceptionState) | 463 void Range::deleteContents(ExceptionState& exceptionState) |
464 { | 464 { |
465 checkDeleteExtract(exceptionState); | 465 ASSERT(boundaryPointsValid()); |
466 if (exceptionState.hadException()) | |
467 return; | |
468 | 466 |
469 { | 467 { |
470 EventQueueScope eventQueueScope; | 468 EventQueueScope eventQueueScope; |
471 processContents(DELETE_CONTENTS, exceptionState); | 469 processContents(DELETE_CONTENTS, exceptionState); |
472 } | 470 } |
473 } | 471 } |
474 | 472 |
475 bool Range::intersectsNode(Node* refNode, ExceptionState& exceptionState) | 473 bool Range::intersectsNode(Node* refNode, ExceptionState& exceptionState) |
476 { | 474 { |
477 // http://developer.mozilla.org/en/docs/DOM:range.intersectsNode | 475 // http://developer.mozilla.org/en/docs/DOM:range.intersectsNode |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 } | 791 } |
794 } | 792 } |
795 firstChildInAncestorToProcess = direction == ProcessContentsForward ? an
cestor->nextSibling() : ancestor->previousSibling(); | 793 firstChildInAncestorToProcess = direction == ProcessContentsForward ? an
cestor->nextSibling() : ancestor->previousSibling(); |
796 } | 794 } |
797 | 795 |
798 return clonedContainer.release(); | 796 return clonedContainer.release(); |
799 } | 797 } |
800 | 798 |
801 PassRefPtrWillBeRawPtr<DocumentFragment> Range::extractContents(ExceptionState&
exceptionState) | 799 PassRefPtrWillBeRawPtr<DocumentFragment> Range::extractContents(ExceptionState&
exceptionState) |
802 { | 800 { |
803 checkDeleteExtract(exceptionState); | 801 checkExtractPrecondition(exceptionState); |
804 if (exceptionState.hadException()) | 802 if (exceptionState.hadException()) |
805 return nullptr; | 803 return nullptr; |
806 | 804 |
807 return processContents(EXTRACT_CONTENTS, exceptionState); | 805 return processContents(EXTRACT_CONTENTS, exceptionState); |
808 } | 806 } |
809 | 807 |
810 PassRefPtrWillBeRawPtr<DocumentFragment> Range::cloneContents(ExceptionState& ex
ceptionState) | 808 PassRefPtrWillBeRawPtr<DocumentFragment> Range::cloneContents(ExceptionState& ex
ceptionState) |
811 { | 809 { |
812 return processContents(CLONE_CONTENTS, exceptionState); | 810 return processContents(CLONE_CONTENTS, exceptionState); |
813 } | 811 } |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 | 1289 |
1292 void Range::setStartBefore(Node* refNode, ExceptionState& exceptionState) | 1290 void Range::setStartBefore(Node* refNode, ExceptionState& exceptionState) |
1293 { | 1291 { |
1294 checkNodeBA(refNode, exceptionState); | 1292 checkNodeBA(refNode, exceptionState); |
1295 if (exceptionState.hadException()) | 1293 if (exceptionState.hadException()) |
1296 return; | 1294 return; |
1297 | 1295 |
1298 setStart(refNode->parentNode(), refNode->nodeIndex(), exceptionState); | 1296 setStart(refNode->parentNode(), refNode->nodeIndex(), exceptionState); |
1299 } | 1297 } |
1300 | 1298 |
1301 void Range::checkDeleteExtract(ExceptionState& exceptionState) | 1299 void Range::checkExtractPrecondition(ExceptionState& exceptionState) |
1302 { | 1300 { |
1303 ASSERT(boundaryPointsValid()); | 1301 ASSERT(boundaryPointsValid()); |
1304 | 1302 |
1305 if (!commonAncestorContainer()) | 1303 if (!commonAncestorContainer()) |
1306 return; | 1304 return; |
1307 | 1305 |
1308 Node* pastLast = pastLastNode(); | 1306 Node* pastLast = pastLastNode(); |
1309 for (Node* n = firstNode(); n != pastLast; n = NodeTraversal::next(*n)) { | 1307 for (Node* n = firstNode(); n != pastLast; n = NodeTraversal::next(*n)) { |
1310 if (n->isDocumentTypeNode()) { | 1308 if (n->isDocumentTypeNode()) { |
1311 exceptionState.throwDOMException(HierarchyRequestError, "The Range c
ontains a doctype node."); | 1309 exceptionState.throwDOMException(HierarchyRequestError, "The Range c
ontains a doctype node."); |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1710 | 1708 |
1711 void showTree(const blink::Range* range) | 1709 void showTree(const blink::Range* range) |
1712 { | 1710 { |
1713 if (range && range->boundaryPointsValid()) { | 1711 if (range && range->boundaryPointsValid()) { |
1714 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); | 1712 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); |
1715 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); | 1713 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); |
1716 } | 1714 } |
1717 } | 1715 } |
1718 | 1716 |
1719 #endif | 1717 #endif |
OLD | NEW |