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

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

Issue 11188012: gesture recognizer: Remove the touch-event queue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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 | 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/touch_event_queue.h" 5 #include "content/browser/renderer_host/touch_event_queue.h"
6 6
7 #include "content/browser/renderer_host/render_widget_host_impl.h" 7 #include "content/browser/renderer_host/render_widget_host_impl.h"
8 #include "content/public/browser/render_widget_host_view.h" 8 #include "content/public/browser/render_widget_host_view.h"
9 #include "content/port/browser/render_widget_host_view_port.h" 9 #include "content/port/browser/render_widget_host_view_port.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 TouchEventQueue::TouchEventQueue(RenderWidgetHostImpl* host) 13 TouchEventQueue::TouchEventQueue(RenderWidgetHostImpl* host)
14 : render_widget_host_(host) { 14 : render_widget_host_(host) {
15 } 15 }
16 16
17 TouchEventQueue::~TouchEventQueue() { 17 TouchEventQueue::~TouchEventQueue() {
18 } 18 }
19 19
20 void TouchEventQueue::QueueEvent(const WebKit::WebTouchEvent& event) { 20 void TouchEventQueue::QueueEvent(const WebKit::WebTouchEvent& event) {
21 if (touch_queue_.empty()) { 21 if (touch_queue_.empty()) {
22 // There is no touch event in the queue. Forward it to the renderer 22 // There is no touch event in the queue. Forward it to the renderer
23 // immediately. 23 // immediately.
24 touch_queue_.push_back(event); 24 touch_queue_.push_back(event);
25 render_widget_host_->ForwardTouchEventImmediately(event); 25 render_widget_host_->ForwardTouchEventImmediately(event);
26 return; 26 return;
27 } 27 }
28 28
29 // TODO(sad): Coalesce with |touch_queue_.back()| if appropriate. 29 // If the last queued touch-event was a touch-move, and the current event is
rjkroege 2012/10/17 15:57:35 don't you need to queue moves separately for diffe
sadrul 2012/10/17 16:12:45 The current WebTouchEvent (i.e. |event|) will stil
30 // http://crbug.com/110231 30 // also a touch-move, then the events can be coalesced into a single event.
31 if (!empty()) {
32 WebKit::WebTouchEvent& last_event = touch_queue_.back();
33 if (event.type == WebKit::WebInputEvent::TouchMove &&
34 last_event.type == WebKit::WebInputEvent::TouchMove &&
35 event.modifiers == last_event.modifiers &&
36 event.touchesLength == last_event.touchesLength) {
37 // The WebTouchPoints include absolute position information. So it is
38 // sufficient to simply replace the previous event with the new event.
39 touch_queue_.pop_back();
40 }
41 }
31 touch_queue_.push_back(event); 42 touch_queue_.push_back(event);
32 } 43 }
33 44
34 void TouchEventQueue::ProcessTouchAck(bool processed) { 45 void TouchEventQueue::ProcessTouchAck(bool processed) {
46 PopTouchEventToView(processed);
47 // If there's a queued touch-event, then forward it to the renderer now.
48 if (!touch_queue_.empty())
49 render_widget_host_->ForwardTouchEventImmediately(touch_queue_.front());
50 }
51
52 void TouchEventQueue::FlushQueue() {
53 while (!touch_queue_.empty())
54 PopTouchEventToView(false);
55 }
56
57 void TouchEventQueue::Reset() {
58 touch_queue_.clear();
59 }
60
61 void TouchEventQueue::PopTouchEventToView(bool processed) {
35 CHECK(!touch_queue_.empty()); 62 CHECK(!touch_queue_.empty());
36 WebKit::WebTouchEvent acked_event = touch_queue_.front(); 63 WebKit::WebTouchEvent acked_event = touch_queue_.front();
37 touch_queue_.pop_front(); 64 touch_queue_.pop_front();
38 65
39 // Note that acking the touch-event may result in multiple gestures being sent 66 // Note that acking the touch-event may result in multiple gestures being sent
40 // to the renderer. 67 // to the renderer.
41 RenderWidgetHostViewPort* view = RenderWidgetHostViewPort::FromRWHV( 68 RenderWidgetHostViewPort* view = RenderWidgetHostViewPort::FromRWHV(
42 render_widget_host_->GetView()); 69 render_widget_host_->GetView());
43 view->ProcessAckedTouchEvent(acked_event, processed); 70 view->ProcessAckedTouchEvent(acked_event, processed);
44
45 // If there's a queued touch-event, then forward it to the renderer now.
46 if (!touch_queue_.empty())
47 render_widget_host_->ForwardTouchEventImmediately(touch_queue_.front());
48 } 71 }
49 72
50 } // namespace content 73 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698