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

Side by Side Diff: third_party/WebKit/Source/core/editing/VisibleUnits.cpp

Issue 2126743002: Make previousPositionOf() to handle yet another no previous position case (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-07-06T16:42:17 Created 4 years, 5 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 | third_party/WebKit/Source/core/editing/VisibleUnitsTest.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, 2008, 2009 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
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 3214 matching lines...) Expand 10 before | Expand all | Expand 10 after
3225 3225
3226 // return null visible position if there is no previous visible position 3226 // return null visible position if there is no previous visible position
3227 if (pos.atStartOfTree()) 3227 if (pos.atStartOfTree())
3228 return VisiblePositionTemplate<Strategy>(); 3228 return VisiblePositionTemplate<Strategy>();
3229 3229
3230 // we should always be able to make the affinity |TextAffinity::Downstream|, 3230 // we should always be able to make the affinity |TextAffinity::Downstream|,
3231 // because going previous from an |TextAffinity::Upstream| position can 3231 // because going previous from an |TextAffinity::Upstream| position can
3232 // never yield another |TextAffinity::Upstream position| (unless line wrap 3232 // never yield another |TextAffinity::Upstream position| (unless line wrap
3233 // length is 0!). 3233 // length is 0!).
3234 const VisiblePositionTemplate<Strategy> prev = createVisiblePosition(pos); 3234 const VisiblePositionTemplate<Strategy> prev = createVisiblePosition(pos);
3235 DCHECK_NE(prev.deepEquivalent(), visiblePosition.deepEquivalent()); 3235 if (prev.deepEquivalent() == visiblePosition.deepEquivalent())
3236 return VisiblePositionTemplate<Strategy>();
3236 3237
3237 switch (rule) { 3238 switch (rule) {
3238 case CanCrossEditingBoundary: 3239 case CanCrossEditingBoundary:
3239 return prev; 3240 return prev;
3240 case CannotCrossEditingBoundary: 3241 case CannotCrossEditingBoundary:
3241 return honorEditingBoundaryAtOrBefore(prev, visiblePosition.deepEquivale nt()); 3242 return honorEditingBoundaryAtOrBefore(prev, visiblePosition.deepEquivale nt());
3242 case CanSkipOverEditingBoundary: 3243 case CanSkipOverEditingBoundary:
3243 return skipToStartOfEditingBoundary(prev, visiblePosition.deepEquivalent ()); 3244 return skipToStartOfEditingBoundary(prev, visiblePosition.deepEquivalent ());
3244 } 3245 }
3245 3246
3246 NOTREACHED(); 3247 NOTREACHED();
3247 return honorEditingBoundaryAtOrBefore(prev, visiblePosition.deepEquivalent() ); 3248 return honorEditingBoundaryAtOrBefore(prev, visiblePosition.deepEquivalent() );
3248 } 3249 }
3249 3250
3250 VisiblePosition previousPositionOf(const VisiblePosition& visiblePosition, Editi ngBoundaryCrossingRule rule) 3251 VisiblePosition previousPositionOf(const VisiblePosition& visiblePosition, Editi ngBoundaryCrossingRule rule)
3251 { 3252 {
3252 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); 3253 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule);
3253 } 3254 }
3254 3255
3255 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi siblePosition, EditingBoundaryCrossingRule rule) 3256 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi siblePosition, EditingBoundaryCrossingRule rule)
3256 { 3257 {
3257 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio n, rule); 3258 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio n, rule);
3258 } 3259 }
3259 3260
3260 } // namespace blink 3261 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698