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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // FIXME (9535): Canonicalizing to the leftmost candidate means that if | 98 // FIXME (9535): Canonicalizing to the leftmost candidate means that if |
99 // we're at a line wrap, we will ask layoutObjects to paint downstream | 99 // we're at a line wrap, we will ask layoutObjects to paint downstream |
100 // carets for other layoutObjects. To fix this, we need to either a) add | 100 // carets for other layoutObjects. To fix this, we need to either a) add |
101 // code to all paintCarets to pass the responsibility off to the appropriate | 101 // code to all paintCarets to pass the responsibility off to the appropriate |
102 // layoutObject for VisiblePosition's like these, or b) canonicalize to the | 102 // layoutObject for VisiblePosition's like these, or b) canonicalize to the |
103 // rightmost candidate unless the affinity is upstream. | 103 // rightmost candidate unless the affinity is upstream. |
104 if (position.isNull()) | 104 if (position.isNull()) |
105 return PositionType(); | 105 return PositionType(); |
106 | 106 |
107 DCHECK(position.document()); | 107 DCHECK(position.document()); |
108 position.document()->updateLayoutIgnorePendingStylesheets(); | 108 position.document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
109 | 109 |
110 Node* node = position.computeContainerNode(); | 110 Node* node = position.computeContainerNode(); |
111 | 111 |
112 PositionType candidate = mostBackwardCaretPosition(position); | 112 PositionType candidate = mostBackwardCaretPosition(position); |
113 if (isVisuallyEquivalentCandidate(candidate)) | 113 if (isVisuallyEquivalentCandidate(candidate)) |
114 return candidate; | 114 return candidate; |
115 candidate = mostForwardCaretPosition(position); | 115 candidate = mostForwardCaretPosition(position); |
116 if (isVisuallyEquivalentCandidate(candidate)) | 116 if (isVisuallyEquivalentCandidate(candidate)) |
117 return candidate; | 117 return candidate; |
118 | 118 |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 // context, but there is no further text. Force a search with what's | 812 // context, but there is no further text. Force a search with what's |
813 // available. | 813 // available. |
814 // TODO(xiaochengh): Do we still have to search the whole string? | 814 // TODO(xiaochengh): Do we still have to search the whole string? |
815 next = searchFunction(string.data(), string.size(), prefixLength, DontHa
veMoreContext, needMoreContext); | 815 next = searchFunction(string.data(), string.size(), prefixLength, DontHa
veMoreContext, needMoreContext); |
816 DCHECK(!needMoreContext); | 816 DCHECK(!needMoreContext); |
817 } | 817 } |
818 | 818 |
819 if (it.atEnd() && next == string.size()) { | 819 if (it.atEnd() && next == string.size()) { |
820 pos = it.startPositionInCurrentContainer(); | 820 pos = it.startPositionInCurrentContainer(); |
821 } else if (next != invalidOffset && next != prefixLength) { | 821 } else if (next != invalidOffset && next != prefixLength) { |
822 // TODO(dglazkov): The use of updateLayoutIgnorePendingStylesheets needs
to be audited. | 822 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStyleshee
ts needs to be audited. |
823 // see http://crbug.com/590369 for more details. | 823 // see http://crbug.com/590369 for more details. |
824 searchStart.document()->updateLayoutIgnorePendingStylesheets(); | 824 searchStart.document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
825 // Use the character iterator to translate the next value into a DOM | 825 // Use the character iterator to translate the next value into a DOM |
826 // position. | 826 // position. |
827 CharacterIteratorAlgorithm<Strategy> charIt(searchStart, searchEnd, Text
IteratorEmitsCharactersBetweenAllVisiblePositions); | 827 CharacterIteratorAlgorithm<Strategy> charIt(searchStart, searchEnd, Text
IteratorEmitsCharactersBetweenAllVisiblePositions); |
828 charIt.advance(next - prefixLength - 1); | 828 charIt.advance(next - prefixLength - 1); |
829 pos = charIt.endPosition(); | 829 pos = charIt.endPosition(); |
830 | 830 |
831 if (charIt.characterAt(0) == '\n') { | 831 if (charIt.characterAt(0) == '\n') { |
832 // TODO(yosin) workaround for collapsed range (where only start | 832 // TODO(yosin) workaround for collapsed range (where only start |
833 // position is correct) emitted for some emitted newlines | 833 // position is correct) emitted for some emitted newlines |
834 // (see rdar://5192593) | 834 // (see rdar://5192593) |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 } | 1292 } |
1293 | 1293 |
1294 VisiblePosition previousLinePosition(const VisiblePosition& visiblePosition, Lay
outUnit lineDirectionPoint, EditableType editableType) | 1294 VisiblePosition previousLinePosition(const VisiblePosition& visiblePosition, Lay
outUnit lineDirectionPoint, EditableType editableType) |
1295 { | 1295 { |
1296 Position p = visiblePosition.deepEquivalent(); | 1296 Position p = visiblePosition.deepEquivalent(); |
1297 Node* node = p.anchorNode(); | 1297 Node* node = p.anchorNode(); |
1298 | 1298 |
1299 if (!node) | 1299 if (!node) |
1300 return VisiblePosition(); | 1300 return VisiblePosition(); |
1301 | 1301 |
1302 node->document().updateLayoutIgnorePendingStylesheets(); | 1302 node->document().updateStyleAndLayoutIgnorePendingStylesheets(); |
1303 | 1303 |
1304 LayoutObject* layoutObject = node->layoutObject(); | 1304 LayoutObject* layoutObject = node->layoutObject(); |
1305 if (!layoutObject) | 1305 if (!layoutObject) |
1306 return VisiblePosition(); | 1306 return VisiblePosition(); |
1307 | 1307 |
1308 RootInlineBox* root = 0; | 1308 RootInlineBox* root = 0; |
1309 InlineBox* box = computeInlineBoxPosition(visiblePosition).inlineBox; | 1309 InlineBox* box = computeInlineBoxPosition(visiblePosition).inlineBox; |
1310 if (box) { | 1310 if (box) { |
1311 root = box->root().prevRootBox(); | 1311 root = box->root().prevRootBox(); |
1312 // We want to skip zero height boxes. | 1312 // We want to skip zero height boxes. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1345 } | 1345 } |
1346 | 1346 |
1347 VisiblePosition nextLinePosition(const VisiblePosition& visiblePosition, LayoutU
nit lineDirectionPoint, EditableType editableType) | 1347 VisiblePosition nextLinePosition(const VisiblePosition& visiblePosition, LayoutU
nit lineDirectionPoint, EditableType editableType) |
1348 { | 1348 { |
1349 Position p = visiblePosition.deepEquivalent(); | 1349 Position p = visiblePosition.deepEquivalent(); |
1350 Node* node = p.anchorNode(); | 1350 Node* node = p.anchorNode(); |
1351 | 1351 |
1352 if (!node) | 1352 if (!node) |
1353 return VisiblePosition(); | 1353 return VisiblePosition(); |
1354 | 1354 |
1355 node->document().updateLayoutIgnorePendingStylesheets(); | 1355 node->document().updateStyleAndLayoutIgnorePendingStylesheets(); |
1356 | 1356 |
1357 LayoutObject* layoutObject = node->layoutObject(); | 1357 LayoutObject* layoutObject = node->layoutObject(); |
1358 if (!layoutObject) | 1358 if (!layoutObject) |
1359 return VisiblePosition(); | 1359 return VisiblePosition(); |
1360 | 1360 |
1361 RootInlineBox* root = 0; | 1361 RootInlineBox* root = 0; |
1362 InlineBox* box = computeInlineBoxPosition(visiblePosition).inlineBox; | 1362 InlineBox* box = computeInlineBoxPosition(visiblePosition).inlineBox; |
1363 if (box) { | 1363 if (box) { |
1364 root = box->root().nextRootBox(); | 1364 root = box->root().nextRootBox(); |
1365 // We want to skip zero height boxes. | 1365 // We want to skip zero height boxes. |
(...skipping 1885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3251 { | 3251 { |
3252 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); | 3252 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); |
3253 } | 3253 } |
3254 | 3254 |
3255 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi
siblePosition, EditingBoundaryCrossingRule rule) | 3255 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi
siblePosition, EditingBoundaryCrossingRule rule) |
3256 { | 3256 { |
3257 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio
n, rule); | 3257 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio
n, rule); |
3258 } | 3258 } |
3259 | 3259 |
3260 } // namespace blink | 3260 } // namespace blink |
OLD | NEW |