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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 // RenderWidgetHostViewAura, public: | 361 // RenderWidgetHostViewAura, public: |
362 | 362 |
363 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host, | 363 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host, |
364 bool is_guest_view_hack) | 364 bool is_guest_view_hack) |
365 : host_(RenderWidgetHostImpl::From(host)), | 365 : host_(RenderWidgetHostImpl::From(host)), |
366 window_(nullptr), | 366 window_(nullptr), |
367 delegated_frame_host_(new DelegatedFrameHost(this)), | 367 delegated_frame_host_(new DelegatedFrameHost(this)), |
368 in_shutdown_(false), | 368 in_shutdown_(false), |
369 in_bounds_changed_(false), | 369 in_bounds_changed_(false), |
370 is_fullscreen_(false), | 370 is_fullscreen_(false), |
371 popup_parent_host_view_(NULL), | 371 popup_parent_host_view_(nullptr), |
372 popup_child_host_view_(NULL), | 372 popup_child_host_view_(nullptr), |
373 is_loading_(false), | 373 is_loading_(false), |
374 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 374 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
375 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), | 375 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
376 text_input_flags_(0), | 376 text_input_flags_(0), |
377 can_compose_inline_(true), | 377 can_compose_inline_(true), |
378 has_composition_text_(false), | 378 has_composition_text_(false), |
379 accept_return_character_(false), | 379 accept_return_character_(false), |
380 last_swapped_software_frame_scale_factor_(1.f), | 380 last_swapped_software_frame_scale_factor_(1.f), |
381 paint_canvas_(NULL), | 381 begin_frame_source_(nullptr), |
382 observing_begin_frame_source_(false), | |
383 paint_canvas_(nullptr), | |
382 synthetic_move_sent_(false), | 384 synthetic_move_sent_(false), |
383 cursor_visibility_state_in_renderer_(UNKNOWN), | 385 cursor_visibility_state_in_renderer_(UNKNOWN), |
384 #if defined(OS_WIN) | 386 #if defined(OS_WIN) |
385 legacy_render_widget_host_HWND_(NULL), | 387 legacy_render_widget_host_HWND_(nullptr), |
386 legacy_window_destroyed_(false), | 388 legacy_window_destroyed_(false), |
387 #endif | 389 #endif |
388 has_snapped_to_boundary_(false), | 390 has_snapped_to_boundary_(false), |
389 is_guest_view_hack_(is_guest_view_hack), | 391 is_guest_view_hack_(is_guest_view_hack), |
390 begin_frame_observer_proxy_(this), | |
391 set_focus_on_mouse_down_or_key_event_(false), | 392 set_focus_on_mouse_down_or_key_event_(false), |
392 device_scale_factor_(0.0f), | 393 device_scale_factor_(0.0f), |
393 disable_input_event_router_for_testing_(false), | 394 disable_input_event_router_for_testing_(false), |
394 weak_ptr_factory_(this) { | 395 weak_ptr_factory_(this) { |
395 if (!is_guest_view_hack_) | 396 if (!is_guest_view_hack_) |
396 host_->SetView(this); | 397 host_->SetView(this); |
397 | 398 |
398 // Let the page-level input event router know about our surface ID | 399 // Let the page-level input event router know about our surface ID |
399 // namespace for surface-based hit testing. | 400 // namespace for surface-based hit testing. |
400 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { | 401 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
653 | 654 |
654 NOTIMPLEMENTED(); | 655 NOTIMPLEMENTED(); |
655 return static_cast<gfx::NativeViewAccessible>(NULL); | 656 return static_cast<gfx::NativeViewAccessible>(NULL); |
656 } | 657 } |
657 | 658 |
658 ui::TextInputClient* RenderWidgetHostViewAura::GetTextInputClient() { | 659 ui::TextInputClient* RenderWidgetHostViewAura::GetTextInputClient() { |
659 return this; | 660 return this; |
660 } | 661 } |
661 | 662 |
662 void RenderWidgetHostViewAura::OnSetNeedsBeginFrames(bool needs_begin_frames) { | 663 void RenderWidgetHostViewAura::OnSetNeedsBeginFrames(bool needs_begin_frames) { |
663 begin_frame_observer_proxy_.SetNeedsBeginFrames(needs_begin_frames); | 664 if (observing_begin_frame_source_ == needs_begin_frames) |
665 return; | |
666 | |
667 observing_begin_frame_source_ = needs_begin_frames; | |
no sievers
2016/04/07 20:35:35
nit: I'm wondering if calling it |needs_begin_fram
| |
668 if (begin_frame_source_) { | |
669 if (observing_begin_frame_source_) | |
670 begin_frame_source_->AddObserver(this); | |
671 else | |
672 begin_frame_source_->RemoveObserver(this); | |
673 } | |
664 } | 674 } |
665 | 675 |
666 void RenderWidgetHostViewAura::SendBeginFrame(const cc::BeginFrameArgs& args) { | 676 void RenderWidgetHostViewAura::OnBeginFrame(const cc::BeginFrameArgs& args) { |
667 delegated_frame_host_->SetVSyncParameters(args.frame_time, args.interval); | 677 delegated_frame_host_->SetVSyncParameters(args.frame_time, args.interval); |
sunnyps
2016/04/07 23:57:54
nit: Does this belong in DelegatedFrameHost::OnBeg
enne (OOO)
2016/04/14 18:12:16
Not unless you think the DelegatedFrameHost should
sunnyps
2016/04/19 01:00:22
Sorry for the late reply. I confused this with OnS
| |
668 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); | 678 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); |
679 last_begin_frame_args_ = args; | |
680 } | |
681 | |
682 const cc::BeginFrameArgs& RenderWidgetHostViewAura::LastUsedBeginFrameArgs() | |
683 const { | |
684 return last_begin_frame_args_; | |
685 } | |
686 | |
687 void RenderWidgetHostViewAura::OnBeginFrameSourcePausedChanged(bool paused) { | |
688 // Ignored for now. If the begin frame source is paused, the renderer | |
689 // doesn't need to be informed about it and will just not receive more | |
690 // begin frames. | |
691 } | |
692 | |
693 void RenderWidgetHostViewAura::AsValueInto( | |
694 base::trace_event::TracedValue* dict) const { | |
695 // TODO(enne): implement me? | |
669 } | 696 } |
670 | 697 |
671 void RenderWidgetHostViewAura::SetKeyboardFocus() { | 698 void RenderWidgetHostViewAura::SetKeyboardFocus() { |
672 #if defined(OS_WIN) | 699 #if defined(OS_WIN) |
673 if (CanFocus()) { | 700 if (CanFocus()) { |
674 aura::WindowTreeHost* host = window_->GetHost(); | 701 aura::WindowTreeHost* host = window_->GetHost(); |
675 if (host) { | 702 if (host) { |
676 gfx::AcceleratedWidget hwnd = host->GetAcceleratedWidget(); | 703 gfx::AcceleratedWidget hwnd = host->GetAcceleratedWidget(); |
677 if (!(::GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_NOACTIVATE)) | 704 if (!(::GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_NOACTIVATE)) |
678 ::SetFocus(hwnd); | 705 ::SetFocus(hwnd); |
(...skipping 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2644 | 2671 |
2645 #if defined(OS_WIN) | 2672 #if defined(OS_WIN) |
2646 // The parent may have changed here. Ensure that the legacy window is | 2673 // The parent may have changed here. Ensure that the legacy window is |
2647 // reparented accordingly. | 2674 // reparented accordingly. |
2648 if (legacy_render_widget_host_HWND_) | 2675 if (legacy_render_widget_host_HWND_) |
2649 legacy_render_widget_host_HWND_->UpdateParent( | 2676 legacy_render_widget_host_HWND_->UpdateParent( |
2650 reinterpret_cast<HWND>(GetNativeViewId())); | 2677 reinterpret_cast<HWND>(GetNativeViewId())); |
2651 #endif | 2678 #endif |
2652 | 2679 |
2653 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); | 2680 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); |
2654 if (window_->GetHost()->compositor()) | |
2655 begin_frame_observer_proxy_.SetCompositor(window_->GetHost()->compositor()); | |
2656 } | 2681 } |
2657 | 2682 |
2658 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 2683 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
2659 aura::client::CursorClient* cursor_client = | 2684 aura::client::CursorClient* cursor_client = |
2660 aura::client::GetCursorClient(window_->GetRootWindow()); | 2685 aura::client::GetCursorClient(window_->GetRootWindow()); |
2661 if (cursor_client) | 2686 if (cursor_client) |
2662 cursor_client->RemoveObserver(this); | 2687 cursor_client->RemoveObserver(this); |
2663 | 2688 |
2664 DetachFromInputMethod(); | 2689 DetachFromInputMethod(); |
2665 | 2690 |
2666 window_->GetHost()->RemoveObserver(this); | 2691 window_->GetHost()->RemoveObserver(this); |
2667 delegated_frame_host_->ResetCompositor(); | 2692 delegated_frame_host_->ResetCompositor(); |
2668 begin_frame_observer_proxy_.ResetCompositor(); | |
2669 | 2693 |
2670 #if defined(OS_WIN) | 2694 #if defined(OS_WIN) |
2671 // Update the legacy window's parent temporarily to the desktop window. It | 2695 // Update the legacy window's parent temporarily to the desktop window. It |
2672 // will eventually get reparented to the right root. | 2696 // will eventually get reparented to the right root. |
2673 if (legacy_render_widget_host_HWND_) | 2697 if (legacy_render_widget_host_HWND_) |
2674 legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow()); | 2698 legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow()); |
2675 #endif | 2699 #endif |
2676 } | 2700 } |
2677 | 2701 |
2678 void RenderWidgetHostViewAura::DetachFromInputMethod() { | 2702 void RenderWidgetHostViewAura::DetachFromInputMethod() { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2901 void RenderWidgetHostViewAura::DelegatedFrameHostOnLostCompositorResources() { | 2925 void RenderWidgetHostViewAura::DelegatedFrameHostOnLostCompositorResources() { |
2902 host_->ScheduleComposite(); | 2926 host_->ScheduleComposite(); |
2903 } | 2927 } |
2904 | 2928 |
2905 void RenderWidgetHostViewAura::DelegatedFrameHostUpdateVSyncParameters( | 2929 void RenderWidgetHostViewAura::DelegatedFrameHostUpdateVSyncParameters( |
2906 const base::TimeTicks& timebase, | 2930 const base::TimeTicks& timebase, |
2907 const base::TimeDelta& interval) { | 2931 const base::TimeDelta& interval) { |
2908 host_->UpdateVSyncParameters(timebase, interval); | 2932 host_->UpdateVSyncParameters(timebase, interval); |
2909 } | 2933 } |
2910 | 2934 |
2935 void RenderWidgetHostViewAura::SetBeginFrameSource( | |
2936 cc::BeginFrameSource* source) { | |
2937 if (begin_frame_source_ && observing_begin_frame_source_) | |
2938 begin_frame_source_->RemoveObserver(this); | |
2939 begin_frame_source_ = source; | |
2940 if (begin_frame_source_ && observing_begin_frame_source_) | |
2941 begin_frame_source_->AddObserver(this); | |
2942 } | |
2943 | |
2911 void RenderWidgetHostViewAura::OnDidNavigateMainFrameToNewPage() { | 2944 void RenderWidgetHostViewAura::OnDidNavigateMainFrameToNewPage() { |
2912 ui::GestureRecognizer::Get()->CancelActiveTouches(window_); | 2945 ui::GestureRecognizer::Get()->CancelActiveTouches(window_); |
2913 } | 2946 } |
2914 | 2947 |
2915 void RenderWidgetHostViewAura::LockCompositingSurface() { | 2948 void RenderWidgetHostViewAura::LockCompositingSurface() { |
2916 NOTIMPLEMENTED(); | 2949 NOTIMPLEMENTED(); |
2917 } | 2950 } |
2918 | 2951 |
2919 void RenderWidgetHostViewAura::UnlockCompositingSurface() { | 2952 void RenderWidgetHostViewAura::UnlockCompositingSurface() { |
2920 NOTIMPLEMENTED(); | 2953 NOTIMPLEMENTED(); |
2921 } | 2954 } |
2922 | 2955 |
2923 uint32_t RenderWidgetHostViewAura::GetSurfaceIdNamespace() { | 2956 uint32_t RenderWidgetHostViewAura::GetSurfaceIdNamespace() { |
2924 return delegated_frame_host_->GetSurfaceIdNamespace(); | 2957 return delegated_frame_host_->GetSurfaceIdNamespace(); |
2925 } | 2958 } |
2926 | 2959 |
2927 cc::SurfaceId RenderWidgetHostViewAura::SurfaceIdForTesting() const { | 2960 cc::SurfaceId RenderWidgetHostViewAura::SurfaceIdForTesting() const { |
2928 return delegated_frame_host_->SurfaceIdForTesting(); | 2961 return delegated_frame_host_->SurfaceIdForTesting(); |
2929 } | 2962 } |
2930 | 2963 |
2931 //////////////////////////////////////////////////////////////////////////////// | 2964 //////////////////////////////////////////////////////////////////////////////// |
2932 // RenderWidgetHostViewBase, public: | 2965 // RenderWidgetHostViewBase, public: |
2933 | 2966 |
2934 // static | 2967 // static |
2935 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2968 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2936 GetScreenInfoForWindow(results, NULL); | 2969 GetScreenInfoForWindow(results, NULL); |
2937 } | 2970 } |
2938 | 2971 |
2939 } // namespace content | 2972 } // namespace content |
OLD | NEW |