OLD | NEW |
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 Loading... |
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 |
OLD | NEW |