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

Unified Diff: content/browser/renderer_host/input/touch_event_queue.cc

Issue 26923002: Consolidate WebInputEvent coalescing logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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/input/touch_event_queue.cc
diff --git a/content/browser/renderer_host/input/touch_event_queue.cc b/content/browser/renderer_host/input/touch_event_queue.cc
index 7447c7f42f987bf356858ea6f4fd603de51e60d0..50d21e12cbe3e1db3c5b31feda80f51c8953f8e3 100644
--- a/content/browser/renderer_host/input/touch_event_queue.cc
+++ b/content/browser/renderer_host/input/touch_event_queue.cc
@@ -20,8 +20,7 @@ typedef std::vector<TouchEventWithLatencyInfo> WebTouchEventWithLatencyList;
class CoalescedWebTouchEvent {
public:
explicit CoalescedWebTouchEvent(const TouchEventWithLatencyInfo& event)
- : coalesced_event_(event),
- ignore_ack_(false) {
+ : coalesced_event_(event) {
events_.push_back(event);
TRACE_EVENT_ASYNC_BEGIN0(
"input", "TouchEventQueue::QueueEvent", this);
@@ -36,31 +35,11 @@ class CoalescedWebTouchEvent {
// the event was coalesced.
bool CoalesceEventIfPossible(
const TouchEventWithLatencyInfo& event_with_latency) {
- if (coalesced_event_.event.type == WebKit::WebInputEvent::TouchMove &&
- event_with_latency.event.type == WebKit::WebInputEvent::TouchMove &&
- coalesced_event_.event.modifiers ==
- event_with_latency.event.modifiers &&
- coalesced_event_.event.touchesLength ==
- event_with_latency.event.touchesLength &&
- !ignore_ack_) {
+ if (!ignore_ack_ &&
+ coalesced_event_.TryCoalesceWith(event_with_latency)) {
TRACE_EVENT_INSTANT0(
"input", "TouchEventQueue::MoveCoalesced", TRACE_EVENT_SCOPE_THREAD);
events_.push_back(event_with_latency);
- // The WebTouchPoints include absolute position information. So it is
- // sufficient to simply replace the previous event with the new event.
- // However, it is necessary to make sure that all the points have the
- // correct state, i.e. the touch-points that moved in the last event, but
- // didn't change in the current event, will have Stationary state. It is
- // necessary to change them back to Moved state.
- const WebKit::WebTouchEvent last_event = coalesced_event_.event;
- const ui::LatencyInfo last_latency = coalesced_event_.latency;
- coalesced_event_ = event_with_latency;
- coalesced_event_.latency.MergeWith(last_latency);
- for (unsigned i = 0; i < last_event.touchesLength; ++i) {
- if (last_event.touches[i].state == WebKit::WebTouchPoint::StateMoved)
- coalesced_event_.event.touches[i].state =
- WebKit::WebTouchPoint::StateMoved;
- }
return true;
}

Powered by Google App Engine
This is Rietveld 408576698