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

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: Address review comments. 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
« no previous file with comments | « ui/strings/ui_strings.grd ('k') | ui/views/controls/prefix_selector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_edit_commands.h"
16 #include "ui/base/ime/text_input_client.h" 17 #include "ui/base/ime/text_input_client.h"
17 #include "ui/compositor/canvas_painter.h" 18 #include "ui/compositor/canvas_painter.h"
18 #import "ui/events/cocoa/cocoa_event_utils.h" 19 #import "ui/events/cocoa/cocoa_event_utils.h"
19 #include "ui/events/keycodes/dom/dom_code.h" 20 #include "ui/events/keycodes/dom/dom_code.h"
20 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" 21 #import "ui/events/keycodes/keyboard_code_conversion_mac.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_->IsTextEditCommandEnabled(command))
395 textInputClient_->IsEditCommandEnabled(commandId)) 395 textInputClient_->SetTextEditCommandForNextKeyEvent(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_->IsTextEditCommandEnabled(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_->IsTextEditCommandEnabled(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_->IsTextEditCommandEnabled(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_->IsTextEditCommandEnabled(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(
454 [self handleAction:IDS_APP_PASTE 453 textInputClient_->IsTextEditCommandEnabled(ui::TextEditCommand::PASTE));
454 [self handleAction:ui::TextEditCommand::PASTE
455 keyCode:ui::VKEY_V 455 keyCode:ui::VKEY_V
456 domCode:ui::DomCode::US_V 456 domCode:ui::DomCode::US_V
457 eventFlags:ui::EF_CONTROL_DOWN]; 457 eventFlags:ui::EF_CONTROL_DOWN];
458 } 458 }
459 459
460 - (void)selectAll:(id)sender { 460 - (void)selectAll:(id)sender {
461 DCHECK(textInputClient_->IsEditCommandEnabled(IDS_APP_SELECT_ALL)); 461 DCHECK(textInputClient_->IsTextEditCommandEnabled(
462 [self handleAction:IDS_APP_SELECT_ALL 462 ui::TextEditCommand::SELECT_ALL));
463 [self handleAction:ui::TextEditCommand::SELECT_ALL
463 keyCode:ui::VKEY_A 464 keyCode:ui::VKEY_A
464 domCode:ui::DomCode::US_A 465 domCode:ui::DomCode::US_A
465 eventFlags:ui::EF_CONTROL_DOWN]; 466 eventFlags:ui::EF_CONTROL_DOWN];
466 } 467 }
467 468
468 // BaseView implementation. 469 // BaseView implementation.
469 470
470 // Don't use tracking areas from BaseView. BridgedContentView's tracks 471 // Don't use tracking areas from BaseView. BridgedContentView's tracks
471 // NSTrackingCursorUpdate and Apple's documentation suggests it's incompatible. 472 // NSTrackingCursorUpdate and Apple's documentation suggests it's incompatible.
472 - (void)enableTracking { 473 - (void)enableTracking {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 } 681 }
681 682
682 // Selection movement and scrolling. 683 // Selection movement and scrolling.
683 684
684 - (void)moveForward:(id)sender { 685 - (void)moveForward:(id)sender {
685 IsTextRTL(textInputClient_) ? [self moveLeft:sender] 686 IsTextRTL(textInputClient_) ? [self moveLeft:sender]
686 : [self moveRight:sender]; 687 : [self moveRight:sender];
687 } 688 }
688 689
689 - (void)moveRight:(id)sender { 690 - (void)moveRight:(id)sender {
690 [self handleAction:IDS_MOVE_RIGHT 691 [self handleAction:ui::TextEditCommand::MOVE_RIGHT
691 keyCode:ui::VKEY_RIGHT 692 keyCode:ui::VKEY_RIGHT
692 domCode:ui::DomCode::ARROW_RIGHT 693 domCode:ui::DomCode::ARROW_RIGHT
693 eventFlags:0]; 694 eventFlags:0];
694 } 695 }
695 696
696 - (void)moveBackward:(id)sender { 697 - (void)moveBackward:(id)sender {
697 IsTextRTL(textInputClient_) ? [self moveRight:sender] 698 IsTextRTL(textInputClient_) ? [self moveRight:sender]
698 : [self moveLeft:sender]; 699 : [self moveLeft:sender];
699 } 700 }
700 701
701 - (void)moveLeft:(id)sender { 702 - (void)moveLeft:(id)sender {
702 [self handleAction:IDS_MOVE_LEFT 703 [self handleAction:ui::TextEditCommand::MOVE_LEFT
703 keyCode:ui::VKEY_LEFT 704 keyCode:ui::VKEY_LEFT
704 domCode:ui::DomCode::ARROW_LEFT 705 domCode:ui::DomCode::ARROW_LEFT
705 eventFlags:0]; 706 eventFlags:0];
706 } 707 }
707 708
708 - (void)moveUp:(id)sender { 709 - (void)moveUp:(id)sender {
709 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE 710 [self handleAction:ui::TextEditCommand::MOVE_TO_BEGINNING_OF_LINE
710 keyCode:ui::VKEY_UP 711 keyCode:ui::VKEY_UP
711 domCode:ui::DomCode::ARROW_UP 712 domCode:ui::DomCode::ARROW_UP
712 eventFlags:0]; 713 eventFlags:0];
713 } 714 }
714 715
715 - (void)moveDown:(id)sender { 716 - (void)moveDown:(id)sender {
716 [self handleAction:IDS_MOVE_TO_END_OF_LINE 717 [self handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE
717 keyCode:ui::VKEY_DOWN 718 keyCode:ui::VKEY_DOWN
718 domCode:ui::DomCode::ARROW_DOWN 719 domCode:ui::DomCode::ARROW_DOWN
719 eventFlags:0]; 720 eventFlags:0];
720 } 721 }
721 722
722 - (void)moveWordForward:(id)sender { 723 - (void)moveWordForward:(id)sender {
723 IsTextRTL(textInputClient_) ? [self moveWordLeft:sender] 724 IsTextRTL(textInputClient_) ? [self moveWordLeft:sender]
724 : [self moveWordRight:sender]; 725 : [self moveWordRight:sender];
725 } 726 }
726 727
727 - (void)moveWordBackward:(id)sender { 728 - (void)moveWordBackward:(id)sender {
728 IsTextRTL(textInputClient_) ? [self moveWordRight:sender] 729 IsTextRTL(textInputClient_) ? [self moveWordRight:sender]
729 : [self moveWordLeft:sender]; 730 : [self moveWordLeft:sender];
730 } 731 }
731 732
732 - (void)moveToBeginningOfLine:(id)sender { 733 - (void)moveToBeginningOfLine:(id)sender {
733 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE 734 [self handleAction:ui::TextEditCommand::MOVE_TO_BEGINNING_OF_LINE
734 keyCode:ui::VKEY_HOME 735 keyCode:ui::VKEY_HOME
735 domCode:ui::DomCode::HOME 736 domCode:ui::DomCode::HOME
736 eventFlags:0]; 737 eventFlags:0];
737 } 738 }
738 739
739 - (void)moveToEndOfLine:(id)sender { 740 - (void)moveToEndOfLine:(id)sender {
740 [self handleAction:IDS_MOVE_TO_END_OF_LINE 741 [self handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE
741 keyCode:ui::VKEY_END 742 keyCode:ui::VKEY_END
742 domCode:ui::DomCode::END 743 domCode:ui::DomCode::END
743 eventFlags:0]; 744 eventFlags:0];
744 } 745 }
745 746
746 - (void)moveToBeginningOfParagraph:(id)sender { 747 - (void)moveToBeginningOfParagraph:(id)sender {
747 [self moveToBeginningOfLine:sender]; 748 [self moveToBeginningOfLine:sender];
748 } 749 }
749 750
750 - (void)moveToEndOfParagraph:(id)sender { 751 - (void)moveToEndOfParagraph:(id)sender {
751 [self moveToEndOfLine:sender]; 752 [self moveToEndOfLine:sender];
752 } 753 }
753 754
754 - (void)moveToEndOfDocument:(id)sender { 755 - (void)moveToEndOfDocument:(id)sender {
755 [self handleAction:IDS_MOVE_TO_END_OF_LINE 756 [self handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE
756 keyCode:ui::VKEY_END 757 keyCode:ui::VKEY_END
757 domCode:ui::DomCode::END 758 domCode:ui::DomCode::END
758 eventFlags:ui::EF_CONTROL_DOWN]; 759 eventFlags:ui::EF_CONTROL_DOWN];
759 } 760 }
760 761
761 - (void)moveToBeginningOfDocument:(id)sender { 762 - (void)moveToBeginningOfDocument:(id)sender {
762 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE 763 [self handleAction:ui::TextEditCommand::MOVE_TO_BEGINNING_OF_LINE
763 keyCode:ui::VKEY_HOME 764 keyCode:ui::VKEY_HOME
764 domCode:ui::DomCode::HOME 765 domCode:ui::DomCode::HOME
765 eventFlags:ui::EF_CONTROL_DOWN]; 766 eventFlags:ui::EF_CONTROL_DOWN];
766 } 767 }
767 768
768 - (void)pageDown:(id)sender { 769 - (void)pageDown:(id)sender {
769 [self handleAction:IDS_MOVE_TO_END_OF_LINE 770 [self handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE
770 keyCode:ui::VKEY_NEXT 771 keyCode:ui::VKEY_NEXT
771 domCode:ui::DomCode::PAGE_DOWN 772 domCode:ui::DomCode::PAGE_DOWN
772 eventFlags:0]; 773 eventFlags:0];
773 } 774 }
774 775
775 - (void)pageUp:(id)sender { 776 - (void)pageUp:(id)sender {
776 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE 777 [self handleAction:ui::TextEditCommand::MOVE_TO_BEGINNING_OF_LINE
777 keyCode:ui::VKEY_PRIOR 778 keyCode:ui::VKEY_PRIOR
778 domCode:ui::DomCode::PAGE_UP 779 domCode:ui::DomCode::PAGE_UP
779 eventFlags:0]; 780 eventFlags:0];
780 } 781 }
781 782
782 - (void)moveBackwardAndModifySelection:(id)sender { 783 - (void)moveBackwardAndModifySelection:(id)sender {
783 IsTextRTL(textInputClient_) ? [self moveRightAndModifySelection:sender] 784 IsTextRTL(textInputClient_) ? [self moveRightAndModifySelection:sender]
784 : [self moveLeftAndModifySelection:sender]; 785 : [self moveLeftAndModifySelection:sender];
785 } 786 }
786 787
787 - (void)moveForwardAndModifySelection:(id)sender { 788 - (void)moveForwardAndModifySelection:(id)sender {
788 IsTextRTL(textInputClient_) ? [self moveLeftAndModifySelection:sender] 789 IsTextRTL(textInputClient_) ? [self moveLeftAndModifySelection:sender]
789 : [self moveRightAndModifySelection:sender]; 790 : [self moveRightAndModifySelection:sender];
790 } 791 }
791 792
792 - (void)moveWordForwardAndModifySelection:(id)sender { 793 - (void)moveWordForwardAndModifySelection:(id)sender {
793 IsTextRTL(textInputClient_) ? [self moveWordLeftAndModifySelection:sender] 794 IsTextRTL(textInputClient_) ? [self moveWordLeftAndModifySelection:sender]
794 : [self moveWordRightAndModifySelection:sender]; 795 : [self moveWordRightAndModifySelection:sender];
795 } 796 }
796 797
797 - (void)moveWordBackwardAndModifySelection:(id)sender { 798 - (void)moveWordBackwardAndModifySelection:(id)sender {
798 IsTextRTL(textInputClient_) ? [self moveWordRightAndModifySelection:sender] 799 IsTextRTL(textInputClient_) ? [self moveWordRightAndModifySelection:sender]
799 : [self moveWordLeftAndModifySelection:sender]; 800 : [self moveWordLeftAndModifySelection:sender];
800 } 801 }
801 802
802 - (void)moveUpAndModifySelection:(id)sender { 803 - (void)moveUpAndModifySelection:(id)sender {
803 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION 804 [self handleAction:ui::TextEditCommand::
805 MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION
804 keyCode:ui::VKEY_UP 806 keyCode:ui::VKEY_UP
805 domCode:ui::DomCode::ARROW_UP 807 domCode:ui::DomCode::ARROW_UP
806 eventFlags:ui::EF_SHIFT_DOWN]; 808 eventFlags:ui::EF_SHIFT_DOWN];
807 } 809 }
808 810
809 - (void)moveDownAndModifySelection:(id)sender { 811 - (void)moveDownAndModifySelection:(id)sender {
810 [self handleAction:IDS_MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION 812 [self
811 keyCode:ui::VKEY_DOWN 813 handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION
812 domCode:ui::DomCode::ARROW_DOWN 814 keyCode:ui::VKEY_DOWN
813 eventFlags:ui::EF_SHIFT_DOWN]; 815 domCode:ui::DomCode::ARROW_DOWN
816 eventFlags:ui::EF_SHIFT_DOWN];
814 } 817 }
815 818
816 - (void)moveToBeginningOfLineAndModifySelection:(id)sender { 819 - (void)moveToBeginningOfLineAndModifySelection:(id)sender {
817 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION 820 [self handleAction:ui::TextEditCommand::
821 MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION
818 keyCode:ui::VKEY_HOME 822 keyCode:ui::VKEY_HOME
819 domCode:ui::DomCode::HOME 823 domCode:ui::DomCode::HOME
820 eventFlags:ui::EF_SHIFT_DOWN]; 824 eventFlags:ui::EF_SHIFT_DOWN];
821 } 825 }
822 826
823 - (void)moveToEndOfLineAndModifySelection:(id)sender { 827 - (void)moveToEndOfLineAndModifySelection:(id)sender {
824 [self handleAction:IDS_MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION 828 [self
825 keyCode:ui::VKEY_END 829 handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION
826 domCode:ui::DomCode::END 830 keyCode:ui::VKEY_END
827 eventFlags:ui::EF_SHIFT_DOWN]; 831 domCode:ui::DomCode::END
832 eventFlags:ui::EF_SHIFT_DOWN];
828 } 833 }
829 834
830 - (void)moveToBeginningOfParagraphAndModifySelection:(id)sender { 835 - (void)moveToBeginningOfParagraphAndModifySelection:(id)sender {
831 [self moveToBeginningOfLineAndModifySelection:sender]; 836 [self moveToBeginningOfLineAndModifySelection:sender];
832 } 837 }
833 838
834 - (void)moveToEndOfParagraphAndModifySelection:(id)sender { 839 - (void)moveToEndOfParagraphAndModifySelection:(id)sender {
835 [self moveToEndOfLineAndModifySelection:sender]; 840 [self moveToEndOfLineAndModifySelection:sender];
836 } 841 }
837 842
838 - (void)moveToEndOfDocumentAndModifySelection:(id)sender { 843 - (void)moveToEndOfDocumentAndModifySelection:(id)sender {
839 [self handleAction:IDS_MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION 844 [self
840 keyCode:ui::VKEY_END 845 handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION
841 domCode:ui::DomCode::END 846 keyCode:ui::VKEY_END
842 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN]; 847 domCode:ui::DomCode::END
848 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN];
843 } 849 }
844 850
845 - (void)moveToBeginningOfDocumentAndModifySelection:(id)sender { 851 - (void)moveToBeginningOfDocumentAndModifySelection:(id)sender {
846 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION 852 [self handleAction:ui::TextEditCommand::
853 MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION
847 keyCode:ui::VKEY_HOME 854 keyCode:ui::VKEY_HOME
848 domCode:ui::DomCode::HOME 855 domCode:ui::DomCode::HOME
849 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN]; 856 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN];
850 } 857 }
851 858
852 - (void)pageDownAndModifySelection:(id)sender { 859 - (void)pageDownAndModifySelection:(id)sender {
853 [self handleAction:IDS_MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION 860 [self
854 keyCode:ui::VKEY_NEXT 861 handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION
855 domCode:ui::DomCode::PAGE_DOWN 862 keyCode:ui::VKEY_NEXT
856 eventFlags:ui::EF_SHIFT_DOWN]; 863 domCode:ui::DomCode::PAGE_DOWN
864 eventFlags:ui::EF_SHIFT_DOWN];
857 } 865 }
858 866
859 - (void)pageUpAndModifySelection:(id)sender { 867 - (void)pageUpAndModifySelection:(id)sender {
860 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION 868 [self handleAction:ui::TextEditCommand::
869 MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION
861 keyCode:ui::VKEY_PRIOR 870 keyCode:ui::VKEY_PRIOR
862 domCode:ui::DomCode::PAGE_UP 871 domCode:ui::DomCode::PAGE_UP
863 eventFlags:ui::EF_SHIFT_DOWN]; 872 eventFlags:ui::EF_SHIFT_DOWN];
864 } 873 }
865 874
866 - (void)moveParagraphForwardAndModifySelection:(id)sender { 875 - (void)moveParagraphForwardAndModifySelection:(id)sender {
867 [self handleAction:IDS_MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION 876 [self
868 keyCode:ui::VKEY_DOWN 877 handleAction:ui::TextEditCommand::MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION
869 domCode:ui::DomCode::ARROW_DOWN 878 keyCode:ui::VKEY_DOWN
870 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN]; 879 domCode:ui::DomCode::ARROW_DOWN
880 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN];
871 } 881 }
872 882
873 - (void)moveParagraphBackwardAndModifySelection:(id)sender { 883 - (void)moveParagraphBackwardAndModifySelection:(id)sender {
874 [self handleAction:IDS_MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION 884 [self handleAction:ui::TextEditCommand::
885 MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION
875 keyCode:ui::VKEY_UP 886 keyCode:ui::VKEY_UP
876 domCode:ui::DomCode::ARROW_UP 887 domCode:ui::DomCode::ARROW_UP
877 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN]; 888 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN];
878 } 889 }
879 890
880 - (void)moveWordRight:(id)sender { 891 - (void)moveWordRight:(id)sender {
881 [self handleAction:IDS_MOVE_WORD_RIGHT 892 [self handleAction:ui::TextEditCommand::MOVE_WORD_RIGHT
882 keyCode:ui::VKEY_RIGHT 893 keyCode:ui::VKEY_RIGHT
883 domCode:ui::DomCode::ARROW_RIGHT 894 domCode:ui::DomCode::ARROW_RIGHT
884 eventFlags:ui::EF_CONTROL_DOWN]; 895 eventFlags:ui::EF_CONTROL_DOWN];
885 } 896 }
886 897
887 - (void)moveWordLeft:(id)sender { 898 - (void)moveWordLeft:(id)sender {
888 [self handleAction:IDS_MOVE_WORD_LEFT 899 [self handleAction:ui::TextEditCommand::MOVE_WORD_LEFT
889 keyCode:ui::VKEY_LEFT 900 keyCode:ui::VKEY_LEFT
890 domCode:ui::DomCode::ARROW_LEFT 901 domCode:ui::DomCode::ARROW_LEFT
891 eventFlags:ui::EF_CONTROL_DOWN]; 902 eventFlags:ui::EF_CONTROL_DOWN];
892 } 903 }
893 904
894 - (void)moveRightAndModifySelection:(id)sender { 905 - (void)moveRightAndModifySelection:(id)sender {
895 [self handleAction:IDS_MOVE_RIGHT_AND_MODIFY_SELECTION 906 [self handleAction:ui::TextEditCommand::MOVE_RIGHT_AND_MODIFY_SELECTION
896 keyCode:ui::VKEY_RIGHT 907 keyCode:ui::VKEY_RIGHT
897 domCode:ui::DomCode::ARROW_RIGHT 908 domCode:ui::DomCode::ARROW_RIGHT
898 eventFlags:ui::EF_SHIFT_DOWN]; 909 eventFlags:ui::EF_SHIFT_DOWN];
899 } 910 }
900 911
901 - (void)moveLeftAndModifySelection:(id)sender { 912 - (void)moveLeftAndModifySelection:(id)sender {
902 [self handleAction:IDS_MOVE_LEFT_AND_MODIFY_SELECTION 913 [self handleAction:ui::TextEditCommand::MOVE_LEFT_AND_MODIFY_SELECTION
903 keyCode:ui::VKEY_LEFT 914 keyCode:ui::VKEY_LEFT
904 domCode:ui::DomCode::ARROW_LEFT 915 domCode:ui::DomCode::ARROW_LEFT
905 eventFlags:ui::EF_SHIFT_DOWN]; 916 eventFlags:ui::EF_SHIFT_DOWN];
906 } 917 }
907 918
908 - (void)moveWordRightAndModifySelection:(id)sender { 919 - (void)moveWordRightAndModifySelection:(id)sender {
909 [self handleAction:IDS_MOVE_WORD_RIGHT_AND_MODIFY_SELECTION 920 [self handleAction:ui::TextEditCommand::MOVE_WORD_RIGHT_AND_MODIFY_SELECTION
910 keyCode:ui::VKEY_RIGHT 921 keyCode:ui::VKEY_RIGHT
911 domCode:ui::DomCode::ARROW_RIGHT 922 domCode:ui::DomCode::ARROW_RIGHT
912 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN]; 923 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN];
913 } 924 }
914 925
915 - (void)moveWordLeftAndModifySelection:(id)sender { 926 - (void)moveWordLeftAndModifySelection:(id)sender {
916 [self handleAction:IDS_MOVE_WORD_LEFT_AND_MODIFY_SELECTION 927 [self handleAction:ui::TextEditCommand::MOVE_WORD_LEFT_AND_MODIFY_SELECTION
917 keyCode:ui::VKEY_LEFT 928 keyCode:ui::VKEY_LEFT
918 domCode:ui::DomCode::ARROW_LEFT 929 domCode:ui::DomCode::ARROW_LEFT
919 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN]; 930 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN];
920 } 931 }
921 932
922 - (void)moveToLeftEndOfLine:(id)sender { 933 - (void)moveToLeftEndOfLine:(id)sender {
923 IsTextRTL(textInputClient_) ? [self moveToEndOfLine:sender] 934 IsTextRTL(textInputClient_) ? [self moveToEndOfLine:sender]
924 : [self moveToBeginningOfLine:sender]; 935 : [self moveToBeginningOfLine:sender];
925 } 936 }
926 937
(...skipping 10 matching lines...) Expand all
937 948
938 - (void)moveToRightEndOfLineAndModifySelection:(id)sender { 949 - (void)moveToRightEndOfLineAndModifySelection:(id)sender {
939 IsTextRTL(textInputClient_) 950 IsTextRTL(textInputClient_)
940 ? [self moveToBeginningOfLineAndModifySelection:sender] 951 ? [self moveToBeginningOfLineAndModifySelection:sender]
941 : [self moveToEndOfLineAndModifySelection:sender]; 952 : [self moveToEndOfLineAndModifySelection:sender];
942 } 953 }
943 954
944 // Deletions. 955 // Deletions.
945 956
946 - (void)deleteForward:(id)sender { 957 - (void)deleteForward:(id)sender {
947 [self handleAction:IDS_DELETE_FORWARD 958 [self handleAction:ui::TextEditCommand::DELETE_FORWARD
948 keyCode:ui::VKEY_DELETE 959 keyCode:ui::VKEY_DELETE
949 domCode:ui::DomCode::DEL 960 domCode:ui::DomCode::DEL
950 eventFlags:0]; 961 eventFlags:0];
951 } 962 }
952 963
953 - (void)deleteBackward:(id)sender { 964 - (void)deleteBackward:(id)sender {
954 [self handleAction:IDS_DELETE_BACKWARD 965 [self handleAction:ui::TextEditCommand::DELETE_BACKWARD
955 keyCode:ui::VKEY_BACK 966 keyCode:ui::VKEY_BACK
956 domCode:ui::DomCode::BACKSPACE 967 domCode:ui::DomCode::BACKSPACE
957 eventFlags:0]; 968 eventFlags:0];
958 } 969 }
959 970
960 - (void)deleteWordForward:(id)sender { 971 - (void)deleteWordForward:(id)sender {
961 [self handleAction:IDS_DELETE_WORD_FORWARD 972 [self handleAction:ui::TextEditCommand::DELETE_WORD_FORWARD
962 keyCode:ui::VKEY_DELETE 973 keyCode:ui::VKEY_DELETE
963 domCode:ui::DomCode::DEL 974 domCode:ui::DomCode::DEL
964 eventFlags:ui::EF_CONTROL_DOWN]; 975 eventFlags:ui::EF_CONTROL_DOWN];
965 } 976 }
966 977
967 - (void)deleteWordBackward:(id)sender { 978 - (void)deleteWordBackward:(id)sender {
968 [self handleAction:IDS_DELETE_WORD_BACKWARD 979 [self handleAction:ui::TextEditCommand::DELETE_WORD_BACKWARD
969 keyCode:ui::VKEY_BACK 980 keyCode:ui::VKEY_BACK
970 domCode:ui::DomCode::BACKSPACE 981 domCode:ui::DomCode::BACKSPACE
971 eventFlags:ui::EF_CONTROL_DOWN]; 982 eventFlags:ui::EF_CONTROL_DOWN];
972 } 983 }
973 984
974 - (void)deleteToBeginningOfLine:(id)sender { 985 - (void)deleteToBeginningOfLine:(id)sender {
975 [self handleAction:IDS_DELETE_TO_BEGINNING_OF_LINE 986 [self handleAction:ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE
976 keyCode:ui::VKEY_BACK 987 keyCode:ui::VKEY_BACK
977 domCode:ui::DomCode::BACKSPACE 988 domCode:ui::DomCode::BACKSPACE
978 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN]; 989 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN];
979 } 990 }
980 991
981 - (void)deleteToEndOfLine:(id)sender { 992 - (void)deleteToEndOfLine:(id)sender {
982 [self handleAction:IDS_DELETE_TO_END_OF_LINE 993 [self handleAction:ui::TextEditCommand::DELETE_TO_END_OF_LINE
983 keyCode:ui::VKEY_DELETE 994 keyCode:ui::VKEY_DELETE
984 domCode:ui::DomCode::DEL 995 domCode:ui::DomCode::DEL
985 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN]; 996 eventFlags:ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN];
986 } 997 }
987 998
988 - (void)deleteToBeginningOfParagraph:(id)sender { 999 - (void)deleteToBeginningOfParagraph:(id)sender {
989 [self deleteToBeginningOfLine:sender]; 1000 [self deleteToBeginningOfLine:sender];
990 } 1001 }
991 1002
992 - (void)deleteToEndOfParagraph:(id)sender { 1003 - (void)deleteToEndOfParagraph:(id)sender {
993 [self deleteToEndOfLine:sender]; 1004 [self deleteToEndOfLine:sender];
994 } 1005 }
995 1006
996 // Cancellation. 1007 // Cancellation.
997 1008
998 - (void)cancelOperation:(id)sender { 1009 - (void)cancelOperation:(id)sender {
999 [self handleAction:0 1010 [self handleAction:ui::TextEditCommand::INVALID_COMMAND
1000 keyCode:ui::VKEY_ESCAPE 1011 keyCode:ui::VKEY_ESCAPE
1001 domCode:ui::DomCode::ESCAPE 1012 domCode:ui::DomCode::ESCAPE
1002 eventFlags:0]; 1013 eventFlags:0];
1003 } 1014 }
1004 1015
1005 // Support for Services in context menus. 1016 // Support for Services in context menus.
1006 // Currently we only support reading and writing plain strings. 1017 // Currently we only support reading and writing plain strings.
1007 - (id)validRequestorForSendType:(NSString*)sendType 1018 - (id)validRequestorForSendType:(NSString*)sendType
1008 returnType:(NSString*)returnType { 1019 returnType:(NSString*)returnType {
1009 BOOL canWrite = [sendType isEqualToString:NSStringPboardType] && 1020 BOOL canWrite = [sendType isEqualToString:NSStringPboardType] &&
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 1198
1188 // NSUserInterfaceValidations protocol implementation. 1199 // NSUserInterfaceValidations protocol implementation.
1189 1200
1190 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { 1201 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item {
1191 if (!textInputClient_) 1202 if (!textInputClient_)
1192 return NO; 1203 return NO;
1193 1204
1194 SEL action = [item action]; 1205 SEL action = [item action];
1195 1206
1196 if (action == @selector(undo:)) 1207 if (action == @selector(undo:))
1197 return textInputClient_->IsEditCommandEnabled(IDS_APP_UNDO); 1208 return textInputClient_->IsTextEditCommandEnabled(
1209 ui::TextEditCommand::UNDO);
1198 if (action == @selector(redo:)) 1210 if (action == @selector(redo:))
1199 return textInputClient_->IsEditCommandEnabled(IDS_APP_REDO); 1211 return textInputClient_->IsTextEditCommandEnabled(
1212 ui::TextEditCommand::REDO);
1200 if (action == @selector(cut:)) 1213 if (action == @selector(cut:))
1201 return textInputClient_->IsEditCommandEnabled(IDS_APP_CUT); 1214 return textInputClient_->IsTextEditCommandEnabled(ui::TextEditCommand::CUT);
1202 if (action == @selector(copy:)) 1215 if (action == @selector(copy:))
1203 return textInputClient_->IsEditCommandEnabled(IDS_APP_COPY); 1216 return textInputClient_->IsTextEditCommandEnabled(
1217 ui::TextEditCommand::COPY);
1204 if (action == @selector(paste:)) 1218 if (action == @selector(paste:))
1205 return textInputClient_->IsEditCommandEnabled(IDS_APP_PASTE); 1219 return textInputClient_->IsTextEditCommandEnabled(
1220 ui::TextEditCommand::PASTE);
1206 if (action == @selector(selectAll:)) 1221 if (action == @selector(selectAll:))
1207 return textInputClient_->IsEditCommandEnabled(IDS_APP_SELECT_ALL); 1222 return textInputClient_->IsTextEditCommandEnabled(
1223 ui::TextEditCommand::SELECT_ALL);
1208 1224
1209 return NO; 1225 return NO;
1210 } 1226 }
1211 1227
1212 // NSDraggingSource protocol implementation. 1228 // NSDraggingSource protocol implementation.
1213 1229
1214 - (NSDragOperation)draggingSession:(NSDraggingSession*)session 1230 - (NSDragOperation)draggingSession:(NSDraggingSession*)session
1215 sourceOperationMaskForDraggingContext:(NSDraggingContext)context { 1231 sourceOperationMaskForDraggingContext:(NSDraggingContext)context {
1216 return NSDragOperationEvery; 1232 return NSDragOperationEvery;
1217 } 1233 }
(...skipping 14 matching lines...) Expand all
1232 } 1248 }
1233 1249
1234 return [super accessibilityAttributeValue:attribute]; 1250 return [super accessibilityAttributeValue:attribute];
1235 } 1251 }
1236 1252
1237 - (id)accessibilityHitTest:(NSPoint)point { 1253 - (id)accessibilityHitTest:(NSPoint)point {
1238 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; 1254 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point];
1239 } 1255 }
1240 1256
1241 @end 1257 @end
OLDNEW
« no previous file with comments | « ui/strings/ui_strings.grd ('k') | ui/views/controls/prefix_selector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698