diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 058b7f236663..a12d958ab305 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -264,6 +264,7 @@ nsString* nsContentUtils::sModifierSeparator = nullptr; bool nsContentUtils::sInitialized = false; bool nsContentUtils::sIsFullScreenApiEnabled = false; +bool nsContentUtils::sIsUnprefixedFullscreenApiEnabled = false; bool nsContentUtils::sTrustedFullScreenOnly = true; bool nsContentUtils::sIsCutCopyAllowed = true; bool nsContentUtils::sIsFrameTimingPrefEnabled = false; @@ -539,6 +540,9 @@ nsContentUtils::Init() Preferences::AddBoolVarCache(&sIsFullScreenApiEnabled, "full-screen-api.enabled"); + Preferences::AddBoolVarCache(&sIsUnprefixedFullscreenApiEnabled, + "full-screen-api.unprefix.enabled"); + Preferences::AddBoolVarCache(&sTrustedFullScreenOnly, "full-screen-api.allow-trusted-requests-only"); diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index c4c3a3aa6674..775b6a7b168c 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -1912,6 +1912,12 @@ public: */ static bool IsFullScreenApiEnabled(); + /** + * Returns true if the unprefixed fullscreen API is enabled. + */ + static bool IsUnprefixedFullscreenApiEnabled() + { return sIsUnprefixedFullscreenApiEnabled; } + /** * Returns true if requests for full-screen are allowed in the current * context. Requests are only allowed if the user initiated them (like with @@ -2661,6 +2667,7 @@ private: static bool sIsHandlingKeyBoardEvent; static bool sAllowXULXBL_for_file; static bool sIsFullScreenApiEnabled; + static bool sIsUnprefixedFullscreenApiEnabled; static bool sTrustedFullScreenOnly; static bool sIsCutCopyAllowed; static uint32_t sHandlingInputTimeout; diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 1cae937b2984..2b0f649b027e 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -11680,6 +11680,14 @@ nsresult nsDocument::RemoteFrameFullscreenReverted() return NS_OK; } +/* static */ bool +nsDocument::IsUnprefixedFullscreenEnabled(JSContext* aCx, JSObject* aObject) +{ + MOZ_ASSERT(NS_IsMainThread()); + return nsContentUtils::IsCallerChrome() || + nsContentUtils::IsUnprefixedFullscreenApiEnabled(); +} + static void ReleaseVRDeviceProxyRef(void *, nsIAtom*, void *aPropertyValue, void *) { diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h index 5167e07d6a59..60f1237c6226 100644 --- a/dom/base/nsDocument.h +++ b/dom/base/nsDocument.h @@ -1236,6 +1236,8 @@ public: // already_AddRefed BlockedTrackingNodes() const; + static bool IsUnprefixedFullscreenEnabled(JSContext* aCx, JSObject* aObject); + // Do the "fullscreen element ready check" from the fullscreen spec. // It returns true if the given element is allowed to go into fullscreen. bool FullscreenElementReadyCheck(Element* aElement, bool aWasCallerChrome); diff --git a/dom/webidl/Document.webidl b/dom/webidl/Document.webidl index 67e461637309..40f17f1aa5bd 100644 --- a/dom/webidl/Document.webidl +++ b/dom/webidl/Document.webidl @@ -224,13 +224,16 @@ partial interface Document { partial interface Document { // Note: Per spec the 'S' in these two is lowercase, but the "Moz" // versions hve it uppercase. + [Func="nsDocument::IsUnprefixedFullscreenEnabled"] readonly attribute boolean fullscreenEnabled; [BinaryName="fullscreenEnabled", Deprecated="PrefixedFullscreenAPI"] readonly attribute boolean mozFullScreenEnabled; + [Func="nsDocument::IsUnprefixedFullscreenEnabled"] readonly attribute Element? fullscreenElement; [BinaryName="fullscreenElement", Deprecated="PrefixedFullscreenAPI"] readonly attribute Element? mozFullScreenElement; + [Func="nsDocument::IsUnprefixedFullscreenEnabled"] void exitFullscreen(); [BinaryName="exitFullscreen", Deprecated="PrefixedFullscreenAPI"] void mozCancelFullScreen(); diff --git a/dom/webidl/Element.webidl b/dom/webidl/Element.webidl index 1e2da94a9dd7..3eb36bbab549 100644 --- a/dom/webidl/Element.webidl +++ b/dom/webidl/Element.webidl @@ -259,7 +259,7 @@ partial interface Element { * The options parameter is non-standard. In Gecko, it can be: * a RequestFullscreenOptions object */ - [Throws, UnsafeInPrerendering] + [Throws, UnsafeInPrerendering, Func="nsDocument::IsUnprefixedFullscreenEnabled"] void requestFullscreen(optional any options); [Throws, UnsafeInPrerendering, BinaryName="requestFullscreen", Deprecated="PrefixedFullscreenAPI"] void mozRequestFullScreen(optional any options); diff --git a/dom/webidl/EventHandler.webidl b/dom/webidl/EventHandler.webidl index eba8c4acba90..d37851dda5ff 100644 --- a/dom/webidl/EventHandler.webidl +++ b/dom/webidl/EventHandler.webidl @@ -118,7 +118,9 @@ interface GlobalEventHandlers { attribute EventHandler onlostpointercapture; // Fullscreen events handlers + [Func="nsDocument::IsUnprefixedFullscreenEnabled"] attribute EventHandler onfullscreenchange; + [Func="nsDocument::IsUnprefixedFullscreenEnabled"] attribute EventHandler onfullscreenerror; attribute EventHandler onmozfullscreenchange; attribute EventHandler onmozfullscreenerror;