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

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 nit 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..9701920482fc4e9a6c043891f98e0b49fbed1a03 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 kWheelCoalesceInterval =
+ base::TimeDelta::FromMilliseconds(100);
+
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)),
+ mouse_wheel_coalesce_timer_(new base::ElapsedTimer()),
weak_factory_(this) {
CHECK(delegate_);
CHECK_NE(MSG_ROUTING_NONE, routing_id_);
@@ -1860,6 +1867,11 @@ InputEventAckState RenderWidgetHostImpl::FilterInputEvent(
event.type == WebInputEvent::GestureTapDown ||
event.type == WebInputEvent::RawKeyDown) {
delegate_->OnUserInteraction(event.type);
+ } else if (event.type == WebInputEvent::MouseWheel) {
+ if (mouse_wheel_coalesce_timer_->Elapsed() > kWheelCoalesceInterval)
+ delegate_->OnUserInteraction(event.type);
+
+ mouse_wheel_coalesce_timer_.reset(new base::ElapsedTimer());
}
}

Powered by Google App Engine
This is Rietveld 408576698