chromium/cc/input/scroll_snap_data.cc

// Copyright 2017 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/scroll_snap_data.h"

#include <algorithm>
#include <cmath>
#include <limits>
#include <memory>
#include <optional>

#include "base/auto_reset.h"
#include "base/check.h"
#include "base/notreached.h"
#include "cc/base/features.h"
#include "cc/input/snap_selection_strategy.h"
#include "ui/gfx/geometry/vector2d_f.h"

namespace cc {
namespace {

gfx::Vector2dF DistanceFromCorridor(double dx,
                                    double dy,
                                    const gfx::RectF& area) {}

bool IsMutualVisible(const SnapSearchResult& a, const SnapSearchResult& b) {}

void SetOrUpdateResult(const SnapSearchResult& candidate,
                       std::optional<SnapSearchResult>* result) {}

const std::optional<SnapSearchResult>& ClosestSearchResult(
    const gfx::PointF reference_point,
    SearchAxis axis,
    const std::optional<SnapSearchResult>& a,
    const std::optional<SnapSearchResult>& b) {}

std::optional<SnapSearchResult> SearchResultForDodgingRange(
    const gfx::RangeF& area_range,
    const gfx::RangeF& dodging_range,
    const SnapSearchResult& aligned_candidate,
    float preferred_offset,
    float scroll_padding,
    float snapport_size,
    SnapAlignment alignment) {}

bool CanCoverSnapportOnAxis(SearchAxis axis,
                            const gfx::RectF& container_rect,
                            const gfx::RectF& area_rect) {}

}  // namespace

SnapSearchResult::SnapSearchResult(float offset,
                                   SearchAxis axis,
                                   gfx::RangeF snapport_visible_range,
                                   float snapport_max_visible)
    :{}

void SnapSearchResult::Clip(float max_snap) {}

void SnapSearchResult::Union(const SnapSearchResult& other) {}

SnapContainerData::SnapContainerData()
    :{}

SnapContainerData::SnapContainerData(ScrollSnapType type)
    :{}

SnapContainerData::SnapContainerData(ScrollSnapType type,
                                     const gfx::RectF& rect,
                                     const gfx::PointF& max)
    :{}

SnapContainerData::SnapContainerData(const SnapContainerData& other) = default;

SnapContainerData::SnapContainerData(SnapContainerData&& other) = default;

SnapContainerData::~SnapContainerData() = default;

SnapContainerData& SnapContainerData::operator=(
    const SnapContainerData& other) = default;

SnapContainerData& SnapContainerData::operator=(SnapContainerData&& other) =
    default;

void SnapContainerData::AddSnapAreaData(SnapAreaData snap_area_data) {}

SnapPositionData SnapContainerData::FindSnapPositionWithViewportAdjustment(
    const SnapSelectionStrategy& strategy,
    double snapport_height_adjustment) {}

SnapPositionData SnapContainerData::FindSnapPosition(
    const SnapSelectionStrategy& strategy) const {}

// This method is called only if the preferred algorithm fails to find either an
// x or a y snap position.
// The base algorithm searches on x (if appropriate) and then y (if
// appropriate). Each search is along the corridor in the search direction.
// For a search in the x-direction, areas as excluded from consideration if the
// range in the y-direction does not overlap the y base position (i.e. can
// scroll-snap in the x-direction without scrolling in the y-direction). Rules
// for scroll-snap in the y-direction are symmetric. This is the preferred
// approach, though the ordering of the searches should perhaps be determined
// based on axis locking.
// In cases where no valid snap points are found via searches along the axis
// corridors, the snap selection strategy allows for selection of areas outside
// of the corridors.
bool SnapContainerData::FindSnapPositionForMutualSnap(
    const SnapSelectionStrategy& strategy,
    gfx::PointF* snap_position) const {}

std::optional<SnapSearchResult>
SnapContainerData::GetTargetSnapAreaSearchResult(
    const SnapSelectionStrategy& strategy,
    SearchAxis axis,
    SnapSearchResult cross_axis_snap_result) const {}

void SnapContainerData::UpdateSnapAreaForTesting(ElementId element_id,
                                                 SnapAreaData snap_area_data) {}

const TargetSnapAreaElementIds& SnapContainerData::GetTargetSnapAreaElementIds()
    const {}

bool SnapContainerData::SetTargetSnapAreaElementIds(
    TargetSnapAreaElementIds ids) {}

std::optional<SnapSearchResult> SnapContainerData::FindClosestValidArea(
    SearchAxis axis,
    const SnapSelectionStrategy& strategy,
    const SnapSearchResult& cross_axis_snap_result) const {}

std::optional<SnapSearchResult> SnapContainerData::FindClosestValidAreaInternal(
    SearchAxis axis,
    const SnapSelectionStrategy& strategy,
    const SnapSearchResult& cross_axis_snap_result,
    bool should_consider_covering,
    std::optional<gfx::RangeF> active_element_range) const {}

SnapSearchResult SnapContainerData::GetSnapSearchResult(
    SearchAxis axis,
    const SnapAreaData& area) const {}

std::optional<SnapSearchResult> SnapContainerData::FindCoveringCandidate(
    const SnapAreaData& area,
    SearchAxis axis,
    const SnapSearchResult& aligned_candidate,
    float intended_position) const {}

constexpr float kSnapportCoveredTolerance =;
bool SnapContainerData::IsSnapportCoveredOnAxis(
    SearchAxis axis,
    float current_offset,
    const gfx::RectF& area_rect) const {}

// TODO(crbug.com/40941354): Use tolerance value less than 1.
// It is currently set to 1 because of differences in the way Blink and cc
// currently handle fractional offsets when snapping.
constexpr float kSnappedToTolerance =;
bool SnapContainerData::IsSnappedToArea(
    const SnapAreaData& area,
    const gfx::PointF& scroll_offset) const {}

gfx::RectF SnapContainerData::snapport() const {}

void SnapContainerData::UpdateSearchAlternative(
    SnapSearchResult& current_result,
    const SnapSearchResult& candidate_result,
    const SnapAreaData& candidate_area,
    const SnapSelectionStrategy& strategy) const {}

void SnapContainerData::SelectAlternativeIdForSearchResult(
    SnapSearchResult& selection,
    const std::optional<SnapSearchResult>& cross_selection,
    float cross_current_position,
    float cross_max_position) const {}

SnapAxis SnapContainerData::SelectAxisToFollowForMutualVisibility(
    const SnapSelectionStrategy& strategy,
    const SnapSearchResult& selected_x,
    const SnapSearchResult& selected_y) const {}

std::ostream& operator<<(std::ostream& ostream, const SnapAreaData& area_data) {}

std::ostream& operator<<(std::ostream& ostream,
                         const SnapContainerData& container_data) {}

}  // namespace cc