Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <new> | 7 #include <new> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool HandleEvent(WebInputEvent& event, InputEventAckState ack_result) { | 103 bool HandleEvent(WebInputEvent& event, InputEventAckState ack_result) { |
| 104 return queue_->HandleEvent(ui::WebInputEventTraits::Clone(event), | 104 return queue_->HandleEvent(ui::WebInputEventTraits::Clone(event), |
| 105 ui::LatencyInfo(), DISPATCH_TYPE_BLOCKING, | 105 ui::LatencyInfo(), DISPATCH_TYPE_BLOCKING, |
| 106 ack_result); | 106 ack_result); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void NeedsMainFrame(int routing_id) override { needs_main_frame_ = true; } | 109 void NeedsMainFrame(int routing_id) override { needs_main_frame_ = true; } |
| 110 | 110 |
| 111 WebInputEventQueue<EventWithDispatchType>& event_queue() { | 111 WebInputEventQueue<QueuedItem>& event_queue() { |
| 112 return queue_->shared_state_.events_; | 112 return queue_->shared_state_.events_; |
| 113 } | 113 } |
| 114 | 114 |
| 115 bool last_touch_start_forced_nonblocking_due_to_fling() { | 115 bool last_touch_start_forced_nonblocking_due_to_fling() { |
| 116 return queue_->last_touch_start_forced_nonblocking_due_to_fling_; | 116 return queue_->last_touch_start_forced_nonblocking_due_to_fling_; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void set_enable_fling_passive_listener_flag(bool enable_flag) { | 119 void set_enable_fling_passive_listener_flag(bool enable_flag) { |
| 120 queue_->enable_fling_passive_listener_flag_ = enable_flag; | 120 queue_->enable_fling_passive_listener_flag_ = enable_flag; |
| 121 } | 121 } |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 433 | 433 |
| 434 WebMouseEvent mouseDown = | 434 WebMouseEvent mouseDown = |
| 435 SyntheticWebMouseEventBuilder::Build(WebInputEvent::MouseDown, 10, 10, 0); | 435 SyntheticWebMouseEventBuilder::Build(WebInputEvent::MouseDown, 10, 10, 0); |
| 436 | 436 |
| 437 WebMouseEvent mouseMove = | 437 WebMouseEvent mouseMove = |
| 438 SyntheticWebMouseEventBuilder::Build(WebInputEvent::MouseMove, 10, 10, 0); | 438 SyntheticWebMouseEventBuilder::Build(WebInputEvent::MouseMove, 10, 10, 0); |
| 439 | 439 |
| 440 WebMouseEvent mouseUp = | 440 WebMouseEvent mouseUp = |
| 441 SyntheticWebMouseEventBuilder::Build(WebInputEvent::MouseUp, 10, 10, 0); | 441 SyntheticWebMouseEventBuilder::Build(WebInputEvent::MouseUp, 10, 10, 0); |
| 442 | 442 |
| 443 WebMouseWheelEvent wheelEvents[2] = { | 443 WebMouseWheelEvent wheelEvents[3] = { |
| 444 SyntheticWebMouseWheelEventBuilder::Build(10, 10, 0, 53, 0, false), | 444 SyntheticWebMouseWheelEventBuilder::Build(10, 10, 0, 53, 0, false), |
| 445 SyntheticWebMouseWheelEventBuilder::Build(20, 20, 0, 53, 0, false), | 445 SyntheticWebMouseWheelEventBuilder::Build(20, 20, 0, 53, 0, false), |
| 446 SyntheticWebMouseWheelEventBuilder::Build(20, 20, 0, 53, 1, false), | |
| 446 }; | 447 }; |
| 447 | 448 |
| 448 EXPECT_FALSE(main_task_runner_->HasPendingTask()); | 449 EXPECT_FALSE(main_task_runner_->HasPendingTask()); |
| 449 EXPECT_EQ(0u, event_queue().size()); | 450 EXPECT_EQ(0u, event_queue().size()); |
| 450 | 451 |
| 451 // Simulate enqueing a discrete event, followed by continuous events and | 452 // Simulate enqueing a discrete event, followed by continuous events and |
|
mustaq
2017/03/24 15:31:18
"Discrete" vs "continuous": do we define these ter
dtapuska
2017/03/24 20:16:34
Continuous are rAF aligned events. Discrete aren't
| |
| 452 // then a discrete event. The last discrete event should flush the | 453 // then a discrete event. The last discrete event should flush the |
| 453 // continuous events so the aren't aligned to rAF and are processed | 454 // continuous events so the aren't aligned to rAF and are processed |
| 454 // immediately. | 455 // immediately. |
| 455 HandleEvent(mouseDown, INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 456 HandleEvent(mouseDown, INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
| 456 HandleEvent(mouseMove, INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 457 HandleEvent(mouseMove, INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
| 457 HandleEvent(wheelEvents[0], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 458 HandleEvent(wheelEvents[0], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
| 458 HandleEvent(wheelEvents[1], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 459 HandleEvent(wheelEvents[1], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
| 459 HandleEvent(mouseUp, INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 460 HandleEvent(mouseUp, INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
| 460 | 461 |
| 461 EXPECT_EQ(4u, event_queue().size()); | 462 EXPECT_EQ(4u, event_queue().size()); |
| 462 EXPECT_TRUE(main_task_runner_->HasPendingTask()); | 463 EXPECT_TRUE(main_task_runner_->HasPendingTask()); |
| 463 EXPECT_TRUE(needs_main_frame_); | 464 EXPECT_TRUE(needs_main_frame_); |
| 464 main_task_runner_->RunUntilIdle(); | 465 main_task_runner_->RunUntilIdle(); |
| 465 EXPECT_EQ(0u, event_queue().size()); | 466 EXPECT_EQ(0u, event_queue().size()); |
| 466 RunPendingTasksWithSimulatedRaf(); | 467 RunPendingTasksWithSimulatedRaf(); |
| 467 | 468 |
| 468 // Simulate the rAF running before the PostTask occurs. The first rAF | 469 // Simulate the rAF running before the PostTask occurs. The rAF |
| 469 // shouldn't do anything. | 470 // will consume everything. |
| 470 HandleEvent(mouseDown, INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 471 HandleEvent(mouseDown, INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
| 471 HandleEvent(wheelEvents[0], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 472 HandleEvent(wheelEvents[0], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
| 472 EXPECT_EQ(2u, event_queue().size()); | 473 EXPECT_EQ(2u, event_queue().size()); |
| 473 EXPECT_TRUE(needs_main_frame_); | 474 EXPECT_TRUE(needs_main_frame_); |
| 474 RunSimulatedRafOnce(); | 475 RunSimulatedRafOnce(); |
| 475 EXPECT_FALSE(needs_main_frame_); | 476 EXPECT_FALSE(needs_main_frame_); |
| 476 EXPECT_EQ(2u, event_queue().size()); | 477 EXPECT_EQ(0u, event_queue().size()); |
| 478 main_task_runner_->RunUntilIdle(); | |
| 479 | |
| 480 // Simulate event consumption but no rAF signal. The mouse wheel events | |
| 481 // should still be in the queue. | |
| 482 handled_events_.clear(); | |
| 483 HandleEvent(mouseDown, INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | |
| 484 HandleEvent(wheelEvents[0], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | |
| 485 HandleEvent(wheelEvents[2], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | |
|
mustaq
2017/03/24 15:31:18
Wondering why wheelEvent[2] not [1]? Event |modifi
dtapuska
2017/03/24 20:16:35
Because 0 and 1 will get coalesced together. The m
| |
| 486 EXPECT_EQ(3u, event_queue().size()); | |
| 487 EXPECT_TRUE(needs_main_frame_); | |
| 477 main_task_runner_->RunUntilIdle(); | 488 main_task_runner_->RunUntilIdle(); |
| 478 EXPECT_TRUE(needs_main_frame_); | 489 EXPECT_TRUE(needs_main_frame_); |
| 479 EXPECT_EQ(1u, event_queue().size()); | 490 EXPECT_EQ(2u, event_queue().size()); |
| 480 RunPendingTasksWithSimulatedRaf(); | 491 RunSimulatedRafOnce(); |
| 481 EXPECT_EQ(0u, event_queue().size()); | 492 EXPECT_EQ(wheelEvents[0].modifiers(), |
| 493 handled_events_.at(1).event().modifiers()); | |
| 494 EXPECT_EQ(wheelEvents[2].modifiers(), | |
| 495 handled_events_.at(2).event().modifiers()); | |
|
mustaq
2017/03/24 15:31:18
Please add a longer raf/non-raf queued sequence, t
dtapuska
2017/03/24 20:16:37
Done.
| |
| 482 } | 496 } |
| 483 | 497 |
| 484 TEST_P(MainThreadEventQueueTest, RafAlignedTouchInput) { | 498 TEST_P(MainThreadEventQueueTest, RafAlignedTouchInput) { |
| 485 // Don't run the test when we aren't supporting rAF aligned input. | 499 // Don't run the test when we aren't supporting rAF aligned input. |
| 486 if ((raf_aligned_input_setting_ & kRafAlignedEnabledTouch) == 0) | 500 if ((raf_aligned_input_setting_ & kRafAlignedEnabledTouch) == 0) |
| 487 return; | 501 return; |
| 488 | 502 |
| 489 SyntheticWebTouchEvent kEvents[3]; | 503 SyntheticWebTouchEvent kEvents[3]; |
| 490 kEvents[0].PressPoint(10, 10); | 504 kEvents[0].PressPoint(10, 10); |
| 491 kEvents[1].PressPoint(10, 10); | 505 kEvents[1].PressPoint(10, 10); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 503 for (SyntheticWebTouchEvent& event : kEvents) | 517 for (SyntheticWebTouchEvent& event : kEvents) |
| 504 HandleEvent(event, INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 518 HandleEvent(event, INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
| 505 | 519 |
| 506 EXPECT_EQ(3u, event_queue().size()); | 520 EXPECT_EQ(3u, event_queue().size()); |
| 507 EXPECT_TRUE(main_task_runner_->HasPendingTask()); | 521 EXPECT_TRUE(main_task_runner_->HasPendingTask()); |
| 508 EXPECT_TRUE(needs_main_frame_); | 522 EXPECT_TRUE(needs_main_frame_); |
| 509 main_task_runner_->RunUntilIdle(); | 523 main_task_runner_->RunUntilIdle(); |
| 510 EXPECT_EQ(0u, event_queue().size()); | 524 EXPECT_EQ(0u, event_queue().size()); |
| 511 RunPendingTasksWithSimulatedRaf(); | 525 RunPendingTasksWithSimulatedRaf(); |
| 512 | 526 |
| 513 // Simulate the rAF running before the PostTask occurs. The first rAF | 527 // Simulate the rAF running before the PostTask occurs. The rAF |
| 514 // shouldn't do anything. | 528 // will consume everything. |
| 515 HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 529 HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
| 516 HandleEvent(kEvents[1], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 530 HandleEvent(kEvents[1], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
| 517 EXPECT_EQ(2u, event_queue().size()); | 531 EXPECT_EQ(2u, event_queue().size()); |
| 518 EXPECT_TRUE(needs_main_frame_); | 532 EXPECT_TRUE(needs_main_frame_); |
| 519 RunSimulatedRafOnce(); | 533 RunSimulatedRafOnce(); |
| 520 EXPECT_FALSE(needs_main_frame_); | 534 EXPECT_FALSE(needs_main_frame_); |
| 535 EXPECT_EQ(0u, event_queue().size()); | |
| 536 main_task_runner_->RunUntilIdle(); | |
| 537 | |
| 538 // Simulate event consumption but no rAF signal. The mouse wheel events | |
|
mustaq
2017/03/24 15:31:18
s/mouse wheel events/touchmove event/.
dtapuska
2017/03/24 20:16:36
Done.
| |
| 539 // should still be in the queue. | |
| 540 handled_events_.clear(); | |
| 541 HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | |
| 542 HandleEvent(kEvents[1], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | |
| 521 EXPECT_EQ(2u, event_queue().size()); | 543 EXPECT_EQ(2u, event_queue().size()); |
| 522 RunPendingTasksWithSimulatedRaf(); | 544 EXPECT_TRUE(needs_main_frame_); |
| 523 EXPECT_EQ(0u, event_queue().size()); | 545 main_task_runner_->RunUntilIdle(); |
| 546 EXPECT_TRUE(needs_main_frame_); | |
| 547 EXPECT_EQ(1u, event_queue().size()); | |
| 548 RunSimulatedRafOnce(); | |
| 524 | 549 |
| 525 // Simulate the touch move being discrete | 550 // Simulate the touch move being discrete |
| 526 kEvents[0].touchStartOrFirstTouchMove = true; | 551 kEvents[0].touchStartOrFirstTouchMove = true; |
| 527 kEvents[1].touchStartOrFirstTouchMove = true; | 552 kEvents[1].touchStartOrFirstTouchMove = true; |
| 528 | 553 |
| 529 for (SyntheticWebTouchEvent& event : kEvents) | 554 for (SyntheticWebTouchEvent& event : kEvents) |
| 530 HandleEvent(event, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 555 HandleEvent(event, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 531 | 556 |
| 532 EXPECT_EQ(3u, event_queue().size()); | 557 EXPECT_EQ(3u, event_queue().size()); |
| 533 EXPECT_TRUE(main_task_runner_->HasPendingTask()); | 558 EXPECT_TRUE(main_task_runner_->HasPendingTask()); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 829 "MainThreadResponsivenessScrollIntervention", "Control"); | 854 "MainThreadResponsivenessScrollIntervention", "Control"); |
| 830 queue_ = new MainThreadEventQueue(kTestRoutingID, | 855 queue_ = new MainThreadEventQueue(kTestRoutingID, |
| 831 &dummy_main_thread_event_queue_client_, | 856 &dummy_main_thread_event_queue_client_, |
| 832 main_task_runner_, &renderer_scheduler_); | 857 main_task_runner_, &renderer_scheduler_); |
| 833 EXPECT_FALSE(enable_non_blocking_due_to_main_thread_responsiveness_flag()); | 858 EXPECT_FALSE(enable_non_blocking_due_to_main_thread_responsiveness_flag()); |
| 834 EXPECT_EQ(base::TimeDelta::FromMilliseconds(0), | 859 EXPECT_EQ(base::TimeDelta::FromMilliseconds(0), |
| 835 main_thread_responsiveness_threshold()); | 860 main_thread_responsiveness_threshold()); |
| 836 } | 861 } |
| 837 | 862 |
| 838 } // namespace content | 863 } // namespace content |
| OLD | NEW |