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

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

Issue 1305963003: Introduce {next,previous}PositionOf() as replacement of {next,previous}() member functions in Positi (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-22T00:12:04 Rebase Created 5 years, 4 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
« no previous file with comments | « no previous file | Source/core/editing/Editor.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 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 if (position.isNull()) 1148 if (position.isNull())
1149 return Position(); 1149 return Position();
1150 1150
1151 Element* fromRootEditableElement = position.anchorNode()->rootEditableElemen t(); 1151 Element* fromRootEditableElement = position.anchorNode()->rootEditableElemen t();
1152 1152
1153 bool atStartOfLine = isStartOfLine(VisiblePosition(position, affinity)); 1153 bool atStartOfLine = isStartOfLine(VisiblePosition(position, affinity));
1154 bool rendered = isVisuallyEquivalentCandidate(position); 1154 bool rendered = isVisuallyEquivalentCandidate(position);
1155 1155
1156 Position currentPos = position; 1156 Position currentPos = position;
1157 while (!currentPos.atStartOfTree()) { 1157 while (!currentPos.atStartOfTree()) {
1158 currentPos = currentPos.previous(); 1158 // TODO(yosin) When we use |previousCharacterPosition()| other than
1159 // finding leading whitespace, we should use |Character| instead of
1160 // |CodePoint|.
1161 currentPos = previousPositionOf(currentPos, PositionMoveType::CodePoint) ;
1159 1162
1160 if (currentPos.anchorNode()->rootEditableElement() != fromRootEditableEl ement) 1163 if (currentPos.anchorNode()->rootEditableElement() != fromRootEditableEl ement)
1161 return position; 1164 return position;
1162 1165
1163 if (atStartOfLine || !rendered) { 1166 if (atStartOfLine || !rendered) {
1164 if (isVisuallyEquivalentCandidate(currentPos)) 1167 if (isVisuallyEquivalentCandidate(currentPos))
1165 return currentPos; 1168 return currentPos;
1166 } else if (rendersInDifferentPosition(position, currentPos)) { 1169 } else if (rendersInDifferentPosition(position, currentPos)) {
1167 return currentPos; 1170 return currentPos;
1168 } 1171 }
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 // if the selection starts just before a paragraph break, skip over it 1448 // if the selection starts just before a paragraph break, skip over it
1446 if (isEndOfParagraph(visiblePosition)) 1449 if (isEndOfParagraph(visiblePosition))
1447 return visiblePosition.next().deepEquivalent().downstream(); 1450 return visiblePosition.next().deepEquivalent().downstream();
1448 1451
1449 // otherwise, make sure to be at the start of the first selected node, 1452 // otherwise, make sure to be at the start of the first selected node,
1450 // instead of possibly at the end of the last node before the selection 1453 // instead of possibly at the end of the last node before the selection
1451 return visiblePosition.deepEquivalent().downstream(); 1454 return visiblePosition.deepEquivalent().downstream();
1452 } 1455 }
1453 1456
1454 } // namespace blink 1457 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/core/editing/Editor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698