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

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

Issue 189773005: Revert of Have Position deal with more references (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | « no previous file | Source/core/dom/Position.cpp » ('j') | 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) 2004, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 bool isOrphan() const { return m_anchorNode && !m_anchorNode->inDocument(); } 145 bool isOrphan() const { return m_anchorNode && !m_anchorNode->inDocument(); }
146 146
147 Element* element() const; 147 Element* element() const;
148 PassRefPtr<CSSComputedStyleDeclaration> computedStyle() const; 148 PassRefPtr<CSSComputedStyleDeclaration> computedStyle() const;
149 149
150 // Move up or down the DOM by one position. 150 // Move up or down the DOM by one position.
151 // Offsets are computed using render text for nodes that have renderers - bu t note that even when 151 // Offsets are computed using render text for nodes that have renderers - bu t note that even when
152 // using composed characters, the result may be inside a single user-visible character if a ligature is formed. 152 // using composed characters, the result may be inside a single user-visible character if a ligature is formed.
153 Position previous(PositionMoveType = CodePoint) const; 153 Position previous(PositionMoveType = CodePoint) const;
154 Position next(PositionMoveType = CodePoint) const; 154 Position next(PositionMoveType = CodePoint) const;
155 static int uncheckedPreviousOffset(const Node&, int current); 155 static int uncheckedPreviousOffset(const Node*, int current);
156 static int uncheckedPreviousOffsetForBackwardDeletion(const Node&, int curre nt); 156 static int uncheckedPreviousOffsetForBackwardDeletion(const Node*, int curre nt);
157 static int uncheckedNextOffset(const Node&, int current); 157 static int uncheckedNextOffset(const Node*, int current);
158 158
159 // These can be either inside or just before/after the node, depending on 159 // These can be either inside or just before/after the node, depending on
160 // if the node is ignored by editing or not. 160 // if the node is ignored by editing or not.
161 // FIXME: These should go away. They only make sense for legacy positions. 161 // FIXME: These should go away. They only make sense for legacy positions.
162 bool atFirstEditingPositionForNode() const; 162 bool atFirstEditingPositionForNode() const;
163 bool atLastEditingPositionForNode() const; 163 bool atLastEditingPositionForNode() const;
164 164
165 // Returns true if the visually equivalent positions around have different e ditability 165 // Returns true if the visually equivalent positions around have different e ditability
166 bool atEditingBoundary() const; 166 bool atEditingBoundary() const;
167 Node* parentEditingBoundary() const; 167 Node* parentEditingBoundary() const;
(...skipping 18 matching lines...) Expand all
186 void getInlineBoxAndOffset(EAffinity, InlineBox*&, int& caretOffset) const; 186 void getInlineBoxAndOffset(EAffinity, InlineBox*&, int& caretOffset) const;
187 void getInlineBoxAndOffset(EAffinity, TextDirection primaryDirection, Inline Box*&, int& caretOffset) const; 187 void getInlineBoxAndOffset(EAffinity, TextDirection primaryDirection, Inline Box*&, int& caretOffset) const;
188 188
189 TextDirection primaryDirection() const; 189 TextDirection primaryDirection() const;
190 190
191 static bool hasRenderedNonAnonymousDescendantsWithHeight(RenderObject*); 191 static bool hasRenderedNonAnonymousDescendantsWithHeight(RenderObject*);
192 static bool nodeIsUserSelectNone(Node*); 192 static bool nodeIsUserSelectNone(Node*);
193 static bool nodeIsUserSelectAll(const Node*); 193 static bool nodeIsUserSelectAll(const Node*);
194 static Node* rootUserSelectAllForNode(Node*); 194 static Node* rootUserSelectAllForNode(Node*);
195 195
196 static ContainerNode* findParent(const Node*);
197
196 void debugPosition(const char* msg = "") const; 198 void debugPosition(const char* msg = "") const;
197 199
198 #ifndef NDEBUG 200 #ifndef NDEBUG
199 void formatForDebugger(char* buffer, unsigned length) const; 201 void formatForDebugger(char* buffer, unsigned length) const;
200 void showAnchorTypeAndOffset() const; 202 void showAnchorTypeAndOffset() const;
201 void showTreeForThis() const; 203 void showTreeForThis() const;
202 #endif 204 #endif
203 205
204 private: 206 private:
205 int offsetForPositionAfterAnchor() const; 207 int offsetForPositionAfterAnchor() const;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 return Position(node.parentNode(), node.nodeIndex(), Position::PositionIsOff setInAnchor); 253 return Position(node.parentNode(), node.nodeIndex(), Position::PositionIsOff setInAnchor);
252 } 254 }
253 255
254 inline Position positionInParentAfterNode(const Node& node) 256 inline Position positionInParentAfterNode(const Node& node)
255 { 257 {
256 ASSERT(node.parentNode()); 258 ASSERT(node.parentNode());
257 return Position(node.parentNode(), node.nodeIndex() + 1, Position::PositionI sOffsetInAnchor); 259 return Position(node.parentNode(), node.nodeIndex() + 1, Position::PositionI sOffsetInAnchor);
258 } 260 }
259 261
260 // positionBeforeNode and positionAfterNode return neighbor-anchored positions, construction is O(1) 262 // positionBeforeNode and positionAfterNode return neighbor-anchored positions, construction is O(1)
261 inline Position positionBeforeNode(Node& anchorNode) 263 inline Position positionBeforeNode(Node* anchorNode)
262 { 264 {
263 return Position(PassRefPtr<Node>(anchorNode), Position::PositionIsBeforeAnch or); 265 ASSERT(anchorNode);
266 return Position(anchorNode, Position::PositionIsBeforeAnchor);
264 } 267 }
265 268
266 inline Position positionAfterNode(Node& anchorNode) 269 inline Position positionAfterNode(Node* anchorNode)
267 { 270 {
268 return Position(PassRefPtr<Node>(anchorNode), Position::PositionIsAfterAncho r); 271 ASSERT(anchorNode);
272 return Position(anchorNode, Position::PositionIsAfterAnchor);
269 } 273 }
270 274
271 inline int lastOffsetInNode(Node& node) 275 inline int lastOffsetInNode(Node* node)
272 { 276 {
273 return node.offsetInCharacters() ? node.maxCharacterOffset() : static_cast<i nt>(node.countChildren()); 277 return node->offsetInCharacters() ? node->maxCharacterOffset() : static_cast <int>(node->countChildren());
274 } 278 }
275 279
276 // firstPositionInNode and lastPositionInNode return parent-anchored positions, lastPositionInNode construction is O(n) due to countChildren() 280 // firstPositionInNode and lastPositionInNode return parent-anchored positions, lastPositionInNode construction is O(n) due to countChildren()
277 inline Position firstPositionInNode(Node* anchorNode) 281 inline Position firstPositionInNode(Node* anchorNode)
278 { 282 {
279 if (anchorNode->isTextNode()) 283 if (anchorNode->isTextNode())
280 return Position(anchorNode, 0, Position::PositionIsOffsetInAnchor); 284 return Position(anchorNode, 0, Position::PositionIsOffsetInAnchor);
281 return Position(anchorNode, Position::PositionIsBeforeChildren); 285 return Position(anchorNode, Position::PositionIsBeforeChildren);
282 } 286 }
283 287
284 inline Position lastPositionInNode(Node* anchorNode) 288 inline Position lastPositionInNode(Node* anchorNode)
285 { 289 {
286 if (anchorNode->isTextNode()) 290 if (anchorNode->isTextNode())
287 return Position(anchorNode, lastOffsetInNode(*anchorNode), Position::Pos itionIsOffsetInAnchor); 291 return Position(anchorNode, lastOffsetInNode(anchorNode), Position::Posi tionIsOffsetInAnchor);
288 return Position(anchorNode, Position::PositionIsAfterChildren); 292 return Position(anchorNode, Position::PositionIsAfterChildren);
289 } 293 }
290 294
291 inline int minOffsetForNode(Node* anchorNode, int offset) 295 inline int minOffsetForNode(Node* anchorNode, int offset)
292 { 296 {
293 if (anchorNode->offsetInCharacters()) 297 if (anchorNode->offsetInCharacters())
294 return std::min(offset, anchorNode->maxCharacterOffset()); 298 return std::min(offset, anchorNode->maxCharacterOffset());
295 299
296 int newOffset = 0; 300 int newOffset = 0;
297 for (Node* node = anchorNode->firstChild(); node && newOffset < offset; node = node->nextSibling()) 301 for (Node* node = anchorNode->firstChild(); node && newOffset < offset; node = node->nextSibling())
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 340
337 } // namespace WebCore 341 } // namespace WebCore
338 342
339 #ifndef NDEBUG 343 #ifndef NDEBUG
340 // Outside the WebCore namespace for ease of invocation from gdb. 344 // Outside the WebCore namespace for ease of invocation from gdb.
341 void showTree(const WebCore::Position&); 345 void showTree(const WebCore::Position&);
342 void showTree(const WebCore::Position*); 346 void showTree(const WebCore::Position*);
343 #endif 347 #endif
344 348
345 #endif // Position_h 349 #endif // Position_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/Position.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698