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 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1736 } | 1736 } |
1737 | 1737 |
1738 void Range::didRemoveText(Node* text, unsigned offset, unsigned length) | 1738 void Range::didRemoveText(Node* text, unsigned offset, unsigned length) |
1739 { | 1739 { |
1740 ASSERT(text); | 1740 ASSERT(text); |
1741 ASSERT(text->document() == m_ownerDocument); | 1741 ASSERT(text->document() == m_ownerDocument); |
1742 boundaryTextRemoved(m_start, text, offset, length); | 1742 boundaryTextRemoved(m_start, text, offset, length); |
1743 boundaryTextRemoved(m_end, text, offset, length); | 1743 boundaryTextRemoved(m_end, text, offset, length); |
1744 } | 1744 } |
1745 | 1745 |
1746 static inline void boundaryTextNodesMerged(RangeBoundaryPoint& boundary, NodeWit
hIndex& oldNode, unsigned offset) | 1746 static inline void boundaryTextNodesMerged(RangeBoundaryPoint& boundary, const N
odeWithIndex& oldNode, unsigned offset) |
1747 { | 1747 { |
1748 if (boundary.container() == oldNode.node()) | 1748 if (boundary.container() == oldNode.node()) |
1749 boundary.set(oldNode.node()->previousSibling(), boundary.offset() + offs
et, 0); | 1749 boundary.set(oldNode.node().previousSibling(), boundary.offset() + offse
t, 0); |
1750 else if (boundary.container() == oldNode.node()->parentNode() && boundary.of
fset() == oldNode.index()) | 1750 else if (boundary.container() == oldNode.node().parentNode() && boundary.off
set() == oldNode.index()) |
1751 boundary.set(oldNode.node()->previousSibling(), offset, 0); | 1751 boundary.set(oldNode.node().previousSibling(), offset, 0); |
1752 } | 1752 } |
1753 | 1753 |
1754 void Range::didMergeTextNodes(NodeWithIndex& oldNode, unsigned offset) | 1754 void Range::didMergeTextNodes(const NodeWithIndex& oldNode, unsigned offset) |
1755 { | 1755 { |
1756 ASSERT(oldNode.node()); | 1756 ASSERT(oldNode.node().document() == m_ownerDocument); |
1757 ASSERT(oldNode.node()->document() == m_ownerDocument); | 1757 ASSERT(oldNode.node().parentNode()); |
1758 ASSERT(oldNode.node()->parentNode()); | 1758 ASSERT(oldNode.node().isTextNode()); |
1759 ASSERT(oldNode.node()->isTextNode()); | 1759 ASSERT(oldNode.node().previousSibling()); |
1760 ASSERT(oldNode.node()->previousSibling()); | 1760 ASSERT(oldNode.node().previousSibling()->isTextNode()); |
1761 ASSERT(oldNode.node()->previousSibling()->isTextNode()); | |
1762 boundaryTextNodesMerged(m_start, oldNode, offset); | 1761 boundaryTextNodesMerged(m_start, oldNode, offset); |
1763 boundaryTextNodesMerged(m_end, oldNode, offset); | 1762 boundaryTextNodesMerged(m_end, oldNode, offset); |
1764 } | 1763 } |
1765 | 1764 |
1766 static inline void boundaryTextNodeSplit(RangeBoundaryPoint& boundary, Text* old
Node) | 1765 static inline void boundaryTextNodeSplit(RangeBoundaryPoint& boundary, Text& old
Node) |
1767 { | 1766 { |
1768 if (boundary.container() != oldNode) | 1767 if (boundary.container() != oldNode) |
1769 return; | 1768 return; |
1770 unsigned boundaryOffset = boundary.offset(); | 1769 unsigned boundaryOffset = boundary.offset(); |
1771 if (boundaryOffset <= oldNode->length()) | 1770 if (boundaryOffset <= oldNode.length()) |
1772 return; | 1771 return; |
1773 boundary.set(oldNode->nextSibling(), boundaryOffset - oldNode->length(), 0); | 1772 boundary.set(oldNode.nextSibling(), boundaryOffset - oldNode.length(), 0); |
1774 } | 1773 } |
1775 | 1774 |
1776 void Range::didSplitTextNode(Text* oldNode) | 1775 void Range::didSplitTextNode(Text& oldNode) |
1777 { | 1776 { |
1778 ASSERT(oldNode); | 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()); | |
1784 boundaryTextNodeSplit(m_start, oldNode); | 1782 boundaryTextNodeSplit(m_start, oldNode); |
1785 boundaryTextNodeSplit(m_end, oldNode); | 1783 boundaryTextNodeSplit(m_end, oldNode); |
1786 } | 1784 } |
1787 | 1785 |
1788 void Range::expand(const String& unit, ExceptionState& exceptionState) | 1786 void Range::expand(const String& unit, ExceptionState& exceptionState) |
1789 { | 1787 { |
1790 VisiblePosition start(startPosition()); | 1788 VisiblePosition start(startPosition()); |
1791 VisiblePosition end(endPosition()); | 1789 VisiblePosition end(endPosition()); |
1792 if (unit == "word") { | 1790 if (unit == "word") { |
1793 start = startOfWord(start); | 1791 start = startOfWord(start); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1889 | 1887 |
1890 void showTree(const WebCore::Range* range) | 1888 void showTree(const WebCore::Range* range) |
1891 { | 1889 { |
1892 if (range && range->boundaryPointsValid()) { | 1890 if (range && range->boundaryPointsValid()) { |
1893 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); | 1891 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); |
1894 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); | 1892 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); |
1895 } | 1893 } |
1896 } | 1894 } |
1897 | 1895 |
1898 #endif | 1896 #endif |
OLD | NEW |