chromium/third_party/blink/renderer/platform/widget/input/elastic_overscroll_controller_bezier.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 "third_party/blink/renderer/platform/widget/input/elastic_overscroll_controller_bezier.h"
#include "ui/gfx/geometry/vector2d_conversions.h"

namespace blink {

namespace {
// The following constants are determined experimentally.

// Used to determine how far the scroller is allowed to stretch.
constexpr double kOverscrollBoundaryMultiplier =;

// Maximum duration for the bounce back animation.
constexpr double kBounceBackMaxDurationMilliseconds =;

// Time taken by the bounce back animation (in milliseconds) to scroll 1 px.
constexpr double kBounceBackMillisecondsPerPixel =;

// Threshold above which a forward animation should be played. Stray finger
// movements can cause velocities to be non-zero. This in-turn may lead to minor
// jerks when the bounce back animation is being played. Expressed in pixels per
// second.
constexpr double kIgnoreForwardBounceVelocityThreshold =;

constexpr double kOverbounceMaxDurationMilliseconds =;
constexpr double kOverbounceMillisecondsPerPixel =;
constexpr double kOverbounceDistanceMultiplier =;

// Control points for the bounce forward Cubic Bezier curve.
constexpr double kBounceForwardsX1 =;
constexpr double kBounceForwardsY1 =;
constexpr double kBounceForwardsX2 =;
constexpr double kBounceForwardsY2 =;

// Control points for the bounce back Cubic Bezier curve.
constexpr double kBounceBackwardsX1 =;
constexpr double kBounceBackwardsY1 =;
constexpr double kBounceBackwardsX2 =;
constexpr double kBounceBackwardsY2 =;

base::TimeDelta CalculateBounceForwardsDuration(
    double bounce_forwards_distance) {}

base::TimeDelta CalculateBounceBackDuration(double bounce_back_distance) {}
}  // namespace

// Scale one of the control points of the Cubic Bezier curve based on the
// initial_velocity (which is expressed in terms of pixels / ms).
gfx::CubicBezier InitialVelocityBasedBezierCurve(const double initial_velocity,
                                                 const double x1,
                                                 const double y1,
                                                 const double x2,
                                                 const double y2) {}

ElasticOverscrollControllerBezier::ElasticOverscrollControllerBezier(
    cc::ScrollElasticityHelper* helper)
    :{}

// Returns the maximum amount to be overscrolled.
gfx::Vector2dF ElasticOverscrollControllerBezier::OverscrollBoundary(
    const gfx::Size& scroller_bounds) const {}

void ElasticOverscrollControllerBezier::DidEnterMomentumAnimatedState() {}

double ElasticOverscrollControllerBezier::StretchAmountForForwardBounce(
    const gfx::CubicBezier bounce_forwards_curve,
    const base::TimeDelta& delta,
    const base::TimeDelta& bounce_forwards_duration,
    const double velocity,
    const double initial_stretch,
    const double bounce_forwards_distance) const {}

double ElasticOverscrollControllerBezier::StretchAmountForBackwardBounce(
    const gfx::CubicBezier bounce_backwards_curve,
    const base::TimeDelta& delta,
    const base::TimeDelta& bounce_backwards_duration,
    const double bounce_forwards_distance) const {}

gfx::Vector2d ElasticOverscrollControllerBezier::StretchAmountForTimeDelta(
    const base::TimeDelta& delta) const {}

// The goal of this calculation is to map the distance the user has scrolled
// past the boundary into the distance to actually scroll the elastic scroller.
gfx::Vector2d
ElasticOverscrollControllerBezier::StretchAmountForAccumulatedOverscroll(
    const gfx::Vector2dF& accumulated_overscroll) const {}

// This function does the inverse of StretchAmountForAccumulatedOverscroll. As
// in, instead of taking in the amount of distance overscrolled to get the
// bounce distance, it takes in the bounce distance and calculates how much is
// actually overscrolled.
gfx::Vector2d
ElasticOverscrollControllerBezier::AccumulatedOverscrollForStretchAmount(
    const gfx::Vector2dF& stretch_amount) const {}
}  // namespace blink