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

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

Powered by Google App Engine
This is Rietveld 408576698