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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1757 ASSERT(oldNode.node().parentNode()); | 1759 ASSERT(oldNode.node().parentNode()); |
1758 ASSERT(oldNode.node().isTextNode()); | 1760 ASSERT(oldNode.node().isTextNode()); |
1759 ASSERT(oldNode.node().previousSibling()); | 1761 ASSERT(oldNode.node().previousSibling()); |
1760 ASSERT(oldNode.node().previousSibling()->isTextNode()); | 1762 ASSERT(oldNode.node().previousSibling()->isTextNode()); |
1761 boundaryTextNodesMerged(m_start, oldNode, offset); | 1763 boundaryTextNodesMerged(m_start, oldNode, offset); |
1762 boundaryTextNodesMerged(m_end, oldNode, offset); | 1764 boundaryTextNodesMerged(m_end, oldNode, offset); |
1763 } | 1765 } |
1764 | 1766 |
1765 static inline void boundaryTextNodeSplit(RangeBoundaryPoint& boundary, Text& old
Node) | 1767 static inline void boundaryTextNodeSplit(RangeBoundaryPoint& boundary, Text& old
Node) |
1766 { | 1768 { |
1767 if (boundary.container() != oldNode) | 1769 Node* boundaryContainer = boundary.container(); |
1768 return; | |
1769 unsigned boundaryOffset = boundary.offset(); | 1770 unsigned boundaryOffset = boundary.offset(); |
1770 if (boundaryOffset <= oldNode.length()) | 1771 if (boundary.childBefore() == &oldNode) |
1771 return; | 1772 boundary.set(boundaryContainer, boundaryOffset + 1, oldNode.nextSibling(
)); |
1772 boundary.set(oldNode.nextSibling(), boundaryOffset - oldNode.length(), 0); | 1773 else if (boundary.container() == &oldNode && boundaryOffset > oldNode.length
()) |
| 1774 boundary.set(oldNode.nextSibling(), boundaryOffset - oldNode.length(), 0
); |
1773 } | 1775 } |
1774 | 1776 |
1775 void Range::didSplitTextNode(Text& oldNode) | 1777 void Range::didSplitTextNode(Text& oldNode) |
1776 { | 1778 { |
1777 ASSERT(oldNode.document() == m_ownerDocument); | 1779 ASSERT(oldNode.document() == m_ownerDocument); |
1778 ASSERT(oldNode.parentNode()); | 1780 ASSERT(oldNode.parentNode()); |
1779 ASSERT(oldNode.isTextNode()); | 1781 ASSERT(oldNode.isTextNode()); |
1780 ASSERT(oldNode.nextSibling()); | 1782 ASSERT(oldNode.nextSibling()); |
1781 ASSERT(oldNode.nextSibling()->isTextNode()); | 1783 ASSERT(oldNode.nextSibling()->isTextNode()); |
1782 boundaryTextNodeSplit(m_start, oldNode); | 1784 boundaryTextNodeSplit(m_start, oldNode); |
1783 boundaryTextNodeSplit(m_end, oldNode); | 1785 boundaryTextNodeSplit(m_end, oldNode); |
| 1786 ASSERT(boundaryPointsValid()); |
1784 } | 1787 } |
1785 | 1788 |
1786 void Range::expand(const String& unit, ExceptionState& exceptionState) | 1789 void Range::expand(const String& unit, ExceptionState& exceptionState) |
1787 { | 1790 { |
1788 VisiblePosition start(startPosition()); | 1791 VisiblePosition start(startPosition()); |
1789 VisiblePosition end(endPosition()); | 1792 VisiblePosition end(endPosition()); |
1790 if (unit == "word") { | 1793 if (unit == "word") { |
1791 start = startOfWord(start); | 1794 start = startOfWord(start); |
1792 end = endOfWord(end); | 1795 end = endOfWord(end); |
1793 } else if (unit == "sentence") { | 1796 } else if (unit == "sentence") { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1887 | 1890 |
1888 void showTree(const WebCore::Range* range) | 1891 void showTree(const WebCore::Range* range) |
1889 { | 1892 { |
1890 if (range && range->boundaryPointsValid()) { | 1893 if (range && range->boundaryPointsValid()) { |
1891 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); | 1894 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); |
1892 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); | 1895 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); |
1893 } | 1896 } |
1894 } | 1897 } |
1895 | 1898 |
1896 #endif | 1899 #endif |
OLD | NEW |