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 <set> | 7 #include <set> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 #include "ui/aura/env.h" | 59 #include "ui/aura/env.h" |
60 #include "ui/aura/window.h" | 60 #include "ui/aura/window.h" |
61 #include "ui/aura/window_event_dispatcher.h" | 61 #include "ui/aura/window_event_dispatcher.h" |
62 #include "ui/aura/window_observer.h" | 62 #include "ui/aura/window_observer.h" |
63 #include "ui/aura/window_tracker.h" | 63 #include "ui/aura/window_tracker.h" |
64 #include "ui/aura/window_tree_host.h" | 64 #include "ui/aura/window_tree_host.h" |
65 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 65 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
66 #include "ui/base/hit_test.h" | 66 #include "ui/base/hit_test.h" |
67 #include "ui/base/ime/input_method.h" | 67 #include "ui/base/ime/input_method.h" |
68 #include "ui/base/ui_base_types.h" | 68 #include "ui/base/ui_base_types.h" |
| 69 #include "ui/compositor/compositor_vsync_manager.h" |
69 #include "ui/compositor/dip_util.h" | 70 #include "ui/compositor/dip_util.h" |
70 #include "ui/events/blink/blink_event_util.h" | 71 #include "ui/events/blink/blink_event_util.h" |
71 #include "ui/events/event.h" | 72 #include "ui/events/event.h" |
72 #include "ui/events/event_utils.h" | 73 #include "ui/events/event_utils.h" |
73 #include "ui/events/gestures/gesture_recognizer.h" | 74 #include "ui/events/gestures/gesture_recognizer.h" |
74 #include "ui/gfx/canvas.h" | 75 #include "ui/gfx/canvas.h" |
75 #include "ui/gfx/display.h" | 76 #include "ui/gfx/display.h" |
76 #include "ui/gfx/geometry/rect_conversions.h" | 77 #include "ui/gfx/geometry/rect_conversions.h" |
77 #include "ui/gfx/geometry/size_conversions.h" | 78 #include "ui/gfx/geometry/size_conversions.h" |
78 #include "ui/gfx/screen.h" | 79 #include "ui/gfx/screen.h" |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 synthetic_move_sent_(false), | 437 synthetic_move_sent_(false), |
437 cursor_visibility_state_in_renderer_(UNKNOWN), | 438 cursor_visibility_state_in_renderer_(UNKNOWN), |
438 #if defined(OS_WIN) | 439 #if defined(OS_WIN) |
439 legacy_render_widget_host_HWND_(NULL), | 440 legacy_render_widget_host_HWND_(NULL), |
440 legacy_window_destroyed_(false), | 441 legacy_window_destroyed_(false), |
441 showing_context_menu_(false), | 442 showing_context_menu_(false), |
442 #endif | 443 #endif |
443 has_snapped_to_boundary_(false), | 444 has_snapped_to_boundary_(false), |
444 touch_editing_client_(NULL), | 445 touch_editing_client_(NULL), |
445 is_guest_view_hack_(is_guest_view_hack), | 446 is_guest_view_hack_(is_guest_view_hack), |
446 begin_frame_observer_proxy_(this), | |
447 weak_ptr_factory_(this) { | 447 weak_ptr_factory_(this) { |
448 if (!is_guest_view_hack_) | 448 if (!is_guest_view_hack_) |
449 host_->SetView(this); | 449 host_->SetView(this); |
450 | 450 |
451 window_observer_.reset(new WindowObserver(this)); | 451 window_observer_.reset(new WindowObserver(this)); |
452 | 452 |
453 aura::client::SetTooltipText(window_, &tooltip_); | 453 aura::client::SetTooltipText(window_, &tooltip_); |
454 aura::client::SetActivationDelegate(window_, this); | 454 aura::client::SetActivationDelegate(window_, this); |
455 aura::client::SetFocusChangeObserver(window_, this); | 455 aura::client::SetFocusChangeObserver(window_, this); |
456 window_->set_layer_owner_delegate(delegated_frame_host_.get()); | 456 window_->set_layer_owner_delegate(delegated_frame_host_.get()); |
457 gfx::Screen::GetScreenFor(window_)->AddObserver(this); | 457 gfx::Screen::GetScreenFor(window_)->AddObserver(this); |
458 | 458 |
459 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> | 459 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> |
460 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; | 460 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; |
461 SetOverscrollControllerEnabled(overscroll_enabled); | 461 SetOverscrollControllerEnabled(overscroll_enabled); |
462 } | 462 } |
463 | 463 |
464 //////////////////////////////////////////////////////////////////////////////// | 464 //////////////////////////////////////////////////////////////////////////////// |
465 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: | 465 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: |
466 | 466 |
467 bool RenderWidgetHostViewAura::OnMessageReceived( | 467 bool RenderWidgetHostViewAura::OnMessageReceived( |
468 const IPC::Message& message) { | 468 const IPC::Message& message) { |
469 bool handled = true; | 469 bool handled = true; |
470 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAura, message) | 470 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAura, message) |
471 // TODO(kevers): Move to RenderWidgetHostViewImpl and consolidate IPC | 471 // TODO(kevers): Move to RenderWidgetHostViewImpl and consolidate IPC |
472 // messages for TextInput<State|Type>Changed. Corresponding code in | 472 // messages for TextInput<State|Type>Changed. Corresponding code in |
473 // RenderWidgetHostViewAndroid should also be moved at the same time. | 473 // RenderWidgetHostViewAndroid should also be moved at the same time. |
474 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, | 474 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, |
475 OnTextInputStateChanged) | 475 OnTextInputStateChanged) |
476 IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrames, | |
477 OnSetNeedsBeginFrames) | |
478 IPC_MESSAGE_UNHANDLED(handled = false) | 476 IPC_MESSAGE_UNHANDLED(handled = false) |
479 IPC_END_MESSAGE_MAP() | 477 IPC_END_MESSAGE_MAP() |
480 return handled; | 478 return handled; |
481 } | 479 } |
482 | 480 |
483 void RenderWidgetHostViewAura::InitAsChild( | 481 void RenderWidgetHostViewAura::InitAsChild( |
484 gfx::NativeView parent_view) { | 482 gfx::NativeView parent_view) { |
485 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); | 483 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); |
486 window_->Init(ui::LAYER_SOLID_COLOR); | 484 window_->Init(ui::LAYER_SOLID_COLOR); |
487 window_->SetName("RenderWidgetHostViewAura"); | 485 window_->SetName("RenderWidgetHostViewAura"); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 #endif | 695 #endif |
698 | 696 |
699 NOTIMPLEMENTED(); | 697 NOTIMPLEMENTED(); |
700 return static_cast<gfx::NativeViewAccessible>(NULL); | 698 return static_cast<gfx::NativeViewAccessible>(NULL); |
701 } | 699 } |
702 | 700 |
703 ui::TextInputClient* RenderWidgetHostViewAura::GetTextInputClient() { | 701 ui::TextInputClient* RenderWidgetHostViewAura::GetTextInputClient() { |
704 return this; | 702 return this; |
705 } | 703 } |
706 | 704 |
707 void RenderWidgetHostViewAura::OnSetNeedsBeginFrames(bool needs_begin_frames) { | |
708 begin_frame_observer_proxy_.SetNeedsBeginFrames(needs_begin_frames); | |
709 } | |
710 | |
711 void RenderWidgetHostViewAura::SendBeginFrame(const cc::BeginFrameArgs& args) { | |
712 delegated_frame_host_->SetVSyncParameters(args.frame_time, args.interval); | |
713 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); | |
714 } | |
715 | |
716 void RenderWidgetHostViewAura::SetKeyboardFocus() { | 705 void RenderWidgetHostViewAura::SetKeyboardFocus() { |
717 #if defined(OS_WIN) | 706 #if defined(OS_WIN) |
718 if (CanFocus()) { | 707 if (CanFocus()) { |
719 aura::WindowTreeHost* host = window_->GetHost(); | 708 aura::WindowTreeHost* host = window_->GetHost(); |
720 if (host) | 709 if (host) |
721 ::SetFocus(host->GetAcceleratedWidget()); | 710 ::SetFocus(host->GetAcceleratedWidget()); |
722 } | 711 } |
723 #endif | 712 #endif |
724 } | 713 } |
725 | 714 |
(...skipping 1907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2633 | 2622 |
2634 #if defined(OS_WIN) | 2623 #if defined(OS_WIN) |
2635 // The parent may have changed here. Ensure that the legacy window is | 2624 // The parent may have changed here. Ensure that the legacy window is |
2636 // reparented accordingly. | 2625 // reparented accordingly. |
2637 if (legacy_render_widget_host_HWND_) | 2626 if (legacy_render_widget_host_HWND_) |
2638 legacy_render_widget_host_HWND_->UpdateParent( | 2627 legacy_render_widget_host_HWND_->UpdateParent( |
2639 reinterpret_cast<HWND>(GetNativeViewId())); | 2628 reinterpret_cast<HWND>(GetNativeViewId())); |
2640 #endif | 2629 #endif |
2641 | 2630 |
2642 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); | 2631 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); |
2643 if (window_->GetHost()->compositor()) | |
2644 begin_frame_observer_proxy_.SetCompositor(window_->GetHost()->compositor()); | |
2645 } | 2632 } |
2646 | 2633 |
2647 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 2634 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
2648 aura::client::CursorClient* cursor_client = | 2635 aura::client::CursorClient* cursor_client = |
2649 aura::client::GetCursorClient(window_->GetRootWindow()); | 2636 aura::client::GetCursorClient(window_->GetRootWindow()); |
2650 if (cursor_client) | 2637 if (cursor_client) |
2651 cursor_client->RemoveObserver(this); | 2638 cursor_client->RemoveObserver(this); |
2652 | 2639 |
2653 DetachFromInputMethod(); | 2640 DetachFromInputMethod(); |
2654 | 2641 |
2655 window_->GetHost()->RemoveObserver(this); | 2642 window_->GetHost()->RemoveObserver(this); |
2656 delegated_frame_host_->ResetCompositor(); | 2643 delegated_frame_host_->ResetCompositor(); |
2657 begin_frame_observer_proxy_.ResetCompositor(); | |
2658 | 2644 |
2659 #if defined(OS_WIN) | 2645 #if defined(OS_WIN) |
2660 // Update the legacy window's parent temporarily to the desktop window. It | 2646 // Update the legacy window's parent temporarily to the desktop window. It |
2661 // will eventually get reparented to the right root. | 2647 // will eventually get reparented to the right root. |
2662 if (legacy_render_widget_host_HWND_) | 2648 if (legacy_render_widget_host_HWND_) |
2663 legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow()); | 2649 legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow()); |
2664 #endif | 2650 #endif |
2665 } | 2651 } |
2666 | 2652 |
2667 void RenderWidgetHostViewAura::DetachFromInputMethod() { | 2653 void RenderWidgetHostViewAura::DetachFromInputMethod() { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2759 int output_surface_id, | 2745 int output_surface_id, |
2760 const cc::CompositorFrameAck& ack) { | 2746 const cc::CompositorFrameAck& ack) { |
2761 host_->Send(new ViewMsg_ReclaimCompositorResources(host_->GetRoutingID(), | 2747 host_->Send(new ViewMsg_ReclaimCompositorResources(host_->GetRoutingID(), |
2762 output_surface_id, ack)); | 2748 output_surface_id, ack)); |
2763 } | 2749 } |
2764 | 2750 |
2765 void RenderWidgetHostViewAura::DelegatedFrameHostOnLostCompositorResources() { | 2751 void RenderWidgetHostViewAura::DelegatedFrameHostOnLostCompositorResources() { |
2766 host_->ScheduleComposite(); | 2752 host_->ScheduleComposite(); |
2767 } | 2753 } |
2768 | 2754 |
| 2755 void RenderWidgetHostViewAura::DelegatedFrameHostUpdateVSyncParameters( |
| 2756 const base::TimeTicks& timebase, |
| 2757 const base::TimeDelta& interval) { |
| 2758 host_->UpdateVSyncParameters(timebase, interval); |
| 2759 } |
| 2760 |
2769 void RenderWidgetHostViewAura::OnDidNavigateMainFrameToNewPage() { | 2761 void RenderWidgetHostViewAura::OnDidNavigateMainFrameToNewPage() { |
2770 ui::GestureRecognizer::Get()->CancelActiveTouches(window_); | 2762 ui::GestureRecognizer::Get()->CancelActiveTouches(window_); |
2771 } | 2763 } |
2772 | 2764 |
2773 //////////////////////////////////////////////////////////////////////////////// | 2765 //////////////////////////////////////////////////////////////////////////////// |
2774 // RenderWidgetHostViewBase, public: | 2766 // RenderWidgetHostViewBase, public: |
2775 | 2767 |
2776 // static | 2768 // static |
2777 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2769 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2778 GetScreenInfoForWindow(results, NULL); | 2770 GetScreenInfoForWindow(results, NULL); |
2779 } | 2771 } |
2780 | 2772 |
2781 } // namespace content | 2773 } // namespace content |
OLD | NEW |