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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 // RenderWidgetHostViewAura, public: | 359 // RenderWidgetHostViewAura, public: |
360 | 360 |
361 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host, | 361 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host, |
362 bool is_guest_view_hack) | 362 bool is_guest_view_hack) |
363 : host_(RenderWidgetHostImpl::From(host)), | 363 : host_(RenderWidgetHostImpl::From(host)), |
364 window_(nullptr), | 364 window_(nullptr), |
365 delegated_frame_host_(new DelegatedFrameHost(this)), | 365 delegated_frame_host_(new DelegatedFrameHost(this)), |
366 in_shutdown_(false), | 366 in_shutdown_(false), |
367 in_bounds_changed_(false), | 367 in_bounds_changed_(false), |
368 is_fullscreen_(false), | 368 is_fullscreen_(false), |
369 popup_parent_host_view_(NULL), | 369 popup_parent_host_view_(nullptr), |
370 popup_child_host_view_(NULL), | 370 popup_child_host_view_(nullptr), |
371 is_loading_(false), | 371 is_loading_(false), |
372 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 372 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
373 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), | 373 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
374 text_input_flags_(0), | 374 text_input_flags_(0), |
375 can_compose_inline_(true), | 375 can_compose_inline_(true), |
376 has_composition_text_(false), | 376 has_composition_text_(false), |
377 accept_return_character_(false), | 377 accept_return_character_(false), |
| 378 begin_frame_source_(nullptr), |
| 379 needs_begin_frames_(false), |
378 synthetic_move_sent_(false), | 380 synthetic_move_sent_(false), |
379 cursor_visibility_state_in_renderer_(UNKNOWN), | 381 cursor_visibility_state_in_renderer_(UNKNOWN), |
380 #if defined(OS_WIN) | 382 #if defined(OS_WIN) |
381 legacy_render_widget_host_HWND_(NULL), | 383 legacy_render_widget_host_HWND_(nullptr), |
382 legacy_window_destroyed_(false), | 384 legacy_window_destroyed_(false), |
383 #endif | 385 #endif |
384 has_snapped_to_boundary_(false), | 386 has_snapped_to_boundary_(false), |
385 is_guest_view_hack_(is_guest_view_hack), | 387 is_guest_view_hack_(is_guest_view_hack), |
386 begin_frame_observer_proxy_(this), | |
387 set_focus_on_mouse_down_or_key_event_(false), | 388 set_focus_on_mouse_down_or_key_event_(false), |
388 device_scale_factor_(0.0f), | 389 device_scale_factor_(0.0f), |
389 disable_input_event_router_for_testing_(false), | 390 disable_input_event_router_for_testing_(false), |
390 weak_ptr_factory_(this) { | 391 weak_ptr_factory_(this) { |
391 if (!is_guest_view_hack_) | 392 if (!is_guest_view_hack_) |
392 host_->SetView(this); | 393 host_->SetView(this); |
393 | 394 |
394 // Let the page-level input event router know about our surface ID | 395 // Let the page-level input event router know about our surface ID |
395 // namespace for surface-based hit testing. | 396 // namespace for surface-based hit testing. |
396 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { | 397 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 | 650 |
650 NOTIMPLEMENTED(); | 651 NOTIMPLEMENTED(); |
651 return static_cast<gfx::NativeViewAccessible>(NULL); | 652 return static_cast<gfx::NativeViewAccessible>(NULL); |
652 } | 653 } |
653 | 654 |
654 ui::TextInputClient* RenderWidgetHostViewAura::GetTextInputClient() { | 655 ui::TextInputClient* RenderWidgetHostViewAura::GetTextInputClient() { |
655 return this; | 656 return this; |
656 } | 657 } |
657 | 658 |
658 void RenderWidgetHostViewAura::OnSetNeedsBeginFrames(bool needs_begin_frames) { | 659 void RenderWidgetHostViewAura::OnSetNeedsBeginFrames(bool needs_begin_frames) { |
659 begin_frame_observer_proxy_.SetNeedsBeginFrames(needs_begin_frames); | 660 if (needs_begin_frames_ == needs_begin_frames) |
| 661 return; |
| 662 |
| 663 needs_begin_frames_ = needs_begin_frames; |
| 664 if (begin_frame_source_) { |
| 665 if (needs_begin_frames_) |
| 666 begin_frame_source_->AddObserver(this); |
| 667 else |
| 668 begin_frame_source_->RemoveObserver(this); |
| 669 } |
660 } | 670 } |
661 | 671 |
662 void RenderWidgetHostViewAura::SendBeginFrame(const cc::BeginFrameArgs& args) { | 672 bool RenderWidgetHostViewAura::OnBeginFrameDerivedImpl( |
| 673 const cc::BeginFrameArgs& args) { |
663 delegated_frame_host_->SetVSyncParameters(args.frame_time, args.interval); | 674 delegated_frame_host_->SetVSyncParameters(args.frame_time, args.interval); |
664 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); | 675 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); |
| 676 return true; |
| 677 } |
| 678 |
| 679 void RenderWidgetHostViewAura::OnBeginFrameSourcePausedChanged(bool paused) { |
| 680 // Ignored for now. If the begin frame source is paused, the renderer |
| 681 // doesn't need to be informed about it and will just not receive more |
| 682 // begin frames. |
665 } | 683 } |
666 | 684 |
667 void RenderWidgetHostViewAura::SetKeyboardFocus() { | 685 void RenderWidgetHostViewAura::SetKeyboardFocus() { |
668 #if defined(OS_WIN) | 686 #if defined(OS_WIN) |
669 if (CanFocus()) { | 687 if (CanFocus()) { |
670 aura::WindowTreeHost* host = window_->GetHost(); | 688 aura::WindowTreeHost* host = window_->GetHost(); |
671 if (host) { | 689 if (host) { |
672 gfx::AcceleratedWidget hwnd = host->GetAcceleratedWidget(); | 690 gfx::AcceleratedWidget hwnd = host->GetAcceleratedWidget(); |
673 if (!(::GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_NOACTIVATE)) | 691 if (!(::GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_NOACTIVATE)) |
674 ::SetFocus(hwnd); | 692 ::SetFocus(hwnd); |
(...skipping 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2641 | 2659 |
2642 #if defined(OS_WIN) | 2660 #if defined(OS_WIN) |
2643 // The parent may have changed here. Ensure that the legacy window is | 2661 // The parent may have changed here. Ensure that the legacy window is |
2644 // reparented accordingly. | 2662 // reparented accordingly. |
2645 if (legacy_render_widget_host_HWND_) | 2663 if (legacy_render_widget_host_HWND_) |
2646 legacy_render_widget_host_HWND_->UpdateParent( | 2664 legacy_render_widget_host_HWND_->UpdateParent( |
2647 reinterpret_cast<HWND>(GetNativeViewId())); | 2665 reinterpret_cast<HWND>(GetNativeViewId())); |
2648 #endif | 2666 #endif |
2649 | 2667 |
2650 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); | 2668 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); |
2651 if (window_->GetHost()->compositor()) | |
2652 begin_frame_observer_proxy_.SetCompositor(window_->GetHost()->compositor()); | |
2653 } | 2669 } |
2654 | 2670 |
2655 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 2671 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
2656 aura::client::CursorClient* cursor_client = | 2672 aura::client::CursorClient* cursor_client = |
2657 aura::client::GetCursorClient(window_->GetRootWindow()); | 2673 aura::client::GetCursorClient(window_->GetRootWindow()); |
2658 if (cursor_client) | 2674 if (cursor_client) |
2659 cursor_client->RemoveObserver(this); | 2675 cursor_client->RemoveObserver(this); |
2660 | 2676 |
2661 DetachFromInputMethod(); | 2677 DetachFromInputMethod(); |
2662 | 2678 |
2663 window_->GetHost()->RemoveObserver(this); | 2679 window_->GetHost()->RemoveObserver(this); |
2664 delegated_frame_host_->ResetCompositor(); | 2680 delegated_frame_host_->ResetCompositor(); |
2665 begin_frame_observer_proxy_.ResetCompositor(); | |
2666 | 2681 |
2667 #if defined(OS_WIN) | 2682 #if defined(OS_WIN) |
2668 // Update the legacy window's parent temporarily to the desktop window. It | 2683 // Update the legacy window's parent temporarily to the desktop window. It |
2669 // will eventually get reparented to the right root. | 2684 // will eventually get reparented to the right root. |
2670 if (legacy_render_widget_host_HWND_) | 2685 if (legacy_render_widget_host_HWND_) |
2671 legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow()); | 2686 legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow()); |
2672 #endif | 2687 #endif |
2673 } | 2688 } |
2674 | 2689 |
2675 void RenderWidgetHostViewAura::DetachFromInputMethod() { | 2690 void RenderWidgetHostViewAura::DetachFromInputMethod() { |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2896 void RenderWidgetHostViewAura::DelegatedFrameHostOnLostCompositorResources() { | 2911 void RenderWidgetHostViewAura::DelegatedFrameHostOnLostCompositorResources() { |
2897 host_->ScheduleComposite(); | 2912 host_->ScheduleComposite(); |
2898 } | 2913 } |
2899 | 2914 |
2900 void RenderWidgetHostViewAura::DelegatedFrameHostUpdateVSyncParameters( | 2915 void RenderWidgetHostViewAura::DelegatedFrameHostUpdateVSyncParameters( |
2901 const base::TimeTicks& timebase, | 2916 const base::TimeTicks& timebase, |
2902 const base::TimeDelta& interval) { | 2917 const base::TimeDelta& interval) { |
2903 host_->UpdateVSyncParameters(timebase, interval); | 2918 host_->UpdateVSyncParameters(timebase, interval); |
2904 } | 2919 } |
2905 | 2920 |
| 2921 void RenderWidgetHostViewAura::SetBeginFrameSource( |
| 2922 cc::BeginFrameSource* source) { |
| 2923 if (begin_frame_source_ && needs_begin_frames_) |
| 2924 begin_frame_source_->RemoveObserver(this); |
| 2925 begin_frame_source_ = source; |
| 2926 if (begin_frame_source_ && needs_begin_frames_) |
| 2927 begin_frame_source_->AddObserver(this); |
| 2928 } |
| 2929 |
2906 void RenderWidgetHostViewAura::OnDidNavigateMainFrameToNewPage() { | 2930 void RenderWidgetHostViewAura::OnDidNavigateMainFrameToNewPage() { |
2907 ui::GestureRecognizer::Get()->CancelActiveTouches(window_); | 2931 ui::GestureRecognizer::Get()->CancelActiveTouches(window_); |
2908 } | 2932 } |
2909 | 2933 |
2910 void RenderWidgetHostViewAura::LockCompositingSurface() { | 2934 void RenderWidgetHostViewAura::LockCompositingSurface() { |
2911 NOTIMPLEMENTED(); | 2935 NOTIMPLEMENTED(); |
2912 } | 2936 } |
2913 | 2937 |
2914 void RenderWidgetHostViewAura::UnlockCompositingSurface() { | 2938 void RenderWidgetHostViewAura::UnlockCompositingSurface() { |
2915 NOTIMPLEMENTED(); | 2939 NOTIMPLEMENTED(); |
2916 } | 2940 } |
2917 | 2941 |
2918 uint32_t RenderWidgetHostViewAura::GetSurfaceIdNamespace() { | 2942 uint32_t RenderWidgetHostViewAura::GetSurfaceIdNamespace() { |
2919 return delegated_frame_host_->GetSurfaceIdNamespace(); | 2943 return delegated_frame_host_->GetSurfaceIdNamespace(); |
2920 } | 2944 } |
2921 | 2945 |
2922 cc::SurfaceId RenderWidgetHostViewAura::SurfaceIdForTesting() const { | 2946 cc::SurfaceId RenderWidgetHostViewAura::SurfaceIdForTesting() const { |
2923 return delegated_frame_host_->SurfaceIdForTesting(); | 2947 return delegated_frame_host_->SurfaceIdForTesting(); |
2924 } | 2948 } |
2925 | 2949 |
2926 //////////////////////////////////////////////////////////////////////////////// | 2950 //////////////////////////////////////////////////////////////////////////////// |
2927 // RenderWidgetHostViewBase, public: | 2951 // RenderWidgetHostViewBase, public: |
2928 | 2952 |
2929 // static | 2953 // static |
2930 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2954 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2931 GetScreenInfoForWindow(results, NULL); | 2955 GetScreenInfoForWindow(results, NULL); |
2932 } | 2956 } |
2933 | 2957 |
2934 } // namespace content | 2958 } // namespace content |
OLD | NEW |