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 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 setStart(refNode->parentNode(), refNode->nodeIndex(), exceptionState); | 1450 setStart(refNode->parentNode(), refNode->nodeIndex(), exceptionState); |
1451 } | 1451 } |
1452 | 1452 |
1453 void Range::checkDeleteExtract(ExceptionState& exceptionState) | 1453 void Range::checkDeleteExtract(ExceptionState& exceptionState) |
1454 { | 1454 { |
1455 if (!m_start.container()) { | 1455 if (!m_start.container()) { |
1456 exceptionState.throwDOMException(InvalidStateError, "The range has no co
ntainer. Perhaps 'detatch()' has been invoked on this object?"); | 1456 exceptionState.throwDOMException(InvalidStateError, "The range has no co
ntainer. Perhaps 'detatch()' has been invoked on this object?"); |
1457 return; | 1457 return; |
1458 } | 1458 } |
1459 | 1459 |
| 1460 ASSERT(boundaryPointsValid()); |
| 1461 |
1460 if (!commonAncestorContainer(exceptionState) || exceptionState.hadException(
)) | 1462 if (!commonAncestorContainer(exceptionState) || exceptionState.hadException(
)) |
1461 return; | 1463 return; |
1462 | 1464 |
1463 Node* pastLast = pastLastNode(); | 1465 Node* pastLast = pastLastNode(); |
1464 for (Node* n = firstNode(); n != pastLast; n = NodeTraversal::next(*n)) { | 1466 for (Node* n = firstNode(); n != pastLast; n = NodeTraversal::next(*n)) { |
1465 if (n->isDocumentTypeNode()) { | 1467 if (n->isDocumentTypeNode()) { |
1466 exceptionState.throwDOMException(HierarchyRequestError, "The Range c
ontains a doctype node."); | 1468 exceptionState.throwDOMException(HierarchyRequestError, "The Range c
ontains a doctype node."); |
1467 return; | 1469 return; |
1468 } | 1470 } |
1469 } | 1471 } |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1758 ASSERT(oldNode.node()->parentNode()); | 1760 ASSERT(oldNode.node()->parentNode()); |
1759 ASSERT(oldNode.node()->isTextNode()); | 1761 ASSERT(oldNode.node()->isTextNode()); |
1760 ASSERT(oldNode.node()->previousSibling()); | 1762 ASSERT(oldNode.node()->previousSibling()); |
1761 ASSERT(oldNode.node()->previousSibling()->isTextNode()); | 1763 ASSERT(oldNode.node()->previousSibling()->isTextNode()); |
1762 boundaryTextNodesMerged(m_start, oldNode, offset); | 1764 boundaryTextNodesMerged(m_start, oldNode, offset); |
1763 boundaryTextNodesMerged(m_end, oldNode, offset); | 1765 boundaryTextNodesMerged(m_end, oldNode, offset); |
1764 } | 1766 } |
1765 | 1767 |
1766 static inline void boundaryTextNodeSplit(RangeBoundaryPoint& boundary, Text* old
Node) | 1768 static inline void boundaryTextNodeSplit(RangeBoundaryPoint& boundary, Text* old
Node) |
1767 { | 1769 { |
1768 if (boundary.container() != oldNode) | 1770 Node* boundaryContainer = boundary.container(); |
1769 return; | |
1770 unsigned boundaryOffset = boundary.offset(); | 1771 unsigned boundaryOffset = boundary.offset(); |
1771 if (boundaryOffset <= oldNode->length()) | 1772 if (boundary.childBefore() == oldNode) |
1772 return; | 1773 boundary.set(boundaryContainer, boundaryOffset + 1, oldNode->nextSibling
()); |
1773 boundary.set(oldNode->nextSibling(), boundaryOffset - oldNode->length(), 0); | 1774 else if (boundary.container() == oldNode && boundaryOffset > oldNode->length
()) |
| 1775 boundary.set(oldNode->nextSibling(), boundaryOffset - oldNode->length(),
0); |
1774 } | 1776 } |
1775 | 1777 |
1776 void Range::didSplitTextNode(Text* oldNode) | 1778 void Range::didSplitTextNode(Text* oldNode) |
1777 { | 1779 { |
1778 ASSERT(oldNode); | 1780 ASSERT(oldNode); |
1779 ASSERT(oldNode->document() == m_ownerDocument); | 1781 ASSERT(oldNode->document() == m_ownerDocument); |
1780 ASSERT(oldNode->parentNode()); | 1782 ASSERT(oldNode->parentNode()); |
1781 ASSERT(oldNode->isTextNode()); | 1783 ASSERT(oldNode->isTextNode()); |
1782 ASSERT(oldNode->nextSibling()); | 1784 ASSERT(oldNode->nextSibling()); |
1783 ASSERT(oldNode->nextSibling()->isTextNode()); | 1785 ASSERT(oldNode->nextSibling()->isTextNode()); |
1784 boundaryTextNodeSplit(m_start, oldNode); | 1786 boundaryTextNodeSplit(m_start, oldNode); |
1785 boundaryTextNodeSplit(m_end, oldNode); | 1787 boundaryTextNodeSplit(m_end, oldNode); |
| 1788 ASSERT(boundaryPointsValid()); |
1786 } | 1789 } |
1787 | 1790 |
1788 void Range::expand(const String& unit, ExceptionState& exceptionState) | 1791 void Range::expand(const String& unit, ExceptionState& exceptionState) |
1789 { | 1792 { |
1790 VisiblePosition start(startPosition()); | 1793 VisiblePosition start(startPosition()); |
1791 VisiblePosition end(endPosition()); | 1794 VisiblePosition end(endPosition()); |
1792 if (unit == "word") { | 1795 if (unit == "word") { |
1793 start = startOfWord(start); | 1796 start = startOfWord(start); |
1794 end = endOfWord(end); | 1797 end = endOfWord(end); |
1795 } else if (unit == "sentence") { | 1798 } else if (unit == "sentence") { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1889 | 1892 |
1890 void showTree(const WebCore::Range* range) | 1893 void showTree(const WebCore::Range* range) |
1891 { | 1894 { |
1892 if (range && range->boundaryPointsValid()) { | 1895 if (range && range->boundaryPointsValid()) { |
1893 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); | 1896 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); |
1894 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); | 1897 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); |
1895 } | 1898 } |
1896 } | 1899 } |
1897 | 1900 |
1898 #endif | 1901 #endif |
OLD | NEW |