#include "third_party/blink/renderer/platform/widget/input/main_thread_event_queue.h"
#include <utility>
#include "base/containers/circular_deque.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "cc/base/features.h"
#include "cc/metrics/event_metrics.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/input/web_coalesced_input_event.h"
#include "third_party/blink/public/common/input/web_gesture_event.h"
#include "third_party/blink/public/common/input/web_input_event_attribution.h"
#include "third_party/blink/public/common/input/web_mouse_wheel_event.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace blink {
namespace {
constexpr base::TimeDelta kMaxRafDelay = …;
class QueuedClosure : public MainThreadEventQueueTask { … };
constexpr base::TimeDelta kAsyncTouchMoveInterval = …;
bool IsGestureScroll(WebInputEvent::Type type) { … }
}
class QueuedWebInputEvent : public MainThreadEventQueueTask { … };
MainThreadEventQueue::MainThreadEventQueue(
MainThreadEventQueueClient* client,
const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
scoped_refptr<scheduler::WidgetScheduler> widget_scheduler,
bool allow_raf_aligned_input)
: … { … }
MainThreadEventQueue::~MainThreadEventQueue() { … }
bool MainThreadEventQueue::Allowed(const WebInputEvent& event,
bool force_allow) { … }
void MainThreadEventQueue::HandleEvent(
std::unique_ptr<WebCoalescedInputEvent> event,
DispatchType original_dispatch_type,
mojom::blink::InputEventResultState ack_result,
const WebInputEventAttribution& attribution,
std::unique_ptr<cc::EventMetrics> metrics,
HandledEventCallback callback,
bool allow_main_gesture_scroll) { … }
void MainThreadEventQueue::QueueClosure(base::OnceClosure closure) { … }
void MainThreadEventQueue::PossiblyScheduleMainFrame() { … }
void MainThreadEventQueue::DispatchEvents() { … }
static bool IsAsyncTouchMove(
const std::unique_ptr<MainThreadEventQueueTask>& queued_item) { … }
void MainThreadEventQueue::RafFallbackTimerFired() { … }
void MainThreadEventQueue::ClearRafFallbackTimerForTesting() { … }
bool MainThreadEventQueue::IsEmptyForTesting() { … }
void MainThreadEventQueue::DispatchRafAlignedInput(base::TimeTicks frame_time) { … }
void MainThreadEventQueue::PostTaskToMainThread() { … }
void MainThreadEventQueue::QueueEvent(
std::unique_ptr<MainThreadEventQueueTask> event) { … }
bool MainThreadEventQueue::IsRawUpdateEvent(
const std::unique_ptr<MainThreadEventQueueTask>& item) const { … }
bool MainThreadEventQueue::ShouldFlushQueue(
const std::unique_ptr<MainThreadEventQueueTask>& item) const { … }
bool MainThreadEventQueue::IsRafAlignedEvent(
const std::unique_ptr<MainThreadEventQueueTask>& item) const { … }
void MainThreadEventQueue::HandleEventResampling(
const std::unique_ptr<MainThreadEventQueueTask>& item,
base::TimeTicks frame_time) { … }
bool MainThreadEventQueue::HandleEventOnMainThread(
const WebCoalescedInputEvent& event,
const WebInputEventAttribution& attribution,
std::unique_ptr<cc::EventMetrics> metrics,
HandledEventCallback handled_callback) { … }
void MainThreadEventQueue::SetNeedsMainFrame() { … }
void MainThreadEventQueue::ClearClient() { … }
void MainThreadEventQueue::SetNeedsLowLatency(bool low_latency) { … }
void MainThreadEventQueue::SetNeedsUnbufferedInputForDebugger(bool unbuffered) { … }
void MainThreadEventQueue::SetHasPointerRawUpdateEventHandlers(
bool has_handlers) { … }
void MainThreadEventQueue::RequestUnbufferedInputEvents() { … }
void MainThreadEventQueue::UnblockQueuedBlockingTouchMovesIfNeeded(
const WebInputEvent& dispatched_event,
mojom::blink::InputEventResultState ack_result) { … }
MainThreadEventQueue::MainThreadOnly&
MainThreadEventQueue::GetMainThreadOnly() { … }
MainThreadEventQueue::CompositorThreadOnly&
MainThreadEventQueue::GetCompositorThreadOnly() { … }
}