#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include <memory>
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h"
#include "base/task/single_thread_task_runner.h"
#include "cc/input/main_thread_scrolling_reason.h"
#include "cc/layers/solid_color_scrollbar_layer.h"
#include "third_party/blink/public/mojom/scroll/scroll_into_view_params.mojom-blink.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/core/accessibility/ax_object_cache.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/page_scale_constraints.h"
#include "third_party/blink/renderer/core/frame/page_scale_constraints_set.h"
#include "third_party/blink/renderer/core/frame/root_frame_viewport.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/fullscreen/fullscreen.h"
#include "third_party/blink/renderer/core/input/event_handler.h"
#include "third_party/blink/renderer/core/inspector/identifiers_factory.h"
#include "third_party/blink/renderer/core/layout/layout_box.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/page/scrolling/root_scroller_controller.h"
#include "third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.h"
#include "third_party/blink/renderer/core/page/scrolling/snap_coordinator.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/paint/paint_property_tree_builder.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/scroll/scroll_alignment.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/scrollbar.h"
#include "third_party/blink/renderer/core/scroll/scrollbar_theme_overlay_mobile.h"
#include "third_party/blink/renderer/core/scroll/smooth_scroll_sequencer.h"
#include "third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h"
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
#include "third_party/blink/renderer/platform/graphics/paint/effect_paint_property_node.h"
#include "third_party/blink/renderer/platform/graphics/paint/foreign_layer_display_item.h"
#include "third_party/blink/renderer/platform/graphics/paint/transform_paint_property_node.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/traced_value.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/geometry/size_f.h"
namespace blink {
namespace {
OverscrollType ComputeOverscrollType() { … }
}
VisualViewport::VisualViewport(Page& owner)
: … { … }
const TransformPaintPropertyNode*
VisualViewport::GetDeviceEmulationTransformNode() const { … }
const TransformPaintPropertyNode*
VisualViewport::GetOverscrollElasticityTransformNode() const { … }
const TransformPaintPropertyNode* VisualViewport::GetPageScaleNode() const { … }
const TransformPaintPropertyNode* VisualViewport::GetScrollTranslationNode()
const { … }
const ScrollPaintPropertyNode* VisualViewport::GetScrollNode() const { … }
const TransformPaintPropertyNode*
VisualViewport::TransformNodeForViewportScrollbars() const { … }
PaintPropertyChangeType VisualViewport::UpdatePaintPropertyNodesIfNeeded(
PaintPropertyTreeBuilderFragmentContext& context) { … }
VisualViewport::~VisualViewport() = default;
void VisualViewport::Trace(Visitor* visitor) const { … }
void VisualViewport::EnqueueScrollEvent() { … }
void VisualViewport::EnqueueResizeEvent() { … }
void VisualViewport::SetSize(const gfx::Size& size) { … }
void VisualViewport::Reset() { … }
void VisualViewport::MainFrameDidChangeSize() { … }
gfx::RectF VisualViewport::VisibleRect(
IncludeScrollbarsInRect scrollbar_inclusion) const { … }
gfx::PointF VisualViewport::ViewportCSSPixelsToRootFrame(
const gfx::PointF& point) const { … }
void VisualViewport::SetLocation(const gfx::PointF& new_location) { … }
void VisualViewport::Move(const ScrollOffset& delta) { … }
void VisualViewport::SetScale(float scale) { … }
double VisualViewport::OffsetLeft() const { … }
double VisualViewport::OffsetTop() const { … }
double VisualViewport::Width() const { … }
double VisualViewport::Height() const { … }
double VisualViewport::ScaleForVisualViewport() const { … }
void VisualViewport::SetScaleAndLocation(float scale,
bool is_pinch_gesture_active,
const gfx::PointF& location) { … }
double VisualViewport::VisibleWidthCSSPx() const { … }
double VisualViewport::VisibleHeightCSSPx() const { … }
bool VisualViewport::DidSetScaleOrLocation(float scale,
bool is_pinch_gesture_active,
const gfx::PointF& location) { … }
void VisualViewport::CreateLayers() { … }
void VisualViewport::InitializeScrollbars() { … }
EScrollbarWidth VisualViewport::CSSScrollbarWidth() const { … }
std::optional<blink::Color> VisualViewport::CSSScrollbarThumbColor() const { … }
void VisualViewport::DropCompositorScrollDeltaNextCommit() { … }
int VisualViewport::ScrollbarThickness() const { … }
void VisualViewport::UpdateScrollbarLayer(ScrollbarOrientation orientation) { … }
bool VisualViewport::VisualViewportSuppliesScrollbars() const { … }
const Document* VisualViewport::GetDocument() const { … }
CompositorElementId VisualViewport::GetScrollElementId() const { … }
bool VisualViewport::ScrollAnimatorEnabled() const { … }
ChromeClient* VisualViewport::GetChromeClient() const { … }
SmoothScrollSequencer* VisualViewport::GetSmoothScrollSequencer() const { … }
bool VisualViewport::SetScrollOffset(
const ScrollOffset& offset,
mojom::blink::ScrollType scroll_type,
mojom::blink::ScrollBehavior scroll_behavior,
ScrollCallback on_finish) { … }
bool VisualViewport::SetScrollOffset(
const ScrollOffset& offset,
mojom::blink::ScrollType scroll_type,
mojom::blink::ScrollBehavior scroll_behavior) { … }
PhysicalOffset VisualViewport::LocalToScrollOriginOffset() const { … }
PhysicalRect VisualViewport::ScrollIntoView(
const PhysicalRect& rect_in_absolute,
const PhysicalBoxStrut& scroll_margin,
const mojom::blink::ScrollIntoViewParamsPtr& params) { … }
int VisualViewport::ScrollSize(ScrollbarOrientation orientation) const { … }
gfx::Vector2d VisualViewport::MinimumScrollOffsetInt() const { … }
gfx::Vector2d VisualViewport::MaximumScrollOffsetInt() const { … }
ScrollOffset VisualViewport::MaximumScrollOffset() const { … }
ScrollOffset VisualViewport::MaximumScrollOffsetAtScale(float scale) const { … }
gfx::Point VisualViewport::ClampDocumentOffsetAtScale(const gfx::Point& offset,
float scale) { … }
void VisualViewport::SetBrowserControlsAdjustment(float adjustment) { … }
float VisualViewport::BrowserControlsAdjustment() const { … }
bool VisualViewport::UserInputScrollable(ScrollbarOrientation) const { … }
gfx::Size VisualViewport::ContentsSize() const { … }
gfx::Rect VisualViewport::VisibleContentRect(
IncludeScrollbarsInRect scrollbar_inclusion) const { … }
scoped_refptr<base::SingleThreadTaskRunner> VisualViewport::GetTimerTaskRunner()
const { … }
mojom::blink::ColorScheme VisualViewport::UsedColorSchemeScrollbars() const { … }
void VisualViewport::UpdateScrollOffset(const ScrollOffset& position,
mojom::blink::ScrollType scroll_type) { … }
cc::Layer* VisualViewport::LayerForScrolling() const { … }
cc::Layer* VisualViewport::LayerForHorizontalScrollbar() const { … }
cc::Layer* VisualViewport::LayerForVerticalScrollbar() const { … }
RootFrameViewport* VisualViewport::GetRootFrameViewport() const { … }
bool VisualViewport::IsActiveViewport() const { … }
LocalFrame& VisualViewport::LocalMainFrame() const { … }
gfx::Size VisualViewport::ExcludeScrollbars(const gfx::Size& size) const { … }
bool VisualViewport::ScheduleAnimation() { … }
void VisualViewport::ClampToBoundaries() { … }
gfx::RectF VisualViewport::ViewportToRootFrame(
const gfx::RectF& rect_in_viewport) const { … }
gfx::Rect VisualViewport::ViewportToRootFrame(
const gfx::Rect& rect_in_viewport) const { … }
gfx::RectF VisualViewport::RootFrameToViewport(
const gfx::RectF& rect_in_root_frame) const { … }
gfx::Rect VisualViewport::RootFrameToViewport(
const gfx::Rect& rect_in_root_frame) const { … }
gfx::PointF VisualViewport::ViewportToRootFrame(
const gfx::PointF& point_in_viewport) const { … }
gfx::PointF VisualViewport::RootFrameToViewport(
const gfx::PointF& point_in_root_frame) const { … }
gfx::Point VisualViewport::ViewportToRootFrame(
const gfx::Point& point_in_viewport) const { … }
gfx::Point VisualViewport::RootFrameToViewport(
const gfx::Point& point_in_root_frame) const { … }
bool VisualViewport::ShouldDisableDesktopWorkarounds() const { … }
cc::AnimationHost* VisualViewport::GetCompositorAnimationHost() const { … }
cc::AnimationTimeline* VisualViewport::GetCompositorAnimationTimeline() const { … }
void VisualViewport::NotifyRootFrameViewport() const { … }
ScrollbarTheme& VisualViewport::GetPageScrollbarTheme() const { … }
PaintArtifactCompositor* VisualViewport::GetPaintArtifactCompositor() const { … }
std::unique_ptr<TracedValue> VisualViewport::ViewportToTracedValue() const { … }
void VisualViewport::DisposeImpl() { … }
void VisualViewport::Paint(GraphicsContext& context) const { … }
void VisualViewport::UsedColorSchemeChanged() { … }
void VisualViewport::ScrollbarColorChanged() { … }
void VisualViewport::UpdateScrollbarColor(cc::SolidColorScrollbarLayer& layer) { … }
}