#include "third_party/blink/renderer/core/scroll/scroll_into_view_util.h"
#include <optional>
#include <tuple>
#include "third_party/blink/public/mojom/scroll/scroll_into_view_params.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_scroll_into_view_options.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/execution_context/security_context.h"
#include "third_party/blink/renderer/core/frame/frame.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/html/html_frame_owner_element.h"
#include "third_party/blink/renderer/core/layout/geometry/box_strut.h"
#include "third_party/blink/renderer/core/layout/geometry/physical_offset.h"
#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h"
#include "third_party/blink/renderer/core/layout/layout_box.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/map_coordinates_flags.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/frame_tree.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/scroll/scroll_alignment.h"
#include "third_party/blink/renderer/core/scroll/scrollable_area.h"
#include "third_party/blink/renderer/core/scroll/smooth_scroll_sequencer.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "ui/gfx/geometry/rect_f.h"
namespace blink {
namespace {
bool AllowedToPropagateToParent(
const LocalFrame& from_frame,
const mojom::blink::ScrollIntoViewParamsPtr& params) { … }
ALWAYS_INLINE ScrollableArea* GetScrollableAreaForLayoutBox(
const LayoutBox& box,
const mojom::blink::ScrollIntoViewParamsPtr& params) { … }
std::optional<LayoutBox*> GetScrollParent(
const LayoutBox& box,
const mojom::blink::ScrollIntoViewParamsPtr& params) { … }
ALWAYS_INLINE void AdjustRectToNotEmpty(PhysicalRect& rect) { … }
ALWAYS_INLINE void AdjustRectAndParamsForParentFrame(
const LayoutBox& current_box,
const LayoutBox* next_box,
PhysicalRect& absolute_rect_to_scroll,
mojom::blink::ScrollIntoViewParamsPtr& params) { … }
std::optional<PhysicalRect> PerformBubblingScrollIntoView(
const LayoutBox& box,
const PhysicalRect& absolute_rect,
mojom::blink::ScrollIntoViewParamsPtr& params,
const PhysicalBoxStrut& scroll_margin,
bool from_remote_frame) { … }
}
namespace scroll_into_view_util {
void ScrollRectToVisible(const LayoutObject& layout_object,
const PhysicalRect& absolute_rect,
mojom::blink::ScrollIntoViewParamsPtr params,
bool from_remote_frame) { … }
gfx::RectF FocusedEditableBoundsFromParams(
const gfx::RectF& caret_rect,
const mojom::blink::ScrollIntoViewParamsPtr& params) { … }
void ConvertParamsToParentFrame(mojom::blink::ScrollIntoViewParamsPtr& params,
const gfx::RectF& caret_rect_in_src,
const LayoutObject& src_frame,
const LayoutView& dest_frame) { … }
mojom::blink::ScrollIntoViewParamsPtr CreateScrollIntoViewParams(
const mojom::blink::ScrollAlignment& align_x,
const mojom::blink::ScrollAlignment& align_y,
mojom::blink::ScrollType scroll_type,
bool make_visible_in_visual_viewport,
mojom::blink::ScrollBehavior scroll_behavior,
bool is_for_scroll_sequence,
bool cross_origin_boundaries) { … }
namespace {
mojom::blink::ScrollAlignment ResolveToPhysicalAlignment(
V8ScrollLogicalPosition::Enum inline_alignment,
V8ScrollLogicalPosition::Enum block_alignment,
ScrollOrientation axis,
const ComputedStyle& computed_style) { … }
V8ScrollLogicalPosition::Enum SnapAlignmentToV8ScrollLogicalPosition(
cc::SnapAlignment alignment) { … }
}
mojom::blink::ScrollIntoViewParamsPtr CreateScrollIntoViewParams(
const ScrollIntoViewOptions& options,
const ComputedStyle& computed_style) { … }
mojom::blink::ScrollIntoViewParamsPtr CreateScrollIntoViewParams(
const ComputedStyle& computed_style) { … }
ScrollOffset GetScrollOffsetToExpose(
const ScrollableArea& scroll_area,
const PhysicalRect& local_expose_rect,
const PhysicalBoxStrut& expose_scroll_margin,
const mojom::blink::ScrollAlignment& align_x,
const mojom::blink::ScrollAlignment& align_y) { … }
mojom::blink::ScrollAlignment PhysicalAlignmentFromSnapAlignStyle(
const LayoutBox& box,
ScrollOrientation axis) { … }
}
}