#include "third_party/blink/renderer/platform/widget/input/input_handler_proxy.h"
#include <stddef.h>
#include <algorithm>
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/profiler/sample_metadata.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/default_tick_clock.h"
#include "base/trace_event/trace_event.h"
#include "base/types/optional_ref.h"
#include "build/build_config.h"
#include "cc/base/features.h"
#include "cc/input/browser_controls_offset_tags_info.h"
#include "cc/input/main_thread_scrolling_reason.h"
#include "cc/metrics/event_metrics.h"
#include "cc/trees/latency_info_swap_promise_monitor.h"
#include "services/tracing/public/cpp/perfetto/flow_event_utils.h"
#include "services/tracing/public/cpp/perfetto/macros.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/input/web_input_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/public/common/input/web_pointer_event.h"
#include "third_party/blink/public/common/input/web_touch_event.h"
#include "third_party/blink/renderer/platform/widget/input/compositor_thread_event_queue.h"
#include "third_party/blink/renderer/platform/widget/input/cursor_control_handler.h"
#include "third_party/blink/renderer/platform/widget/input/elastic_overscroll_controller.h"
#include "third_party/blink/renderer/platform/widget/input/event_with_callback.h"
#include "third_party/blink/renderer/platform/widget/input/input_handler_proxy_client.h"
#include "third_party/blink/renderer/platform/widget/input/input_metrics.h"
#include "third_party/blink/renderer/platform/widget/input/scroll_predictor.h"
#include "ui/events/types/scroll_input_type.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/latency/latency_info.h"
ChromeLatencyInfo;
TrackEvent;
ScrollThread;
namespace blink {
namespace {
cc::ScrollStateData CreateScrollStateDataForGesture(
const WebGestureEvent& event) { … }
cc::ScrollState CreateScrollStateForInertialUpdate(
const gfx::Vector2dF& delta) { … }
ui::ScrollInputType GestureScrollInputType(WebGestureDevice device) { … }
cc::SnapFlingController::GestureScrollType GestureScrollEventType(
WebInputEvent::Type web_event_type) { … }
cc::SnapFlingController::GestureScrollUpdateInfo GetGestureScrollUpdateInfo(
const WebGestureEvent& event) { … }
cc::ScrollBeginThreadState RecordScrollingThread(
bool scrolling_on_compositor_thread,
bool blocked_on_main_at_begin,
WebGestureDevice device) { … }
bool IsGestureScrollOrPinch(WebInputEvent::Type type) { … }
bool DoNotEnqueueLateScrollEvents(
cc::InputHandlerClient::ScrollEventDispatchMode mode) { … }
}
InputHandlerProxy::InputHandlerProxy(cc::InputHandler& input_handler,
InputHandlerProxyClient* client)
: … { … }
InputHandlerProxy::~InputHandlerProxy() { … }
void InputHandlerProxy::WillShutdown() { … }
void InputHandlerProxy::HandleInputEventWithLatencyInfo(
std::unique_ptr<blink::WebCoalescedInputEvent> event,
std::unique_ptr<cc::EventMetrics> metrics,
EventDispositionCallback callback) { … }
void InputHandlerProxy::ContinueScrollBeginAfterMainThreadHitTest(
std::unique_ptr<blink::WebCoalescedInputEvent> event,
std::unique_ptr<cc::EventMetrics> metrics,
EventDispositionCallback callback,
cc::ElementId hit_test_result) { … }
void InputHandlerProxy::DispatchSingleInputEvent(
std::unique_ptr<EventWithCallback> event_with_callback) { … }
bool InputHandlerProxy::HasQueuedEventsReadyForDispatch(
bool frame_aligned) const { … }
void InputHandlerProxy::DispatchQueuedInputEvents(bool frame_aligned) { … }
void InputHandlerProxy::GenerateAndDispatchSytheticScrollPrediction(
const viz::BeginFrameArgs& args) { … }
void InputHandlerProxy::UpdateElasticOverscroll() { … }
void InputHandlerProxy::InjectScrollbarGestureScroll(
const WebInputEvent::Type type,
const gfx::PointF& position_in_widget,
const cc::InputHandlerPointerResult& pointer_result,
const ui::LatencyInfo& latency_info,
const base::TimeTicks original_timestamp,
const cc::EventMetrics* original_metrics) { … }
bool HasScrollbarJumpKeyModifier(const WebInputEvent& event) { … }
InputHandlerProxy::EventDisposition
InputHandlerProxy::RouteToTypeSpecificHandler(
EventWithCallback* event_with_callback,
const WebInputEventAttribution& original_attribution) { … }
WebInputEventAttribution InputHandlerProxy::PerformEventAttribution(
const WebInputEvent& event) { … }
void InputHandlerProxy::RecordScrollBegin(
WebGestureDevice device,
uint32_t main_thread_hit_tested_reasons,
uint32_t main_thread_repaint_reasons) { … }
InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel(
const WebMouseWheelEvent& wheel_event) { … }
InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollBegin(
const WebGestureEvent& gesture_event) { … }
InputHandlerProxy::EventDisposition
InputHandlerProxy::HandleGestureScrollUpdate(
const WebGestureEvent& gesture_event,
const WebInputEventAttribution& original_attribution,
cc::EventMetrics* metrics,
int64_t trace_id) { … }
InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollEnd(
const WebGestureEvent& gesture_event) { … }
void InputHandlerProxy::InputHandlerScrollEnd() { … }
InputHandlerProxy::EventDisposition InputHandlerProxy::HitTestTouchEvent(
const WebTouchEvent& touch_event,
bool* is_touching_scrolling_layer,
cc::TouchAction* allowed_touch_action) { … }
InputHandlerProxy::EventDisposition InputHandlerProxy::HandleTouchStart(
EventWithCallback* event_with_callback) { … }
InputHandlerProxy::EventDisposition InputHandlerProxy::HandleTouchMove(
EventWithCallback* event_with_callback) { … }
InputHandlerProxy::EventDisposition InputHandlerProxy::HandleTouchEnd(
EventWithCallback* event_with_callback) { … }
void InputHandlerProxy::Animate(base::TimeTicks time) { … }
void InputHandlerProxy::ReconcileElasticOverscrollAndRootScroll() { … }
void InputHandlerProxy::SetPrefersReducedMotion(bool prefers_reduced_motion) { … }
void InputHandlerProxy::UpdateRootLayerStateForSynchronousInputHandler(
const gfx::PointF& total_scroll_offset,
const gfx::PointF& max_scroll_offset,
const gfx::SizeF& scrollable_size,
float page_scale_factor,
float min_page_scale_factor,
float max_page_scale_factor) { … }
void InputHandlerProxy::DeliverInputForBeginFrame(
const viz::BeginFrameArgs& args) { … }
void InputHandlerProxy::DeliverInputForHighLatencyMode() { … }
void InputHandlerProxy::DeliverInputForDeadline() { … }
void InputHandlerProxy::DidFinishImplFrame() { … }
bool InputHandlerProxy::HasQueuedInput() const { … }
void InputHandlerProxy::SetScrollEventDispatchMode(
ScrollEventDispatchMode mode) { … }
void InputHandlerProxy::SetSynchronousInputHandler(
SynchronousInputHandler* synchronous_input_handler) { … }
void InputHandlerProxy::SynchronouslySetRootScrollOffset(
const gfx::PointF& root_offset) { … }
void InputHandlerProxy::SynchronouslyZoomBy(float magnify_delta,
const gfx::Point& anchor) { … }
bool InputHandlerProxy::GetSnapFlingInfoAndSetAnimatingSnapTarget(
const gfx::Vector2dF& current_delta,
const gfx::Vector2dF& natural_displacement,
gfx::PointF* initial_offset,
gfx::PointF* target_offset) const { … }
gfx::PointF InputHandlerProxy::ScrollByForSnapFling(
const gfx::Vector2dF& delta) { … }
void InputHandlerProxy::ScrollEndForSnapFling(bool did_finish) { … }
void InputHandlerProxy::RequestAnimationForSnapFling() { … }
void InputHandlerProxy::UpdateBrowserControlsState(
cc::BrowserControlsState constraints,
cc::BrowserControlsState current,
bool animate,
base::optional_ref<const cc::BrowserControlsOffsetTagsInfo>
offset_tags_info) { … }
void InputHandlerProxy::FlushQueuedEventsForTesting() { … }
void InputHandlerProxy::HandleOverscroll(
const gfx::PointF& causal_event_viewport_point,
const cc::InputHandlerScrollResult& scroll_result) { … }
void InputHandlerProxy::RequestAnimation() { … }
void InputHandlerProxy::HandleScrollElasticityOverscroll(
const WebGestureEvent& gesture_event,
const cc::InputHandlerScrollResult& scroll_result) { … }
void InputHandlerProxy::SetTickClockForTesting(
const base::TickClock* tick_clock) { … }
const cc::InputHandlerPointerResult InputHandlerProxy::HandlePointerDown(
EventWithCallback* event_with_callback,
const gfx::PointF& position) { … }
const cc::InputHandlerPointerResult InputHandlerProxy::HandlePointerMove(
EventWithCallback* event_with_callback,
const gfx::PointF& position,
bool should_cancel_scrollbar_drag) { … }
const cc::InputHandlerPointerResult InputHandlerProxy::HandlePointerUp(
EventWithCallback* event_with_callback,
const gfx::PointF& position) { … }
void InputHandlerProxy::SetDeferBeginMainFrame(
bool defer_begin_main_frame) const { … }
void InputHandlerProxy::RequestCallbackAfterEventQueueFlushed(
base::OnceClosure callback) { … }
}