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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 #include "ui/aura/env.h" | 57 #include "ui/aura/env.h" |
58 #include "ui/aura/window.h" | 58 #include "ui/aura/window.h" |
59 #include "ui/aura/window_event_dispatcher.h" | 59 #include "ui/aura/window_event_dispatcher.h" |
60 #include "ui/aura/window_observer.h" | 60 #include "ui/aura/window_observer.h" |
61 #include "ui/aura/window_tracker.h" | 61 #include "ui/aura/window_tracker.h" |
62 #include "ui/aura/window_tree_host.h" | 62 #include "ui/aura/window_tree_host.h" |
63 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 63 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
64 #include "ui/base/hit_test.h" | 64 #include "ui/base/hit_test.h" |
65 #include "ui/base/ime/input_method.h" | 65 #include "ui/base/ime/input_method.h" |
66 #include "ui/base/ui_base_types.h" | 66 #include "ui/base/ui_base_types.h" |
67 #include "ui/compositor/compositor_vsync_manager.h" | |
68 #include "ui/compositor/dip_util.h" | 67 #include "ui/compositor/dip_util.h" |
69 #include "ui/events/event.h" | 68 #include "ui/events/event.h" |
70 #include "ui/events/event_utils.h" | 69 #include "ui/events/event_utils.h" |
71 #include "ui/events/gestures/gesture_recognizer.h" | 70 #include "ui/events/gestures/gesture_recognizer.h" |
72 #include "ui/gfx/canvas.h" | 71 #include "ui/gfx/canvas.h" |
73 #include "ui/gfx/display.h" | 72 #include "ui/gfx/display.h" |
74 #include "ui/gfx/geometry/rect_conversions.h" | 73 #include "ui/gfx/geometry/rect_conversions.h" |
75 #include "ui/gfx/geometry/size_conversions.h" | 74 #include "ui/gfx/geometry/size_conversions.h" |
76 #include "ui/gfx/screen.h" | 75 #include "ui/gfx/screen.h" |
77 #include "ui/gfx/skia_util.h" | 76 #include "ui/gfx/skia_util.h" |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 paint_canvas_(NULL), | 445 paint_canvas_(NULL), |
447 synthetic_move_sent_(false), | 446 synthetic_move_sent_(false), |
448 cursor_visibility_state_in_renderer_(UNKNOWN), | 447 cursor_visibility_state_in_renderer_(UNKNOWN), |
449 #if defined(OS_WIN) | 448 #if defined(OS_WIN) |
450 legacy_render_widget_host_HWND_(NULL), | 449 legacy_render_widget_host_HWND_(NULL), |
451 legacy_window_destroyed_(false), | 450 legacy_window_destroyed_(false), |
452 #endif | 451 #endif |
453 has_snapped_to_boundary_(false), | 452 has_snapped_to_boundary_(false), |
454 touch_editing_client_(NULL), | 453 touch_editing_client_(NULL), |
455 is_guest_view_hack_(is_guest_view_hack), | 454 is_guest_view_hack_(is_guest_view_hack), |
| 455 begin_frame_observer_proxy_(this), |
456 weak_ptr_factory_(this) { | 456 weak_ptr_factory_(this) { |
457 if (!is_guest_view_hack_) | 457 if (!is_guest_view_hack_) |
458 host_->SetView(this); | 458 host_->SetView(this); |
459 | 459 |
460 window_observer_.reset(new WindowObserver(this)); | 460 window_observer_.reset(new WindowObserver(this)); |
461 aura::client::SetTooltipText(window_, &tooltip_); | 461 aura::client::SetTooltipText(window_, &tooltip_); |
462 aura::client::SetActivationDelegate(window_, this); | 462 aura::client::SetActivationDelegate(window_, this); |
463 aura::client::SetActivationChangeObserver(window_, this); | 463 aura::client::SetActivationChangeObserver(window_, this); |
464 aura::client::SetFocusChangeObserver(window_, this); | 464 aura::client::SetFocusChangeObserver(window_, this); |
465 window_->set_layer_owner_delegate(delegated_frame_host_.get()); | 465 window_->set_layer_owner_delegate(delegated_frame_host_.get()); |
466 gfx::Screen::GetScreenFor(window_)->AddObserver(this); | 466 gfx::Screen::GetScreenFor(window_)->AddObserver(this); |
467 | 467 |
468 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> | 468 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> |
469 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; | 469 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; |
470 SetOverscrollControllerEnabled(overscroll_enabled); | 470 SetOverscrollControllerEnabled(overscroll_enabled); |
471 } | 471 } |
472 | 472 |
473 //////////////////////////////////////////////////////////////////////////////// | 473 //////////////////////////////////////////////////////////////////////////////// |
474 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: | 474 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: |
475 | 475 |
476 bool RenderWidgetHostViewAura::OnMessageReceived( | 476 bool RenderWidgetHostViewAura::OnMessageReceived( |
477 const IPC::Message& message) { | 477 const IPC::Message& message) { |
478 bool handled = true; | 478 bool handled = true; |
479 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAura, message) | 479 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAura, message) |
480 // TODO(kevers): Move to RenderWidgetHostViewImpl and consolidate IPC | 480 // TODO(kevers): Move to RenderWidgetHostViewImpl and consolidate IPC |
481 // messages for TextInput<State|Type>Changed. Corresponding code in | 481 // messages for TextInput<State|Type>Changed. Corresponding code in |
482 // RenderWidgetHostViewAndroid should also be moved at the same time. | 482 // RenderWidgetHostViewAndroid should also be moved at the same time. |
483 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, | 483 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, |
484 OnTextInputStateChanged) | 484 OnTextInputStateChanged) |
| 485 IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrames, |
| 486 OnSetNeedsBeginFrames) |
485 IPC_MESSAGE_UNHANDLED(handled = false) | 487 IPC_MESSAGE_UNHANDLED(handled = false) |
486 IPC_END_MESSAGE_MAP() | 488 IPC_END_MESSAGE_MAP() |
487 return handled; | 489 return handled; |
488 } | 490 } |
489 | 491 |
490 void RenderWidgetHostViewAura::InitAsChild( | 492 void RenderWidgetHostViewAura::InitAsChild( |
491 gfx::NativeView parent_view) { | 493 gfx::NativeView parent_view) { |
492 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); | 494 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); |
493 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); | 495 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
494 window_->SetName("RenderWidgetHostViewAura"); | 496 window_->SetName("RenderWidgetHostViewAura"); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 #endif | 706 #endif |
705 | 707 |
706 NOTIMPLEMENTED(); | 708 NOTIMPLEMENTED(); |
707 return static_cast<gfx::NativeViewAccessible>(NULL); | 709 return static_cast<gfx::NativeViewAccessible>(NULL); |
708 } | 710 } |
709 | 711 |
710 ui::TextInputClient* RenderWidgetHostViewAura::GetTextInputClient() { | 712 ui::TextInputClient* RenderWidgetHostViewAura::GetTextInputClient() { |
711 return this; | 713 return this; |
712 } | 714 } |
713 | 715 |
| 716 void RenderWidgetHostViewAura::OnSetNeedsBeginFrames(bool needs_begin_frames) { |
| 717 begin_frame_observer_proxy_.SetNeedsBeginFrames(needs_begin_frames); |
| 718 } |
| 719 |
| 720 void RenderWidgetHostViewAura::SendBeginFrame(const cc::BeginFrameArgs& args) { |
| 721 delegated_frame_host_->SetVSyncParameters(args.frame_time, args.interval); |
| 722 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); |
| 723 } |
| 724 |
714 void RenderWidgetHostViewAura::SetKeyboardFocus() { | 725 void RenderWidgetHostViewAura::SetKeyboardFocus() { |
715 #if defined(OS_WIN) | 726 #if defined(OS_WIN) |
716 if (CanFocus()) { | 727 if (CanFocus()) { |
717 aura::WindowTreeHost* host = window_->GetHost(); | 728 aura::WindowTreeHost* host = window_->GetHost(); |
718 if (host) | 729 if (host) |
719 ::SetFocus(host->GetAcceleratedWidget()); | 730 ::SetFocus(host->GetAcceleratedWidget()); |
720 } | 731 } |
721 #endif | 732 #endif |
722 } | 733 } |
723 | 734 |
(...skipping 1848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2572 | 2583 |
2573 #if defined(OS_WIN) | 2584 #if defined(OS_WIN) |
2574 // The parent may have changed here. Ensure that the legacy window is | 2585 // The parent may have changed here. Ensure that the legacy window is |
2575 // reparented accordingly. | 2586 // reparented accordingly. |
2576 if (legacy_render_widget_host_HWND_) | 2587 if (legacy_render_widget_host_HWND_) |
2577 legacy_render_widget_host_HWND_->UpdateParent( | 2588 legacy_render_widget_host_HWND_->UpdateParent( |
2578 reinterpret_cast<HWND>(GetNativeViewId())); | 2589 reinterpret_cast<HWND>(GetNativeViewId())); |
2579 #endif | 2590 #endif |
2580 | 2591 |
2581 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); | 2592 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); |
| 2593 begin_frame_observer_proxy_.SetCompositor(window_->GetHost()->compositor()); |
2582 } | 2594 } |
2583 | 2595 |
2584 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 2596 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
2585 aura::client::CursorClient* cursor_client = | 2597 aura::client::CursorClient* cursor_client = |
2586 aura::client::GetCursorClient(window_->GetRootWindow()); | 2598 aura::client::GetCursorClient(window_->GetRootWindow()); |
2587 if (cursor_client) | 2599 if (cursor_client) |
2588 cursor_client->RemoveObserver(this); | 2600 cursor_client->RemoveObserver(this); |
2589 | 2601 |
2590 DetachFromInputMethod(); | 2602 DetachFromInputMethod(); |
2591 | 2603 |
2592 window_->GetHost()->RemoveObserver(this); | 2604 window_->GetHost()->RemoveObserver(this); |
2593 delegated_frame_host_->ResetCompositor(); | 2605 delegated_frame_host_->ResetCompositor(); |
| 2606 begin_frame_observer_proxy_.ResetCompositor(); |
2594 | 2607 |
2595 #if defined(OS_WIN) | 2608 #if defined(OS_WIN) |
2596 // Update the legacy window's parent temporarily to the desktop window. It | 2609 // Update the legacy window's parent temporarily to the desktop window. It |
2597 // will eventually get reparented to the right root. | 2610 // will eventually get reparented to the right root. |
2598 if (legacy_render_widget_host_HWND_) | 2611 if (legacy_render_widget_host_HWND_) |
2599 legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow()); | 2612 legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow()); |
2600 #endif | 2613 #endif |
2601 } | 2614 } |
2602 | 2615 |
2603 void RenderWidgetHostViewAura::DetachFromInputMethod() { | 2616 void RenderWidgetHostViewAura::DetachFromInputMethod() { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2695 int output_surface_id, | 2708 int output_surface_id, |
2696 const cc::CompositorFrameAck& ack) { | 2709 const cc::CompositorFrameAck& ack) { |
2697 host_->Send(new ViewMsg_ReclaimCompositorResources(host_->GetRoutingID(), | 2710 host_->Send(new ViewMsg_ReclaimCompositorResources(host_->GetRoutingID(), |
2698 output_surface_id, ack)); | 2711 output_surface_id, ack)); |
2699 } | 2712 } |
2700 | 2713 |
2701 void RenderWidgetHostViewAura::DelegatedFrameHostOnLostCompositorResources() { | 2714 void RenderWidgetHostViewAura::DelegatedFrameHostOnLostCompositorResources() { |
2702 host_->ScheduleComposite(); | 2715 host_->ScheduleComposite(); |
2703 } | 2716 } |
2704 | 2717 |
2705 void RenderWidgetHostViewAura::DelegatedFrameHostUpdateVSyncParameters( | |
2706 const base::TimeTicks& timebase, | |
2707 const base::TimeDelta& interval) { | |
2708 host_->UpdateVSyncParameters(timebase, interval); | |
2709 } | |
2710 | |
2711 void RenderWidgetHostViewAura::OnDidNavigateMainFrameToNewPage() { | 2718 void RenderWidgetHostViewAura::OnDidNavigateMainFrameToNewPage() { |
2712 ui::GestureRecognizer::Get()->CancelActiveTouches(window_); | 2719 ui::GestureRecognizer::Get()->CancelActiveTouches(window_); |
2713 } | 2720 } |
2714 | 2721 |
2715 //////////////////////////////////////////////////////////////////////////////// | 2722 //////////////////////////////////////////////////////////////////////////////// |
2716 // RenderWidgetHostViewBase, public: | 2723 // RenderWidgetHostViewBase, public: |
2717 | 2724 |
2718 // static | 2725 // static |
2719 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2726 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2720 GetScreenInfoForWindow(results, NULL); | 2727 GetScreenInfoForWindow(results, NULL); |
2721 } | 2728 } |
2722 | 2729 |
2723 } // namespace content | 2730 } // namespace content |
OLD | NEW |