Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 2372873003: Move synthetic gesture input to be aligned with BeginFrame. (Closed)
Patch Set: Fix unittests Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 delegated_frame_host_(new DelegatedFrameHost(this)), 433 delegated_frame_host_(new DelegatedFrameHost(this)),
434 in_shutdown_(false), 434 in_shutdown_(false),
435 in_bounds_changed_(false), 435 in_bounds_changed_(false),
436 is_fullscreen_(false), 436 is_fullscreen_(false),
437 popup_parent_host_view_(nullptr), 437 popup_parent_host_view_(nullptr),
438 popup_child_host_view_(nullptr), 438 popup_child_host_view_(nullptr),
439 is_loading_(false), 439 is_loading_(false),
440 has_composition_text_(false), 440 has_composition_text_(false),
441 accept_return_character_(false), 441 accept_return_character_(false),
442 begin_frame_source_(nullptr), 442 begin_frame_source_(nullptr),
443 needs_begin_frames_(false),
444 needs_flush_input_(false),
445 added_frame_observer_(false),
443 synthetic_move_sent_(false), 446 synthetic_move_sent_(false),
444 cursor_visibility_state_in_renderer_(UNKNOWN), 447 cursor_visibility_state_in_renderer_(UNKNOWN),
445 #if defined(OS_WIN) 448 #if defined(OS_WIN)
446 legacy_render_widget_host_HWND_(nullptr), 449 legacy_render_widget_host_HWND_(nullptr),
447 legacy_window_destroyed_(false), 450 legacy_window_destroyed_(false),
448 virtual_keyboard_requested_(false), 451 virtual_keyboard_requested_(false),
449 #endif 452 #endif
450 has_snapped_to_boundary_(false), 453 has_snapped_to_boundary_(false),
451 is_guest_view_hack_(is_guest_view_hack), 454 is_guest_view_hack_(is_guest_view_hack),
452 set_focus_on_mouse_down_or_key_event_(false), 455 set_focus_on_mouse_down_or_key_event_(false),
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 708
706 NOTIMPLEMENTED(); 709 NOTIMPLEMENTED();
707 return static_cast<gfx::NativeViewAccessible>(NULL); 710 return static_cast<gfx::NativeViewAccessible>(NULL);
708 } 711 }
709 712
710 ui::TextInputClient* RenderWidgetHostViewAura::GetTextInputClient() { 713 ui::TextInputClient* RenderWidgetHostViewAura::GetTextInputClient() {
711 return this; 714 return this;
712 } 715 }
713 716
714 void RenderWidgetHostViewAura::SetNeedsBeginFrames(bool needs_begin_frames) { 717 void RenderWidgetHostViewAura::SetNeedsBeginFrames(bool needs_begin_frames) {
718 needs_begin_frames_ = needs_begin_frames;
719 UpdateNeedsBeginFramesInternal();
720 }
721
722 void RenderWidgetHostViewAura::OnSetNeedsFlushInput() {
723 needs_flush_input_ = true;
724 UpdateNeedsBeginFramesInternal();
725 }
726
727 void RenderWidgetHostViewAura::UpdateNeedsBeginFramesInternal() {
715 if (!begin_frame_source_) 728 if (!begin_frame_source_)
716 return; 729 return;
717 730
718 if (needs_begin_frames) 731 bool needs_frame = needs_begin_frames_ || needs_flush_input_;
732 if (needs_frame == added_frame_observer_)
733 return;
734
735 added_frame_observer_ = needs_frame;
736 if (needs_frame)
719 begin_frame_source_->AddObserver(this); 737 begin_frame_source_->AddObserver(this);
720 else 738 else
721 begin_frame_source_->RemoveObserver(this); 739 begin_frame_source_->RemoveObserver(this);
722 } 740 }
723 741
724 void RenderWidgetHostViewAura::OnBeginFrame( 742 void RenderWidgetHostViewAura::OnBeginFrame(
725 const cc::BeginFrameArgs& args) { 743 const cc::BeginFrameArgs& args) {
744 needs_flush_input_ = false;
745 host_->FlushInput();
746 UpdateNeedsBeginFramesInternal();
726 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); 747 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args));
727 last_begin_frame_args_ = args; 748 last_begin_frame_args_ = args;
728 } 749 }
729 750
730 const cc::BeginFrameArgs& RenderWidgetHostViewAura::LastUsedBeginFrameArgs() 751 const cc::BeginFrameArgs& RenderWidgetHostViewAura::LastUsedBeginFrameArgs()
731 const { 752 const {
732 return last_begin_frame_args_; 753 return last_begin_frame_args_;
733 } 754 }
734 755
735 void RenderWidgetHostViewAura::OnBeginFrameSourcePausedChanged(bool paused) { 756 void RenderWidgetHostViewAura::OnBeginFrameSourcePausedChanged(bool paused) {
(...skipping 2181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2917 host_->Send(new ViewMsg_ReclaimCompositorResources( 2938 host_->Send(new ViewMsg_ReclaimCompositorResources(
2918 host_->GetRoutingID(), compositor_frame_sink_id, is_swap_ack, resources)); 2939 host_->GetRoutingID(), compositor_frame_sink_id, is_swap_ack, resources));
2919 } 2940 }
2920 2941
2921 void RenderWidgetHostViewAura::DelegatedFrameHostOnLostCompositorResources() { 2942 void RenderWidgetHostViewAura::DelegatedFrameHostOnLostCompositorResources() {
2922 host_->ScheduleComposite(); 2943 host_->ScheduleComposite();
2923 } 2944 }
2924 2945
2925 void RenderWidgetHostViewAura::SetBeginFrameSource( 2946 void RenderWidgetHostViewAura::SetBeginFrameSource(
2926 cc::BeginFrameSource* source) { 2947 cc::BeginFrameSource* source) {
2927 bool needs_begin_frames = host_->needs_begin_frames(); 2948 if (begin_frame_source_ && added_frame_observer_) {
2928 if (begin_frame_source_ && needs_begin_frames)
2929 begin_frame_source_->RemoveObserver(this); 2949 begin_frame_source_->RemoveObserver(this);
2950 added_frame_observer_ = false;
2951 }
2930 begin_frame_source_ = source; 2952 begin_frame_source_ = source;
2931 if (begin_frame_source_ && needs_begin_frames) 2953 UpdateNeedsBeginFramesInternal();
2932 begin_frame_source_->AddObserver(this);
2933 } 2954 }
2934 2955
2935 bool RenderWidgetHostViewAura::IsAutoResizeEnabled() const { 2956 bool RenderWidgetHostViewAura::IsAutoResizeEnabled() const {
2936 return host_->auto_resize_enabled(); 2957 return host_->auto_resize_enabled();
2937 } 2958 }
2938 2959
2939 void RenderWidgetHostViewAura::OnDidNavigateMainFrameToNewPage() { 2960 void RenderWidgetHostViewAura::OnDidNavigateMainFrameToNewPage() {
2940 ui::GestureRecognizer::Get()->CancelActiveTouches(window_); 2961 ui::GestureRecognizer::Get()->CancelActiveTouches(window_);
2941 } 2962 }
2942 2963
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
3042 ->GetTextSelection(focused_view) 3063 ->GetTextSelection(focused_view)
3043 ->GetSelectedText(&selected_text)) { 3064 ->GetSelectedText(&selected_text)) {
3044 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. 3065 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard.
3045 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); 3066 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION);
3046 clipboard_writer.WriteText(selected_text); 3067 clipboard_writer.WriteText(selected_text);
3047 } 3068 }
3048 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) 3069 #endif // defined(USE_X11) && !defined(OS_CHROMEOS)
3049 } 3070 }
3050 3071
3051 } // namespace content 3072 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698