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

// Copyright 2017 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_custom_controls_fullscreen_detector.h"

#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/platform/web_fullscreen_video_status.h"
#include "third_party/blink/renderer/core/dom/events/event.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/intersection_observer/intersection_observer_entry.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "ui/gfx/geometry/size_conversions.h"

namespace blink {

WebFullscreenVideoStatus;

namespace {

// If a video takes more that this much of the viewport, it's counted as
// fullscreen without applying the fullscreen heuristics.
// (Assuming we're in the fullscreen mode.)
constexpr float kMostlyFillViewportIntersectionThreshold =;

// If a video takes less that this much of the viewport, we don't
// apply the fullscreen heuristics and just declare it not fullscreen.
// A portrait ultrawide video (21:9) playing on a landscape ultrawide screen
// takes about 18% of the screen, that's why 15% looks like a reasonable
// lowerbound of a real-world fullscreen video.
constexpr float kMinPossibleFullscreenIntersectionThreshold =;

// This is how much of the viewport around the video can be taken by
// margins and framing for it to still be counted as fullscreen.
// It is measured only in the dominant direction, because of potential ratio
// mismatch that would cause big margins in the other direction.
// For example: portrain video on a landscape screen.
constexpr float kMaxAllowedVideoMarginRatio =;

// This is how much of the video can be hidden by something
// before it is nor longer counted as fullscreen.
// This helps to disregard custom controls, ads, accidental markup mistakes.
constexpr float kMaxAllowedPortionOfVideoOffScreen =;

// This heuristic handles a case of videos with an aspect ratio
// different from the screen's aspect ratio.
// Examples: A 4:3 video playing on a 16:9 screen.
//           A portrait video playing on a landscape screen.
// In a nutshell:
//  1. The video should occupy most of the viewport in at least one dimension.
//  2. The video should be almost fully visible on the screen.
bool IsFullscreenVideoOfDifferentRatio(const gfx::Size& video_size,
                                       const gfx::Size& viewport_size,
                                       const gfx::Size& intersection_size) {}

}  // anonymous namespace

MediaCustomControlsFullscreenDetector::MediaCustomControlsFullscreenDetector(
    HTMLVideoElement& video)
    :{}

void MediaCustomControlsFullscreenDetector::Attach() {}

void MediaCustomControlsFullscreenDetector::Detach() {}

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

void MediaCustomControlsFullscreenDetector::ContextDestroyed() {}

void MediaCustomControlsFullscreenDetector::ReportEffectivelyFullscreen(
    bool effectively_fullscreen) {}

void MediaCustomControlsFullscreenDetector::UpdateDominantAndFullscreenStatus(
    bool is_dominant_visible_content,
    bool is_effectively_fullscreen) {}

void MediaCustomControlsFullscreenDetector::OnIntersectionChanged(
    const HeapVector<Member<IntersectionObserverEntry>>& entries) {}

void MediaCustomControlsFullscreenDetector::TriggerObservation() {}

bool MediaCustomControlsFullscreenDetector::IsVideoOrParentFullscreen() {}

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

// static
bool MediaCustomControlsFullscreenDetector::
    IsFullscreenVideoOfDifferentRatioForTesting(
        const gfx::Size& video_size,
        const gfx::Size& viewport_size,
        const gfx::Size& intersection_size) {}

}  // namespace blink