#include "third_party/blink/renderer/core/fullscreen/fullscreen.h"
#include "base/containers/adapters.h"
#include "base/metrics/histogram_macros.h"
#include "base/time/time.h"
#include "third_party/blink/public/mojom/permissions/permission.mojom-blink.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy.mojom-blink.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_fullscreen_options.h"
#include "third_party/blink/renderer/core/css/style_change_reason.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/element_traversal.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/execution_context/agent.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/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/fullscreen/fullscreen_request_type.h"
#include "third_party/blink/renderer/core/fullscreen/scoped_allow_fullscreen.h"
#include "third_party/blink/renderer/core/html/html_body_element.h"
#include "third_party/blink/renderer/core/html/html_dialog_element.h"
#include "third_party/blink/renderer/core/html/html_iframe_element.h"
#include "third_party/blink/renderer/core/html_element_type_helpers.h"
#include "third_party/blink/renderer/core/input/event_handler.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/svg/svg_svg_element.h"
#include "third_party/blink/renderer/platform/bindings/exception_messages.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.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/scheduler/public/event_loop.h"
namespace blink {
namespace {
static constexpr char kFullscreenDurationMetricKeyRequestFullscreen[] = …;
void FullscreenElementChanged(Document& document,
Element* old_element,
Element* new_element,
FullscreenRequestType new_request_type,
const FullscreenOptions* new_options) { … }
class MetaParams : public GarbageCollected<MetaParams> { … };
ElementMetaParamsMap;
ElementMetaParamsMap& FullscreenParamsMap() { … }
bool HasFullscreenFlag(const Element& element) { … }
void SetFullscreenFlag(const Element& element,
FullscreenRequestType request_type,
const FullscreenOptions* options) { … }
void UnsetFullscreenFlag(const Element& element) { … }
FullscreenRequestType GetRequestType(const Element& element) { … }
const MetaParams* GetParams(Element& element) { … }
void GoFullscreen(Element& element,
FullscreenRequestType request_type,
const FullscreenOptions* options) { … }
void Unfullscreen(Element& element) { … }
void Unfullscreen(Document& document) { … }
bool AllowedToUseFullscreen(const Document& document,
ReportOptions report_on_failure) { … }
bool FullscreenIsSupported(const Document& document) { … }
RequestFullscreenError FullscreenElementReadyCheck(
const Element& element,
ReportOptions report_on_failure) { … }
class RequestFullscreenScope { … };
bool RequestFullscreenScope::running_request_fullscreen_ = …;
LocalFrame* NextLocalAncestor(Frame& frame) { … }
Document* NextLocalAncestor(Document& document) { … }
Document& TopmostLocalAncestor(Document& document) { … }
size_t CountFullscreenInTopLayer(const Document& document) { … }
bool IsSimpleFullscreenDocument(const Document& document) { … }
HeapVector<Member<Document>> CollectDocumentsToUnfullscreen(Document& doc) { … }
void FireEvent(const AtomicString& type, Element* element, Document* document) { … }
const AtomicString& AdjustEventType(const AtomicString& type,
FullscreenRequestType request_type) { … }
void EnqueueEvent(const AtomicString& type,
Element& element,
Document& document,
FullscreenRequestType request_type) { … }
const char* GetErrorString(RequestFullscreenError error) { … }
}
const char Fullscreen::kSupplementName[] = …;
Fullscreen& Fullscreen::From(LocalDOMWindow& window) { … }
bool Fullscreen::HasFullscreenElements() { … }
Element* Fullscreen::FullscreenElementFrom(Document& document) { … }
Element* Fullscreen::FullscreenElementForBindingFrom(TreeScope& scope) { … }
bool Fullscreen::IsInFullscreenElementStack(const Element& element) { … }
Fullscreen::Fullscreen(LocalDOMWindow& window)
: … { … }
Fullscreen::~Fullscreen() = default;
void Fullscreen::ContextDestroyed() { … }
void Fullscreen::RequestFullscreen(Element& pending) { … }
ScriptPromise<IDLUndefined> Fullscreen::RequestFullscreen(
Element& pending,
const FullscreenOptions* options,
FullscreenRequestType request_type,
ScriptState* script_state,
ExceptionState* exception_state) { … }
void Fullscreen::EnforceRequestFullscreenConditions(
Element& pending,
Document& document,
base::OnceCallback<void(RequestFullscreenError)> callback) { … }
void Fullscreen::ContinueRequestFullscreenAfterConditionsEnforcement(
Element* pending,
FullscreenRequestType request_type,
const FullscreenOptions* options,
ScriptPromiseResolver<IDLUndefined>* resolver,
RequestFullscreenError error) { … }
void Fullscreen::DidResolveEnterFullscreenRequest(Document& document,
bool granted) { … }
void Fullscreen::ContinueRequestFullscreen(
Document& document,
Element& pending,
FullscreenRequestType request_type,
const FullscreenOptions* options,
ScriptPromiseResolver<IDLUndefined>* resolver,
RequestFullscreenError error) { … }
void Fullscreen::FullyExitFullscreen(Document& document, bool ua_originated) { … }
ScriptPromise<IDLUndefined> Fullscreen::ExitFullscreen(
Document& doc,
ScriptState* script_state,
ExceptionState* exception_state,
bool ua_originated) { … }
void Fullscreen::DidExitFullscreen(Document& document) { … }
void Fullscreen::ContinueExitFullscreen(
Document* doc,
ScriptPromiseResolver<IDLUndefined>* resolver,
bool resize) { … }
bool Fullscreen::FullscreenEnabled(Document& document,
ReportOptions report_on_failure) { … }
void Fullscreen::DidUpdateSize(Element& element) { … }
void Fullscreen::ElementRemoved(Element& node) { … }
bool Fullscreen::IsFullscreenFlagSetFor(const Element& element) { … }
void Fullscreen::Trace(Visitor* visitor) const { … }
Fullscreen::PendingRequest::PendingRequest(
Element* element,
FullscreenRequestType type,
const FullscreenOptions* options,
ScriptPromiseResolver<IDLUndefined>* resolver)
: … { … }
Fullscreen::PendingRequest::~PendingRequest() = default;
void Fullscreen::PendingRequest::Trace(Visitor* visitor) const { … }
}