Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Side by Side Diff: Source/core/dom/Range.cpp

Issue 224113002: Oilpan: move Range object to the oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use STACK_ALLOCATED() + incorporate ager's overview of macros in this area. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 , m_end(m_ownerDocument) 64 , m_end(m_ownerDocument)
65 { 65 {
66 #ifndef NDEBUG 66 #ifndef NDEBUG
67 rangeCounter.increment(); 67 rangeCounter.increment();
68 #endif 68 #endif
69 69
70 ScriptWrappable::init(this); 70 ScriptWrappable::init(this);
71 m_ownerDocument->attachRange(this); 71 m_ownerDocument->attachRange(this);
72 } 72 }
73 73
74 PassRefPtr<Range> Range::create(Document& ownerDocument) 74 PassRefPtrWillBeRawPtr<Range> Range::create(Document& ownerDocument)
75 { 75 {
76 return adoptRef(new Range(ownerDocument)); 76 return adoptRefWillBeNoop(new Range(ownerDocument));
77 } 77 }
78 78
79 inline Range::Range(Document& ownerDocument, Node* startContainer, int startOffs et, Node* endContainer, int endOffset) 79 inline Range::Range(Document& ownerDocument, Node* startContainer, int startOffs et, Node* endContainer, int endOffset)
80 : m_ownerDocument(&ownerDocument) 80 : m_ownerDocument(&ownerDocument)
81 , m_start(m_ownerDocument) 81 , m_start(m_ownerDocument)
82 , m_end(m_ownerDocument) 82 , m_end(m_ownerDocument)
83 { 83 {
84 #ifndef NDEBUG 84 #ifndef NDEBUG
85 rangeCounter.increment(); 85 rangeCounter.increment();
86 #endif 86 #endif
87 87
88 ScriptWrappable::init(this); 88 ScriptWrappable::init(this);
89 m_ownerDocument->attachRange(this); 89 m_ownerDocument->attachRange(this);
90 90
91 // Simply setting the containers and offsets directly would not do any of th e checking 91 // Simply setting the containers and offsets directly would not do any of th e checking
92 // that setStart and setEnd do, so we call those functions. 92 // that setStart and setEnd do, so we call those functions.
93 setStart(startContainer, startOffset); 93 setStart(startContainer, startOffset);
94 setEnd(endContainer, endOffset); 94 setEnd(endContainer, endOffset);
95 } 95 }
96 96
97 PassRefPtr<Range> Range::create(Document& ownerDocument, Node* startContainer, i nt startOffset, Node* endContainer, int endOffset) 97 PassRefPtrWillBeRawPtr<Range> Range::create(Document& ownerDocument, Node* start Container, int startOffset, Node* endContainer, int endOffset)
98 { 98 {
99 return adoptRef(new Range(ownerDocument, startContainer, startOffset, endCon tainer, endOffset)); 99 return adoptRefWillBeNoop(new Range(ownerDocument, startContainer, startOffs et, endContainer, endOffset));
100 } 100 }
101 101
102 PassRefPtr<Range> Range::create(Document& ownerDocument, const Position& start, const Position& end) 102 PassRefPtrWillBeRawPtr<Range> Range::create(Document& ownerDocument, const Posit ion& start, const Position& end)
103 { 103 {
104 return adoptRef(new Range(ownerDocument, start.containerNode(), start.comput eOffsetInContainerNode(), end.containerNode(), end.computeOffsetInContainerNode( ))); 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);
111 111
112 #ifndef NDEBUG 112 #ifndef NDEBUG
113 rangeCounter.decrement(); 113 rangeCounter.decrement();
114 #endif 114 #endif
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 case Node::CDATA_SECTION_NODE: 1213 case Node::CDATA_SECTION_NODE:
1214 case Node::COMMENT_NODE: 1214 case Node::COMMENT_NODE:
1215 case Node::DOCUMENT_TYPE_NODE: 1215 case Node::DOCUMENT_TYPE_NODE:
1216 case Node::PROCESSING_INSTRUCTION_NODE: 1216 case Node::PROCESSING_INSTRUCTION_NODE:
1217 case Node::TEXT_NODE: 1217 case Node::TEXT_NODE:
1218 exceptionState.throwDOMException(InvalidNodeTypeError, "The node pro vided is of type '" + n->nodeName() + "'."); 1218 exceptionState.throwDOMException(InvalidNodeTypeError, "The node pro vided is of type '" + n->nodeName() + "'.");
1219 return; 1219 return;
1220 } 1220 }
1221 } 1221 }
1222 1222
1223 PassRefPtr<Range> Range::cloneRange(ExceptionState& exceptionState) const 1223 PassRefPtrWillBeRawPtr<Range> Range::cloneRange(ExceptionState& exceptionState) const
1224 { 1224 {
1225 if (!m_start.container()) { 1225 if (!m_start.container()) {
1226 exceptionState.throwDOMException(InvalidStateError, "The range has no co ntainer. Perhaps 'detach()' has been invoked on this object?"); 1226 exceptionState.throwDOMException(InvalidStateError, "The range has no co ntainer. Perhaps 'detach()' has been invoked on this object?");
1227 return nullptr; 1227 return nullptr;
1228 } 1228 }
1229 1229
1230 return Range::create(*m_ownerDocument.get(), m_start.container(), m_start.of fset(), m_end.container(), m_end.offset()); 1230 return Range::create(*m_ownerDocument.get(), m_start.container(), m_start.of fset(), m_end.container(), m_end.offset());
1231 } 1231 }
1232 1232
1233 void Range::setStartAfter(Node* refNode, ExceptionState& exceptionState) 1233 void Range::setStartAfter(Node* refNode, ExceptionState& exceptionState)
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 1604
1605 bool areRangesEqual(const Range* a, const Range* b) 1605 bool areRangesEqual(const Range* a, const Range* b)
1606 { 1606 {
1607 if (a == b) 1607 if (a == b)
1608 return true; 1608 return true;
1609 if (!a || !b) 1609 if (!a || !b)
1610 return false; 1610 return false;
1611 return a->startPosition() == b->startPosition() && a->endPosition() == b->en dPosition(); 1611 return a->startPosition() == b->startPosition() && a->endPosition() == b->en dPosition();
1612 } 1612 }
1613 1613
1614 PassRefPtr<Range> rangeOfContents(Node* node) 1614 PassRefPtrWillBeRawPtr<Range> rangeOfContents(Node* node)
1615 { 1615 {
1616 ASSERT(node); 1616 ASSERT(node);
1617 RefPtr<Range> range = Range::create(node->document()); 1617 RefPtrWillBeRawPtr<Range> range = Range::create(node->document());
1618 range->selectNodeContents(node, IGNORE_EXCEPTION); 1618 range->selectNodeContents(node, IGNORE_EXCEPTION);
1619 return range.release(); 1619 return range.release();
1620 } 1620 }
1621 1621
1622 int Range::maxStartOffset() const 1622 int Range::maxStartOffset() const
1623 { 1623 {
1624 if (!m_start.container()) 1624 if (!m_start.container())
1625 return 0; 1625 return 0;
1626 if (!m_start.container()->offsetInCharacters()) 1626 if (!m_start.container()->offsetInCharacters())
1627 return m_start.container()->countChildren(); 1627 return m_start.container()->countChildren();
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 if (quads.isEmpty()) 1877 if (quads.isEmpty())
1878 return FloatRect(); 1878 return FloatRect();
1879 1879
1880 FloatRect result; 1880 FloatRect result;
1881 for (size_t i = 0; i < quads.size(); ++i) 1881 for (size_t i = 0; i < quads.size(); ++i)
1882 result.unite(quads[i].boundingBox()); 1882 result.unite(quads[i].boundingBox());
1883 1883
1884 return result; 1884 return result;
1885 } 1885 }
1886 1886
1887 void Range::trace(Visitor*)
1888 {
1889 }
1890
1887 } // namespace WebCore 1891 } // namespace WebCore
1888 1892
1889 #ifndef NDEBUG 1893 #ifndef NDEBUG
1890 1894
1891 void showTree(const WebCore::Range* range) 1895 void showTree(const WebCore::Range* range)
1892 { 1896 {
1893 if (range && range->boundaryPointsValid()) { 1897 if (range && range->boundaryPointsValid()) {
1894 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); 1898 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E");
1895 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); 1899 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset());
1896 } 1900 }
1897 } 1901 }
1898 1902
1899 #endif 1903 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698