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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 } | 100 } |
| 101 | 101 |
| 102 PassRefPtrWillBeRawPtr<Range> Range::create(Document& ownerDocument, const Posit ion& start, const Position& end) | 102 PassRefPtrWillBeRawPtr<Range> Range::create(Document& ownerDocument, const Posit ion& start, const Position& end) |
| 103 { | 103 { |
| 104 return adoptRefWillBeNoop(new Range(ownerDocument, start.containerNode(), st art.computeOffsetInContainerNode(), end.containerNode(), end.computeOffsetInCont ainerNode())); | 104 return adoptRefWillBeNoop(new Range(ownerDocument, start.containerNode(), st art.computeOffsetInContainerNode(), end.containerNode(), end.computeOffsetInCont ainerNode())); |
| 105 } | 105 } |
| 106 | 106 |
| 107 Range::~Range() | 107 Range::~Range() |
| 108 { | 108 { |
| 109 // Always detach (even if we've already detached) to fix https://bugs.webkit .org/show_bug.cgi?id=26044 | 109 // Always detach (even if we've already detached) to fix https://bugs.webkit .org/show_bug.cgi?id=26044 |
| 110 m_ownerDocument->detachRange(this); | 110 m_ownerDocument->detachRange(this); |
|
haraken
2014/06/02 14:38:43
You cannot touch an on-heap object in a destructor
sof
2014/06/02 14:41:02
Sorry, forgot to check this dtor. Will address.
sof
2014/06/02 16:26:18
Done.
| |
| 111 | 111 |
| 112 #ifndef NDEBUG | 112 #ifndef NDEBUG |
| 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); |
| (...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1489 if (n == nodeToBeRemoved) { | 1489 if (n == nodeToBeRemoved) { |
| 1490 boundary.setToBeforeChild(nodeToBeRemoved); | 1490 boundary.setToBeforeChild(nodeToBeRemoved); |
| 1491 return; | 1491 return; |
| 1492 } | 1492 } |
| 1493 } | 1493 } |
| 1494 } | 1494 } |
| 1495 | 1495 |
| 1496 void Range::nodeWillBeRemoved(Node& node) | 1496 void Range::nodeWillBeRemoved(Node& node) |
| 1497 { | 1497 { |
| 1498 ASSERT(node.document() == m_ownerDocument); | 1498 ASSERT(node.document() == m_ownerDocument); |
| 1499 ASSERT(node != m_ownerDocument); | 1499 ASSERT(node != m_ownerDocument.get()); |
| 1500 | 1500 |
| 1501 // FIXME: Once DOMNodeRemovedFromDocument mutation event removed, we | 1501 // FIXME: Once DOMNodeRemovedFromDocument mutation event removed, we |
| 1502 // should change following if-statement to ASSERT(!node->parentNode). | 1502 // should change following if-statement to ASSERT(!node->parentNode). |
| 1503 if (!node.parentNode()) | 1503 if (!node.parentNode()) |
| 1504 return; | 1504 return; |
| 1505 boundaryNodeWillBeRemoved(m_start, node); | 1505 boundaryNodeWillBeRemoved(m_start, node); |
| 1506 boundaryNodeWillBeRemoved(m_end, node); | 1506 boundaryNodeWillBeRemoved(m_end, node); |
| 1507 } | 1507 } |
| 1508 | 1508 |
| 1509 static inline void boundaryTextInserted(RangeBoundaryPoint& boundary, Node* text , unsigned offset, unsigned length) | 1509 static inline void boundaryTextInserted(RangeBoundaryPoint& boundary, Node* text , unsigned offset, unsigned length) |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1671 if (quads.isEmpty()) | 1671 if (quads.isEmpty()) |
| 1672 return FloatRect(); | 1672 return FloatRect(); |
| 1673 | 1673 |
| 1674 FloatRect result; | 1674 FloatRect result; |
| 1675 for (size_t i = 0; i < quads.size(); ++i) | 1675 for (size_t i = 0; i < quads.size(); ++i) |
| 1676 result.unite(quads[i].boundingBox()); | 1676 result.unite(quads[i].boundingBox()); |
| 1677 | 1677 |
| 1678 return result; | 1678 return result; |
| 1679 } | 1679 } |
| 1680 | 1680 |
| 1681 void Range::trace(Visitor*) | 1681 void Range::trace(Visitor* visitor) |
| 1682 { | 1682 { |
| 1683 visitor->trace(m_ownerDocument); | |
| 1683 } | 1684 } |
| 1684 | 1685 |
| 1685 } // namespace WebCore | 1686 } // namespace WebCore |
| 1686 | 1687 |
| 1687 #ifndef NDEBUG | 1688 #ifndef NDEBUG |
| 1688 | 1689 |
| 1689 void showTree(const WebCore::Range* range) | 1690 void showTree(const WebCore::Range* range) |
| 1690 { | 1691 { |
| 1691 if (range && range->boundaryPointsValid()) { | 1692 if (range && range->boundaryPointsValid()) { |
| 1692 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); | 1693 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); |
| 1693 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); | 1694 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); |
| 1694 } | 1695 } |
| 1695 } | 1696 } |
| 1696 | 1697 |
| 1697 #endif | 1698 #endif |
| OLD | NEW |