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

Side by Side Diff: Source/core/dom/RangeBoundaryPoint.h

Issue 178613003: Make Document::nodeChildrenWillBeRemoved() take a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use PassRefPtr Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Range.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 Node* container() const; 42 Node* container() const;
43 int offset() const; 43 int offset() const;
44 Node* childBefore() const; 44 Node* childBefore() const;
45 45
46 void clear(); 46 void clear();
47 47
48 void set(PassRefPtr<Node> container, int offset, Node* childBefore); 48 void set(PassRefPtr<Node> container, int offset, Node* childBefore);
49 void setOffset(int offset); 49 void setOffset(int offset);
50 50
51 void setToBeforeChild(Node&); 51 void setToBeforeChild(Node&);
52 void setToStartOfNode(PassRefPtr<Node>); 52 void setToStartOfNode(Node&);
53 void setToEndOfNode(PassRefPtr<Node>); 53 void setToEndOfNode(Node&);
54 54
55 void childBeforeWillBeRemoved(); 55 void childBeforeWillBeRemoved();
56 void invalidateOffset() const; 56 void invalidateOffset() const;
57 void ensureOffsetIsValid() const; 57 void ensureOffsetIsValid() const;
58 58
59 private: 59 private:
60 static const int invalidOffset = -1; 60 static const int invalidOffset = -1;
61 61
62 RefPtr<Node> m_containerNode; 62 RefPtr<Node> m_containerNode;
63 mutable int m_offsetInContainer; 63 mutable int m_offsetInContainer;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 138
139 inline void RangeBoundaryPoint::setToBeforeChild(Node& child) 139 inline void RangeBoundaryPoint::setToBeforeChild(Node& child)
140 { 140 {
141 ASSERT(child.parentNode()); 141 ASSERT(child.parentNode());
142 m_childBeforeBoundary = child.previousSibling(); 142 m_childBeforeBoundary = child.previousSibling();
143 m_containerNode = child.parentNode(); 143 m_containerNode = child.parentNode();
144 m_offsetInContainer = m_childBeforeBoundary ? invalidOffset : 0; 144 m_offsetInContainer = m_childBeforeBoundary ? invalidOffset : 0;
145 } 145 }
146 146
147 inline void RangeBoundaryPoint::setToStartOfNode(PassRefPtr<Node> container) 147 inline void RangeBoundaryPoint::setToStartOfNode(Node& container)
148 { 148 {
149 ASSERT(container); 149 m_containerNode = PassRefPtr<Node>(container);
150 m_containerNode = container;
151 m_offsetInContainer = 0; 150 m_offsetInContainer = 0;
152 m_childBeforeBoundary = nullptr; 151 m_childBeforeBoundary = nullptr;
153 } 152 }
154 153
155 inline void RangeBoundaryPoint::setToEndOfNode(PassRefPtr<Node> container) 154 inline void RangeBoundaryPoint::setToEndOfNode(Node& container)
156 { 155 {
157 ASSERT(container); 156 m_containerNode = PassRefPtr<Node>(container);
158 m_containerNode = container;
159 if (m_containerNode->offsetInCharacters()) { 157 if (m_containerNode->offsetInCharacters()) {
160 m_offsetInContainer = m_containerNode->maxCharacterOffset(); 158 m_offsetInContainer = m_containerNode->maxCharacterOffset();
161 m_childBeforeBoundary = nullptr; 159 m_childBeforeBoundary = nullptr;
162 } else { 160 } else {
163 m_childBeforeBoundary = m_containerNode->lastChild(); 161 m_childBeforeBoundary = m_containerNode->lastChild();
164 m_offsetInContainer = m_childBeforeBoundary ? invalidOffset : 0; 162 m_offsetInContainer = m_childBeforeBoundary ? invalidOffset : 0;
165 } 163 }
166 } 164 }
167 165
168 inline void RangeBoundaryPoint::childBeforeWillBeRemoved() 166 inline void RangeBoundaryPoint::childBeforeWillBeRemoved()
(...skipping 21 matching lines...) Expand all
190 } else { 188 } else {
191 if (a.offset() != b.offset()) 189 if (a.offset() != b.offset())
192 return false; 190 return false;
193 } 191 }
194 return true; 192 return true;
195 } 193 }
196 194
197 } 195 }
198 196
199 #endif 197 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Range.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698