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

Unified 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: fix-builds 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/touch_event_queue.cc
diff --git a/content/browser/renderer_host/touch_event_queue.cc b/content/browser/renderer_host/touch_event_queue.cc
index d66727daa30ba8d06490380bc669dcbcadcb80d3..560a43b72c8fe7983fcf6ec0136a7f905c92162c 100644
--- a/content/browser/renderer_host/touch_event_queue.cc
+++ b/content/browser/renderer_host/touch_event_queue.cc
@@ -26,12 +26,27 @@ void TouchEventQueue::QueueEvent(const WebKit::WebTouchEvent& event) {
return;
}
- // TODO(sad): Coalesce with |touch_queue_.back()| if appropriate.
- // http://crbug.com/110231
- touch_queue_.push_back(event);
+ if (!CoalesceIfPossible(event))
+ touch_queue_.push_back(event);
aelias_OOO_until_Jul13 2012/10/17 01:52:57 Can we just move the coalescing logic into QueueEv
sadrul 2012/10/17 02:18:00 Good idea. Done.
}
void TouchEventQueue::ProcessTouchAck(bool processed) {
+ PopTouchEventToView(processed);
+ // If there's a queued touch-event, then forward it to the renderer now.
+ if (!touch_queue_.empty())
+ render_widget_host_->ForwardTouchEventImmediately(touch_queue_.front());
+}
+
+void TouchEventQueue::FlushQueue() {
+ while (!touch_queue_.empty())
+ PopTouchEventToView(false);
+}
+
+void TouchEventQueue::Reset() {
+ touch_queue_.clear();
+}
+
+void TouchEventQueue::PopTouchEventToView(bool processed) {
CHECK(!touch_queue_.empty());
WebKit::WebTouchEvent acked_event = touch_queue_.front();
touch_queue_.pop_front();
@@ -41,10 +56,29 @@ void TouchEventQueue::ProcessTouchAck(bool processed) {
RenderWidgetHostViewPort* view = RenderWidgetHostViewPort::FromRWHV(
render_widget_host_->GetView());
view->ProcessAckedTouchEvent(acked_event, processed);
+}
- // If there's a queued touch-event, then forward it to the renderer now.
- if (!touch_queue_.empty())
- render_widget_host_->ForwardTouchEventImmediately(touch_queue_.front());
+bool TouchEventQueue::CoalesceIfPossible(const WebKit::WebTouchEvent& event) {
+ if (empty())
+ return false;
+
+ // Allow coalescing only touch-move events, and only if they have the same
+ // number of touches and the same modifiers.
+ WebKit::WebTouchEvent& last_event = touch_queue_.back();
+ if (event.type != WebKit::WebInputEvent::TouchMove ||
+ last_event.type != WebKit::WebInputEvent::TouchMove)
+ return false;
+
+ if (event.modifiers != last_event.modifiers)
+ return false;
+ if (event.touchesLength != last_event.touchesLength)
+ return false;
+
+ // The WebTouchPoints include absolute position information. So it is
+ // sufficient to simply replace the previous event with the new event.
+ touch_queue_.pop_back();
+ touch_queue_.push_back(event);
+ return true;
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698