Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1705)

Side by Side Diff: ui/views/cocoa/bridged_content_view.mm

Issue 2027133002: Modify ui::TextInputClient to use ui::TextEditCommand enum in place of resource ids. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor4_up_down_mac
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ui/views/cocoa/bridged_content_view.h" 5 #import "ui/views/cocoa/bridged_content_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "base/mac/mac_util.h" 8 #import "base/mac/mac_util.h"
9 #import "base/mac/scoped_nsobject.h" 9 #import "base/mac/scoped_nsobject.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
11 #include "skia/ext/skia_utils_mac.h" 11 #include "skia/ext/skia_utils_mac.h"
12 #include "ui/base/cocoa/cocoa_base_utils.h" 12 #include "ui/base/cocoa/cocoa_base_utils.h"
13 #include "ui/base/dragdrop/drag_drop_types.h" 13 #include "ui/base/dragdrop/drag_drop_types.h"
14 #include "ui/base/dragdrop/os_exchange_data_provider_mac.h" 14 #include "ui/base/dragdrop/os_exchange_data_provider_mac.h"
15 #include "ui/base/ime/input_method.h" 15 #include "ui/base/ime/input_method.h"
16 #include "ui/base/ime/text_input_client.h" 16 #include "ui/base/ime/text_input_client.h"
17 #include "ui/compositor/canvas_painter.h" 17 #include "ui/compositor/canvas_painter.h"
18 #import "ui/events/cocoa/cocoa_event_utils.h" 18 #import "ui/events/cocoa/cocoa_event_utils.h"
19 #include "ui/events/keycodes/dom/dom_code.h" 19 #include "ui/events/keycodes/dom/dom_code.h"
20 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" 20 #import "ui/events/keycodes/keyboard_code_conversion_mac.h"
21 #include "ui/events/text_edit_commands.h"
21 #include "ui/gfx/canvas_paint_mac.h" 22 #include "ui/gfx/canvas_paint_mac.h"
22 #include "ui/gfx/geometry/rect.h" 23 #include "ui/gfx/geometry/rect.h"
23 #import "ui/gfx/mac/coordinate_conversion.h" 24 #import "ui/gfx/mac/coordinate_conversion.h"
24 #include "ui/gfx/path.h" 25 #include "ui/gfx/path.h"
25 #import "ui/gfx/path_mac.h" 26 #import "ui/gfx/path_mac.h"
26 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 27 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
27 #include "ui/strings/grit/ui_strings.h"
28 #import "ui/views/cocoa/bridged_native_widget.h" 28 #import "ui/views/cocoa/bridged_native_widget.h"
29 #import "ui/views/cocoa/drag_drop_client_mac.h" 29 #import "ui/views/cocoa/drag_drop_client_mac.h"
30 #include "ui/views/controls/menu/menu_config.h" 30 #include "ui/views/controls/menu/menu_config.h"
31 #include "ui/views/controls/menu/menu_controller.h" 31 #include "ui/views/controls/menu/menu_controller.h"
32 #include "ui/views/view.h" 32 #include "ui/views/view.h"
33 #include "ui/views/widget/native_widget_mac.h" 33 #include "ui/views/widget/native_widget_mac.h"
34 #include "ui/views/widget/widget.h" 34 #include "ui/views/widget/widget.h"
35 35
36 using views::MenuController; 36 using views::MenuController;
37 37
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 // TextInputClient, the keyCode that toolkit-views expects internally. 215 // TextInputClient, the keyCode that toolkit-views expects internally.
216 // For example, moveToLeftEndOfLine: would pass ui::VKEY_HOME in non-RTL locales 216 // For example, moveToLeftEndOfLine: would pass ui::VKEY_HOME in non-RTL locales
217 // even though the Home key on Mac defaults to moveToBeginningOfDocument:. 217 // even though the Home key on Mac defaults to moveToBeginningOfDocument:.
218 // This approach also allows action messages a user 218 // This approach also allows action messages a user
219 // may have remapped in ~/Library/KeyBindings/DefaultKeyBinding.dict to be 219 // may have remapped in ~/Library/KeyBindings/DefaultKeyBinding.dict to be
220 // catered for. 220 // catered for.
221 // Note: default key bindings in Mac can be read from StandardKeyBinding.dict 221 // Note: default key bindings in Mac can be read from StandardKeyBinding.dict
222 // which lives in /System/Library/Frameworks/AppKit.framework/Resources. Do 222 // which lives in /System/Library/Frameworks/AppKit.framework/Resources. Do
223 // `plutil -convert xml1 -o StandardKeyBinding.xml StandardKeyBinding.dict` to 223 // `plutil -convert xml1 -o StandardKeyBinding.xml StandardKeyBinding.dict` to
224 // get something readable. 224 // get something readable.
225 - (void)handleAction:(int)commandId 225 - (void)handleAction:(ui::TextEditCommand)command
226 keyCode:(ui::KeyboardCode)keyCode 226 keyCode:(ui::KeyboardCode)keyCode
227 domCode:(ui::DomCode)domCode 227 domCode:(ui::DomCode)domCode
228 eventFlags:(int)eventFlags; 228 eventFlags:(int)eventFlags;
229 229
230 // Notification handler invoked when the Full Keyboard Access mode is changed. 230 // Notification handler invoked when the Full Keyboard Access mode is changed.
231 - (void)onFullKeyboardAccessModeChanged:(NSNotification*)notification; 231 - (void)onFullKeyboardAccessModeChanged:(NSNotification*)notification;
232 232
233 // Returns the native Widget's drag drop client. Possibly null. 233 // Returns the native Widget's drag drop client. Possibly null.
234 - (views::DragDropClientMac*)dragDropClient; 234 - (views::DragDropClientMac*)dragDropClient;
235 235
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 return; 372 return;
373 373
374 DCHECK(theEvent); 374 DCHECK(theEvent);
375 ui::KeyEvent event(theEvent); 375 ui::KeyEvent event(theEvent);
376 if (DispatchEventToMenu(hostedView_->GetWidget(), event.key_code())) 376 if (DispatchEventToMenu(hostedView_->GetWidget(), event.key_code()))
377 return; 377 return;
378 378
379 hostedView_->GetWidget()->GetInputMethod()->DispatchKeyEvent(&event); 379 hostedView_->GetWidget()->GetInputMethod()->DispatchKeyEvent(&event);
380 } 380 }
381 381
382 - (void)handleAction:(int)commandId 382 - (void)handleAction:(ui::TextEditCommand)command
383 keyCode:(ui::KeyboardCode)keyCode 383 keyCode:(ui::KeyboardCode)keyCode
384 domCode:(ui::DomCode)domCode 384 domCode:(ui::DomCode)domCode
385 eventFlags:(int)eventFlags { 385 eventFlags:(int)eventFlags {
386 if (!hostedView_) 386 if (!hostedView_)
387 return; 387 return;
388 388
389 if (DispatchEventToMenu(hostedView_->GetWidget(), keyCode)) 389 if (DispatchEventToMenu(hostedView_->GetWidget(), keyCode))
390 return; 390 return;
391 391
392 // If there's an active TextInputClient, schedule the editing command to be 392 // If there's an active TextInputClient, schedule the editing command to be
393 // performed. 393 // performed.
394 if (commandId && textInputClient_ && 394 if (textInputClient_ && textInputClient_->IsEditCommandEnabled(command))
395 textInputClient_->IsEditCommandEnabled(commandId)) 395 textInputClient_->SetEditCommandForNextKeyEvent(command);
396 textInputClient_->SetEditCommandForNextKeyEvent(commandId);
397 396
398 // Generate a synthetic event with the keycode toolkit-views expects. 397 // Generate a synthetic event with the keycode toolkit-views expects.
399 ui::KeyEvent event(ui::ET_KEY_PRESSED, keyCode, domCode, eventFlags); 398 ui::KeyEvent event(ui::ET_KEY_PRESSED, keyCode, domCode, eventFlags);
400 hostedView_->GetWidget()->GetInputMethod()->DispatchKeyEvent(&event); 399 hostedView_->GetWidget()->GetInputMethod()->DispatchKeyEvent(&event);
401 } 400 }
402 401
403 - (void)onFullKeyboardAccessModeChanged:(NSNotification*)notification { 402 - (void)onFullKeyboardAccessModeChanged:(NSNotification*)notification {
404 DCHECK([[notification name] 403 DCHECK([[notification name]
405 isEqualToString:kFullKeyboardAccessChangedNotification]); 404 isEqualToString:kFullKeyboardAccessChangedNotification]);
406 [self updateFullKeyboardAccess]; 405 [self updateFullKeyboardAccess];
407 } 406 }
408 407
409 - (views::DragDropClientMac*)dragDropClient { 408 - (views::DragDropClientMac*)dragDropClient {
410 views::BridgedNativeWidget* bridge = 409 views::BridgedNativeWidget* bridge =
411 views::NativeWidgetMac::GetBridgeForNativeWindow([self window]); 410 views::NativeWidgetMac::GetBridgeForNativeWindow([self window]);
412 return bridge ? bridge->drag_drop_client() : nullptr; 411 return bridge ? bridge->drag_drop_client() : nullptr;
413 } 412 }
414 413
415 - (void)undo:(id)sender { 414 - (void)undo:(id)sender {
416 // This DCHECK is more strict than a similar check in handleAction:. It can be 415 // This DCHECK is more strict than a similar check in handleAction:. It can be
417 // done here because the actors sending these actions should be calling 416 // done here because the actors sending these actions should be calling
418 // validateUserInterfaceItem: before enabling UI that allows these messages to 417 // validateUserInterfaceItem: before enabling UI that allows these messages to
419 // be sent. Checking it here would be too late to provide correct UI feedback 418 // be sent. Checking it here would be too late to provide correct UI feedback
420 // (e.g. there will be no "beep"). 419 // (e.g. there will be no "beep").
421 DCHECK(textInputClient_->IsEditCommandEnabled(IDS_APP_UNDO)); 420 DCHECK(textInputClient_->IsEditCommandEnabled(ui::TextEditCommand::UNDO));
422 [self handleAction:IDS_APP_UNDO 421 [self handleAction:ui::TextEditCommand::UNDO
423 keyCode:ui::VKEY_Z 422 keyCode:ui::VKEY_Z
424 domCode:ui::DomCode::US_Z 423 domCode:ui::DomCode::US_Z
425 eventFlags:ui::EF_CONTROL_DOWN]; 424 eventFlags:ui::EF_CONTROL_DOWN];
426 } 425 }
427 426
428 - (void)redo:(id)sender { 427 - (void)redo:(id)sender {
429 DCHECK(textInputClient_->IsEditCommandEnabled(IDS_APP_REDO)); 428 DCHECK(textInputClient_->IsEditCommandEnabled(ui::TextEditCommand::REDO));
430 [self handleAction:IDS_APP_REDO 429 [self handleAction:ui::TextEditCommand::REDO
431 keyCode:ui::VKEY_Z 430 keyCode:ui::VKEY_Z
432 domCode:ui::DomCode::US_Z 431 domCode:ui::DomCode::US_Z
433 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN]; 432 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN];
434 } 433 }
435 434
436 - (void)cut:(id)sender { 435 - (void)cut:(id)sender {
437 DCHECK(textInputClient_->IsEditCommandEnabled(IDS_APP_CUT)); 436 DCHECK(textInputClient_->IsEditCommandEnabled(ui::TextEditCommand::CUT));
438 [self handleAction:IDS_APP_CUT 437 [self handleAction:ui::TextEditCommand::CUT
439 keyCode:ui::VKEY_X 438 keyCode:ui::VKEY_X
440 domCode:ui::DomCode::US_X 439 domCode:ui::DomCode::US_X
441 eventFlags:ui::EF_CONTROL_DOWN]; 440 eventFlags:ui::EF_CONTROL_DOWN];
442 } 441 }
443 442
444 - (void)copy:(id)sender { 443 - (void)copy:(id)sender {
445 DCHECK(textInputClient_->IsEditCommandEnabled(IDS_APP_COPY)); 444 DCHECK(textInputClient_->IsEditCommandEnabled(ui::TextEditCommand::COPY));
446 [self handleAction:IDS_APP_COPY 445 [self handleAction:ui::TextEditCommand::COPY
447 keyCode:ui::VKEY_C 446 keyCode:ui::VKEY_C
448 domCode:ui::DomCode::US_C 447 domCode:ui::DomCode::US_C
449 eventFlags:ui::EF_CONTROL_DOWN]; 448 eventFlags:ui::EF_CONTROL_DOWN];
450 } 449 }
451 450
452 - (void)paste:(id)sender { 451 - (void)paste:(id)sender {
453 DCHECK(textInputClient_->IsEditCommandEnabled(IDS_APP_PASTE)); 452 DCHECK(textInputClient_->IsEditCommandEnabled(ui::TextEditCommand::PASTE));
454 [self handleAction:IDS_APP_PASTE 453 [self handleAction:ui::TextEditCommand::PASTE
455 keyCode:ui::VKEY_V 454 keyCode:ui::VKEY_V
456 domCode:ui::DomCode::US_V 455 domCode:ui::DomCode::US_V
457 eventFlags:ui::EF_CONTROL_DOWN]; 456 eventFlags:ui::EF_CONTROL_DOWN];
458 } 457 }
459 458
460 - (void)selectAll:(id)sender { 459 - (void)selectAll:(id)sender {
461 DCHECK(textInputClient_->IsEditCommandEnabled(IDS_APP_SELECT_ALL)); 460 DCHECK(
462 [self handleAction:IDS_APP_SELECT_ALL 461 textInputClient_->IsEditCommandEnabled(ui::TextEditCommand::SELECT_ALL));
462 [self handleAction:ui::TextEditCommand::SELECT_ALL
463 keyCode:ui::VKEY_A 463 keyCode:ui::VKEY_A
464 domCode:ui::DomCode::US_A 464 domCode:ui::DomCode::US_A
465 eventFlags:ui::EF_CONTROL_DOWN]; 465 eventFlags:ui::EF_CONTROL_DOWN];
466 } 466 }
467 467
468 // BaseView implementation. 468 // BaseView implementation.
469 469
470 // Don't use tracking areas from BaseView. BridgedContentView's tracks 470 // Don't use tracking areas from BaseView. BridgedContentView's tracks
471 // NSTrackingCursorUpdate and Apple's documentation suggests it's incompatible. 471 // NSTrackingCursorUpdate and Apple's documentation suggests it's incompatible.
472 - (void)enableTracking { 472 - (void)enableTracking {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 } 680 }
681 681
682 // Selection movement and scrolling. 682 // Selection movement and scrolling.
683 683
684 - (void)moveForward:(id)sender { 684 - (void)moveForward:(id)sender {
685 IsTextRTL(textInputClient_) ? [self moveLeft:sender] 685 IsTextRTL(textInputClient_) ? [self moveLeft:sender]
686 : [self moveRight:sender]; 686 : [self moveRight:sender];
687 } 687 }
688 688
689 - (void)moveRight:(id)sender { 689 - (void)moveRight:(id)sender {
690 [self handleAction:IDS_MOVE_RIGHT 690 [self handleAction:ui::TextEditCommand::MOVE_RIGHT
691 keyCode:ui::VKEY_RIGHT 691 keyCode:ui::VKEY_RIGHT
692 domCode:ui::DomCode::ARROW_RIGHT 692 domCode:ui::DomCode::ARROW_RIGHT
693 eventFlags:0]; 693 eventFlags:0];
694 } 694 }
695 695
696 - (void)moveBackward:(id)sender { 696 - (void)moveBackward:(id)sender {
697 IsTextRTL(textInputClient_) ? [self moveRight:sender] 697 IsTextRTL(textInputClient_) ? [self moveRight:sender]
698 : [self moveLeft:sender]; 698 : [self moveLeft:sender];
699 } 699 }
700 700
701 - (void)moveLeft:(id)sender { 701 - (void)moveLeft:(id)sender {
702 [self handleAction:IDS_MOVE_LEFT 702 [self handleAction:ui::TextEditCommand::MOVE_LEFT
703 keyCode:ui::VKEY_LEFT 703 keyCode:ui::VKEY_LEFT
704 domCode:ui::DomCode::ARROW_LEFT 704 domCode:ui::DomCode::ARROW_LEFT
705 eventFlags:0]; 705 eventFlags:0];
706 } 706 }
707 707
708 - (void)moveUp:(id)sender { 708 - (void)moveUp:(id)sender {
709 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE 709 [self handleAction:ui::TextEditCommand::MOVE_TO_BEGINNING_OF_LINE
710 keyCode:ui::VKEY_UP 710 keyCode:ui::VKEY_UP
711 domCode:ui::DomCode::ARROW_UP 711 domCode:ui::DomCode::ARROW_UP
712 eventFlags:0]; 712 eventFlags:0];
713 } 713 }
714 714
715 - (void)moveDown:(id)sender { 715 - (void)moveDown:(id)sender {
716 [self handleAction:IDS_MOVE_TO_END_OF_LINE 716 [self handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE
717 keyCode:ui::VKEY_DOWN 717 keyCode:ui::VKEY_DOWN
718 domCode:ui::DomCode::ARROW_DOWN 718 domCode:ui::DomCode::ARROW_DOWN
719 eventFlags:0]; 719 eventFlags:0];
720 } 720 }
721 721
722 - (void)moveWordForward:(id)sender { 722 - (void)moveWordForward:(id)sender {
723 IsTextRTL(textInputClient_) ? [self moveWordLeft:sender] 723 IsTextRTL(textInputClient_) ? [self moveWordLeft:sender]
724 : [self moveWordRight:sender]; 724 : [self moveWordRight:sender];
725 } 725 }
726 726
727 - (void)moveWordBackward:(id)sender { 727 - (void)moveWordBackward:(id)sender {
728 IsTextRTL(textInputClient_) ? [self moveWordRight:sender] 728 IsTextRTL(textInputClient_) ? [self moveWordRight:sender]
729 : [self moveWordLeft:sender]; 729 : [self moveWordLeft:sender];
730 } 730 }
731 731
732 - (void)moveToBeginningOfLine:(id)sender { 732 - (void)moveToBeginningOfLine:(id)sender {
733 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE 733 [self handleAction:ui::TextEditCommand::MOVE_TO_BEGINNING_OF_LINE
734 keyCode:ui::VKEY_HOME 734 keyCode:ui::VKEY_HOME
735 domCode:ui::DomCode::HOME 735 domCode:ui::DomCode::HOME
736 eventFlags:0]; 736 eventFlags:0];
737 } 737 }
738 738
739 - (void)moveToEndOfLine:(id)sender { 739 - (void)moveToEndOfLine:(id)sender {
740 [self handleAction:IDS_MOVE_TO_END_OF_LINE 740 [self handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE
741 keyCode:ui::VKEY_END 741 keyCode:ui::VKEY_END
742 domCode:ui::DomCode::END 742 domCode:ui::DomCode::END
743 eventFlags:0]; 743 eventFlags:0];
744 } 744 }
745 745
746 - (void)moveToBeginningOfParagraph:(id)sender { 746 - (void)moveToBeginningOfParagraph:(id)sender {
747 [self moveToBeginningOfLine:sender]; 747 [self moveToBeginningOfLine:sender];
748 } 748 }
749 749
750 - (void)moveToEndOfParagraph:(id)sender { 750 - (void)moveToEndOfParagraph:(id)sender {
751 [self moveToEndOfLine:sender]; 751 [self moveToEndOfLine:sender];
752 } 752 }
753 753
754 - (void)moveToEndOfDocument:(id)sender { 754 - (void)moveToEndOfDocument:(id)sender {
755 [self handleAction:IDS_MOVE_TO_END_OF_LINE 755 [self handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE
756 keyCode:ui::VKEY_END 756 keyCode:ui::VKEY_END
757 domCode:ui::DomCode::END 757 domCode:ui::DomCode::END
758 eventFlags:ui::EF_CONTROL_DOWN]; 758 eventFlags:ui::EF_CONTROL_DOWN];
759 } 759 }
760 760
761 - (void)moveToBeginningOfDocument:(id)sender { 761 - (void)moveToBeginningOfDocument:(id)sender {
762 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE 762 [self handleAction:ui::TextEditCommand::MOVE_TO_BEGINNING_OF_LINE
763 keyCode:ui::VKEY_HOME 763 keyCode:ui::VKEY_HOME
764 domCode:ui::DomCode::HOME 764 domCode:ui::DomCode::HOME
765 eventFlags:ui::EF_CONTROL_DOWN]; 765 eventFlags:ui::EF_CONTROL_DOWN];
766 } 766 }
767 767
768 - (void)pageDown:(id)sender { 768 - (void)pageDown:(id)sender {
769 [self handleAction:IDS_MOVE_TO_END_OF_LINE 769 [self handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE
770 keyCode:ui::VKEY_NEXT 770 keyCode:ui::VKEY_NEXT
771 domCode:ui::DomCode::PAGE_DOWN 771 domCode:ui::DomCode::PAGE_DOWN
772 eventFlags:0]; 772 eventFlags:0];
773 } 773 }
774 774
775 - (void)pageUp:(id)sender { 775 - (void)pageUp:(id)sender {
776 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE 776 [self handleAction:ui::TextEditCommand::MOVE_TO_BEGINNING_OF_LINE
777 keyCode:ui::VKEY_PRIOR 777 keyCode:ui::VKEY_PRIOR
778 domCode:ui::DomCode::PAGE_UP 778 domCode:ui::DomCode::PAGE_UP
779 eventFlags:0]; 779 eventFlags:0];
780 } 780 }
781 781
782 - (void)moveBackwardAndModifySelection:(id)sender { 782 - (void)moveBackwardAndModifySelection:(id)sender {
783 IsTextRTL(textInputClient_) ? [self moveRightAndModifySelection:sender] 783 IsTextRTL(textInputClient_) ? [self moveRightAndModifySelection:sender]
784 : [self moveLeftAndModifySelection:sender]; 784 : [self moveLeftAndModifySelection:sender];
785 } 785 }
786 786
787 - (void)moveForwardAndModifySelection:(id)sender { 787 - (void)moveForwardAndModifySelection:(id)sender {
788 IsTextRTL(textInputClient_) ? [self moveLeftAndModifySelection:sender] 788 IsTextRTL(textInputClient_) ? [self moveLeftAndModifySelection:sender]
789 : [self moveRightAndModifySelection:sender]; 789 : [self moveRightAndModifySelection:sender];
790 } 790 }
791 791
792 - (void)moveWordForwardAndModifySelection:(id)sender { 792 - (void)moveWordForwardAndModifySelection:(id)sender {
793 IsTextRTL(textInputClient_) ? [self moveWordLeftAndModifySelection:sender] 793 IsTextRTL(textInputClient_) ? [self moveWordLeftAndModifySelection:sender]
794 : [self moveWordRightAndModifySelection:sender]; 794 : [self moveWordRightAndModifySelection:sender];
795 } 795 }
796 796
797 - (void)moveWordBackwardAndModifySelection:(id)sender { 797 - (void)moveWordBackwardAndModifySelection:(id)sender {
798 IsTextRTL(textInputClient_) ? [self moveWordRightAndModifySelection:sender] 798 IsTextRTL(textInputClient_) ? [self moveWordRightAndModifySelection:sender]
799 : [self moveWordLeftAndModifySelection:sender]; 799 : [self moveWordLeftAndModifySelection:sender];
800 } 800 }
801 801
802 - (void)moveUpAndModifySelection:(id)sender { 802 - (void)moveUpAndModifySelection:(id)sender {
803 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION 803 [self handleAction:ui::TextEditCommand::
804 MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION
804 keyCode:ui::VKEY_UP 805 keyCode:ui::VKEY_UP
805 domCode:ui::DomCode::ARROW_UP 806 domCode:ui::DomCode::ARROW_UP
806 eventFlags:ui::EF_SHIFT_DOWN]; 807 eventFlags:ui::EF_SHIFT_DOWN];
807 } 808 }
808 809
809 - (void)moveDownAndModifySelection:(id)sender { 810 - (void)moveDownAndModifySelection:(id)sender {
810 [self handleAction:IDS_MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION 811 [self
811 keyCode:ui::VKEY_DOWN 812 handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION
812 domCode:ui::DomCode::ARROW_DOWN 813 keyCode:ui::VKEY_DOWN
813 eventFlags:ui::EF_SHIFT_DOWN]; 814 domCode:ui::DomCode::ARROW_DOWN
815 eventFlags:ui::EF_SHIFT_DOWN];
814 } 816 }
815 817
816 - (void)moveToBeginningOfLineAndModifySelection:(id)sender { 818 - (void)moveToBeginningOfLineAndModifySelection:(id)sender {
817 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION 819 [self handleAction:ui::TextEditCommand::
820 MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION
818 keyCode:ui::VKEY_HOME 821 keyCode:ui::VKEY_HOME
819 domCode:ui::DomCode::HOME 822 domCode:ui::DomCode::HOME
820 eventFlags:ui::EF_SHIFT_DOWN]; 823 eventFlags:ui::EF_SHIFT_DOWN];
821 } 824 }
822 825
823 - (void)moveToEndOfLineAndModifySelection:(id)sender { 826 - (void)moveToEndOfLineAndModifySelection:(id)sender {
824 [self handleAction:IDS_MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION 827 [self
825 keyCode:ui::VKEY_END 828 handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION
826 domCode:ui::DomCode::END 829 keyCode:ui::VKEY_END
827 eventFlags:ui::EF_SHIFT_DOWN]; 830 domCode:ui::DomCode::END
831 eventFlags:ui::EF_SHIFT_DOWN];
828 } 832 }
829 833
830 - (void)moveToBeginningOfParagraphAndModifySelection:(id)sender { 834 - (void)moveToBeginningOfParagraphAndModifySelection:(id)sender {
831 [self moveToBeginningOfLineAndModifySelection:sender]; 835 [self moveToBeginningOfLineAndModifySelection:sender];
832 } 836 }
833 837
834 - (void)moveToEndOfParagraphAndModifySelection:(id)sender { 838 - (void)moveToEndOfParagraphAndModifySelection:(id)sender {
835 [self moveToEndOfLineAndModifySelection:sender]; 839 [self moveToEndOfLineAndModifySelection:sender];
836 } 840 }
837 841
838 - (void)moveToEndOfDocumentAndModifySelection:(id)sender { 842 - (void)moveToEndOfDocumentAndModifySelection:(id)sender {
839 [self handleAction:IDS_MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION 843 [self
840 keyCode:ui::VKEY_END 844 handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION
841 domCode:ui::DomCode::END 845 keyCode:ui::VKEY_END
842 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN]; 846 domCode:ui::DomCode::END
847 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN];
843 } 848 }
844 849
845 - (void)moveToBeginningOfDocumentAndModifySelection:(id)sender { 850 - (void)moveToBeginningOfDocumentAndModifySelection:(id)sender {
846 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION 851 [self handleAction:ui::TextEditCommand::
852 MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION
847 keyCode:ui::VKEY_HOME 853 keyCode:ui::VKEY_HOME
848 domCode:ui::DomCode::HOME 854 domCode:ui::DomCode::HOME
849 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN]; 855 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN];
850 } 856 }
851 857
852 - (void)pageDownAndModifySelection:(id)sender { 858 - (void)pageDownAndModifySelection:(id)sender {
853 [self handleAction:IDS_MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION 859 [self
854 keyCode:ui::VKEY_NEXT 860 handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION
855 domCode:ui::DomCode::PAGE_DOWN 861 keyCode:ui::VKEY_NEXT
856 eventFlags:ui::EF_SHIFT_DOWN]; 862 domCode:ui::DomCode::PAGE_DOWN
863 eventFlags:ui::EF_SHIFT_DOWN];
857 } 864 }
858 865
859 - (void)pageUpAndModifySelection:(id)sender { 866 - (void)pageUpAndModifySelection:(id)sender {
860 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION 867 [self handleAction:ui::TextEditCommand::
868 MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION
861 keyCode:ui::VKEY_PRIOR 869 keyCode:ui::VKEY_PRIOR
862 domCode:ui::DomCode::PAGE_UP 870 domCode:ui::DomCode::PAGE_UP
863 eventFlags:ui::EF_SHIFT_DOWN]; 871 eventFlags:ui::EF_SHIFT_DOWN];
864 } 872 }
865 873
866 - (void)moveParagraphForwardAndModifySelection:(id)sender { 874 - (void)moveParagraphForwardAndModifySelection:(id)sender {
867 [self handleAction:IDS_MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION 875 [self
868 keyCode:ui::VKEY_DOWN 876 handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION
869 domCode:ui::DomCode::ARROW_DOWN 877 keyCode:ui::VKEY_DOWN
870 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN]; 878 domCode:ui::DomCode::ARROW_DOWN
879 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN];
871 } 880 }
872 881
873 - (void)moveParagraphBackwardAndModifySelection:(id)sender { 882 - (void)moveParagraphBackwardAndModifySelection:(id)sender {
874 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION 883 [self handleAction:ui::TextEditCommand::
884 MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION
875 keyCode:ui::VKEY_UP 885 keyCode:ui::VKEY_UP
876 domCode:ui::DomCode::ARROW_UP 886 domCode:ui::DomCode::ARROW_UP
877 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN]; 887 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN];
878 } 888 }
879 889
880 - (void)moveWordRight:(id)sender { 890 - (void)moveWordRight:(id)sender {
881 [self handleAction:IDS_MOVE_WORD_RIGHT 891 [self handleAction:ui::TextEditCommand::MOVE_WORD_RIGHT
882 keyCode:ui::VKEY_RIGHT 892 keyCode:ui::VKEY_RIGHT
883 domCode:ui::DomCode::ARROW_RIGHT 893 domCode:ui::DomCode::ARROW_RIGHT
884 eventFlags:ui::EF_CONTROL_DOWN]; 894 eventFlags:ui::EF_CONTROL_DOWN];
885 } 895 }
886 896
887 - (void)moveWordLeft:(id)sender { 897 - (void)moveWordLeft:(id)sender {
888 [self handleAction:IDS_MOVE_WORD_LEFT 898 [self handleAction:ui::TextEditCommand::MOVE_WORD_LEFT
889 keyCode:ui::VKEY_LEFT 899 keyCode:ui::VKEY_LEFT
890 domCode:ui::DomCode::ARROW_LEFT 900 domCode:ui::DomCode::ARROW_LEFT
891 eventFlags:ui::EF_CONTROL_DOWN]; 901 eventFlags:ui::EF_CONTROL_DOWN];
892 } 902 }
893 903
894 - (void)moveRightAndModifySelection:(id)sender { 904 - (void)moveRightAndModifySelection:(id)sender {
895 [self handleAction:IDS_MOVE_RIGHT_AND_MODIFY_SELECTION 905 [self handleAction:ui::TextEditCommand::MOVE_RIGHT_AND_MODIFY_SELECTION
896 keyCode:ui::VKEY_RIGHT 906 keyCode:ui::VKEY_RIGHT
897 domCode:ui::DomCode::ARROW_RIGHT 907 domCode:ui::DomCode::ARROW_RIGHT
898 eventFlags:ui::EF_SHIFT_DOWN]; 908 eventFlags:ui::EF_SHIFT_DOWN];
899 } 909 }
900 910
901 - (void)moveLeftAndModifySelection:(id)sender { 911 - (void)moveLeftAndModifySelection:(id)sender {
902 [self handleAction:IDS_MOVE_LEFT_AND_MODIFY_SELECTION 912 [self handleAction:ui::TextEditCommand::MOVE_LEFT_AND_MODIFY_SELECTION
903 keyCode:ui::VKEY_LEFT 913 keyCode:ui::VKEY_LEFT
904 domCode:ui::DomCode::ARROW_LEFT 914 domCode:ui::DomCode::ARROW_LEFT
905 eventFlags:ui::EF_SHIFT_DOWN]; 915 eventFlags:ui::EF_SHIFT_DOWN];
906 } 916 }
907 917
908 - (void)moveWordRightAndModifySelection:(id)sender { 918 - (void)moveWordRightAndModifySelection:(id)sender {
909 [self handleAction:IDS_MOVE_WORD_RIGHT_AND_MODIFY_SELECTION 919 [self handleAction:ui::TextEditCommand::MOVE_WORD_RIGHT_AND_MODIFY_SELECTION
910 keyCode:ui::VKEY_RIGHT 920 keyCode:ui::VKEY_RIGHT
911 domCode:ui::DomCode::ARROW_RIGHT 921 domCode:ui::DomCode::ARROW_RIGHT
912 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN]; 922 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN];
913 } 923 }
914 924
915 - (void)moveWordLeftAndModifySelection:(id)sender { 925 - (void)moveWordLeftAndModifySelection:(id)sender {
916 [self handleAction:IDS_MOVE_WORD_LEFT_AND_MODIFY_SELECTION 926 [self handleAction:ui::TextEditCommand::MOVE_WORD_LEFT_AND_MODIFY_SELECTION
917 keyCode:ui::VKEY_LEFT 927 keyCode:ui::VKEY_LEFT
918 domCode:ui::DomCode::ARROW_LEFT 928 domCode:ui::DomCode::ARROW_LEFT
919 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN]; 929 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN];
920 } 930 }
921 931
922 - (void)moveToLeftEndOfLine:(id)sender { 932 - (void)moveToLeftEndOfLine:(id)sender {
923 IsTextRTL(textInputClient_) ? [self moveToEndOfLine:sender] 933 IsTextRTL(textInputClient_) ? [self moveToEndOfLine:sender]
924 : [self moveToBeginningOfLine:sender]; 934 : [self moveToBeginningOfLine:sender];
925 } 935 }
926 936
(...skipping 10 matching lines...) Expand all
937 947
938 - (void)moveToRightEndOfLineAndModifySelection:(id)sender { 948 - (void)moveToRightEndOfLineAndModifySelection:(id)sender {
939 IsTextRTL(textInputClient_) 949 IsTextRTL(textInputClient_)
940 ? [self moveToBeginningOfLineAndModifySelection:sender] 950 ? [self moveToBeginningOfLineAndModifySelection:sender]
941 : [self moveToEndOfLineAndModifySelection:sender]; 951 : [self moveToEndOfLineAndModifySelection:sender];
942 } 952 }
943 953
944 // Deletions. 954 // Deletions.
945 955
946 - (void)deleteForward:(id)sender { 956 - (void)deleteForward:(id)sender {
947 [self handleAction:IDS_DELETE_FORWARD 957 [self handleAction:ui::TextEditCommand::DELETE_FORWARD
948 keyCode:ui::VKEY_DELETE 958 keyCode:ui::VKEY_DELETE
949 domCode:ui::DomCode::DEL 959 domCode:ui::DomCode::DEL
950 eventFlags:0]; 960 eventFlags:0];
951 } 961 }
952 962
953 - (void)deleteBackward:(id)sender { 963 - (void)deleteBackward:(id)sender {
954 [self handleAction:IDS_DELETE_BACKWARD 964 [self handleAction:ui::TextEditCommand::DELETE_BACKWARD
955 keyCode:ui::VKEY_BACK 965 keyCode:ui::VKEY_BACK
956 domCode:ui::DomCode::BACKSPACE 966 domCode:ui::DomCode::BACKSPACE
957 eventFlags:0]; 967 eventFlags:0];
958 } 968 }
959 969
960 - (void)deleteWordForward:(id)sender { 970 - (void)deleteWordForward:(id)sender {
961 [self handleAction:IDS_DELETE_WORD_FORWARD 971 [self handleAction:ui::TextEditCommand::DELETE_WORD_FORWARD
962 keyCode:ui::VKEY_DELETE 972 keyCode:ui::VKEY_DELETE
963 domCode:ui::DomCode::DEL 973 domCode:ui::DomCode::DEL
964 eventFlags:ui::EF_CONTROL_DOWN]; 974 eventFlags:ui::EF_CONTROL_DOWN];
965 } 975 }
966 976
967 - (void)deleteWordBackward:(id)sender { 977 - (void)deleteWordBackward:(id)sender {
968 [self handleAction:IDS_DELETE_WORD_BACKWARD 978 [self handleAction:ui::TextEditCommand::DELETE_WORD_BACKWARD
969 keyCode:ui::VKEY_BACK 979 keyCode:ui::VKEY_BACK
970 domCode:ui::DomCode::BACKSPACE 980 domCode:ui::DomCode::BACKSPACE
971 eventFlags:ui::EF_CONTROL_DOWN]; 981 eventFlags:ui::EF_CONTROL_DOWN];
972 } 982 }
973 983
974 - (void)deleteToBeginningOfLine:(id)sender { 984 - (void)deleteToBeginningOfLine:(id)sender {
975 [self handleAction:IDS_DELETE_TO_BEGINNING_OF_LINE 985 [self handleAction:ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE
976 keyCode:ui::VKEY_BACK 986 keyCode:ui::VKEY_BACK
977 domCode:ui::DomCode::BACKSPACE 987 domCode:ui::DomCode::BACKSPACE
978 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN]; 988 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN];
979 } 989 }
980 990
981 - (void)deleteToEndOfLine:(id)sender { 991 - (void)deleteToEndOfLine:(id)sender {
982 [self handleAction:IDS_DELETE_TO_END_OF_LINE 992 [self handleAction:ui::TextEditCommand::DELETE_TO_END_OF_LINE
983 keyCode:ui::VKEY_DELETE 993 keyCode:ui::VKEY_DELETE
984 domCode:ui::DomCode::DEL 994 domCode:ui::DomCode::DEL
985 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN]; 995 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN];
986 } 996 }
987 997
988 - (void)deleteToBeginningOfParagraph:(id)sender { 998 - (void)deleteToBeginningOfParagraph:(id)sender {
989 [self deleteToBeginningOfLine:sender]; 999 [self deleteToBeginningOfLine:sender];
990 } 1000 }
991 1001
992 - (void)deleteToEndOfParagraph:(id)sender { 1002 - (void)deleteToEndOfParagraph:(id)sender {
993 [self deleteToEndOfLine:sender]; 1003 [self deleteToEndOfLine:sender];
994 } 1004 }
995 1005
996 // Cancellation. 1006 // Cancellation.
997 1007
998 - (void)cancelOperation:(id)sender { 1008 - (void)cancelOperation:(id)sender {
999 [self handleAction:0 1009 [self handleAction:ui::TextEditCommand::INVALID_COMMAND
1000 keyCode:ui::VKEY_ESCAPE 1010 keyCode:ui::VKEY_ESCAPE
1001 domCode:ui::DomCode::ESCAPE 1011 domCode:ui::DomCode::ESCAPE
1002 eventFlags:0]; 1012 eventFlags:0];
1003 } 1013 }
1004 1014
1005 // Support for Services in context menus. 1015 // Support for Services in context menus.
1006 // Currently we only support reading and writing plain strings. 1016 // Currently we only support reading and writing plain strings.
1007 - (id)validRequestorForSendType:(NSString*)sendType 1017 - (id)validRequestorForSendType:(NSString*)sendType
1008 returnType:(NSString*)returnType { 1018 returnType:(NSString*)returnType {
1009 BOOL canWrite = [sendType isEqualToString:NSStringPboardType] && 1019 BOOL canWrite = [sendType isEqualToString:NSStringPboardType] &&
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 1197
1188 // NSUserInterfaceValidations protocol implementation. 1198 // NSUserInterfaceValidations protocol implementation.
1189 1199
1190 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { 1200 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item {
1191 if (!textInputClient_) 1201 if (!textInputClient_)
1192 return NO; 1202 return NO;
1193 1203
1194 SEL action = [item action]; 1204 SEL action = [item action];
1195 1205
1196 if (action == @selector(undo:)) 1206 if (action == @selector(undo:))
1197 return textInputClient_->IsEditCommandEnabled(IDS_APP_UNDO); 1207 return textInputClient_->IsEditCommandEnabled(ui::TextEditCommand::UNDO);
1198 if (action == @selector(redo:)) 1208 if (action == @selector(redo:))
1199 return textInputClient_->IsEditCommandEnabled(IDS_APP_REDO); 1209 return textInputClient_->IsEditCommandEnabled(ui::TextEditCommand::REDO);
1200 if (action == @selector(cut:)) 1210 if (action == @selector(cut:))
1201 return textInputClient_->IsEditCommandEnabled(IDS_APP_CUT); 1211 return textInputClient_->IsEditCommandEnabled(ui::TextEditCommand::CUT);
1202 if (action == @selector(copy:)) 1212 if (action == @selector(copy:))
1203 return textInputClient_->IsEditCommandEnabled(IDS_APP_COPY); 1213 return textInputClient_->IsEditCommandEnabled(ui::TextEditCommand::COPY);
1204 if (action == @selector(paste:)) 1214 if (action == @selector(paste:))
1205 return textInputClient_->IsEditCommandEnabled(IDS_APP_PASTE); 1215 return textInputClient_->IsEditCommandEnabled(ui::TextEditCommand::PASTE);
1206 if (action == @selector(selectAll:)) 1216 if (action == @selector(selectAll:))
1207 return textInputClient_->IsEditCommandEnabled(IDS_APP_SELECT_ALL); 1217 return textInputClient_->IsEditCommandEnabled(
1218 ui::TextEditCommand::SELECT_ALL);
1208 1219
1209 return NO; 1220 return NO;
1210 } 1221 }
1211 1222
1212 // NSDraggingSource protocol implementation. 1223 // NSDraggingSource protocol implementation.
1213 1224
1214 - (NSDragOperation)draggingSession:(NSDraggingSession*)session 1225 - (NSDragOperation)draggingSession:(NSDraggingSession*)session
1215 sourceOperationMaskForDraggingContext:(NSDraggingContext)context { 1226 sourceOperationMaskForDraggingContext:(NSDraggingContext)context {
1216 return NSDragOperationEvery; 1227 return NSDragOperationEvery;
1217 } 1228 }
(...skipping 14 matching lines...) Expand all
1232 } 1243 }
1233 1244
1234 return [super accessibilityAttributeValue:attribute]; 1245 return [super accessibilityAttributeValue:attribute];
1235 } 1246 }
1236 1247
1237 - (id)accessibilityHitTest:(NSPoint)point { 1248 - (id)accessibilityHitTest:(NSPoint)point {
1238 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; 1249 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point];
1239 } 1250 }
1240 1251
1241 @end 1252 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698