OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008, 2009, 2010 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 169 } |
170 | 170 |
171 const VisibleSelectionInFlatTree& FrameSelection::selectionInFlatTree() const | 171 const VisibleSelectionInFlatTree& FrameSelection::selectionInFlatTree() const |
172 { | 172 { |
173 return visibleSelection<EditingInFlatTreeStrategy>(); | 173 return visibleSelection<EditingInFlatTreeStrategy>(); |
174 } | 174 } |
175 | 175 |
176 void FrameSelection::moveTo(const VisiblePosition &pos, EUserTriggered userTrigg
ered, CursorAlignOnScroll align) | 176 void FrameSelection::moveTo(const VisiblePosition &pos, EUserTriggered userTrigg
ered, CursorAlignOnScroll align) |
177 { | 177 { |
178 SetSelectionOptions options = CloseTyping | ClearTypingStyle | userTriggered
; | 178 SetSelectionOptions options = CloseTyping | ClearTypingStyle | userTriggered
; |
179 setSelection(VisibleSelection(pos, pos, selection().isDirectional()), option
s, align); | 179 bool isHandleVisible = userTriggered == UserTriggered; |
| 180 setSelection(VisibleSelection(pos, pos, selection().isDirectional(), isHandl
eVisible), options, align); |
180 } | 181 } |
181 | 182 |
182 void FrameSelection::moveTo(const VisiblePosition &base, const VisiblePosition &
extent, EUserTriggered userTriggered) | 183 void FrameSelection::moveTo(const VisiblePosition &base, const VisiblePosition &
extent, EUserTriggered userTriggered) |
183 { | 184 { |
184 const bool selectionHasDirection = true; | 185 const bool selectionHasDirection = true; |
185 SetSelectionOptions options = CloseTyping | ClearTypingStyle | userTriggered
; | 186 SetSelectionOptions options = CloseTyping | ClearTypingStyle | userTriggered
; |
186 setSelection(VisibleSelection(base, extent, selectionHasDirection), options)
; | 187 setSelection(VisibleSelection(base, extent, selectionHasDirection), options)
; |
187 } | 188 } |
188 | 189 |
189 void FrameSelection::moveTo(const Position &pos, TextAffinity affinity) | 190 void FrameSelection::moveTo(const Position &pos, TextAffinity affinity) |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 } | 1263 } |
1263 | 1264 |
1264 bool FrameSelection::selectWordAroundPosition(const VisiblePosition& position) | 1265 bool FrameSelection::selectWordAroundPosition(const VisiblePosition& position) |
1265 { | 1266 { |
1266 static const EWordSide wordSideList[2] = { RightWordIfOnBoundary, LeftWordIf
OnBoundary }; | 1267 static const EWordSide wordSideList[2] = { RightWordIfOnBoundary, LeftWordIf
OnBoundary }; |
1267 for (EWordSide wordSide : wordSideList) { | 1268 for (EWordSide wordSide : wordSideList) { |
1268 VisiblePosition start = startOfWord(position, wordSide); | 1269 VisiblePosition start = startOfWord(position, wordSide); |
1269 VisiblePosition end = endOfWord(position, wordSide); | 1270 VisiblePosition end = endOfWord(position, wordSide); |
1270 String text = plainText(EphemeralRange(start.deepEquivalent(), end.deepE
quivalent())); | 1271 String text = plainText(EphemeralRange(start.deepEquivalent(), end.deepE
quivalent())); |
1271 if (!text.isEmpty() && !isSeparator(text.characterStartingAt(0))) { | 1272 if (!text.isEmpty() && !isSeparator(text.characterStartingAt(0))) { |
1272 setSelection(VisibleSelection(start, end), WordGranularity); | 1273 VisibleSelection newSelection(start, end); |
| 1274 newSelection.setIsHandleVisible(selection().isHandleVisible()); |
| 1275 setSelection(newSelection, WordGranularity); |
1273 return true; | 1276 return true; |
1274 } | 1277 } |
1275 } | 1278 } |
1276 | 1279 |
1277 return false; | 1280 return false; |
1278 } | 1281 } |
1279 | 1282 |
1280 GranularityStrategy* FrameSelection::granularityStrategy() | 1283 GranularityStrategy* FrameSelection::granularityStrategy() |
1281 { | 1284 { |
1282 // We do lazy initalization for m_granularityStrategy, because if we | 1285 // We do lazy initalization for m_granularityStrategy, because if we |
(...skipping 13 matching lines...) Expand all Loading... |
1296 m_granularityStrategy = wrapUnique(new CharacterGranularityStrategy()); | 1299 m_granularityStrategy = wrapUnique(new CharacterGranularityStrategy()); |
1297 return m_granularityStrategy.get(); | 1300 return m_granularityStrategy.get(); |
1298 } | 1301 } |
1299 | 1302 |
1300 void FrameSelection::moveRangeSelectionExtent(const IntPoint& contentsPoint) | 1303 void FrameSelection::moveRangeSelectionExtent(const IntPoint& contentsPoint) |
1301 { | 1304 { |
1302 if (isNone()) | 1305 if (isNone()) |
1303 return; | 1306 return; |
1304 | 1307 |
1305 VisibleSelection newSelection = granularityStrategy()->updateExtent(contents
Point, m_frame); | 1308 VisibleSelection newSelection = granularityStrategy()->updateExtent(contents
Point, m_frame); |
| 1309 newSelection.setIsHandleVisible(m_selectionEditor->visibleSelection<EditingS
trategy>().isHandleVisible()); |
1306 setSelection( | 1310 setSelection( |
1307 newSelection, | 1311 newSelection, |
1308 FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle | FrameSe
lection::DoNotClearStrategy | UserTriggered, | 1312 FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle | FrameSe
lection::DoNotClearStrategy | UserTriggered, |
1309 CursorAlignOnScroll::IfNeeded, | 1313 CursorAlignOnScroll::IfNeeded, |
1310 CharacterGranularity); | 1314 CharacterGranularity); |
1311 } | 1315 } |
1312 | 1316 |
1313 void FrameSelection::moveRangeSelection(const VisiblePosition& basePosition, con
st VisiblePosition& extentPosition, TextGranularity granularity) | 1317 void FrameSelection::moveRangeSelection(const VisiblePosition& basePosition, con
st VisiblePosition& extentPosition, TextGranularity granularity) |
1314 { | 1318 { |
1315 VisibleSelection newSelection(basePosition, extentPosition); | 1319 VisibleSelection newSelection(basePosition, extentPosition); |
| 1320 newSelection.setIsHandleVisible(m_selectionEditor->visibleSelection<EditingS
trategy>().isHandleVisible()); |
1316 newSelection.expandUsingGranularity(granularity); | 1321 newSelection.expandUsingGranularity(granularity); |
1317 | 1322 |
1318 if (newSelection.isNone()) | 1323 if (newSelection.isNone()) |
1319 return; | 1324 return; |
1320 | 1325 |
1321 setSelection(newSelection, granularity); | 1326 setSelection(newSelection, granularity); |
1322 } | 1327 } |
1323 | 1328 |
1324 void FrameSelection::updateIfNeeded() | 1329 void FrameSelection::updateIfNeeded() |
1325 { | 1330 { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 | 1377 |
1373 void showTree(const blink::FrameSelection* sel) | 1378 void showTree(const blink::FrameSelection* sel) |
1374 { | 1379 { |
1375 if (sel) | 1380 if (sel) |
1376 sel->showTreeForThis(); | 1381 sel->showTreeForThis(); |
1377 else | 1382 else |
1378 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); | 1383 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); |
1379 } | 1384 } |
1380 | 1385 |
1381 #endif | 1386 #endif |
OLD | NEW |