#include "third_party/blink/renderer/core/intersection_observer/intersection_geometry.h"
#include "base/numerics/safe_conversions.h"
#include "third_party/blink/renderer/core/display_lock/display_lock_utilities.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/html/html_frame_owner_element.h"
#include "third_party/blink/renderer/core/intersection_observer/intersection_observer_entry.h"
#include "third_party/blink/renderer/core/layout/adjust_for_absolute_zoom.h"
#include "third_party/blink/renderer/core/layout/hit_test_result.h"
#include "third_party/blink/renderer/core/layout/layout_box.h"
#include "third_party/blink/renderer/core/layout/layout_embedded_content.h"
#include "third_party/blink/renderer/core/layout/layout_inline.h"
#include "third_party/blink/renderer/core/layout/layout_text.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/paint/clip_path_clipper.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace blink {
namespace {
LayoutUnit ComputeMargin(const Length& length,
float reference_length,
float zoom) { … }
PhysicalBoxStrut ResolveMargin(const Vector<Length>& margin,
const gfx::SizeF& reference_size,
float zoom) { … }
void ApplyMargin(gfx::RectF& expand_rect,
const Vector<Length>& margin,
float zoom,
const gfx::SizeF& reference_size) { … }
gfx::RectF InitializeRootRect(const LayoutObject* root) { … }
gfx::RectF GetBoxBounds(const LayoutBox* box, bool use_overflow_clip_edge) { … }
gfx::RectF InitializeTargetRect(const LayoutObject* target, unsigned flags) { … }
bool ComputeIsVisible(const LayoutObject* target, const PhysicalRect& rect) { … }
gfx::Transform ObjectToViewTransform(const LayoutObject& object) { … }
void ScrollingContentsToBorderBoxSpace(const LayoutBox* box, gfx::RectF& rect) { … }
bool ClipsSelf(const LayoutObject& object) { … }
bool ClipsContents(const LayoutObject& object) { … }
static const unsigned kConstructorFlagsMask = …;
}
IntersectionGeometry::RootGeometry::RootGeometry(const LayoutObject* root,
const Vector<Length>& margin) { … }
void IntersectionGeometry::RootGeometry::UpdateMargin(
const Vector<Length>& margin) { … }
bool IntersectionGeometry::RootGeometry::operator==(
const RootGeometry& other) const { … }
const LayoutObject* IntersectionGeometry::GetExplicitRootLayoutObject(
const Node& root_node) { … }
IntersectionGeometry::IntersectionGeometry(
const Node* root_node,
const Element& target_element,
const Vector<Length>& root_margin,
const Vector<float>& thresholds,
const Vector<Length>& target_margin,
const Vector<Length>& scroll_margin,
unsigned flags,
std::optional<RootGeometry>& root_geometry,
CachedRects* cached_rects)
: … { … }
IntersectionGeometry::RootAndTarget::RootAndTarget(
const Node* root_node,
const Element& target_element,
bool has_target_margin,
bool has_scroll_margin)
: … { … }
bool IsAllowedLayoutObjectType(const LayoutObject& target) { … }
const LayoutObject* IntersectionGeometry::GetTargetLayoutObject(
const Element& target_element) { … }
const LayoutObject* IntersectionGeometry::RootAndTarget::GetRootLayoutObject(
const Node* root_node) const { … }
void IntersectionGeometry::RootAndTarget::ComputeRelationship(
bool root_is_implicit,
bool has_target_margin,
bool has_scroll_margin) { … }
bool IntersectionGeometry::CanUseGeometryMapper(const LayoutObject& object) { … }
void IntersectionGeometry::UpdateShouldUseCachedRects(
const RootAndTarget& root_and_target,
CachedRects* cached_rects) { … }
void IntersectionGeometry::ComputeGeometry(const RootGeometry& root_geometry,
const RootAndTarget& root_and_target,
const Vector<float>& thresholds,
const Vector<Length>& target_margin,
const Vector<Length>& scroll_margin,
CachedRects* cached_rects) { … }
bool IntersectionGeometry::ClipToRoot(const RootAndTarget& root_and_target,
const gfx::RectF& root_rect,
gfx::RectF& unclipped_intersection_rect,
gfx::RectF& intersection_rect,
const Vector<Length>& scroll_margin,
CachedRects* cached_rects) { … }
bool IntersectionGeometry::ApplyClip(const LayoutObject* target,
const LayoutBox* local_ancestor,
const LayoutObject* root,
const gfx::RectF& root_rect,
gfx::RectF& unclipped_intersection_rect,
gfx::RectF& intersection_rect,
const Vector<Length>& scroll_margin,
bool ignore_local_clip_path,
bool root_scrolls_target,
CachedRects* cached_rects) { … }
wtf_size_t IntersectionGeometry::FirstThresholdGreaterThan(
float ratio,
const Vector<float>& thresholds) const { … }
gfx::Vector2dF IntersectionGeometry::ComputeMinScrollDeltaToUpdate(
const RootAndTarget& root_and_target,
const gfx::Transform& target_to_view_transform,
const gfx::Transform& root_to_view_transform,
const Vector<float>& thresholds,
const Vector<Length>& scroll_margin) const { … }
}