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 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1537 { | 1537 { |
1538 ASSERT(oldNode.node().document() == m_ownerDocument); | 1538 ASSERT(oldNode.node().document() == m_ownerDocument); |
1539 ASSERT(oldNode.node().parentNode()); | 1539 ASSERT(oldNode.node().parentNode()); |
1540 ASSERT(oldNode.node().isTextNode()); | 1540 ASSERT(oldNode.node().isTextNode()); |
1541 ASSERT(oldNode.node().previousSibling()); | 1541 ASSERT(oldNode.node().previousSibling()); |
1542 ASSERT(oldNode.node().previousSibling()->isTextNode()); | 1542 ASSERT(oldNode.node().previousSibling()->isTextNode()); |
1543 boundaryTextNodesMerged(m_start, oldNode, offset); | 1543 boundaryTextNodesMerged(m_start, oldNode, offset); |
1544 boundaryTextNodesMerged(m_end, oldNode, offset); | 1544 boundaryTextNodesMerged(m_end, oldNode, offset); |
1545 } | 1545 } |
1546 | 1546 |
1547 void Range::updateOwnerDocumentIfNeeded() | |
1548 { | |
1549 ASSERT(m_start.container()); | |
1550 ASSERT(m_end.container()); | |
1551 Document& newDocument = m_start.container()->document(); | |
1552 ASSERT(newDocument == m_end.container()->document()); | |
1553 if (newDocument == m_ownerDocument) | |
1554 return; | |
1555 m_ownerDocument->detachRange(this); | |
1556 m_ownerDocument = &newDocument; | |
1557 m_ownerDocument->attachRange(this); | |
Yuta Kitamura
2014/06/18 03:22:37
I'm not sure migrating to another document is an e
yosin_UTC9
2014/06/18 08:55:40
I checked FireFox and IE. Behavior is as same as C
| |
1558 } | |
1559 | |
1547 static inline void boundaryTextNodeSplit(RangeBoundaryPoint& boundary, Text& old Node) | 1560 static inline void boundaryTextNodeSplit(RangeBoundaryPoint& boundary, Text& old Node) |
1548 { | 1561 { |
1549 Node* boundaryContainer = boundary.container(); | 1562 Node* boundaryContainer = boundary.container(); |
1550 unsigned boundaryOffset = boundary.offset(); | 1563 unsigned boundaryOffset = boundary.offset(); |
1551 if (boundary.childBefore() == &oldNode) | 1564 if (boundary.childBefore() == &oldNode) |
1552 boundary.set(boundaryContainer, boundaryOffset + 1, oldNode.nextSibling( )); | 1565 boundary.set(boundaryContainer, boundaryOffset + 1, oldNode.nextSibling( )); |
1553 else if (boundary.container() == &oldNode && boundaryOffset > oldNode.length ()) | 1566 else if (boundary.container() == &oldNode && boundaryOffset > oldNode.length ()) |
1554 boundary.set(oldNode.nextSibling(), boundaryOffset - oldNode.length(), 0 ); | 1567 boundary.set(oldNode.nextSibling(), boundaryOffset - oldNode.length(), 0 ); |
1555 } | 1568 } |
1556 | 1569 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1671 | 1684 |
1672 void showTree(const WebCore::Range* range) | 1685 void showTree(const WebCore::Range* range) |
1673 { | 1686 { |
1674 if (range && range->boundaryPointsValid()) { | 1687 if (range && range->boundaryPointsValid()) { |
1675 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); | 1688 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); |
1676 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); | 1689 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); |
1677 } | 1690 } |
1678 } | 1691 } |
1679 | 1692 |
1680 #endif | 1693 #endif |
OLD | NEW |