| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 return; | 235 return; |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 | 238 |
| 239 m_frameCaret->stopCaretBlinkTimer(); | 239 m_frameCaret->stopCaretBlinkTimer(); |
| 240 updateAppearance(); | 240 updateAppearance(); |
| 241 | 241 |
| 242 // Always clear the x position used for vertical arrow navigation. | 242 // Always clear the x position used for vertical arrow navigation. |
| 243 // It will be restored by the vertical arrow navigation code if necessary. | 243 // It will be restored by the vertical arrow navigation code if necessary. |
| 244 m_xPosForVerticalArrowNavigation = NoXPosForVerticalArrowNavigation(); | 244 m_xPosForVerticalArrowNavigation = NoXPosForVerticalArrowNavigation(); |
| 245 // TODO(yosin): Can we move this to at end of this function? | 245 |
| 246 // This may dispatch a synchronous focus-related events. | 246 if (!(options & DoNotSetFocus)) { |
| 247 selectFrameElementInParentIfFullySelected(); | 247 // TODO(yosin): Can we move this to at end of this function? This may |
| 248 if (!isAvailable() || document() != currentDocument) { | 248 // dispatch a synchronous focus-related events. |
| 249 // editing/selection/selectallchildren-crash.html and | 249 selectFrameElementInParentIfFullySelected(); |
| 250 // editing/selection/longpress-selection-in-iframe-removed-crash.html | 250 if (!isAvailable() || document() != currentDocument) { |
| 251 // reach here. | 251 // editing/selection/selectallchildren-crash.html and |
| 252 return; | 252 // editing/selection/longpress-selection-in-iframe-removed-crash.html |
| 253 // reach here. |
| 254 return; |
| 255 } |
| 253 } | 256 } |
| 254 EUserTriggered userTriggered = selectionOptionsToUserTriggered(options); | 257 EUserTriggered userTriggered = selectionOptionsToUserTriggered(options); |
| 255 notifyLayoutObjectOfSelectionChange(userTriggered); | 258 notifyLayoutObjectOfSelectionChange(userTriggered); |
| 256 if (userTriggered == UserTriggered) { | 259 if (userTriggered == UserTriggered) { |
| 257 ScrollAlignment alignment; | 260 ScrollAlignment alignment; |
| 258 | 261 |
| 259 if (m_frame->editor().behavior().shouldCenterAlignWhenSelectionIsRevealed()) | 262 if (m_frame->editor().behavior().shouldCenterAlignWhenSelectionIsRevealed()) |
| 260 alignment = (align == CursorAlignOnScroll::Always) | 263 alignment = (align == CursorAlignOnScroll::Always) |
| 261 ? ScrollAlignment::alignCenterAlways | 264 ? ScrollAlignment::alignCenterAlways |
| 262 : ScrollAlignment::alignCenterIfNeeded; | 265 : ScrollAlignment::alignCenterIfNeeded; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 364 |
| 362 // The return value of |FrameSelection::modify()| is different based on | 365 // The return value of |FrameSelection::modify()| is different based on |
| 363 // value of |userTriggered| parameter. | 366 // value of |userTriggered| parameter. |
| 364 // When |userTriggered| is |userTriggered|, |modify()| returns false if | 367 // When |userTriggered| is |userTriggered|, |modify()| returns false if |
| 365 // "selectstart" event is dispatched and canceled, otherwise returns true. | 368 // "selectstart" event is dispatched and canceled, otherwise returns true. |
| 366 // When |userTriggered| is |NotUserTrigged|, return value specifies whether | 369 // When |userTriggered| is |NotUserTrigged|, return value specifies whether |
| 367 // selection is modified or not. | 370 // selection is modified or not. |
| 368 bool FrameSelection::modify(EAlteration alter, | 371 bool FrameSelection::modify(EAlteration alter, |
| 369 SelectionDirection direction, | 372 SelectionDirection direction, |
| 370 TextGranularity granularity, | 373 TextGranularity granularity, |
| 371 EUserTriggered userTriggered) { | 374 EUserTriggered userTriggered, |
| 375 SetSelectionOptions noFocusFlag) { |
| 376 DCHECK(noFocusFlag == 0 || noFocusFlag == DoNotSetFocus); |
| 372 SelectionModifier selectionModifier( | 377 SelectionModifier selectionModifier( |
| 373 *frame(), computeVisibleSelectionInDOMTreeDeprecated(), | 378 *frame(), computeVisibleSelectionInDOMTreeDeprecated(), |
| 374 m_xPosForVerticalArrowNavigation); | 379 m_xPosForVerticalArrowNavigation); |
| 375 const bool modified = selectionModifier.modify(alter, direction, granularity); | 380 const bool modified = selectionModifier.modify(alter, direction, granularity); |
| 376 if (userTriggered == UserTriggered && | 381 if (userTriggered == UserTriggered && |
| 377 selectionModifier.selection().isRange() && | 382 selectionModifier.selection().isRange() && |
| 378 computeVisibleSelectionInDOMTreeDeprecated().isCaret() && | 383 computeVisibleSelectionInDOMTreeDeprecated().isCaret() && |
| 379 dispatchSelectStart(computeVisibleSelectionInDOMTreeDeprecated()) != | 384 dispatchSelectStart(computeVisibleSelectionInDOMTreeDeprecated()) != |
| 380 DispatchEventResult::NotCanceled) { | 385 DispatchEventResult::NotCanceled) { |
| 381 return false; | 386 return false; |
| 382 } | 387 } |
| 383 if (!modified) { | 388 if (!modified) { |
| 384 if (userTriggered == NotUserTriggered) | 389 if (userTriggered == NotUserTriggered) |
| 385 return false; | 390 return false; |
| 386 // If spatial navigation enabled, focus navigator will move focus to | 391 // If spatial navigation enabled, focus navigator will move focus to |
| 387 // another element. See snav-input.html and snav-textarea.html | 392 // another element. See snav-input.html and snav-textarea.html |
| 388 if (isSpatialNavigationEnabled(m_frame)) | 393 if (isSpatialNavigationEnabled(m_frame)) |
| 389 return false; | 394 return false; |
| 390 // Even if selection isn't changed, we prevent to default action, e.g. | 395 // Even if selection isn't changed, we prevent to default action, e.g. |
| 391 // scroll window when caret is at end of content editable. | 396 // scroll window when caret is at end of content editable. |
| 392 return true; | 397 return true; |
| 393 } | 398 } |
| 394 | 399 |
| 395 const SetSelectionOptions options = | 400 const SetSelectionOptions options = |
| 396 CloseTyping | ClearTypingStyle | userTriggered; | 401 CloseTyping | ClearTypingStyle | userTriggered | noFocusFlag; |
| 397 setSelection(selectionModifier.selection(), options); | 402 setSelection(selectionModifier.selection(), options); |
| 398 | 403 |
| 399 if (granularity == LineGranularity || granularity == ParagraphGranularity) | 404 if (granularity == LineGranularity || granularity == ParagraphGranularity) |
| 400 m_xPosForVerticalArrowNavigation = | 405 m_xPosForVerticalArrowNavigation = |
| 401 selectionModifier.xPosForVerticalArrowNavigation(); | 406 selectionModifier.xPosForVerticalArrowNavigation(); |
| 402 | 407 |
| 403 if (userTriggered == UserTriggered) | 408 if (userTriggered == UserTriggered) |
| 404 m_granularity = CharacterGranularity; | 409 m_granularity = CharacterGranularity; |
| 405 | 410 |
| 406 scheduleVisualUpdateForPaintInvalidationIfNeeded(); | 411 scheduleVisualUpdateForPaintInvalidationIfNeeded(); |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 } | 1180 } |
| 1176 | 1181 |
| 1177 void showTree(const blink::FrameSelection* sel) { | 1182 void showTree(const blink::FrameSelection* sel) { |
| 1178 if (sel) | 1183 if (sel) |
| 1179 sel->showTreeForThis(); | 1184 sel->showTreeForThis(); |
| 1180 else | 1185 else |
| 1181 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; | 1186 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; |
| 1182 } | 1187 } |
| 1183 | 1188 |
| 1184 #endif | 1189 #endif |
| OLD | NEW |