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

Unified Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 1407053010: Make mouse wheel events trigger WebContentsObserver::DidGetUserInteraction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nits Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_impl.cc
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index cc7def8580adc072b2a0119b72d1e6b8d12fdabf..4cb3afb692ae12f550e7ace3af79dba39e77c12f 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -92,6 +92,12 @@ using blink::WebTextDirection;
namespace content {
namespace {
+// The amount of time after a mouse wheel event is sent to the delegate
+// OnUserInteraction method before another mouse wheel event will be sent. Equal
+// to blink's EventHandler interval for detecting the end of a scroll event.
+const base::TimeDelta g_wheel_coalesce_interval =
calamity 2015/11/03 02:16:13 nit: Consider kWheelCoalesceInterval if this is ne
dominickn 2015/11/03 21:29:42 I'll leave this unless one of the content reviewer
tdresser 2015/11/03 21:39:48 I think kWheelCoalesceInterval would be more stand
dominickn 2015/11/04 00:18:31 Done.
+ base::TimeDelta::FromMilliseconds(100);
nasko 2015/11/03 20:45:59 What is the rationale for picking this number?
dominickn 2015/11/03 21:29:42 It's the same value used by blink in its orthogona
nasko 2015/11/04 17:31:22 Please put this in a comment, so it is clear for p
dominickn 2015/11/04 23:21:25 Done, expanded the preceding comment.
+
bool g_check_for_pending_resize_ack = true;
// <process id, routing id>
@@ -204,6 +210,7 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)),
new_content_rendering_delay_(
base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)),
+ wheel_coalesce_timer_(nullptr),
nasko 2015/11/03 20:45:59 scoped_ptr is default initialized to nullptr, so n
dominickn 2015/11/03 21:29:42 Done.
weak_factory_(this) {
CHECK(delegate_);
CHECK_NE(MSG_ROUTING_NONE, routing_id_);
@@ -1860,6 +1867,12 @@ InputEventAckState RenderWidgetHostImpl::FilterInputEvent(
event.type == WebInputEvent::GestureTapDown ||
event.type == WebInputEvent::RawKeyDown) {
delegate_->OnUserInteraction(event.type);
+ } else if (event.type == WebInputEvent::MouseWheel) {
+ if (!wheel_coalesce_timer_.get() ||
+ wheel_coalesce_timer_->Elapsed() > g_wheel_coalesce_interval) {
+ delegate_->OnUserInteraction(event.type);
+ }
+ wheel_coalesce_timer_.reset(new base::ElapsedTimer());
nasko 2015/11/03 20:45:59 If the timer will always be reset to something, wh
dominickn 2015/11/03 21:29:42 Done.
}
}

Powered by Google App Engine
This is Rietveld 408576698