chromium/cc/input/input_handler.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "cc/input/input_handler.h"

#include <string>
#include <utility>
#include <vector>

#include "base/feature_list.h"
#include "base/notreached.h"
#include "base/types/optional_ref.h"
#include "build/build_config.h"
#include "cc/base/features.h"
#include "cc/input/browser_controls_offset_manager.h"
#include "cc/input/browser_controls_offset_tags_info.h"
#include "cc/input/scroll_elasticity_helper.h"
#include "cc/input/scroll_utils.h"
#include "cc/input/scrollbar_controller.h"
#include "cc/input/snap_selection_strategy.h"
#include "cc/layers/viewport.h"
#include "cc/trees/compositor_commit_data.h"
#include "cc/trees/latency_info_swap_promise_monitor.h"
#include "cc/trees/layer_tree_host_impl.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/layer_tree_settings.h"
#include "cc/trees/property_tree.h"
#include "cc/trees/scroll_node.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/vector2d_f.h"

namespace cc {

namespace {

enum SlowScrollMetricThread {};

InputHandlerClient::ScrollEventDispatchMode GetScrollEventDispatchMode() {}

}  // namespace

InputHandlerCommitData::InputHandlerCommitData() = default;
InputHandlerCommitData::~InputHandlerCommitData() = default;

// static
base::WeakPtr<InputHandler> InputHandler::Create(
    CompositorDelegateForInput& compositor_delegate) {}

InputHandler::InputHandler(CompositorDelegateForInput& compositor_delegate)
    :{}

InputHandler::~InputHandler() = default;

//
// =========== InputHandler Interface
//

base::WeakPtr<InputHandler> InputHandler::AsWeakPtr() {}

void InputHandler::BindToClient(InputHandlerClient* client) {}

InputHandler::ScrollStatus InputHandler::ScrollBegin(ScrollState* scroll_state,
                                                     ui::ScrollInputType type) {}

InputHandler::ScrollStatus InputHandler::RootScrollBegin(
    ScrollState* scroll_state,
    ui::ScrollInputType type) {}

InputHandlerScrollResult InputHandler::ScrollUpdate(
    ScrollState scroll_state,
    base::TimeDelta delayed_by) {}

void InputHandler::AdjustScrollDeltaForScrollbarSnap(
    ScrollState& scroll_state) {}

void InputHandler::ScrollEnd(bool should_snap) {}

void InputHandler::RecordScrollBegin(
    ui::ScrollInputType input_type,
    ScrollBeginThreadState scroll_start_state) {}

void InputHandler::RecordScrollEnd(ui::ScrollInputType input_type) {}

InputHandlerPointerResult InputHandler::MouseMoveAt(
    const gfx::Point& viewport_point) {}

PointerResultType InputHandler::HitTest(const gfx::PointF& viewport_point) {}

InputHandlerPointerResult InputHandler::MouseDown(
    const gfx::PointF& viewport_point,
    bool shift_modifier) {}

InputHandlerPointerResult InputHandler::MouseUp(
    const gfx::PointF& viewport_point) {}

void InputHandler::MouseLeave() {}

ElementId InputHandler::FindFrameElementIdAtPoint(
    const gfx::PointF& viewport_point) {}

void InputHandler::RequestUpdateForSynchronousInputHandler() {}

void InputHandler::SetSynchronousInputHandlerRootScrollOffset(
    const gfx::PointF& root_content_offset) {}

void InputHandler::PinchGestureBegin(const gfx::Point& anchor,
                                     ui::ScrollInputType source) {}

void InputHandler::PinchGestureUpdate(float magnify_delta,
                                      const gfx::Point& anchor) {}

void InputHandler::PinchGestureEnd(const gfx::Point& anchor) {}

void InputHandler::SetNeedsAnimateInput() {}

bool InputHandler::IsCurrentlyScrollingViewport() const {}

EventListenerProperties InputHandler::GetEventListenerProperties(
    EventListenerClass event_class) const {}

bool InputHandler::HasBlockingWheelEventHandlerAt(
    const gfx::Point& viewport_point) const {}

InputHandler::TouchStartOrMoveEventListenerType
InputHandler::EventListenerTypeForTouchStartOrMoveAt(
    const gfx::Point& viewport_point,
    TouchAction* out_touch_action) {}

std::unique_ptr<LatencyInfoSwapPromiseMonitor>
InputHandler::CreateLatencyInfoSwapPromiseMonitor(ui::LatencyInfo* latency) {}

std::unique_ptr<EventsMetricsManager::ScopedMonitor>
InputHandler::GetScopedEventMetricsMonitor(
    EventsMetricsManager::ScopedMonitor::DoneCallback done_callback) {}

ScrollElasticityHelper* InputHandler::CreateScrollElasticityHelper() {}

void InputHandler::DestroyScrollElasticityHelper() {}

bool InputHandler::GetScrollOffsetForLayer(ElementId element_id,
                                           gfx::PointF* offset) {}

bool InputHandler::ScrollLayerTo(ElementId element_id,
                                 const gfx::PointF& offset) {}

std::optional<gfx::PointF> InputHandler::ConstrainFling(gfx::PointF original) {}

double InputHandler::PredictViewportBoundsDelta(
    gfx::Vector2dF scroll_distance) {}

bool InputHandler::GetSnapFlingInfoAndSetAnimatingSnapTarget(
    const gfx::Vector2dF& current_delta,
    const gfx::Vector2dF& natural_displacement_in_viewport,
    gfx::PointF* out_initial_position,
    gfx::PointF* out_target_position) {}

void InputHandler::ScrollEndForSnapFling(bool did_finish) {}

void InputHandler::NotifyInputEvent() {}

//
// =========== InputDelegateForCompositor Interface
//

void InputHandler::ProcessCommitDeltas(
    CompositorCommitData* commit_data,
    const MutatorHost* main_thread_mutator_host) {}

void InputHandler::TickAnimations(base::TimeTicks monotonic_time) {}

void InputHandler::WillShutdown() {}

void InputHandler::WillDraw() {}

void InputHandler::WillBeginImplFrame(const viz::BeginFrameArgs& args) {}

void InputHandler::DidCommit() {}

void InputHandler::DidActivatePendingTree() {}

void InputHandler::DidFinishImplFrame() {}

void InputHandler::OnBeginImplFrameDeadline() {}

void InputHandler::RootLayerStateMayHaveChanged() {}

void InputHandler::DidRegisterScrollbar(ElementId scroll_element_id,
                                        ScrollbarOrientation orientation) {}

void InputHandler::DidUnregisterScrollbar(ElementId scroll_element_id,
                                          ScrollbarOrientation orientation) {}

void InputHandler::ScrollOffsetAnimationFinished() {}

void InputHandler::SetPrefersReducedMotion(bool prefers_reduced_motion) {}

bool InputHandler::IsCurrentlyScrolling() const {}

ActivelyScrollingType InputHandler::GetActivelyScrollingType() const {}

bool InputHandler::IsHandlingTouchSequence() const {}

bool InputHandler::IsCurrentScrollMainRepainted() const {}

bool InputHandler::HasQueuedInput() const {}

ScrollNode* InputHandler::CurrentlyScrollingNode() {}

const ScrollNode* InputHandler::CurrentlyScrollingNode() const {}

ScrollTree& InputHandler::GetScrollTree() {}

ScrollTree& InputHandler::GetScrollTree() const {}

ScrollNode* InputHandler::InnerViewportScrollNode() const {}

ScrollNode* InputHandler::OuterViewportScrollNode() const {}

Viewport& InputHandler::GetViewport() const {}

void InputHandler::SetNeedsCommit() {}

LayerTreeImpl& InputHandler::ActiveTree() {}

LayerTreeImpl& InputHandler::ActiveTree() const {}

FrameSequenceTrackerType InputHandler::GetTrackerTypeForScroll(
    ui::ScrollInputType input_type) const {}

float InputHandler::LineStep() const {}

// TODO(mehdika): There is some redundancy between this function and
// ScrollbarController::GetScrollDistanceForScrollbarPart, these two need to be
// kept in sync.
gfx::Vector2dF InputHandler::ResolveScrollGranularityToPixels(
    const ScrollNode& scroll_node,
    const gfx::Vector2dF& scroll_delta,
    ui::ScrollGranularity granularity) {}

InputHandler::ScrollHitTestResult InputHandler::HitTestScrollNode(
    const gfx::PointF& device_viewport_point) const {}

ScrollNode* InputHandler::GetNodeToScroll(ScrollNode* node) const {}

ScrollNode* InputHandler::GetNodeToScrollForLayer(
    const LayerImpl* layer) const {}

bool InputHandler::IsInitialScrollHitTestReliable(
    const LayerImpl* layer_impl,
    const LayerImpl* first_scrollable_or_opaque_to_hit_test_layer,
    ScrollNode*& out_node_to_scroll) const {}

gfx::Vector2dF InputHandler::ComputeScrollDelta(const ScrollNode& scroll_node,
                                                const gfx::Vector2dF& delta) {}

bool InputHandler::CalculateLocalScrollDeltaAndStartPoint(
    const ScrollNode& scroll_node,
    const gfx::PointF& viewport_point,
    const gfx::Vector2dF& viewport_delta,
    gfx::Vector2dF* out_local_scroll_delta,
    gfx::PointF* out_local_start_point /*= nullptr*/) {}

gfx::Vector2dF InputHandler::ScrollNodeWithViewportSpaceDelta(
    const ScrollNode& scroll_node,
    const gfx::PointF& viewport_point,
    const gfx::Vector2dF& viewport_delta) {}

gfx::Vector2dF InputHandler::ScrollNodeWithLocalDelta(
    const ScrollNode& scroll_node,
    const gfx::Vector2dF& local_delta) const {}

// TODO(danakj): Make this into two functions, one with delta, one with
// viewport_point, no bool required.
gfx::Vector2dF InputHandler::ScrollSingleNode(const ScrollNode& scroll_node,
                                              const gfx::Vector2dF& delta,
                                              const gfx::Point& viewport_point,
                                              bool is_direct_manipulation) {}

void InputHandler::ScrollLatchedScroller(ScrollState& scroll_state,
                                         base::TimeDelta delayed_by) {}

bool InputHandler::CanPropagate(ScrollNode* scroll_node, float x, float y) {}

ScrollNode* InputHandler::FindNodeToLatch(ScrollState* scroll_state,
                                          ScrollNode* starting_node,
                                          ui::ScrollInputType type) {}

void InputHandler::UpdateRootLayerStateForSynchronousInputHandler() {}

void InputHandler::DidLatchToScroller(const ScrollState& scroll_state,
                                      ui::ScrollInputType type) {}

bool InputHandler::CanConsumeDelta(const ScrollState& scroll_state,
                                   const ScrollNode& scroll_node) {}

bool InputHandler::ShouldAnimateScroll(const ScrollState& scroll_state) const {}

bool InputHandler::SnapAtScrollEnd(SnapReason reason) {}

bool InputHandler::IsAnimatingForSnap() const {}

gfx::PointF InputHandler::GetVisualScrollOffset(
    const ScrollNode& scroll_node) const {}

void InputHandler::ClearCurrentlyScrollingNode() {}

std::optional<gfx::PointF> InputHandler::ScrollAnimationUpdateTarget(
    const ScrollNode& scroll_node,
    const gfx::Vector2dF& scroll_delta,
    base::TimeDelta delayed_by) {}

void InputHandler::UpdateScrollSourceInfo(const ScrollState& scroll_state,
                                          ui::ScrollInputType type) {}

// Return true if scrollable node for 'ancestor' is the same as 'child' or an
// ancestor along the scroll tree.
bool InputHandler::IsScrolledBy(LayerImpl* child, ScrollNode* ancestor) {}

gfx::Vector2dF InputHandler::UserScrollableDelta(
    const ScrollNode& node,
    const gfx::Vector2dF& delta) const {}

bool InputHandler::ScrollbarScrollIsActive() {}

void InputHandler::SetDeferBeginMainFrame(bool defer_begin_main_frame) const {}

void InputHandler::UpdateBrowserControlsState(
    BrowserControlsState constraints,
    BrowserControlsState current,
    bool animate,
    base::optional_ref<const BrowserControlsOffsetTagsInfo> offset_tags_info) {}

void InputHandler::SetIsHandlingTouchSequence(bool is_handling_touch_sequence) {}

bool InputHandler::CurrentScrollNeedsFrameAlignment() const {}

std::unique_ptr<SnapSelectionStrategy> InputHandler::CreateSnapStrategy(
    const ScrollState& scroll_state,
    const gfx::PointF& current_offset,
    SnapReason snap_reason) const {}

}  // namespace cc