OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #include "ui/aura/client/window_tree_client.h" | 55 #include "ui/aura/client/window_tree_client.h" |
56 #include "ui/aura/env.h" | 56 #include "ui/aura/env.h" |
57 #include "ui/aura/window.h" | 57 #include "ui/aura/window.h" |
58 #include "ui/aura/window_event_dispatcher.h" | 58 #include "ui/aura/window_event_dispatcher.h" |
59 #include "ui/aura/window_observer.h" | 59 #include "ui/aura/window_observer.h" |
60 #include "ui/aura/window_tracker.h" | 60 #include "ui/aura/window_tracker.h" |
61 #include "ui/aura/window_tree_host.h" | 61 #include "ui/aura/window_tree_host.h" |
62 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 62 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
63 #include "ui/base/hit_test.h" | 63 #include "ui/base/hit_test.h" |
64 #include "ui/base/ime/input_method.h" | 64 #include "ui/base/ime/input_method.h" |
| 65 #include "ui/base/ime/input_method_observer.h" |
65 #include "ui/base/ui_base_types.h" | 66 #include "ui/base/ui_base_types.h" |
66 #include "ui/compositor/compositor_vsync_manager.h" | 67 #include "ui/compositor/compositor_vsync_manager.h" |
67 #include "ui/compositor/dip_util.h" | 68 #include "ui/compositor/dip_util.h" |
68 #include "ui/events/event.h" | 69 #include "ui/events/event.h" |
69 #include "ui/events/event_utils.h" | 70 #include "ui/events/event_utils.h" |
70 #include "ui/events/gestures/gesture_recognizer.h" | 71 #include "ui/events/gestures/gesture_recognizer.h" |
71 #include "ui/gfx/canvas.h" | 72 #include "ui/gfx/canvas.h" |
72 #include "ui/gfx/display.h" | 73 #include "ui/gfx/display.h" |
73 #include "ui/gfx/geometry/rect_conversions.h" | 74 #include "ui/gfx/geometry/rect_conversions.h" |
74 #include "ui/gfx/geometry/size_conversions.h" | 75 #include "ui/gfx/geometry/size_conversions.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 318 |
318 if (event.type() == ui::ET_GESTURE_BEGIN) { | 319 if (event.type() == ui::ET_GESTURE_BEGIN) { |
319 const ui::GestureEvent& gesture = | 320 const ui::GestureEvent& gesture = |
320 static_cast<const ui::GestureEvent&>(event); | 321 static_cast<const ui::GestureEvent&>(event); |
321 return gesture.details().touch_points() == 1; | 322 return gesture.details().touch_points() == 1; |
322 } | 323 } |
323 | 324 |
324 return false; | 325 return false; |
325 } | 326 } |
326 | 327 |
| 328 class KeyboardBoundsUnchangedListener : public ui::InputMethodObserver { |
| 329 public: |
| 330 KeyboardBoundsUnchangedListener(ui::InputMethod* input_method, |
| 331 RenderWidgetHostImpl* host) |
| 332 : host_(host) { |
| 333 input_method->AddObserver(this); |
| 334 } |
| 335 |
| 336 private: |
| 337 ~KeyboardBoundsUnchangedListener() override {} |
| 338 |
| 339 // Overridden from ui::InputMethodObserver: |
| 340 void OnTextInputTypeChanged(const ui::TextInputClient* client) override {} |
| 341 void OnFocus() override {} |
| 342 void OnBlur() override {} |
| 343 void OnCaretBoundsChanged(const ui::TextInputClient* client) override {} |
| 344 void OnTextInputStateChanged(const ui::TextInputClient* client) override {} |
| 345 void OnInputMethodDestroyed(const ui::InputMethod* input_method) override { |
| 346 delete this; |
| 347 } |
| 348 void OnShowImeIfNeeded() override {} |
| 349 void OnKeyboardBoundsUnchanged() override { |
| 350 host_->Send(new ViewMsg_FocusChangeComplete(host_->GetRoutingID())); |
| 351 } |
| 352 |
| 353 RenderWidgetHostImpl* const host_; |
| 354 |
| 355 DISALLOW_COPY_AND_ASSIGN(KeyboardBoundsUnchangedListener); |
| 356 }; |
| 357 |
327 } // namespace | 358 } // namespace |
328 | 359 |
329 // We need to watch for mouse events outside a Web Popup or its parent | 360 // We need to watch for mouse events outside a Web Popup or its parent |
330 // and dismiss the popup for certain events. | 361 // and dismiss the popup for certain events. |
331 class RenderWidgetHostViewAura::EventFilterForPopupExit | 362 class RenderWidgetHostViewAura::EventFilterForPopupExit |
332 : public ui::EventHandler { | 363 : public ui::EventHandler { |
333 public: | 364 public: |
334 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) | 365 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) |
335 : rwhva_(rwhva) { | 366 : rwhva_(rwhva) { |
336 DCHECK(rwhva_); | 367 DCHECK(rwhva_); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 aura::client::SetTooltipText(window_, &tooltip_); | 477 aura::client::SetTooltipText(window_, &tooltip_); |
447 aura::client::SetActivationDelegate(window_, this); | 478 aura::client::SetActivationDelegate(window_, this); |
448 aura::client::SetActivationChangeObserver(window_, this); | 479 aura::client::SetActivationChangeObserver(window_, this); |
449 aura::client::SetFocusChangeObserver(window_, this); | 480 aura::client::SetFocusChangeObserver(window_, this); |
450 window_->set_layer_owner_delegate(delegated_frame_host_.get()); | 481 window_->set_layer_owner_delegate(delegated_frame_host_.get()); |
451 gfx::Screen::GetScreenFor(window_)->AddObserver(this); | 482 gfx::Screen::GetScreenFor(window_)->AddObserver(this); |
452 | 483 |
453 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> | 484 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> |
454 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; | 485 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; |
455 SetOverscrollControllerEnabled(overscroll_enabled); | 486 SetOverscrollControllerEnabled(overscroll_enabled); |
| 487 |
| 488 if (GetInputMethod()) |
| 489 new KeyboardBoundsUnchangedListener(GetInputMethod(), host_); |
456 } | 490 } |
457 | 491 |
458 //////////////////////////////////////////////////////////////////////////////// | 492 //////////////////////////////////////////////////////////////////////////////// |
459 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: | 493 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: |
460 | 494 |
461 bool RenderWidgetHostViewAura::OnMessageReceived( | 495 bool RenderWidgetHostViewAura::OnMessageReceived( |
462 const IPC::Message& message) { | 496 const IPC::Message& message) { |
463 bool handled = true; | 497 bool handled = true; |
464 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAura, message) | 498 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAura, message) |
465 // TODO(kevers): Move to RenderWidgetHostViewImpl and consolidate IPC | 499 // TODO(kevers): Move to RenderWidgetHostViewImpl and consolidate IPC |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 } | 893 } |
860 } | 894 } |
861 | 895 |
862 void RenderWidgetHostViewAura::OnTextInputStateChanged( | 896 void RenderWidgetHostViewAura::OnTextInputStateChanged( |
863 const ViewHostMsg_TextInputState_Params& params) { | 897 const ViewHostMsg_TextInputState_Params& params) { |
864 text_input_flags_ = params.flags; | 898 text_input_flags_ = params.flags; |
865 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) { | 899 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) { |
866 if (GetInputMethod()) | 900 if (GetInputMethod()) |
867 GetInputMethod()->ShowImeIfNeeded(); | 901 GetInputMethod()->ShowImeIfNeeded(); |
868 } | 902 } |
| 903 |
| 904 if (!GetInputMethod() || !GetInputMethod()->SupportsOnScreenKeyboard()) |
| 905 host_->Send(new ViewMsg_FocusChangeComplete(host_->GetRoutingID())); |
869 } | 906 } |
870 | 907 |
871 void RenderWidgetHostViewAura::ImeCancelComposition() { | 908 void RenderWidgetHostViewAura::ImeCancelComposition() { |
872 if (GetInputMethod()) | 909 if (GetInputMethod()) |
873 GetInputMethod()->CancelComposition(this); | 910 GetInputMethod()->CancelComposition(this); |
874 has_composition_text_ = false; | 911 has_composition_text_ = false; |
875 } | 912 } |
876 | 913 |
877 void RenderWidgetHostViewAura::ImeCompositionRangeChanged( | 914 void RenderWidgetHostViewAura::ImeCompositionRangeChanged( |
878 const gfx::Range& range, | 915 const gfx::Range& range, |
(...skipping 1756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2635 | 2672 |
2636 //////////////////////////////////////////////////////////////////////////////// | 2673 //////////////////////////////////////////////////////////////////////////////// |
2637 // RenderWidgetHostViewBase, public: | 2674 // RenderWidgetHostViewBase, public: |
2638 | 2675 |
2639 // static | 2676 // static |
2640 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2677 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2641 GetScreenInfoForWindow(results, NULL); | 2678 GetScreenInfoForWindow(results, NULL); |
2642 } | 2679 } |
2643 | 2680 |
2644 } // namespace content | 2681 } // namespace content |
OLD | NEW |