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

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

Issue 1177503003: Remove the 2-level input method system & InputMethodBridge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased & removed views::View::GetTextInputClient & removed GetFocusedTextInputClient. Created 5 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_native_widget.h" 5 #import "ui/views/cocoa/bridged_native_widget.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #import "base/mac/foundation_util.h" 10 #import "base/mac/foundation_util.h"
11 #include "base/mac/mac_util.h" 11 #include "base/mac/mac_util.h"
12 #import "base/mac/sdk_forward_declarations.h" 12 #import "base/mac/sdk_forward_declarations.h"
13 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
14 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" 14 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h"
15 #include "ui/base/hit_test.h" 15 #include "ui/base/hit_test.h"
16 #include "ui/base/ime/input_method.h" 16 #include "ui/base/ime/input_method.h"
17 #include "ui/base/ime/input_method_factory.h" 17 #include "ui/base/ime/input_method_factory.h"
18 #include "ui/gfx/display.h" 18 #include "ui/gfx/display.h"
19 #include "ui/gfx/geometry/dip_util.h" 19 #include "ui/gfx/geometry/dip_util.h"
20 #import "ui/gfx/mac/coordinate_conversion.h" 20 #import "ui/gfx/mac/coordinate_conversion.h"
21 #import "ui/gfx/mac/nswindow_frame_controls.h" 21 #import "ui/gfx/mac/nswindow_frame_controls.h"
22 #include "ui/gfx/screen.h" 22 #include "ui/gfx/screen.h"
23 #import "ui/views/cocoa/bridged_content_view.h" 23 #import "ui/views/cocoa/bridged_content_view.h"
24 #import "ui/views/cocoa/cocoa_mouse_capture.h" 24 #import "ui/views/cocoa/cocoa_mouse_capture.h"
25 #include "ui/views/cocoa/tooltip_manager_mac.h" 25 #include "ui/views/cocoa/tooltip_manager_mac.h"
26 #import "ui/views/cocoa/views_nswindow_delegate.h" 26 #import "ui/views/cocoa/views_nswindow_delegate.h"
27 #import "ui/views/cocoa/widget_owner_nswindow_adapter.h" 27 #import "ui/views/cocoa/widget_owner_nswindow_adapter.h"
28 #include "ui/views/ime/input_method_bridge.h"
29 #include "ui/views/ime/null_input_method.h"
30 #include "ui/views/view.h" 28 #include "ui/views/view.h"
31 #include "ui/views/views_delegate.h" 29 #include "ui/views/views_delegate.h"
32 #include "ui/views/widget/native_widget_mac.h" 30 #include "ui/views/widget/native_widget_mac.h"
33 #include "ui/views/widget/widget.h" 31 #include "ui/views/widget/widget.h"
34 #include "ui/views/widget/widget_aura_utils.h" 32 #include "ui/views/widget/widget_aura_utils.h"
35 #include "ui/views/widget/widget_delegate.h" 33 #include "ui/views/widget/widget_delegate.h"
36 34
37 // The NSView that hosts the composited CALayer drawing the UI. It fills the 35 // The NSView that hosts the composited CALayer drawing the UI. It fills the
38 // window but is not hittable so that accessibility hit tests always go to the 36 // window but is not hittable so that accessibility hit tests always go to the
39 // BridgedContentView. 37 // BridgedContentView.
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 bool shows_resize_controls = 698 bool shows_resize_controls =
701 is_resizable && (min_size.IsEmpty() || min_size != max_size); 699 is_resizable && (min_size.IsEmpty() || min_size != max_size);
702 bool shows_fullscreen_controls = 700 bool shows_fullscreen_controls =
703 is_resizable && widget->widget_delegate()->CanMaximize(); 701 is_resizable && widget->widget_delegate()->CanMaximize();
704 702
705 gfx::ApplyNSWindowSizeConstraints(window_, min_size, max_size, 703 gfx::ApplyNSWindowSizeConstraints(window_, min_size, max_size,
706 shows_resize_controls, 704 shows_resize_controls,
707 shows_fullscreen_controls); 705 shows_fullscreen_controls);
708 } 706 }
709 707
710 InputMethod* BridgedNativeWidget::CreateInputMethod() { 708 ui::InputMethod* BridgedNativeWidget::GetInputMethod() {
711 return new InputMethodBridge(this, GetHostInputMethod(), true);
712 }
713
714 ui::InputMethod* BridgedNativeWidget::GetHostInputMethod() {
715 if (!input_method_) { 709 if (!input_method_) {
716 // Delegate is NULL because Mac IME does not need DispatchKeyEventPostIME 710 // Delegate is NULL because Mac IME does not need DispatchKeyEventPostIME
717 // callbacks. 711 // callbacks.
718 input_method_ = ui::CreateInputMethod(NULL, nil); 712 input_method_ = ui::CreateInputMethod(NULL, nil);
713 input_method_->OnFocus();
719 } 714 }
720 return input_method_.get(); 715 return input_method_.get();
721 } 716 }
722 717
723 gfx::Rect BridgedNativeWidget::GetRestoredBounds() const { 718 gfx::Rect BridgedNativeWidget::GetRestoredBounds() const {
724 if (target_fullscreen_state_ || in_fullscreen_transition_) 719 if (target_fullscreen_state_ || in_fullscreen_transition_)
725 return bounds_before_fullscreen_; 720 return bounds_before_fullscreen_;
726 721
727 return gfx::ScreenRectFromNSRect([window_ frame]); 722 return gfx::ScreenRectFromNSRect([window_ frame]);
728 } 723 }
(...skipping 19 matching lines...) Expand all
748 layer()->SetFillsBoundsOpaquely(!translucent); 743 layer()->SetFillsBoundsOpaquely(!translucent);
749 if (translucent) { 744 if (translucent) {
750 [window_ setOpaque:NO]; 745 [window_ setOpaque:NO];
751 [window_ setBackgroundColor:[NSColor clearColor]]; 746 [window_ setBackgroundColor:[NSColor clearColor]];
752 } 747 }
753 748
754 UpdateLayerProperties(); 749 UpdateLayerProperties();
755 } 750 }
756 751
757 //////////////////////////////////////////////////////////////////////////////// 752 ////////////////////////////////////////////////////////////////////////////////
758 // BridgedNativeWidget, internal::InputMethodDelegate:
759
760 void BridgedNativeWidget::DispatchKeyEventPostIME(const ui::KeyEvent& key) {
761 DCHECK(focus_manager_);
762 native_widget_mac_->GetWidget()->OnKeyEvent(const_cast<ui::KeyEvent*>(&key));
763 if (!key.handled())
764 focus_manager_->OnKeyEvent(key);
765 }
766
767 ////////////////////////////////////////////////////////////////////////////////
768 // BridgedNativeWidget, CocoaMouseCaptureDelegate: 753 // BridgedNativeWidget, CocoaMouseCaptureDelegate:
769 754
770 void BridgedNativeWidget::PostCapturedEvent(NSEvent* event) { 755 void BridgedNativeWidget::PostCapturedEvent(NSEvent* event) {
771 [bridged_view_ processCapturedMouseEvent:event]; 756 [bridged_view_ processCapturedMouseEvent:event];
772 } 757 }
773 758
774 void BridgedNativeWidget::OnMouseCaptureLost() { 759 void BridgedNativeWidget::OnMouseCaptureLost() {
775 native_widget_mac_->GetWidget()->OnMouseCaptureLost(); 760 native_widget_mac_->GetWidget()->OnMouseCaptureLost();
776 } 761 }
777 762
778 //////////////////////////////////////////////////////////////////////////////// 763 ////////////////////////////////////////////////////////////////////////////////
779 // BridgedNativeWidget, FocusChangeListener: 764 // BridgedNativeWidget, FocusChangeListener:
780 765
781 void BridgedNativeWidget::OnWillChangeFocus(View* focused_before, 766 void BridgedNativeWidget::OnWillChangeFocus(View* focused_before,
782 View* focused_now) { 767 View* focused_now) {
783 } 768 }
784 769
785 void BridgedNativeWidget::OnDidChangeFocus(View* focused_before, 770 void BridgedNativeWidget::OnDidChangeFocus(View* focused_before,
786 View* focused_now) { 771 View* focused_now) {
787 ui::TextInputClient* input_client = 772 ui::TextInputClient* input_client =
788 focused_now ? focused_now->GetTextInputClient() : NULL; 773 focused_now ? focused_now->GetTextInputClient() : NULL;
yukawa 2015/06/16 02:45:03 Mac build fails with |focused_now->GetTextInputCli
Shu Chen 2015/06/16 05:15:26 Done.
789 [bridged_view_ setTextInputClient:input_client]; 774 [bridged_view_ setTextInputClient:input_client];
790 } 775 }
791 776
792 //////////////////////////////////////////////////////////////////////////////// 777 ////////////////////////////////////////////////////////////////////////////////
793 // BridgedNativeWidget, LayerDelegate: 778 // BridgedNativeWidget, LayerDelegate:
794 779
795 void BridgedNativeWidget::OnPaintLayer(const ui::PaintContext& context) { 780 void BridgedNativeWidget::OnPaintLayer(const ui::PaintContext& context) {
796 DCHECK(window_visible_); 781 DCHECK(window_visible_);
797 native_widget_mac_->GetWidget()->OnNativeWidgetPaint(context); 782 native_widget_mac_->GetWidget()->OnNativeWidgetPaint(context);
798 } 783 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 [bridged_view_ setMouseDownCanMoveWindow:draggable]; 1010 [bridged_view_ setMouseDownCanMoveWindow:draggable];
1026 // AppKit will not update its cache of mouseDownCanMoveWindow unless something 1011 // AppKit will not update its cache of mouseDownCanMoveWindow unless something
1027 // changes. Previously we tried adding an NSView and removing it, but for some 1012 // changes. Previously we tried adding an NSView and removing it, but for some
1028 // reason it required reposting the mouse-down event, and didn't always work. 1013 // reason it required reposting the mouse-down event, and didn't always work.
1029 // Calling the below seems to be an effective solution. 1014 // Calling the below seems to be an effective solution.
1030 [window_ setMovableByWindowBackground:NO]; 1015 [window_ setMovableByWindowBackground:NO];
1031 [window_ setMovableByWindowBackground:YES]; 1016 [window_ setMovableByWindowBackground:YES];
1032 } 1017 }
1033 1018
1034 } // namespace views 1019 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698