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

Side by Side Diff: content/renderer/input/main_thread_event_queue.cc

Issue 2233543002: Make first TouchStart and first TouchMove events on a flinging layer non-blocking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: set non_blocking to true Created 4 years, 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/renderer/input/main_thread_event_queue.h" 5 #include "content/renderer/input/main_thread_event_queue.h"
6 #include "content/common/input/event_with_latency_info.h" 6 #include "content/common/input/event_with_latency_info.h"
7 #include "content/common/input_messages.h" 7 #include "content/common/input_messages.h"
8 8
9 namespace content { 9 namespace content {
10 10
(...skipping 23 matching lines...) Expand all
34 ScopedWebInputEventWithLatencyInfo::CoalesceWith(other); 34 ScopedWebInputEventWithLatencyInfo::CoalesceWith(other);
35 } 35 }
36 36
37 MainThreadEventQueue::MainThreadEventQueue( 37 MainThreadEventQueue::MainThreadEventQueue(
38 int routing_id, 38 int routing_id,
39 MainThreadEventQueueClient* client, 39 MainThreadEventQueueClient* client,
40 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner) 40 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner)
41 : routing_id_(routing_id), 41 : routing_id_(routing_id),
42 client_(client), 42 client_(client),
43 is_flinging_(false), 43 is_flinging_(false),
44 main_task_runner_(main_task_runner) {} 44 main_task_runner_(main_task_runner),
45 waiting_for_first_touch_move_(false) {}
45 46
46 MainThreadEventQueue::~MainThreadEventQueue() {} 47 MainThreadEventQueue::~MainThreadEventQueue() {}
47 48
48 bool MainThreadEventQueue::HandleEvent( 49 bool MainThreadEventQueue::HandleEvent(
49 const blink::WebInputEvent* event, 50 const blink::WebInputEvent* event,
50 const ui::LatencyInfo& latency, 51 const ui::LatencyInfo& latency,
51 InputEventDispatchType original_dispatch_type, 52 InputEventDispatchType original_dispatch_type,
52 InputEventAckState ack_result) { 53 InputEventAckState ack_result) {
53 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING || 54 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING ||
54 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING); 55 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING);
55 DCHECK(ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING || 56 DCHECK(ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING ||
56 ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 57 ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
57 58
58 bool non_blocking = original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING || 59 bool non_blocking = original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING ||
59 ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING; 60 ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING;
60 61
61 InputEventDispatchType dispatch_type = 62 InputEventDispatchType dispatch_type =
62 non_blocking ? DISPATCH_TYPE_NON_BLOCKING : DISPATCH_TYPE_BLOCKING; 63 non_blocking ? DISPATCH_TYPE_NON_BLOCKING : DISPATCH_TYPE_BLOCKING;
63 64
64 bool is_wheel = event->type == blink::WebInputEvent::MouseWheel; 65 bool is_wheel = event->type == blink::WebInputEvent::MouseWheel;
65 bool is_touch = blink::WebInputEvent::isTouchEventType(event->type); 66 bool is_touch = blink::WebInputEvent::isTouchEventType(event->type);
66 67
67 std::unique_ptr<EventWithDispatchType> cloned_event( 68 std::unique_ptr<EventWithDispatchType> cloned_event(
68 new EventWithDispatchType(*event, latency, dispatch_type)); 69 new EventWithDispatchType(*event, latency, dispatch_type));
69 70
70 if (is_touch) { 71 if (is_touch) {
71 blink::WebTouchEvent& touch_event = 72 blink::WebTouchEvent& touch_event =
72 static_cast<blink::WebTouchEvent&>(cloned_event->event()); 73 static_cast<blink::WebTouchEvent&>(cloned_event->event());
73 touch_event.dispatchedDuringFling = is_flinging_; 74 touch_event.dispatchedDuringFling = is_flinging_;
75 bool touch_start_or_first_touch_move = false;
76 if (event->type == blink::WebInputEvent::TouchStart) {
77 waiting_for_first_touch_move_ = true;
78 touch_start_or_first_touch_move = true;
79 } else if (event->type == blink::WebInputEvent::TouchMove) {
80 touch_start_or_first_touch_move = waiting_for_first_touch_move_;
81 waiting_for_first_touch_move_ = false;
82 }
83 touch_event.touchStartOrFirstTouchMove = touch_start_or_first_touch_move;
dtapuska 2016/08/12 14:40:00 Why is this populated here? Can't it be sent from
74 // Adjust the |dispatchType| on the event since the compositor 84 // Adjust the |dispatchType| on the event since the compositor
75 // determined all event listeners are passive. 85 // determined all event listeners are passive.
76 if (non_blocking) { 86 if (non_blocking) {
77 touch_event.dispatchType = 87 touch_event.dispatchType =
78 blink::WebInputEvent::ListenersNonBlockingPassive; 88 blink::WebInputEvent::ListenersNonBlockingPassive;
79 } 89 }
90 if (is_flinging_ && touch_start_or_first_touch_move &&
91 touch_event.dispatchType == blink::WebInputEvent::Blocking) {
92 touch_event.dispatchType =
93 blink::WebInputEvent::ListenersForcedNonBlockingPassiveDueToFling;
94 cloned_event->setDispatchType(DISPATCH_TYPE_NON_BLOCKING);
95 non_blocking = true;
96 }
80 } 97 }
81 if (is_wheel && non_blocking) { 98 if (is_wheel && non_blocking) {
82 // Adjust the |dispatchType| on the event since the compositor 99 // Adjust the |dispatchType| on the event since the compositor
83 // determined all event listeners are passive. 100 // determined all event listeners are passive.
84 static_cast<blink::WebMouseWheelEvent&>(cloned_event->event()) 101 static_cast<blink::WebMouseWheelEvent&>(cloned_event->event())
85 .dispatchType = blink::WebInputEvent::ListenersNonBlockingPassive; 102 .dispatchType = blink::WebInputEvent::ListenersNonBlockingPassive;
86 } 103 }
87 104
88 QueueEvent(std::move(cloned_event)); 105 QueueEvent(std::move(cloned_event));
89 106
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 base::AutoLock lock(event_queue_lock_); 152 base::AutoLock lock(event_queue_lock_);
136 size_t size_before = events_.size(); 153 size_t size_before = events_.size();
137 events_.Queue(std::move(event)); 154 events_.Queue(std::move(event));
138 send_notification = events_.size() != size_before; 155 send_notification = events_.size() != size_before;
139 } 156 }
140 if (send_notification) 157 if (send_notification)
141 SendEventNotificationToMainThread(); 158 SendEventNotificationToMainThread();
142 } 159 }
143 160
144 } // namespace content 161 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/input/main_thread_event_queue.h ('k') | content/renderer/input/main_thread_event_queue_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698