Commit c5431f18 authored by Amruth Raj's avatar Amruth Raj Committed by Commit Bot

Do not coalesce events received before and after a kRelativeMotionEvent

When a WebCoalescedInputEvent is getting built from individual input
events by the renderer, it looks for events that can be coalesced together.
If there is a kRelativeMotionEvent in the queue, existing logic is to
skip it and coalesce the next events. In case of a pointer lock,
kRelativeMotionEvent is sent during a cursor recenter. Events before
kRelativeMotionEvent and events after kRelativeMotionEvent differ by a big
margin and should not be coalesced together.

This patch correctly stops coalescing when a kRelativeMotionEvent is seen
thereby avoiding incorrect bigdeltas from being sent to the DOM.

Bug: 1066544
Change-Id: I1a38391e41f4d0bc11ec67c88e3df1d321bc15bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2226479Reviewed-by: default avatarElla Ge <eirage@chromium.org>
Reviewed-by: default avatarMustaq Ahmed <mustaq@chromium.org>
Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Reviewed-by: default avatarVincent Scheib <scheib@chromium.org>
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774654}
parent 9d570a22
......@@ -63,15 +63,24 @@ class QueuedWebInputEvent : public MainThreadEventQueueTask {
~QueuedWebInputEvent() override {}
bool ArePointerMoveEventTypes(QueuedWebInputEvent* other_event) {
bool AreCoalescablePointerRawUpdateEvents(QueuedWebInputEvent* other_event) {
// There is no pointermove at this point in the queue.
DCHECK(event_->Event().GetType() != WebInputEvent::Type::kPointerMove &&
other_event->event_->Event().GetType() !=
WebInputEvent::Type::kPointerMove);
// Events with modifiers differing by kRelativeMotionEvent should not be
// coalesced. In case of a pointer lock, kRelativeMotionEvent is sent
// when the cursor is recentered. Events post the recentered event have
// a big delta compared to the previous events and hence should not be
// coalesced.
return event_->Event().GetType() ==
WebInputEvent::Type::kPointerRawUpdate &&
other_event->event_->Event().GetType() ==
WebInputEvent::Type::kPointerRawUpdate;
WebInputEvent::Type::kPointerRawUpdate &&
((event_->Event().GetModifiers() &
blink::WebInputEvent::Modifiers::kRelativeMotionEvent) ==
(other_event->event_->Event().GetModifiers() &
blink::WebInputEvent::Modifiers::kRelativeMotionEvent));
}
FilterResult FilterNewEvent(MainThreadEventQueueTask* other_task) override {
......@@ -92,7 +101,7 @@ class QueuedWebInputEvent : public MainThreadEventQueueTask {
// Two pointerevents may not be able to coalesce but we should continue
// looking further down the queue if both of them were rawupdate or move
// events and only their pointer_type, id, or event_type was different.
if (ArePointerMoveEventTypes(other_event))
if (AreCoalescablePointerRawUpdateEvents(other_event))
return FilterResult::KeepIterating;
return FilterResult::StopIterating;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment