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

Side by Side Diff: Source/core/editing/htmlediting.cpp

Issue 23890025: WIP (Introduce WTF::NonNullPtr<T>.) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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/editing/VisibleSelection.cpp ('k') | Source/core/html/FormAssociatedElement.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, 2005, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 261 }
262 262
263 VisiblePosition firstEditablePositionAfterPositionInRoot(const Position& positio n, Node* highestRoot) 263 VisiblePosition firstEditablePositionAfterPositionInRoot(const Position& positio n, Node* highestRoot)
264 { 264 {
265 // position falls before highestRoot. 265 // position falls before highestRoot.
266 if (comparePositions(position, firstPositionInNode(highestRoot)) == -1 && hi ghestRoot->rendererIsEditable()) 266 if (comparePositions(position, firstPositionInNode(highestRoot)) == -1 && hi ghestRoot->rendererIsEditable())
267 return firstPositionInNode(highestRoot); 267 return firstPositionInNode(highestRoot);
268 268
269 Position p = position; 269 Position p = position;
270 270
271 if (&position.deprecatedNode()->treeScope() != &highestRoot->treeScope()) { 271 if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) {
272 Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(p.de precatedNode()); 272 Node* shadowAncestor = highestRoot->treeScope()->ancestorInThisScope(p.d eprecatedNode());
273 if (!shadowAncestor) 273 if (!shadowAncestor)
274 return VisiblePosition(); 274 return VisiblePosition();
275 275
276 p = positionAfterNode(shadowAncestor); 276 p = positionAfterNode(shadowAncestor);
277 } 277 }
278 278
279 while (p.deprecatedNode() && !isEditablePosition(p) && p.deprecatedNode()->i sDescendantOf(highestRoot)) 279 while (p.deprecatedNode() && !isEditablePosition(p) && p.deprecatedNode()->i sDescendantOf(highestRoot))
280 p = isAtomicNode(p.deprecatedNode()) ? positionInParentAfterNode(p.depre catedNode()) : nextVisuallyDistinctCandidate(p); 280 p = isAtomicNode(p.deprecatedNode()) ? positionInParentAfterNode(p.depre catedNode()) : nextVisuallyDistinctCandidate(p);
281 281
282 if (p.deprecatedNode() && p.deprecatedNode() != highestRoot && !p.deprecated Node()->isDescendantOf(highestRoot)) 282 if (p.deprecatedNode() && p.deprecatedNode() != highestRoot && !p.deprecated Node()->isDescendantOf(highestRoot))
283 return VisiblePosition(); 283 return VisiblePosition();
284 284
285 return VisiblePosition(p); 285 return VisiblePosition(p);
286 } 286 }
287 287
288 VisiblePosition lastEditablePositionBeforePositionInRoot(const Position& positio n, Node* highestRoot) 288 VisiblePosition lastEditablePositionBeforePositionInRoot(const Position& positio n, Node* highestRoot)
289 { 289 {
290 // When position falls after highestRoot, the result is easy to compute. 290 // When position falls after highestRoot, the result is easy to compute.
291 if (comparePositions(position, lastPositionInNode(highestRoot)) == 1) 291 if (comparePositions(position, lastPositionInNode(highestRoot)) == 1)
292 return lastPositionInNode(highestRoot); 292 return lastPositionInNode(highestRoot);
293 293
294 Position p = position; 294 Position p = position;
295 295
296 if (&position.deprecatedNode()->treeScope() != &highestRoot->treeScope()) { 296 if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) {
297 Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(p.de precatedNode()); 297 Node* shadowAncestor = highestRoot->treeScope()->ancestorInThisScope(p.d eprecatedNode());
298 if (!shadowAncestor) 298 if (!shadowAncestor)
299 return VisiblePosition(); 299 return VisiblePosition();
300 300
301 p = firstPositionInOrBeforeNode(shadowAncestor); 301 p = firstPositionInOrBeforeNode(shadowAncestor);
302 } 302 }
303 303
304 while (p.deprecatedNode() && !isEditablePosition(p) && p.deprecatedNode()->i sDescendantOf(highestRoot)) 304 while (p.deprecatedNode() && !isEditablePosition(p) && p.deprecatedNode()->i sDescendantOf(highestRoot))
305 p = isAtomicNode(p.deprecatedNode()) ? positionInParentBeforeNode(p.depr ecatedNode()) : previousVisuallyDistinctCandidate(p); 305 p = isAtomicNode(p.deprecatedNode()) ? positionInParentBeforeNode(p.depr ecatedNode()) : previousVisuallyDistinctCandidate(p);
306 306
307 if (p.deprecatedNode() && p.deprecatedNode() != highestRoot && !p.deprecated Node()->isDescendantOf(highestRoot)) 307 if (p.deprecatedNode() && p.deprecatedNode() != highestRoot && !p.deprecated Node()->isDescendantOf(highestRoot))
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 // if the selection starts just before a paragraph break, skip over it 1155 // if the selection starts just before a paragraph break, skip over it
1156 if (isEndOfParagraph(visiblePosition)) 1156 if (isEndOfParagraph(visiblePosition))
1157 return visiblePosition.next().deepEquivalent().downstream(); 1157 return visiblePosition.next().deepEquivalent().downstream();
1158 1158
1159 // otherwise, make sure to be at the start of the first selected node, 1159 // otherwise, make sure to be at the start of the first selected node,
1160 // instead of possibly at the end of the last node before the selection 1160 // instead of possibly at the end of the last node before the selection
1161 return visiblePosition.deepEquivalent().downstream(); 1161 return visiblePosition.deepEquivalent().downstream();
1162 } 1162 }
1163 1163
1164 } // namespace WebCore 1164 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/editing/VisibleSelection.cpp ('k') | Source/core/html/FormAssociatedElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698