#include "third_party/blink/renderer/core/html/anchor_element_metrics_sender.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/not_fatal_until.h"
#include "base/numerics/safe_conversions.h"
#include "base/rand_util.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/input/web_pointer_properties.h"
#include "third_party/blink/public/mojom/loader/navigation_predictor.mojom-blink-forward.h"
#include "third_party/blink/public/mojom/loader/navigation_predictor.mojom-forward.h"
#include "third_party/blink/public/platform/browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/dom_node_ids.h"
#include "third_party/blink/renderer/core/editing/editing_utilities.h"
#include "third_party/blink/renderer/core/events/pointer_event.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/browser_controls.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/screen.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/html/anchor_element_metrics.h"
#include "third_party/blink/renderer/core/html/html_anchor_element.h"
#include "third_party/blink/renderer/core/html/html_area_element.h"
#include "third_party/blink/renderer/core/html/html_collection.h"
#include "third_party/blink/renderer/core/intersection_observer/intersection_observer.h"
#include "third_party/blink/renderer/core/intersection_observer/intersection_observer_entry.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/loader/document_loader.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/pointer_type_names.h"
#include "third_party/blink/renderer/platform/graphics/dom_node_id.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread.h"
#include "third_party/blink/renderer/platform/widget/frame_widget.h"
#include "ui/gfx/geometry/mojom/geometry.mojom-shared.h"
namespace blink {
namespace {
constexpr float kIntersectionRatioThreshold = …;
bool ShouldHaveAnchorElementMetricsSender(Document& document) { … }
wtf_size_t GetMaxNumberOfObservations() { … }
base::TimeDelta GetIntersectionObserverDelay() { … }
bool ShouldReportViewportPositions() { … }
float GetBrowserControlsHeight(Document& document) { … }
}
const char AnchorElementMetricsSender::kSupplementName[] = …;
AnchorElementMetricsSender::~AnchorElementMetricsSender() = default;
AnchorElementMetricsSender* AnchorElementMetricsSender::From(
Document& document) { … }
AnchorElementMetricsSender* AnchorElementMetricsSender::GetForFrame(
LocalFrame* frame) { … }
void AnchorElementMetricsSender::
MaybeReportAnchorElementPointerDataOnHoverTimerFired(
AnchorId anchor_id,
mojom::blink::AnchorElementPointerDataPtr pointer_data) { … }
void AnchorElementMetricsSender::MaybeReportClickedMetricsOnClick(
const HTMLAnchorElement& anchor_element) { … }
void AnchorElementMetricsSender::AddAnchorElement(HTMLAnchorElement& element) { … }
void AnchorElementMetricsSender::RemoveAnchorElement(
HTMLAnchorElement& element) { … }
void AnchorElementMetricsSender::DocumentDetached(Document& document) { … }
void AnchorElementMetricsSender::Trace(Visitor* visitor) const { … }
bool AnchorElementMetricsSender::AssociateInterface() { … }
AnchorElementMetricsSender::AnchorElementMetricsSender(Document& document)
: … { … }
void AnchorElementMetricsSender::SetNowAsNavigationStartForTesting() { … }
void AnchorElementMetricsSender::SetTickClockForTesting(
const base::TickClock* clock) { … }
void AnchorElementMetricsSender::FireUpdateTimerForTesting() { … }
IntersectionObserver*
AnchorElementMetricsSender::GetIntersectionObserverForTesting() { … }
void AnchorElementMetricsSender::SetShouldSkipUpdateDelays(
bool should_skip_for_testing) { … }
void AnchorElementMetricsSender::UpdateVisibleAnchors(
const HeapVector<Member<IntersectionObserverEntry>>& entries) { … }
base::TimeTicks AnchorElementMetricsSender::NavigationStart() const { … }
void AnchorElementMetricsSender::MaybeReportAnchorElementPointerEvent(
HTMLAnchorElement& element,
const PointerEvent& pointer_event) { … }
void AnchorElementMetricsSender::
MaybeReportAnchorElementsPositionOnScrollEnd() { … }
void AnchorElementMetricsSender::RecordPointerDown(
const PointerEvent& pointer_event) { … }
void AnchorElementMetricsSender::EnqueueLeftViewport(
const HTMLAnchorElement& element) { … }
void AnchorElementMetricsSender::EnqueueEnteredViewport(
const HTMLAnchorElement& element) { … }
void AnchorElementMetricsSender::RegisterForLifecycleNotifications() { … }
void AnchorElementMetricsSender::PositionUpdateTimerFired(TimerBase*) { … }
void AnchorElementMetricsSender::ComputeAnchorElementsPositionUpdates() { … }
void AnchorElementMetricsSender::DidFinishLifecycleUpdate(
const LocalFrameView& local_frame_view) { … }
void AnchorElementMetricsSender::MaybeUpdateMetrics() { … }
void AnchorElementMetricsSender::UpdateMetrics(TimerBase* ) { … }
}