| 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 a9875e9b803898053c93819fc1cae9451c0001c4..1acd21707e62408244b7d375f48c0782f483b0a2 100644
|
| --- a/content/renderer/input/main_thread_event_queue.cc
|
| +++ b/content/renderer/input/main_thread_event_queue.cc
|
| @@ -9,6 +9,7 @@
|
| #include "base/strings/string_number_conversions.h"
|
| #include "content/common/input/event_with_latency_info.h"
|
| #include "content/common/input_messages.h"
|
| +#include "content/renderer/render_widget.h"
|
|
|
| namespace content {
|
|
|
| @@ -30,16 +31,7 @@ class QueuedClosure : public MainThreadEventQueueTask {
|
|
|
| bool IsWebInputEvent() const override { return false; }
|
|
|
| - void Dispatch(int routing_id, MainThreadEventQueueClient*) override {
|
| - closure_.Run();
|
| - }
|
| -
|
| - void EventHandled(int routing_id,
|
| - blink::scheduler::RendererScheduler* renderer_scheduler,
|
| - MainThreadEventQueueClient* client,
|
| - blink::WebInputEvent::Type type,
|
| - blink::WebInputEventResult result,
|
| - InputEventAckState ack_result) override {}
|
| + void Dispatch(MainThreadEventQueue*) override { closure_.Run(); }
|
|
|
| private:
|
| base::Closure closure_;
|
| @@ -99,7 +91,7 @@ class QueuedWebInputEvent : public ScopedWebInputEventWithLatencyInfo,
|
|
|
| bool IsWebInputEvent() const override { return true; }
|
|
|
| - void Dispatch(int routing_id, MainThreadEventQueueClient* client) override {
|
| + void Dispatch(MainThreadEventQueue* queue) override {
|
| // 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();
|
| @@ -121,34 +113,11 @@ class QueuedWebInputEvent : public ScopedWebInputEventWithLatencyInfo,
|
| (now - creationTimestamp()).InMicroseconds(), 1, kTenSeconds, 50);
|
| }
|
|
|
| - InputEventDispatchType dispatch_type = dispatchType();
|
| - if (!blockingCoalescedEventIds().empty()) {
|
| - switch (dispatch_type) {
|
| - case DISPATCH_TYPE_BLOCKING:
|
| - dispatch_type = DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN;
|
| - break;
|
| - case DISPATCH_TYPE_NON_BLOCKING:
|
| - dispatch_type = DISPATCH_TYPE_NON_BLOCKING_NOTIFY_MAIN;
|
| - break;
|
| - default:
|
| - NOTREACHED();
|
| - }
|
| - }
|
| - client->HandleEventOnMainThread(routing_id, &coalesced_event(),
|
| - latencyInfo(), dispatch_type);
|
| - }
|
| -
|
| - void EventHandled(int routing_id,
|
| - blink::scheduler::RendererScheduler* renderer_scheduler,
|
| - MainThreadEventQueueClient* client,
|
| - blink::WebInputEvent::Type type,
|
| - blink::WebInputEventResult result,
|
| - InputEventAckState ack_result) override {
|
| + InputEventAckState ack_result = queue->HandleEventOnMainThread(
|
| + coalesced_event(), latencyInfo(), dispatchType());
|
| for (const auto id : blockingCoalescedEventIds()) {
|
| - client->SendInputEventAck(routing_id, type, ack_result, id);
|
| - if (renderer_scheduler) {
|
| - renderer_scheduler->DidHandleInputEventOnMainThread(event(), result);
|
| - }
|
| + queue->SendInputEventAck(event().GetType(), ack_result, id);
|
| + queue->NotifySchedulerOfEventHandled(event(), ack_result);
|
| }
|
| }
|
|
|
| @@ -245,13 +214,9 @@ MainThreadEventQueue::SharedState::SharedState()
|
| MainThreadEventQueue::SharedState::~SharedState() {}
|
|
|
| MainThreadEventQueue::MainThreadEventQueue(
|
| - int routing_id,
|
| - MainThreadEventQueueClient* client,
|
| const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
|
| blink::scheduler::RendererScheduler* renderer_scheduler)
|
| - : routing_id_(routing_id),
|
| - client_(client),
|
| - last_touch_start_forced_nonblocking_due_to_fling_(false),
|
| + : last_touch_start_forced_nonblocking_due_to_fling_(false),
|
| enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled(
|
| features::kPassiveEventListenersDueToFling)),
|
| enable_non_blocking_due_to_main_thread_responsiveness_flag_(
|
| @@ -391,7 +356,7 @@ void MainThreadEventQueue::QueueClosure(const base::Closure& closure) {
|
|
|
| void MainThreadEventQueue::DispatchInFlightEvent() {
|
| if (in_flight_event_) {
|
| - in_flight_event_->Dispatch(routing_id_, client_);
|
| + in_flight_event_->Dispatch(this);
|
| in_flight_event_.reset();
|
| }
|
| }
|
| @@ -410,7 +375,7 @@ void MainThreadEventQueue::PossiblyScheduleMainFrame() {
|
| }
|
| }
|
| if (needs_main_frame)
|
| - client_->NeedsMainFrame(routing_id_);
|
| + NeedsMainFrame();
|
| }
|
|
|
| void MainThreadEventQueue::DispatchEvents() {
|
| @@ -444,15 +409,6 @@ void MainThreadEventQueue::DispatchEvents() {
|
| PossiblyScheduleMainFrame();
|
| }
|
|
|
| -void MainThreadEventQueue::EventHandled(blink::WebInputEvent::Type type,
|
| - blink::WebInputEventResult result,
|
| - InputEventAckState ack_result) {
|
| - if (in_flight_event_) {
|
| - in_flight_event_->EventHandled(routing_id_, renderer_scheduler_, client_,
|
| - type, result, ack_result);
|
| - }
|
| -}
|
| -
|
| void MainThreadEventQueue::DispatchRafAlignedInput(base::TimeTicks frame_time) {
|
| if (IsRafAlignedInputDisabled())
|
| return;
|
| @@ -526,7 +482,7 @@ void MainThreadEventQueue::QueueEvent(
|
| if (needs_post_task)
|
| PostTaskToMainThread();
|
| if (needs_main_frame)
|
| - client_->NeedsMainFrame(routing_id_);
|
| + NeedsMainFrame();
|
| }
|
|
|
| bool MainThreadEventQueue::IsRafAlignedInputDisabled() const {
|
| @@ -550,4 +506,58 @@ bool MainThreadEventQueue::IsRafAlignedEvent(
|
| }
|
| }
|
|
|
| +void MainThreadEventQueue::NotifySchedulerOfEventHandled(
|
| + const blink::WebInputEvent& event,
|
| + InputEventAckState ack_result) {
|
| + if (renderer_scheduler_) {
|
| + renderer_scheduler_->DidHandleInputEventOnMainThread(
|
| + event, ack_result == INPUT_EVENT_ACK_STATE_CONSUMED
|
| + ? blink::WebInputEventResult::kHandledApplication
|
| + : blink::WebInputEventResult::kNotHandled);
|
| + }
|
| +}
|
| +
|
| +MainThreadEventQueueWithRenderWidget::MainThreadEventQueueWithRenderWidget(
|
| + const base::WeakPtr<RenderWidget>& widget,
|
| + blink::scheduler::RendererScheduler* renderer_scheduler)
|
| + : MainThreadEventQueue(renderer_scheduler->CompositorTaskRunner(),
|
| + renderer_scheduler),
|
| + widget_(widget) {}
|
| +
|
| +MainThreadEventQueueWithRenderWidget::~MainThreadEventQueueWithRenderWidget() {}
|
| +
|
| +InputEventAckState
|
| +MainThreadEventQueueWithRenderWidget::HandleEventOnMainThread(
|
| + const blink::WebCoalescedInputEvent& event,
|
| + const ui::LatencyInfo& latency,
|
| + InputEventDispatchType dispatch_type) {
|
| + if (widget_)
|
| + return widget_->HandleInputEvent(event, latency, dispatch_type);
|
| + return INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
|
| +}
|
| +
|
| +void MainThreadEventQueueWithRenderWidget::SendInputEventAck(
|
| + blink::WebInputEvent::Type type,
|
| + InputEventAckState ack_result,
|
| + uint32_t touch_event_id) {
|
| + DCHECK(main_task_runner_->BelongsToCurrentThread());
|
| + if (!widget_)
|
| + return;
|
| + InputEventAck ack(InputEventAckSource::MAIN_THREAD, type, ack_result,
|
| + touch_event_id);
|
| + widget_->Send(new InputHostMsg_HandleInputEvent_ACK(MSG_ROUTING_NONE, ack));
|
| +}
|
| +
|
| +void MainThreadEventQueueWithRenderWidget::NeedsMainFrame() {
|
| + if (main_task_runner_->BelongsToCurrentThread()) {
|
| + if (widget_)
|
| + widget_->SetNeedsMainFrame();
|
| + return;
|
| + }
|
| +
|
| + main_task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&MainThreadEventQueueWithRenderWidget::NeedsMainFrame, this));
|
| +}
|
| +
|
| } // namespace content
|
|
|