#include "third_party/blink/renderer/core/frame/root_frame_viewport.h"
#include "base/barrier_callback.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/task/single_thread_task_runner.h"
#include "cc/input/snap_selection_strategy.h"
#include "third_party/blink/public/mojom/scroll/scroll_into_view_params.mojom-blink.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/layout/layout_box.h"
#include "third_party/blink/renderer/core/layout/scroll_anchor.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/scroll/scroll_alignment.h"
#include "third_party/blink/renderer/core/scroll/scroll_animator.h"
#include "third_party/blink/renderer/core/scroll/scroll_animator_base.h"
#include "third_party/blink/renderer/core/scroll/scroll_into_view_util.h"
#include "third_party/blink/renderer/core/scroll/scrollable_area.h"
#include "third_party/blink/renderer/core/scroll/smooth_scroll_sequencer.h"
#include "ui/gfx/geometry/rect_f.h"
namespace blink {
namespace {
gfx::RectF GetUserScrollableRect(const ScrollableArea& area) { … }
static base::RepeatingCallback<void(ScrollableArea::ScrollCompletionMode)>
MakeViewportScrollCompletion(ScrollableArea::ScrollCallback callback) { … }
}
RootFrameViewport::RootFrameViewport(ScrollableArea& visual_viewport,
ScrollableArea& layout_viewport)
: … { … }
void RootFrameViewport::SetLayoutViewport(ScrollableArea& new_layout_viewport) { … }
ScrollableArea& RootFrameViewport::LayoutViewport() const { … }
PhysicalRect RootFrameViewport::RootContentsToLayoutViewportContents(
LocalFrameView& root_frame_view,
const PhysicalRect& rect) const { … }
void RootFrameViewport::RestoreToAnchor(const ScrollOffset& target_offset) { … }
void RootFrameViewport::DidUpdateVisualViewport() { … }
LayoutBox* RootFrameViewport::GetLayoutBox() const { … }
gfx::QuadF RootFrameViewport::LocalToVisibleContentQuad(
const gfx::QuadF& quad,
const LayoutObject* local_object,
unsigned flags) const { … }
scoped_refptr<base::SingleThreadTaskRunner>
RootFrameViewport::GetTimerTaskRunner() const { … }
int RootFrameViewport::HorizontalScrollbarHeight(
OverlayScrollbarClipBehavior behavior) const { … }
int RootFrameViewport::VerticalScrollbarWidth(
OverlayScrollbarClipBehavior behavior) const { … }
void RootFrameViewport::UpdateScrollAnimator() { … }
ScrollOffset RootFrameViewport::ScrollOffsetFromScrollAnimators() const { … }
gfx::Rect RootFrameViewport::VisibleContentRect(
IncludeScrollbarsInRect scrollbar_inclusion) const { … }
PhysicalRect RootFrameViewport::VisibleScrollSnapportRect(
IncludeScrollbarsInRect scrollbar_inclusion) const { … }
bool RootFrameViewport::ShouldUseIntegerScrollOffset() const { … }
bool RootFrameViewport::IsActive() const { … }
int RootFrameViewport::ScrollSize(ScrollbarOrientation orientation) const { … }
bool RootFrameViewport::IsScrollCornerVisible() const { … }
gfx::Rect RootFrameViewport::ScrollCornerRect() const { … }
void RootFrameViewport::ApplyPendingHistoryRestoreScrollOffset() { … }
bool RootFrameViewport::SetScrollOffset(
const ScrollOffset& offset,
mojom::blink::ScrollType scroll_type,
mojom::blink::ScrollBehavior scroll_behavior,
ScrollCallback on_finish) { … }
mojom::blink::ScrollBehavior RootFrameViewport::ScrollBehaviorStyle() const { … }
mojom::blink::ColorScheme RootFrameViewport::UsedColorSchemeScrollbars() const { … }
ScrollOffset RootFrameViewport::ClampToUserScrollableOffset(
const ScrollOffset& offset) const { … }
PhysicalOffset RootFrameViewport::LocalToScrollOriginOffset() const { … }
PhysicalRect RootFrameViewport::ScrollIntoView(
const PhysicalRect& rect_in_absolute,
const PhysicalBoxStrut& scroll_margin,
const mojom::blink::ScrollIntoViewParamsPtr& params) { … }
void RootFrameViewport::UpdateScrollOffset(
const ScrollOffset& offset,
mojom::blink::ScrollType scroll_type) { … }
bool RootFrameViewport::DistributeScrollBetweenViewports(
const ScrollOffset& offset,
mojom::blink::ScrollType scroll_type,
mojom::blink::ScrollBehavior behavior,
ViewportToScrollFirst scroll_first,
ScrollCallback on_finish) { … }
gfx::Vector2d RootFrameViewport::ScrollOffsetInt() const { … }
ScrollOffset RootFrameViewport::GetScrollOffset() const { … }
gfx::Vector2d RootFrameViewport::MinimumScrollOffsetInt() const { … }
gfx::Vector2d RootFrameViewport::MaximumScrollOffsetInt() const { … }
ScrollOffset RootFrameViewport::MaximumScrollOffset() const { … }
gfx::Size RootFrameViewport::ContentsSize() const { … }
bool RootFrameViewport::UsesCompositedScrolling() const { … }
bool RootFrameViewport::ShouldScrollOnMainThread() const { … }
bool RootFrameViewport::ScrollbarsCanBeActive() const { … }
bool RootFrameViewport::UserInputScrollable(
ScrollbarOrientation orientation) const { … }
bool RootFrameViewport::ShouldPlaceVerticalScrollbarOnLeft() const { … }
void RootFrameViewport::ScrollControlWasSetNeedsPaintInvalidation() { … }
cc::Layer* RootFrameViewport::LayerForHorizontalScrollbar() const { … }
cc::Layer* RootFrameViewport::LayerForVerticalScrollbar() const { … }
cc::Layer* RootFrameViewport::LayerForScrollCorner() const { … }
ScrollResult RootFrameViewport::UserScroll(
ui::ScrollGranularity granularity,
const ScrollOffset& delta,
ScrollableArea::ScrollCallback on_finish) { … }
bool RootFrameViewport::ScrollAnimatorEnabled() const { … }
CompositorElementId RootFrameViewport::GetScrollElementId() const { … }
CompositorElementId RootFrameViewport::GetScrollbarElementId(
ScrollbarOrientation orientation) { … }
ChromeClient* RootFrameViewport::GetChromeClient() const { … }
SmoothScrollSequencer* RootFrameViewport::GetSmoothScrollSequencer() const { … }
void RootFrameViewport::ServiceScrollAnimations(double monotonic_time) { … }
void RootFrameViewport::UpdateCompositorScrollAnimations() { … }
void RootFrameViewport::CancelProgrammaticScrollAnimation() { … }
void RootFrameViewport::ClearScrollableArea() { … }
ScrollbarTheme& RootFrameViewport::GetPageScrollbarTheme() const { … }
const cc::SnapContainerData* RootFrameViewport::GetSnapContainerData() const { … }
void RootFrameViewport::SetSnapContainerData(
std::optional<cc::SnapContainerData> data) { … }
bool RootFrameViewport::SetTargetSnapAreaElementIds(
cc::TargetSnapAreaElementIds snap_target_ids) { … }
void RootFrameViewport::DropCompositorScrollDeltaNextCommit() { … }
bool RootFrameViewport::SnapContainerDataNeedsUpdate() const { … }
void RootFrameViewport::SetSnapContainerDataNeedsUpdate(bool needs_update) { … }
std::optional<gfx::PointF> RootFrameViewport::GetSnapPositionAndSetTarget(
const cc::SnapSelectionStrategy& strategy) { … }
gfx::PointF RootFrameViewport::ScrollOffsetToPosition(
const ScrollOffset& offset) const { … }
ScrollOffset RootFrameViewport::ScrollPositionToOffset(
const gfx::PointF& position) const { … }
void RootFrameViewport::Trace(Visitor* visitor) const { … }
void RootFrameViewport::UpdateSnappedTargetsAndEnqueueScrollSnapChange() { … }
std::optional<cc::TargetSnapAreaElementIds>
RootFrameViewport::GetScrollsnapchangingTargetIds() const { … }
void RootFrameViewport::SetScrollsnapchangingTargetIds(
std::optional<cc::TargetSnapAreaElementIds> new_target_ids) { … }
void RootFrameViewport::
UpdateScrollSnapChangingTargetsAndEnqueueScrollSnapChanging(
const cc::TargetSnapAreaElementIds& new_target_ids) { … }
const cc::SnapSelectionStrategy* RootFrameViewport::GetImplSnapStrategy()
const { … }
void RootFrameViewport::SetImplSnapStrategy(
std::unique_ptr<cc::SnapSelectionStrategy> strategy) { … }
void RootFrameViewport::EnqueueScrollSnapChangingEventFromImplIfNeeded() { … }
std::optional<cc::ElementId> RootFrameViewport::GetTargetedSnapAreaId() { … }
void RootFrameViewport::SetTargetedSnapAreaId(
const std::optional<cc::ElementId>& id) { … }
}