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

/*
 * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

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

#include <memory>

#include "base/functional/callback_helpers.h"
#include "base/metrics/histogram_functions.h"
#include "cc/paint/paint_canvas.h"
#include "media/base/video_frame.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/web_fullscreen_video_status.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_fullscreen_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_image_bitmap_options.h"
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/dom/attribute.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/picture_in_picture_controller.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/html/media/media_custom_controls_fullscreen_detector.h"
#include "third_party/blink/renderer/core/html/media/media_remoting_interstitial.h"
#include "third_party/blink/renderer/core/html/media/media_video_visibility_tracker.h"
#include "third_party/blink/renderer/core/html/media/picture_in_picture_interstitial.h"
#include "third_party/blink/renderer/core/html/media/video_frame_callback_requester.h"
#include "third_party/blink/renderer/core/html/media/video_wake_lock.h"
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/imagebitmap/image_bitmap.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/intersection_observer/intersection_observer_entry.h"
#include "third_party/blink/renderer/core/layout/layout_image.h"
#include "third_party/blink/renderer/core/layout/layout_video.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/loader/resource/video_timing.h"
#include "third_party/blink/renderer/core/paint/timing/paint_timing_detector.h"
#include "third_party/blink/renderer/platform/graphics/canvas_resource_provider.h"
#include "third_party/blink/renderer/platform/graphics/gpu/extensions_3d_util.h"
#include "third_party/blink/renderer/platform/graphics/gpu/shared_gpu_context.h"
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
#include "third_party/blink/renderer/platform/graphics/video_frame_image_util.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/web_test_support.h"

namespace blink {

namespace {
// Represents the visibility threshold to be used by the
// |visibility_tracker_|. Where visibility is defined as: intersecting
// with the viewport and not occluded by other html elements within the page,
// with the exception of MediaControls.
//
// An HTMLVideoElement with visibility greater or equal than a given area
// measured in square CSS pixels (`kVisibilityThreshold`) is considered visible,
// and not visible otherwise.
constexpr int kVisibilityThreshold =;
}  // namespace

HTMLVideoElement::HTMLVideoElement(Document& document)
    :{}

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

bool HTMLVideoElement::HasPendingActivity() const {}

Node::InsertionNotificationRequest HTMLVideoElement::InsertedInto(
    ContainerNode& insertion_point) {}

void HTMLVideoElement::RemovedFrom(ContainerNode& insertion_point) {}

void HTMLVideoElement::ContextDestroyed() {}

bool HTMLVideoElement::LayoutObjectIsNeeded(const DisplayStyle& style) const {}

LayoutObject* HTMLVideoElement::CreateLayoutObject(const ComputedStyle&) {}

void HTMLVideoElement::AttachLayoutTree(AttachContext& context) {}

void HTMLVideoElement::UpdatePosterImage() {}

void HTMLVideoElement::CollectStyleForPresentationAttribute(
    const QualifiedName& name,
    const AtomicString& value,
    MutableCSSPropertyValueSet* style) {}

bool HTMLVideoElement::IsPresentationAttribute(
    const QualifiedName& name) const {}

void HTMLVideoElement::ParseAttribute(
    const AttributeModificationParams& params) {}

unsigned HTMLVideoElement::videoWidth() const {}

unsigned HTMLVideoElement::videoHeight() const {}

gfx::Size HTMLVideoElement::videoVisibleSize() const {}

bool HTMLVideoElement::IsURLAttribute(const Attribute& attribute) const {}

const AtomicString HTMLVideoElement::ImageSourceURL() const {}

void HTMLVideoElement::UpdatePictureInPictureAvailability() {}

// TODO(zqzhang): this callback could be used to hide native controls instead of
// using a settings. See `HTMLMediaElement::onMediaControlsEnabledChange`.
void HTMLVideoElement::SetPersistentState(bool persistent) {}

void HTMLVideoElement::SetPersistentStateInternal(bool persistent) {}

void HTMLVideoElement::CreateVisibilityTrackerIfNeeded() {}

void HTMLVideoElement::ReportVisibility(bool meets_visibility_threshold) {}

bool HTMLVideoElement::IsPersistent() const {}

void HTMLVideoElement::OnPlay() {}

void HTMLVideoElement::OnLoadStarted() {}

void HTMLVideoElement::OnLoadFinished() {}

void HTMLVideoElement::UpdateVideoVisibilityTracker() {}

void HTMLVideoElement::RequestEnterPictureInPicture() {}

void HTMLVideoElement::RequestMediaRemoting() {}

void HTMLVideoElement::RequestVisibility(
    RequestVisibilityCallback request_visibility_cb) {}

void HTMLVideoElement::PaintCurrentFrame(cc::PaintCanvas* canvas,
                                         const gfx::Rect& dest_rect,
                                         const cc::PaintFlags* flags) const {}

bool HTMLVideoElement::HasAvailableVideoFrame() const {}

bool HTMLVideoElement::HasReadableVideoFrame() const {}

void HTMLVideoElement::OnFirstFrame(base::TimeTicks frame_time,
                                    size_t bytes_to_first_frame) {}

void HTMLVideoElement::webkitEnterFullscreen() {}

void HTMLVideoElement::webkitExitFullscreen() {}

bool HTMLVideoElement::webkitSupportsFullscreen() {}

bool HTMLVideoElement::webkitDisplayingFullscreen() {}

void HTMLVideoElement::DidEnterFullscreen() {}

void HTMLVideoElement::DidExitFullscreen() {}

void HTMLVideoElement::DidMoveToNewDocument(Document& old_document) {}

unsigned HTMLVideoElement::webkitDecodedFrameCount() const {}

unsigned HTMLVideoElement::webkitDroppedFrameCount() const {}

KURL HTMLVideoElement::PosterImageURL() const {}

bool HTMLVideoElement::IsDefaultPosterImageURL() const {}

scoped_refptr<StaticBitmapImage> HTMLVideoElement::CreateStaticBitmapImage(
    bool allow_accelerated_images,
    std::optional<gfx::Size> size) {}

scoped_refptr<Image> HTMLVideoElement::GetSourceImageForCanvas(
    FlushReason,
    SourceImageStatus* status,
    const gfx::SizeF&,
    const AlphaDisposition alpha_disposition) {}

bool HTMLVideoElement::WouldTaintOrigin() const {}

gfx::SizeF HTMLVideoElement::ElementSize(
    const gfx::SizeF&,
    const RespectImageOrientationEnum) const {}

gfx::Size HTMLVideoElement::BitmapSourceSize() const {}

ScriptPromise<ImageBitmap> HTMLVideoElement::CreateImageBitmap(
    ScriptState* script_state,
    std::optional<gfx::Rect> crop_rect,
    const ImageBitmapOptions* options,
    ExceptionState& exception_state) {}

void HTMLVideoElement::MediaRemotingStarted(
    const WebString& remote_device_friendly_name) {}

void HTMLVideoElement::MediaRemotingStopped(int error_code) {}

bool HTMLVideoElement::SupportsPictureInPicture() const {}

DisplayType HTMLVideoElement::GetDisplayType() const {}

bool HTMLVideoElement::IsInAutoPIP() const {}

void HTMLVideoElement::OnPictureInPictureStateChange() {}

void HTMLVideoElement::OnEnteredPictureInPicture() {}

void HTMLVideoElement::OnExitedPictureInPicture() {}

void HTMLVideoElement::SetIsEffectivelyFullscreen(
    blink::WebFullscreenVideoStatus status) {}

void HTMLVideoElement::SetIsDominantVisibleContent(bool is_dominant) {}

void HTMLVideoElement::AddedEventListener(
    const AtomicString& event_type,
    RegisteredEventListener& registered_listener) {}

bool HTMLVideoElement::IsRemotingInterstitialVisible() const {}

void HTMLVideoElement::OnIntersectionChangedForLazyLoad(
    const HeapVector<Member<IntersectionObserverEntry>>& entries) {}

void HTMLVideoElement::OnWebMediaPlayerCreated() {}

void HTMLVideoElement::OnWebMediaPlayerCleared() {}

void HTMLVideoElement::RecordVideoOcclusionState(
    std::string_view occlusion_state) const {}

void HTMLVideoElement::AttributeChanged(
    const AttributeModificationParams& params) {}

void HTMLVideoElement::OnRequestVideoFrameCallback() {}

}  // namespace blink