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

Unified Diff: content/renderer/input/main_thread_event_queue.cc

Issue 2450833003: Separate rAF aligned Touch and Mouse Input settings (Closed)
Patch Set: Fix nits Created 4 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/renderer/input/main_thread_event_queue.cc
diff --git a/content/renderer/input/main_thread_event_queue.cc b/content/renderer/input/main_thread_event_queue.cc
index 99881bdf0e1a805a1bb2c7cf84ecd989fe01fc33..64eb81571ad0079f9604a0811fe5f4889425a1bc 100644
--- a/content/renderer/input/main_thread_event_queue.cc
+++ b/content/renderer/input/main_thread_event_queue.cc
@@ -14,7 +14,7 @@ namespace {
const size_t kTenSeconds = 10 * 1000 * 1000;
-bool isContinuousEvent(const std::unique_ptr<EventWithDispatchType>& event) {
+bool IsContinuousEvent(const std::unique_ptr<EventWithDispatchType>& event) {
switch (event->event().type) {
case blink::WebInputEvent::MouseMove:
case blink::WebInputEvent::MouseWheel:
@@ -72,8 +72,10 @@ MainThreadEventQueue::MainThreadEventQueue(
last_touch_start_forced_nonblocking_due_to_fling_(false),
enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled(
features::kPassiveEventListenersDueToFling)),
- handle_raf_aligned_input_(
- base::FeatureList::IsEnabled(features::kRafAlignedInputEvents)),
+ handle_raf_aligned_touch_input_(
+ base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents)),
+ handle_raf_aligned_mouse_input_(
+ base::FeatureList::IsEnabled(features::kRafAlignedMouseInputEvents)),
main_task_runner_(main_task_runner),
renderer_scheduler_(renderer_scheduler) {}
@@ -143,7 +145,7 @@ void MainThreadEventQueue::DispatchInFlightEvent() {
// Report the coalesced count only for continuous events; otherwise
// the zero value would be dominated by non-continuous events.
base::TimeTicks now = base::TimeTicks::Now();
- if (isContinuousEvent(in_flight_event_)) {
+ if (IsContinuousEvent(in_flight_event_)) {
UMA_HISTOGRAM_CUSTOM_COUNTS(
"Event.MainThreadEventQueue.Continuous.QueueingTime",
(now - in_flight_event_->creationTimestamp()).InMicroseconds(), 1,
@@ -178,14 +180,14 @@ void MainThreadEventQueue::DispatchInFlightEvent() {
}
void MainThreadEventQueue::PossiblyScheduleMainFrame() {
- if (!handle_raf_aligned_input_)
+ if (IsRafAlignedInputDisabled())
return;
bool needs_main_frame = false;
{
base::AutoLock lock(shared_state_lock_);
if (!shared_state_.sent_main_frame_request_ &&
!shared_state_.events_.empty() &&
- isContinuousEvent(shared_state_.events_.front())) {
+ IsRafAlignedEvent(shared_state_.events_.front())) {
needs_main_frame = !shared_state_.sent_main_frame_request_;
shared_state_.sent_main_frame_request_ = false;
}
@@ -221,7 +223,7 @@ void MainThreadEventQueue::EventHandled(blink::WebInputEvent::Type type,
}
void MainThreadEventQueue::DispatchRafAlignedInput() {
- if (!handle_raf_aligned_input_)
+ if (IsRafAlignedInputDisabled())
return;
std::deque<std::unique_ptr<EventWithDispatchType>> events_to_process;
@@ -230,7 +232,7 @@ void MainThreadEventQueue::DispatchRafAlignedInput() {
shared_state_.sent_main_frame_request_ = false;
while(!shared_state_.events_.empty()) {
- if (!isContinuousEvent(shared_state_.events_.front()))
+ if (!IsRafAlignedEvent(shared_state_.events_.front()))
break;
events_to_process.emplace_back(shared_state_.events_.Pop());
}
@@ -251,7 +253,7 @@ void MainThreadEventQueue::SendEventNotificationToMainThread() {
void MainThreadEventQueue::QueueEvent(
std::unique_ptr<EventWithDispatchType> event) {
- bool is_continuous = isContinuousEvent(event);
+ bool is_raf_aligned = IsRafAlignedEvent(event);
size_t send_notification_count = 0;
bool needs_main_frame = false;
{
@@ -259,15 +261,16 @@ void MainThreadEventQueue::QueueEvent(
size_t size_before = shared_state_.events_.size();
shared_state_.events_.Queue(std::move(event));
size_t size_after = shared_state_.events_.size();
+
if (size_before != size_after) {
- if (!handle_raf_aligned_input_) {
+ if (IsRafAlignedInputDisabled()) {
send_notification_count = 1;
- } else if (!is_continuous) {
+ } else if (!is_raf_aligned) {
send_notification_count = 1;
// If we had just enqueued a non-rAF input event we will send a series
// of normal post messages to ensure they are all handled right away.
for (size_t pos = size_after - 1; pos >= 1; --pos) {
- if (isContinuousEvent(shared_state_.events_.at(pos - 1)))
+ if (IsRafAlignedEvent(shared_state_.events_.at(pos - 1)))
send_notification_count++;
else
break;
@@ -284,4 +287,26 @@ void MainThreadEventQueue::QueueEvent(
client_->NeedsMainFrame(routing_id_);
}
+bool MainThreadEventQueue::IsRafAlignedInputDisabled() {
+ return !handle_raf_aligned_mouse_input_ && !handle_raf_aligned_touch_input_;
+}
+
+bool MainThreadEventQueue::IsRafAlignedEvent(
+ const std::unique_ptr<EventWithDispatchType>& event) {
+ switch (event->event().type) {
+ case blink::WebInputEvent::MouseMove:
+ case blink::WebInputEvent::MouseWheel:
+ return handle_raf_aligned_mouse_input_;
+ case blink::WebInputEvent::TouchMove:
+ // TouchMoves that are blocking end up blocking scroll. Do not treat
+ // them as continuous events otherwise we will end up waiting up to an
+ // additional frame.
+ return static_cast<const blink::WebTouchEvent&>(event->event())
+ .dispatchType != blink::WebInputEvent::Blocking &&
+ handle_raf_aligned_touch_input_;
+ default:
+ return false;
+ }
+}
+
} // namespace content
« 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