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

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

Issue 13931009: Add latency info to input events sent to RenderWidget. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
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/overscroll_controller.h" 5 #include "content/browser/renderer_host/overscroll_controller.h"
6 6
7 #include "content/browser/renderer_host/gesture_event_filter.h" 7 #include "content/browser/renderer_host/gesture_event_filter.h"
8 #include "content/browser/renderer_host/overscroll_controller_delegate.h" 8 #include "content/browser/renderer_host/overscroll_controller_delegate.h"
9 #include "content/browser/renderer_host/render_widget_host_impl.h" 9 #include "content/browser/renderer_host/render_widget_host_impl.h"
10 #include "content/public/browser/overscroll_configuration.h" 10 #include "content/public/browser/overscroll_configuration.h"
11 #include "content/public/browser/render_widget_host_view.h" 11 #include "content/public/browser/render_widget_host_view.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 OverscrollController::OverscrollController( 15 OverscrollController::OverscrollController(
16 RenderWidgetHostImpl* render_widget_host) 16 RenderWidgetHostImpl* render_widget_host)
17 : render_widget_host_(render_widget_host), 17 : render_widget_host_(render_widget_host),
18 overscroll_mode_(OVERSCROLL_NONE), 18 overscroll_mode_(OVERSCROLL_NONE),
19 overscroll_delta_x_(0.f), 19 overscroll_delta_x_(0.f),
20 overscroll_delta_y_(0.f), 20 overscroll_delta_y_(0.f),
21 delegate_(NULL) { 21 delegate_(NULL) {
22 } 22 }
23 23
24 OverscrollController::~OverscrollController() { 24 OverscrollController::~OverscrollController() {
25 } 25 }
26 26
27 bool OverscrollController::WillDispatchEvent( 27 bool OverscrollController::WillDispatchEvent(
28 const WebKit::WebInputEvent& event) { 28 const WebKit::WebInputEvent& event,
29 const cc::LatencyInfo& latency_info) {
29 if (DispatchEventCompletesAction(event)) { 30 if (DispatchEventCompletesAction(event)) {
30 CompleteAction(); 31 CompleteAction();
31 32
32 // If the overscroll was caused by touch-scrolling, then the gesture event 33 // If the overscroll was caused by touch-scrolling, then the gesture event
33 // that completes the action needs to be sent to the renderer, because the 34 // that completes the action needs to be sent to the renderer, because the
34 // touch-scrolls maintain state in the renderer side (in the compositor, for 35 // touch-scrolls maintain state in the renderer side (in the compositor, for
35 // example), and the event that completes this action needs to be sent to 36 // example), and the event that completes this action needs to be sent to
36 // the renderer so that those states can be updated/reset appropriately. 37 // the renderer so that those states can be updated/reset appropriately.
37 // Send the event through the gesture-event filter when appropriate. 38 // Send the event through the gesture-event filter when appropriate.
38 if (ShouldForwardToGestureFilter(event)) { 39 if (ShouldForwardToGestureFilter(event)) {
39 const WebKit::WebGestureEvent& gevent = 40 const WebKit::WebGestureEvent& gevent =
40 static_cast<const WebKit::WebGestureEvent&>(event); 41 static_cast<const WebKit::WebGestureEvent&>(event);
41 return render_widget_host_->gesture_event_filter()-> 42 return render_widget_host_->gesture_event_filter()->
42 ShouldForward(gevent); 43 ShouldForward(GestureEventWithLatencyInfo(gevent, latency_info));
43 } 44 }
44 45
45 return false; 46 return false;
46 } 47 }
47 48
48 if (overscroll_mode_ != OVERSCROLL_NONE && DispatchEventResetsState(event)) { 49 if (overscroll_mode_ != OVERSCROLL_NONE && DispatchEventResetsState(event)) {
49 SetOverscrollMode(OVERSCROLL_NONE); 50 SetOverscrollMode(OVERSCROLL_NONE);
50 // The overscroll gesture status is being reset. If the event is a 51 // The overscroll gesture status is being reset. If the event is a
51 // gesture event (from either touchscreen or trackpad), then make sure the 52 // gesture event (from either touchscreen or trackpad), then make sure the
52 // gesture event filter gets the event first (if it didn't already process 53 // gesture event filter gets the event first (if it didn't already process
53 // it). 54 // it).
54 if (ShouldForwardToGestureFilter(event)) { 55 if (ShouldForwardToGestureFilter(event)) {
55 const WebKit::WebGestureEvent& gevent = 56 const WebKit::WebGestureEvent& gevent =
56 static_cast<const WebKit::WebGestureEvent&>(event); 57 static_cast<const WebKit::WebGestureEvent&>(event);
57 return render_widget_host_->gesture_event_filter()->ShouldForward(gevent); 58 return render_widget_host_->gesture_event_filter()->ShouldForward(
59 GestureEventWithLatencyInfo(gevent, latency_info));
58 } 60 }
59 61
60 // Let the event be dispatched to the renderer. 62 // Let the event be dispatched to the renderer.
61 return true; 63 return true;
62 } 64 }
63 65
64 if (overscroll_mode_ != OVERSCROLL_NONE) { 66 if (overscroll_mode_ != OVERSCROLL_NONE) {
65 // Consume the event and update overscroll state when in the middle of the 67 // Consume the event and update overscroll state when in the middle of the
66 // overscroll gesture. 68 // overscroll gesture.
67 ProcessEventForOverscroll(event); 69 ProcessEventForOverscroll(event);
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 const WebKit::WebInputEvent& event) const { 300 const WebKit::WebInputEvent& event) const {
299 if (!WebKit::WebInputEvent::isGestureEventType(event.type)) 301 if (!WebKit::WebInputEvent::isGestureEventType(event.type))
300 return false; 302 return false;
301 303
302 // If the GestureEventFilter already processed this event, then the event must 304 // If the GestureEventFilter already processed this event, then the event must
303 // not be sent to the filter again. 305 // not be sent to the filter again.
304 return !render_widget_host_->gesture_event_filter()->HasQueuedGestureEvents(); 306 return !render_widget_host_->gesture_event_filter()->HasQueuedGestureEvents();
305 } 307 }
306 308
307 } // namespace content 309 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/overscroll_controller.h ('k') | content/browser/renderer_host/render_widget_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698