chromium/third_party/blink/renderer/core/html/media/media_video_visibility_tracker.cc

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/core/html/media/media_video_visibility_tracker.h"

#include "base/metrics/histogram_macros.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/shadow_root.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/fullscreen/fullscreen.h"
#include "third_party/blink/renderer/core/html/media/html_video_element.h"
#include "third_party/blink/renderer/core/input/event_handler.h"
#include "third_party/blink/renderer/core/layout/hit_test_result.h"
#include "third_party/blink/renderer/core/layout/layout_video.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/platform/graphics/paint/display_item.h"
#include "third_party/blink/renderer/platform/graphics/paint/display_item_list.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_artifact.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/skia_conversions.h"

namespace blink {

namespace {

// Do a rect-based penetrating list hit test, with a callback that is executed
// at each node.
HitTestResult HitTestForOcclusionRatio(
    const HTMLVideoElement& video_element,
    const PhysicalRect& hit_rect,
    std::optional<HitTestRequest::HitNodeCb> hit_node_cb) {}

float ComputeArea(const PhysicalRect& rect) {}

bool HasEnoughVisibleAreaRemaining(float occluded_area,
                                   const PhysicalRect& video_element_rect,
                                   const int visibility_threshold) {}

float ComputeOccludingArea(const Vector<SkIRect>& occluding_rects,
                           float video_element_area) {}

// Records various UMA metrics related to hit testing and occlusion. All metrics
// recorded by this method represent total counts/percentages after identifying
// whether the `VideoElement` visibility threshold is met (or not).
void RecordTotalCounts(const MediaVideoVisibilityTracker::Metrics& counts) {}

const Vector<AtomicString>& FullscreenEventTypes() {}

// Returns true if `target` has `listener` event listener registered.
bool HasEventListenerRegistered(EventTarget& target,
                                const AtomicString& event_type,
                                const EventListener* listener) {}

// Returns true if `type` is of content type, false otherwise.
//
// In the context of the `MediaVideoVisibilityTracker`, we consider a
// `DisplayItem::Type` to be of content type if it is used to draw content that
// is relevant to occlusion computations.
bool IsContentType(DisplayItem::Type type) {}

void RecordVideoOcclusionState(
    const HTMLVideoElement& video_element,
    const MediaVideoVisibilityTracker::OcclusionState& occlusion_state,
    bool has_sufficiently_visible_video,
    const int visibility_threshold) {}

}  // anonymous namespace

MediaVideoVisibilityTracker::MediaVideoVisibilityTracker(
    HTMLVideoElement& video,
    const int visibility_threshold,
    ReportVisibilityCb report_visibility_cb,
    base::TimeDelta hit_test_interval)
    :{}

MediaVideoVisibilityTracker::~MediaVideoVisibilityTracker() {}

void MediaVideoVisibilityTracker::Attach() {}

void MediaVideoVisibilityTracker::Detach() {}

void MediaVideoVisibilityTracker::UpdateVisibilityTrackerState() {}

void MediaVideoVisibilityTracker::ElementDidMoveToNewDocument() {}

void MediaVideoVisibilityTracker::Invoke(ExecutionContext* context,
                                         Event* event) {}

void MediaVideoVisibilityTracker::MaybeAddFullscreenEventListeners() {}

void MediaVideoVisibilityTracker::MaybeRemoveFullscreenEventListeners() {}

void MediaVideoVisibilityTracker::RequestVisibility(
    RequestVisibilityCallback request_visibility_callback) {}

const MediaVideoVisibilityTracker::ClientIdsSet
MediaVideoVisibilityTracker::GetClientIdsSet(
    DisplayItemClientId start_after_display_item_client_id) const {}

ListBasedHitTestBehavior MediaVideoVisibilityTracker::ComputeOcclusion(
    const ClientIdsSet& client_ids_set,
    Metrics& counts,
    const Node& node) {}

bool MediaVideoVisibilityTracker::MeetsVisibilityThreshold(
    Metrics& counts,
    const PhysicalRect& rect) {}

bool MediaVideoVisibilityTracker::ComputeVisibility() {}

void MediaVideoVisibilityTracker::ComputeAreaOccludedByViewport(
    const LocalFrameView& local_frame_view) {}

void MediaVideoVisibilityTracker::MaybeComputeVisibility(
    ShouldReportVisibility should_report_visibility) {}

void MediaVideoVisibilityTracker::DidFinishLifecycleUpdate(
    const LocalFrameView& local_frame_view) {}

void MediaVideoVisibilityTracker::Trace(Visitor* visitor) const {}

}  // namespace blink