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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // FIXME (9535): Canonicalizing to the leftmost candidate means that if | 95 // FIXME (9535): Canonicalizing to the leftmost candidate means that if |
96 // we're at a line wrap, we will ask layoutObjects to paint downstream | 96 // we're at a line wrap, we will ask layoutObjects to paint downstream |
97 // carets for other layoutObjects. To fix this, we need to either a) add | 97 // carets for other layoutObjects. To fix this, we need to either a) add |
98 // code to all paintCarets to pass the responsibility off to the appropriate | 98 // code to all paintCarets to pass the responsibility off to the appropriate |
99 // layoutObject for VisiblePosition's like these, or b) canonicalize to the | 99 // layoutObject for VisiblePosition's like these, or b) canonicalize to the |
100 // rightmost candidate unless the affinity is upstream. | 100 // rightmost candidate unless the affinity is upstream. |
101 if (position.isNull()) | 101 if (position.isNull()) |
102 return PositionType(); | 102 return PositionType(); |
103 | 103 |
104 DCHECK(position.document()); | 104 DCHECK(position.document()); |
105 position.document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 105 DCHECK(!position.document()->needsLayoutTreeUpdate()); |
106 | 106 |
107 Node* node = position.computeContainerNode(); | 107 Node* node = position.computeContainerNode(); |
108 | 108 |
109 PositionType candidate = mostBackwardCaretPosition(position); | 109 PositionType candidate = mostBackwardCaretPosition(position); |
110 if (isVisuallyEquivalentCandidate(candidate)) | 110 if (isVisuallyEquivalentCandidate(candidate)) |
111 return candidate; | 111 return candidate; |
112 candidate = mostForwardCaretPosition(position); | 112 candidate = mostForwardCaretPosition(position); |
113 if (isVisuallyEquivalentCandidate(candidate)) | 113 if (isVisuallyEquivalentCandidate(candidate)) |
114 return candidate; | 114 return candidate; |
115 | 115 |
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 VisiblePositionInFlatTree logicalEndOfLine(const VisiblePositionInFlatTree& curr
entPosition) | 1233 VisiblePositionInFlatTree logicalEndOfLine(const VisiblePositionInFlatTree& curr
entPosition) |
1234 { | 1234 { |
1235 return logicalEndOfLineAlgorithm<EditingInFlatTreeStrategy>(currentPosition)
; | 1235 return logicalEndOfLineAlgorithm<EditingInFlatTreeStrategy>(currentPosition)
; |
1236 } | 1236 } |
1237 | 1237 |
1238 template <typename Strategy> | 1238 template <typename Strategy> |
1239 bool inSameLineAlgorithm(const PositionWithAffinityTemplate<Strategy>& position1
, const PositionWithAffinityTemplate<Strategy>& position2) | 1239 bool inSameLineAlgorithm(const PositionWithAffinityTemplate<Strategy>& position1
, const PositionWithAffinityTemplate<Strategy>& position2) |
1240 { | 1240 { |
1241 if (position1.isNull() || position2.isNull()) | 1241 if (position1.isNull() || position2.isNull()) |
1242 return false; | 1242 return false; |
| 1243 DCHECK_EQ(position1.position().document(), position2.position().document()); |
| 1244 |
| 1245 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 1246 // needs to be audited. See http://crbug.com/590369 for more details. |
| 1247 position1.position().document()->updateStyleAndLayoutIgnorePendingStylesheet
s(); |
| 1248 |
1243 PositionWithAffinityTemplate<Strategy> startOfLine1 = startOfLine(position1)
; | 1249 PositionWithAffinityTemplate<Strategy> startOfLine1 = startOfLine(position1)
; |
1244 PositionWithAffinityTemplate<Strategy> startOfLine2 = startOfLine(position2)
; | 1250 PositionWithAffinityTemplate<Strategy> startOfLine2 = startOfLine(position2)
; |
1245 if (startOfLine1 == startOfLine2) | 1251 if (startOfLine1 == startOfLine2) |
1246 return true; | 1252 return true; |
1247 PositionTemplate<Strategy> canonicalized1 = canonicalPositionOf(startOfLine1
.position()); | 1253 PositionTemplate<Strategy> canonicalized1 = canonicalPositionOf(startOfLine1
.position()); |
1248 if (canonicalized1 == startOfLine2.position()) | 1254 if (canonicalized1 == startOfLine2.position()) |
1249 return true; | 1255 return true; |
1250 return canonicalized1 == canonicalPositionOf(startOfLine2.position()); | 1256 return canonicalized1 == canonicalPositionOf(startOfLine2.position()); |
1251 } | 1257 } |
1252 | 1258 |
(...skipping 2063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3316 { | 3322 { |
3317 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); | 3323 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); |
3318 } | 3324 } |
3319 | 3325 |
3320 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi
siblePosition, EditingBoundaryCrossingRule rule) | 3326 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi
siblePosition, EditingBoundaryCrossingRule rule) |
3321 { | 3327 { |
3322 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio
n, rule); | 3328 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio
n, rule); |
3323 } | 3329 } |
3324 | 3330 |
3325 } // namespace blink | 3331 } // namespace blink |
OLD | NEW |