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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 rangeCounter.decrement(); | 113 rangeCounter.decrement(); |
114 #endif | 114 #endif |
115 } | 115 } |
116 | 116 |
117 void Range::setDocument(Document& document) | 117 void Range::setDocument(Document& document) |
118 { | 118 { |
119 ASSERT(m_ownerDocument != document); | 119 ASSERT(m_ownerDocument != document); |
120 ASSERT(m_ownerDocument); | 120 ASSERT(m_ownerDocument); |
121 m_ownerDocument->detachRange(this); | 121 m_ownerDocument->detachRange(this); |
122 m_ownerDocument = &document; | 122 m_ownerDocument = &document; |
123 m_start.setToStartOfNode(&document); | 123 m_start.setToStartOfNode(document); |
124 m_end.setToStartOfNode(&document); | 124 m_end.setToStartOfNode(document); |
125 m_ownerDocument->attachRange(this); | 125 m_ownerDocument->attachRange(this); |
126 } | 126 } |
127 | 127 |
128 Node* Range::startContainer(ExceptionState& exceptionState) const | 128 Node* Range::startContainer(ExceptionState& exceptionState) const |
129 { | 129 { |
130 if (!m_start.container()) { | 130 if (!m_start.container()) { |
131 exceptionState.throwDOMException(InvalidStateError, "The range has no co
ntainer. Perhaps 'detatch()' has been invoked on this object?"); | 131 exceptionState.throwDOMException(InvalidStateError, "The range has no co
ntainer. Perhaps 'detatch()' has been invoked on this object?"); |
132 return 0; | 132 return 0; |
133 } | 133 } |
134 | 134 |
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 break; | 1340 break; |
1341 case Node::DOCUMENT_TYPE_NODE: | 1341 case Node::DOCUMENT_TYPE_NODE: |
1342 exceptionState.throwDOMException(InvalidNodeTypeError, "The node
provided is of type '" + refNode->nodeName() + "'."); | 1342 exceptionState.throwDOMException(InvalidNodeTypeError, "The node
provided is of type '" + refNode->nodeName() + "'."); |
1343 return; | 1343 return; |
1344 } | 1344 } |
1345 } | 1345 } |
1346 | 1346 |
1347 if (m_ownerDocument != refNode->document()) | 1347 if (m_ownerDocument != refNode->document()) |
1348 setDocument(refNode->document()); | 1348 setDocument(refNode->document()); |
1349 | 1349 |
1350 m_start.setToStartOfNode(refNode); | 1350 m_start.setToStartOfNode(*refNode); |
1351 m_end.setToEndOfNode(refNode); | 1351 m_end.setToEndOfNode(*refNode); |
1352 } | 1352 } |
1353 | 1353 |
1354 void Range::surroundContents(PassRefPtr<Node> passNewParent, ExceptionState& exc
eptionState) | 1354 void Range::surroundContents(PassRefPtr<Node> passNewParent, ExceptionState& exc
eptionState) |
1355 { | 1355 { |
1356 RefPtr<Node> newParent = passNewParent; | 1356 RefPtr<Node> newParent = passNewParent; |
1357 | 1357 |
1358 if (!m_start.container()) { | 1358 if (!m_start.container()) { |
1359 exceptionState.throwDOMException(InvalidStateError, "The range has no co
ntainer. Perhaps 'detatch()' has been invoked on this object?"); | 1359 exceptionState.throwDOMException(InvalidStateError, "The range has no co
ntainer. Perhaps 'detatch()' has been invoked on this object?"); |
1360 return; | 1360 return; |
1361 } | 1361 } |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 } | 1642 } |
1643 | 1643 |
1644 void Range::nodeChildrenChanged(ContainerNode* container) | 1644 void Range::nodeChildrenChanged(ContainerNode* container) |
1645 { | 1645 { |
1646 ASSERT(container); | 1646 ASSERT(container); |
1647 ASSERT(container->document() == m_ownerDocument); | 1647 ASSERT(container->document() == m_ownerDocument); |
1648 boundaryNodeChildrenChanged(m_start, container); | 1648 boundaryNodeChildrenChanged(m_start, container); |
1649 boundaryNodeChildrenChanged(m_end, container); | 1649 boundaryNodeChildrenChanged(m_end, container); |
1650 } | 1650 } |
1651 | 1651 |
1652 static inline void boundaryNodeChildrenWillBeRemoved(RangeBoundaryPoint& boundar
y, ContainerNode* container) | 1652 static inline void boundaryNodeChildrenWillBeRemoved(RangeBoundaryPoint& boundar
y, ContainerNode& container) |
1653 { | 1653 { |
1654 for (Node* nodeToBeRemoved = container->firstChild(); nodeToBeRemoved; nodeT
oBeRemoved = nodeToBeRemoved->nextSibling()) { | 1654 for (Node* nodeToBeRemoved = container.firstChild(); nodeToBeRemoved; nodeTo
BeRemoved = nodeToBeRemoved->nextSibling()) { |
1655 if (boundary.childBefore() == nodeToBeRemoved) { | 1655 if (boundary.childBefore() == nodeToBeRemoved) { |
1656 boundary.setToStartOfNode(container); | 1656 boundary.setToStartOfNode(container); |
1657 return; | 1657 return; |
1658 } | 1658 } |
1659 | 1659 |
1660 for (Node* n = boundary.container(); n; n = n->parentNode()) { | 1660 for (Node* n = boundary.container(); n; n = n->parentNode()) { |
1661 if (n == nodeToBeRemoved) { | 1661 if (n == nodeToBeRemoved) { |
1662 boundary.setToStartOfNode(container); | 1662 boundary.setToStartOfNode(container); |
1663 return; | 1663 return; |
1664 } | 1664 } |
1665 } | 1665 } |
1666 } | 1666 } |
1667 } | 1667 } |
1668 | 1668 |
1669 void Range::nodeChildrenWillBeRemoved(ContainerNode* container) | 1669 void Range::nodeChildrenWillBeRemoved(ContainerNode& container) |
1670 { | 1670 { |
1671 ASSERT(container); | 1671 ASSERT(container.document() == m_ownerDocument); |
1672 ASSERT(container->document() == m_ownerDocument); | |
1673 boundaryNodeChildrenWillBeRemoved(m_start, container); | 1672 boundaryNodeChildrenWillBeRemoved(m_start, container); |
1674 boundaryNodeChildrenWillBeRemoved(m_end, container); | 1673 boundaryNodeChildrenWillBeRemoved(m_end, container); |
1675 } | 1674 } |
1676 | 1675 |
1677 static inline void boundaryNodeWillBeRemoved(RangeBoundaryPoint& boundary, Node&
nodeToBeRemoved) | 1676 static inline void boundaryNodeWillBeRemoved(RangeBoundaryPoint& boundary, Node&
nodeToBeRemoved) |
1678 { | 1677 { |
1679 if (boundary.childBefore() == nodeToBeRemoved) { | 1678 if (boundary.childBefore() == nodeToBeRemoved) { |
1680 boundary.childBeforeWillBeRemoved(); | 1679 boundary.childBeforeWillBeRemoved(); |
1681 return; | 1680 return; |
1682 } | 1681 } |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1887 | 1886 |
1888 void showTree(const WebCore::Range* range) | 1887 void showTree(const WebCore::Range* range) |
1889 { | 1888 { |
1890 if (range && range->boundaryPointsValid()) { | 1889 if (range && range->boundaryPointsValid()) { |
1891 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); | 1890 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); |
1892 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); | 1891 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); |
1893 } | 1892 } |
1894 } | 1893 } |
1895 | 1894 |
1896 #endif | 1895 #endif |
OLD | NEW |