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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 // The return value of |FrameSelection::modify()| is different based on | 370 // The return value of |FrameSelection::modify()| is different based on |
371 // value of |userTriggered| parameter. | 371 // value of |userTriggered| parameter. |
372 // When |userTriggered| is |userTriggered|, |modify()| returns false if | 372 // When |userTriggered| is |userTriggered|, |modify()| returns false if |
373 // "selectstart" event is dispatched and canceled, otherwise returns true. | 373 // "selectstart" event is dispatched and canceled, otherwise returns true. |
374 // When |userTriggered| is |NotUserTrigged|, return value specifies whether | 374 // When |userTriggered| is |NotUserTrigged|, return value specifies whether |
375 // selection is modified or not. | 375 // selection is modified or not. |
376 bool FrameSelection::Modify(EAlteration alter, | 376 bool FrameSelection::Modify(EAlteration alter, |
377 SelectionDirection direction, | 377 SelectionDirection direction, |
378 TextGranularity granularity, | 378 TextGranularity granularity, |
379 EUserTriggered user_triggered) { | 379 EUserTriggered user_triggered) { |
380 SelectionModifier selection_modifier( | 380 SelectionModifier selection_modifier(*GetFrame(), |
381 *GetFrame(), ComputeVisibleSelectionInDOMTreeDeprecated(), | 381 ComputeVisibleSelectionInDOMTree(), |
382 x_pos_for_vertical_arrow_navigation_); | 382 x_pos_for_vertical_arrow_navigation_); |
383 const bool modified = | 383 const bool modified = |
384 selection_modifier.Modify(alter, direction, granularity); | 384 selection_modifier.Modify(alter, direction, granularity); |
385 if (user_triggered == kUserTriggered && | 385 if (user_triggered == kUserTriggered && |
386 selection_modifier.Selection().IsRange() && | 386 selection_modifier.Selection().IsRange() && |
387 ComputeVisibleSelectionInDOMTreeDeprecated().IsCaret() && | 387 ComputeVisibleSelectionInDOMTree().IsCaret() && |
388 DispatchSelectStart(ComputeVisibleSelectionInDOMTreeDeprecated()) != | 388 DispatchSelectStart(ComputeVisibleSelectionInDOMTree()) != |
389 DispatchEventResult::kNotCanceled) { | 389 DispatchEventResult::kNotCanceled) { |
390 return false; | 390 return false; |
391 } | 391 } |
392 if (!modified) { | 392 if (!modified) { |
393 if (user_triggered == kNotUserTriggered) | 393 if (user_triggered == kNotUserTriggered) |
394 return false; | 394 return false; |
395 // If spatial navigation enabled, focus navigator will move focus to | 395 // If spatial navigation enabled, focus navigator will move focus to |
396 // another element. See snav-input.html and snav-textarea.html | 396 // another element. See snav-input.html and snav-textarea.html |
397 if (IsSpatialNavigationEnabled(frame_)) | 397 if (IsSpatialNavigationEnabled(frame_)) |
398 return false; | 398 return false; |
(...skipping 14 matching lines...) Expand all Loading... |
413 granularity_ = kCharacterGranularity; | 413 granularity_ = kCharacterGranularity; |
414 | 414 |
415 ScheduleVisualUpdateForPaintInvalidationIfNeeded(); | 415 ScheduleVisualUpdateForPaintInvalidationIfNeeded(); |
416 | 416 |
417 return true; | 417 return true; |
418 } | 418 } |
419 | 419 |
420 bool FrameSelection::Modify(EAlteration alter, | 420 bool FrameSelection::Modify(EAlteration alter, |
421 unsigned vertical_distance, | 421 unsigned vertical_distance, |
422 VerticalDirection direction) { | 422 VerticalDirection direction) { |
423 SelectionModifier selection_modifier( | 423 SelectionModifier selection_modifier(*GetFrame(), |
424 *GetFrame(), ComputeVisibleSelectionInDOMTreeDeprecated()); | 424 ComputeVisibleSelectionInDOMTree()); |
425 if (!selection_modifier.ModifyWithPageGranularity(alter, vertical_distance, | 425 if (!selection_modifier.ModifyWithPageGranularity(alter, vertical_distance, |
426 direction)) { | 426 direction)) { |
427 return false; | 427 return false; |
428 } | 428 } |
429 | 429 |
430 SetSelection(selection_modifier.Selection().AsSelection(), | 430 SetSelection(selection_modifier.Selection().AsSelection(), |
431 kCloseTyping | kClearTypingStyle | kUserTriggered, | 431 kCloseTyping | kClearTypingStyle | kUserTriggered, |
432 alter == kAlterationMove ? CursorAlignOnScroll::kAlways | 432 alter == kAlterationMove ? CursorAlignOnScroll::kAlways |
433 : CursorAlignOnScroll::kIfNeeded); | 433 : CursorAlignOnScroll::kIfNeeded); |
434 | 434 |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 } | 1181 } |
1182 | 1182 |
1183 void showTree(const blink::FrameSelection* sel) { | 1183 void showTree(const blink::FrameSelection* sel) { |
1184 if (sel) | 1184 if (sel) |
1185 sel->ShowTreeForThis(); | 1185 sel->ShowTreeForThis(); |
1186 else | 1186 else |
1187 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; | 1187 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; |
1188 } | 1188 } |
1189 | 1189 |
1190 #endif | 1190 #endif |
OLD | NEW |