Chromium Code Reviews| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 , m_start(m_ownerDocument) | 80 , m_start(m_ownerDocument) |
| 81 , m_end(m_ownerDocument) | 81 , m_end(m_ownerDocument) |
| 82 { | 82 { |
| 83 #ifndef NDEBUG | 83 #ifndef NDEBUG |
| 84 rangeCounter.increment(); | 84 rangeCounter.increment(); |
| 85 #endif | 85 #endif |
| 86 | 86 |
| 87 ScriptWrappable::init(this); | 87 ScriptWrappable::init(this); |
| 88 m_ownerDocument->attachRange(this); | 88 m_ownerDocument->attachRange(this); |
| 89 | 89 |
| 90 // Simply setting the containers and offsets directly would not do any of th e checking | 90 // Simply setting the containers and offsets directly would not do any of th e king |
|
Yuta Kitamura
2014/06/18 09:30:29
"king"?
yosin_UTC9
2014/06/18 09:52:33
Done.
| |
| 91 // that setStart and setEnd do, so we call those functions. | 91 // that setStart and setEnd do, so we call those functions. |
| 92 setStart(startContainer, startOffset); | 92 setStart(startContainer, startOffset); |
| 93 setEnd(endContainer, endOffset); | 93 setEnd(endContainer, endOffset); |
| 94 } | 94 } |
| 95 | 95 |
| 96 PassRefPtrWillBeRawPtr<Range> Range::create(Document& ownerDocument, Node* start Container, int startOffset, Node* endContainer, int endOffset) | 96 PassRefPtrWillBeRawPtr<Range> Range::create(Document& ownerDocument, Node* start Container, int startOffset, Node* endContainer, int endOffset) |
| 97 { | 97 { |
| 98 return adoptRefWillBeNoop(new Range(ownerDocument, startContainer, startOffs et, endContainer, endOffset)); | 98 return adoptRefWillBeNoop(new Range(ownerDocument, startContainer, startOffs et, endContainer, endOffset)); |
| 99 } | 99 } |
| 100 | 100 |
| (...skipping 1436 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); | |
| 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 |