| 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 | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
| 7 * rights reserved. | 7 * rights reserved. |
| 8 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 8 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 } | 277 } |
| 278 | 278 |
| 279 void Range::collapse(bool toStart) { | 279 void Range::collapse(bool toStart) { |
| 280 RangeUpdateScope scope(this); | 280 RangeUpdateScope scope(this); |
| 281 if (toStart) | 281 if (toStart) |
| 282 m_end = m_start; | 282 m_end = m_start; |
| 283 else | 283 else |
| 284 m_start = m_end; | 284 m_start = m_end; |
| 285 } | 285 } |
| 286 | 286 |
| 287 bool Range::isNodeFullyContained(Node& node) const { | |
| 288 ContainerNode* parentNode = node.parentNode(); | |
| 289 unsigned nodeIndex = node.nodeIndex(); | |
| 290 return isPointInRange( | |
| 291 parentNode, nodeIndex, | |
| 292 IGNORE_EXCEPTION_FOR_TESTING) // starts in the middle of this | |
| 293 // range, or on the boundary points. | |
| 294 && isPointInRange( | |
| 295 parentNode, nodeIndex + 1, | |
| 296 IGNORE_EXCEPTION_FOR_TESTING); // ends in the middle of this | |
| 297 // range, or on the boundary | |
| 298 // points. | |
| 299 } | |
| 300 | |
| 301 bool Range::hasSameRoot(const Node& node) const { | 287 bool Range::hasSameRoot(const Node& node) const { |
| 302 if (node.document() != m_ownerDocument) | 288 if (node.document() != m_ownerDocument) |
| 303 return false; | 289 return false; |
| 304 // commonAncestorContainer() is O(depth). We should avoid to call it in common | 290 // commonAncestorContainer() is O(depth). We should avoid to call it in common |
| 305 // cases. | 291 // cases. |
| 306 if (node.isInTreeScope() && m_start.container()->isInTreeScope() && | 292 if (node.isInTreeScope() && m_start.container()->isInTreeScope() && |
| 307 &node.treeScope() == &m_start.container()->treeScope()) | 293 &node.treeScope() == &m_start.container()->treeScope()) |
| 308 return true; | 294 return true; |
| 309 return node.commonAncestor(*m_start.container(), NodeTraversal::parent); | 295 return node.commonAncestor(*m_start.container(), NodeTraversal::parent); |
| 310 } | 296 } |
| (...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1825 .data() | 1811 .data() |
| 1826 << "start offset: " << range->startOffset() | 1812 << "start offset: " << range->startOffset() |
| 1827 << ", end offset: " << range->endOffset(); | 1813 << ", end offset: " << range->endOffset(); |
| 1828 } else { | 1814 } else { |
| 1829 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " | 1815 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " |
| 1830 "invalid."; | 1816 "invalid."; |
| 1831 } | 1817 } |
| 1832 } | 1818 } |
| 1833 | 1819 |
| 1834 #endif | 1820 #endif |
| OLD | NEW |