Bug 743198 part 2 - Add unprefixed Fullscreen API to Document and Element.
MozReview-Commit-ID: DLN3dWFQTgR
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -3243,18 +3243,18 @@ GetFullScreenError(nsIDocument* aDoc)
if (!nsContentUtils::IsRequestFullScreenAllowed()) {
return "FullScreenDeniedNotInputDriven";
}
return nullptr;
}
void
-Element::MozRequestFullScreen(JSContext* aCx, JS::Handle<JS::Value> aOptions,
- ErrorResult& aError)
+Element::RequestFullscreen(JSContext* aCx, JS::Handle<JS::Value> aOptions,
+ ErrorResult& aError)
{
MOZ_ASSERT_IF(!aCx, aOptions.isNullOrUndefined());
// Only grant full-screen requests if this is called from inside a trusted
// event handler (i.e. inside an event handler for a user initiated event).
// This stops the full-screen from being abused similar to the popups of old,
// and it also makes it harder for bad guys' script to go full-screen and
// spoof the browser chrome/window and phish logins etc.
// Note that requests for fullscreen inside a web app's origin are exempt
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -723,18 +723,18 @@ public:
void ReleaseCapture()
{
if (nsIPresShell::GetCapturingContent() == this) {
nsIPresShell::SetCapturingContent(nullptr, 0);
}
}
// aCx == nullptr is allowed only if aOptions.isNullOrUndefined()
- void MozRequestFullScreen(JSContext* aCx, JS::Handle<JS::Value> aOptions,
- ErrorResult& aError);
+ void RequestFullscreen(JSContext* aCx, JS::Handle<JS::Value> aOptions,
+ ErrorResult& aError);
void MozRequestPointerLock();
Attr* GetAttributeNode(const nsAString& aName);
already_AddRefed<Attr> SetAttributeNode(Attr& aNewAttr,
ErrorResult& aError);
already_AddRefed<Attr> RemoveAttributeNode(Attr& aOldAttr,
ErrorResult& aError);
Attr* GetAttributeNodeNS(const nsAString& aNamespaceURI,
const nsAString& aLocalName);
@@ -1802,18 +1802,18 @@ NS_IMETHOD SetCapture(bool retargetToEle
NS_IMETHOD ReleaseCapture(void) final override \
{ \
Element::ReleaseCapture(); \
return NS_OK; \
} \
NS_IMETHOD MozRequestFullScreen(void) final override \
{ \
mozilla::ErrorResult rv; \
- Element::MozRequestFullScreen(nullptr, JS::UndefinedHandleValue, rv); \
- return rv.StealNSResult(); \
+ Element::RequestFullscreen(nullptr, JS::UndefinedHandleValue, rv); \
+ return rv.StealNSResult(); \
} \
NS_IMETHOD MozRequestPointerLock(void) final override \
{ \
Element::MozRequestPointerLock(); \
return NS_OK; \
} \
using nsINode::QuerySelector; \
NS_IMETHOD QuerySelector(const nsAString& aSelector, \
--- a/dom/base/nsDeprecatedOperationList.h
+++ b/dom/base/nsDeprecatedOperationList.h
@@ -39,8 +39,9 @@ DEPRECATED_OPERATION(Window_Content)
DEPRECATED_OPERATION(SyncXMLHttpRequest)
DEPRECATED_OPERATION(DataContainerEvent)
DEPRECATED_OPERATION(Window_Controllers)
DEPRECATED_OPERATION(ImportXULIntoContent)
DEPRECATED_OPERATION(PannerNodeDoppler)
DEPRECATED_OPERATION(NavigatorGetUserMedia)
DEPRECATED_OPERATION(WebrtcDeprecatedPrefix)
DEPRECATED_OPERATION(AppCache)
+DEPRECATED_OPERATION(PrefixedFullscreenAPI)
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -11022,22 +11022,22 @@ void
nsDocument::SetFullscreenRoot(nsIDocument* aRoot)
{
mFullscreenRoot = do_GetWeakReference(aRoot);
}
NS_IMETHODIMP
nsDocument::MozCancelFullScreen()
{
- nsIDocument::MozCancelFullScreen();
- return NS_OK;
-}
-
-void
-nsIDocument::MozCancelFullScreen()
+ nsIDocument::ExitFullscreen();
+ return NS_OK;
+}
+
+void
+nsIDocument::ExitFullscreen()
{
RestorePreviousFullScreenState();
}
static void
AskWindowToExitFullscreen(nsIDocument* aDoc)
{
if (XRE_GetProcessType() == GeckoProcessType_Content) {
@@ -11317,17 +11317,17 @@ nsDocument::RestorePreviousFullScreenSta
newFullscreenDoc, NS_LITERAL_STRING("MozDOMFullscreen:NewOrigin"),
/* Bubbles */ true, /* ChromeOnly */ true);
}
}
bool
nsDocument::IsFullScreenDoc()
{
- return GetFullScreenElement() != nullptr;
+ return GetFullscreenElement() != nullptr;
}
class nsCallRequestFullScreen : public nsRunnable
{
public:
explicit nsCallRequestFullScreen(UniquePtr<FullscreenRequest>&& aRequest)
: mRequest(Move(aRequest)) { }
@@ -11420,17 +11420,17 @@ nsDocument::FullScreenStackPush(Element*
{
NS_ASSERTION(aElement, "Must pass non-null to FullScreenStackPush()");
Element* top = FullScreenStackTop();
if (top == aElement || !aElement) {
return false;
}
EventStateManager::SetFullScreenState(aElement, true);
mFullScreenStack.AppendElement(do_GetWeakReference(aElement));
- NS_ASSERTION(GetFullScreenElement() == aElement, "Should match");
+ NS_ASSERTION(GetFullscreenElement() == aElement, "Should match");
UpdateViewportScrollbarOverrideForFullscreen(this);
return true;
}
void
nsDocument::FullScreenStackPop()
{
if (mFullScreenStack.IsEmpty()) {
@@ -11559,17 +11559,17 @@ ReleaseVRDeviceProxyRef(void *, nsIAtom*
}
bool
nsDocument::FullscreenElementReadyCheck(Element* aElement,
bool aWasCallerChrome)
{
NS_ASSERTION(aElement,
"Must pass non-null element to nsDocument::RequestFullScreen");
- if (!aElement || aElement == GetFullScreenElement()) {
+ if (!aElement || aElement == GetFullscreenElement()) {
return false;
}
if (!aElement->IsInDoc()) {
LogFullScreenDenied(true, "FullScreenDeniedNotInDocument", this);
return false;
}
if (aElement->OwnerDoc() != this) {
LogFullScreenDenied(true, "FullScreenDeniedMovedDocument", this);
@@ -11578,18 +11578,18 @@ nsDocument::FullscreenElementReadyCheck(
if (!GetWindow()) {
LogFullScreenDenied(true, "FullScreenDeniedLostWindow", this);
return false;
}
if (!IsFullScreenEnabled(aWasCallerChrome, true)) {
// IsFullScreenEnabled calls LogFullScreenDenied, no need to log.
return false;
}
- if (GetFullScreenElement() &&
- !nsContentUtils::ContentIsDescendantOf(aElement, GetFullScreenElement())) {
+ if (GetFullscreenElement() &&
+ !nsContentUtils::ContentIsDescendantOf(aElement, GetFullscreenElement())) {
// If this document is full-screen, only grant full-screen requests from
// a descendant of the current full-screen element.
LogFullScreenDenied(true, "FullScreenDeniedNotDescendant", this);
return false;
}
if (!nsContentUtils::IsChromeDoc(this) && !IsInActiveTab(this)) {
LogFullScreenDenied(true, "FullScreenDeniedNotFocusedTab", this);
return false;
@@ -11950,24 +11950,24 @@ nsDocument::ApplyFullscreen(const Fullsc
DispatchFullScreenChange(changed[changed.Length() - i - 1]);
}
return true;
}
NS_IMETHODIMP
nsDocument::GetMozFullScreenElement(nsIDOMElement **aFullScreenElement)
{
- Element* el = GetMozFullScreenElement();
+ Element* el = GetFullscreenElement();
nsCOMPtr<nsIDOMElement> retval = do_QueryInterface(el);
retval.forget(aFullScreenElement);
return NS_OK;
}
Element*
-nsDocument::GetFullScreenElement()
+nsDocument::GetFullscreenElement()
{
Element* element = FullScreenStackTop();
NS_ASSERTION(!element ||
element->IsFullScreenAncestor(),
"Fullscreen element should have fullscreen styles applied");
return element;
}
@@ -11977,22 +11977,22 @@ nsDocument::GetMozFullScreen(bool *aFull
*aFullScreen = MozFullScreen();
return NS_OK;
}
NS_IMETHODIMP
nsDocument::GetMozFullScreenEnabled(bool *aFullScreen)
{
NS_ENSURE_ARG_POINTER(aFullScreen);
- *aFullScreen = MozFullScreenEnabled();
+ *aFullScreen = FullscreenEnabled();
return NS_OK;
}
bool
-nsDocument::MozFullScreenEnabled()
+nsDocument::FullscreenEnabled()
{
return IsFullScreenEnabled(nsContentUtils::IsCallerChrome(), false);
}
static bool
HasFullScreenSubDocument(nsIDocument* aDoc)
{
uint32_t count = CountFullscreenSubDocuments(aDoc);
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -1190,17 +1190,16 @@ public:
virtual nsresult GetStateObject(nsIVariant** aResult) override;
virtual nsDOMNavigationTiming* GetNavigationTiming() const override;
virtual nsresult SetNavigationTiming(nsDOMNavigationTiming* aTiming) override;
virtual Element* FindImageMap(const nsAString& aNormalizedMapName) override;
- virtual Element* GetFullScreenElement() override;
virtual nsTArray<Element*> GetFullscreenStack() const override;
virtual void AsyncRequestFullScreen(
mozilla::UniquePtr<FullscreenRequest>&& aRequest) override;
virtual void RestorePreviousFullScreenState() override;
virtual bool IsFullscreenLeaf() override;
virtual bool IsFullScreenDoc() override;
virtual nsresult
RemoteFrameFullscreenChanged(nsIDOMElement* aFrameElement) override;
@@ -1256,18 +1255,18 @@ public:
// styles from the former top element, and applies them to the new top
// element, if there is one.
void FullScreenStackPop();
// Returns the top element from the full-screen stack.
Element* FullScreenStackTop();
// DOM-exposed fullscreen API
- virtual bool MozFullScreenEnabled() override;
- Element* GetMozFullScreenElement() override { return GetFullScreenElement(); }
+ bool FullscreenEnabled() override;
+ Element* GetFullscreenElement() override;
void RequestPointerLock(Element* aElement) override;
bool ShouldLockPointer(Element* aElement, Element* aCurrentLock,
bool aNoFocusCheck = false);
bool SetPointerLock(Element* aElement, int aCursorStyle);
static void UnlockPointer(nsIDocument* aDoc = nullptr);
void SetCurrentOrientation(mozilla::dom::OrientationType aType,
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -1125,24 +1125,16 @@ public:
* Add/Remove an element to the document's id and name hashes
*/
virtual void AddToIdTable(Element* aElement, nsIAtom* aId) = 0;
virtual void RemoveFromIdTable(Element* aElement, nsIAtom* aId) = 0;
virtual void AddToNameTable(Element* aElement, nsIAtom* aName) = 0;
virtual void RemoveFromNameTable(Element* aElement, nsIAtom* aName) = 0;
/**
- * Returns the element which either requested DOM full-screen mode, or
- * contains the element which requested DOM full-screen mode if the
- * requestee is in a subdocument. Note this element must be *in*
- * this document.
- */
- virtual Element* GetFullScreenElement() = 0;
-
- /**
* Returns all elements in the fullscreen stack in the insertion order.
*/
virtual nsTArray<Element*> GetFullscreenStack() const = 0;
/**
* Asynchronously requests that the document make aElement the fullscreen
* element, and move into fullscreen mode. The current fullscreen element
* (if any) is pushed onto the fullscreen element stack, and it can be
@@ -2498,23 +2490,23 @@ public:
return IsSyntheticDocument();
}
Element* GetCurrentScript();
void ReleaseCapture() const;
virtual void MozSetImageElement(const nsAString& aImageElementId,
Element* aElement) = 0;
nsIURI* GetDocumentURIObject() const;
// Not const because all the full-screen goop is not const
- virtual bool MozFullScreenEnabled() = 0;
- virtual Element* GetMozFullScreenElement() = 0;
+ virtual bool FullscreenEnabled() = 0;
+ virtual Element* GetFullscreenElement() = 0;
bool MozFullScreen()
{
return IsFullScreenDoc();
}
- void MozCancelFullScreen();
+ void ExitFullscreen();
Element* GetMozPointerLockElement();
void MozExitPointerLock()
{
UnlockPointer(this);
}
bool Hidden() const
{
return mVisibilityState != mozilla::dom::VisibilityState::Visible;
--- a/dom/locales/en-US/chrome/dom/dom.properties
+++ b/dom/locales/en-US/chrome/dom/dom.properties
@@ -118,16 +118,17 @@ NoExposedPropsWarning=Exposing chrome JS
# LOCALIZATION NOTE: Do not translate "Mutation Event" and "MutationObserver"
MutationEventWarning=Use of Mutation Events is deprecated. Use MutationObserver instead.
# LOCALIZATION NOTE: Do not translate "Components"
ComponentsWarning=The Components object is deprecated. It will soon be removed.
PluginHangUITitle=Warning: Unresponsive plugin
PluginHangUIMessage=%S may be busy, or it may have stopped responding. You can stop the plugin now, or you can continue to see if the plugin will complete.
PluginHangUIWaitButton=Continue
PluginHangUIStopButton=Stop plugin
+PrefixedFullscreenAPIWarning=Prefixed Fullscreen API is deprecated. Please use unprefixed API for fullscreen. For more help https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
# LOCALIZATION NOTE: Do not translate "mozHidden", "mozVisibilityState", "hidden", or "visibilityState"
PrefixedVisibilityAPIWarning='mozHidden' and 'mozVisibilityState' are deprecated. Please use the unprefixed 'hidden' and 'visibilityState' instead.
# LOCALIZATION NOTE: Do not translate "NodeIterator" or "detach()".
NodeIteratorDetachWarning=Calling detach() on a NodeIterator no longer has an effect.
# LOCALIZATION NOTE: Do not translate "LenientThis" and "this"
LenientThisWarning=Ignoring get or set of property that has [LenientThis] because the "this" object is incorrect.
# LOCALIZATION NOTE: Do not translate "nsIDOMWindowUtils", "getWindowWithOuterId", or "nsIWindowMediator"
GetWindowWithOuterIdWarning=Use of nsIDOMWindowUtils.getOuterWindowWithId() is deprecated. Instead, use the nsIWindowMediator method of the same name.
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -215,28 +215,34 @@ partial interface Document {
* Current referrer policy - one of the REFERRER_POLICY_* constants
* from nsIHttpChannel.
*/
[ChromeOnly]
readonly attribute unsigned long referrerPolicy;
};
-// http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#api
+// https://fullscreen.spec.whatwg.org/#api
partial interface Document {
// Note: Per spec the 'S' in these two is lowercase, but the "Moz"
// versions hve it uppercase.
+ readonly attribute boolean fullscreenEnabled;
+ [BinaryName="fullscreenEnabled", Deprecated="PrefixedFullscreenAPI"]
readonly attribute boolean mozFullScreenEnabled;
+ readonly attribute Element? fullscreenElement;
+ [BinaryName="fullscreenElement", Deprecated="PrefixedFullscreenAPI"]
readonly attribute Element? mozFullScreenElement;
- //(Renamed?)void exitFullscreen();
+ void exitFullscreen();
+ [BinaryName="exitFullscreen", Deprecated="PrefixedFullscreenAPI"]
+ void mozCancelFullScreen();
// Gecko-specific fullscreen bits
+ [Deprecated="PrefixedFullscreenAPI"]
readonly attribute boolean mozFullScreen;
- void mozCancelFullScreen();
};
// http://dvcs.w3.org/hg/pointerlock/raw-file/default/index.html#extensions-to-the-document-interface
partial interface Document {
readonly attribute Element? mozPointerLockElement;
void mozExitPointerLock ();
};
--- a/dom/webidl/Element.webidl
+++ b/dom/webidl/Element.webidl
@@ -119,27 +119,16 @@ interface Element : Node {
/**
* If this element has captured the mouse, release the capture. If another
* element has captured the mouse, this method has no effect.
*/
void releaseCapture();
// Mozilla extensions
- /**
- * Requests that this element be made the full-screen element, as per the DOM
- * full-screen api.
- *
- * The options parameter is non-standard. In Gecko, it can be:
- * a RequestFullscreenOptions object
- *
- * @see <https://wiki.mozilla.org/index.php?title=Gecko:FullScreenAPI>
- */
- [Throws, UnsafeInPrerendering]
- void mozRequestFullScreen(optional any options);
/**
* Requests that this element be made the pointer-locked element, as per the DOM
* pointer lock api.
*
* @see <http://dvcs.w3.org/hg/pointerlock/raw-file/default/index.html>
*/
[UnsafeInPrerendering]
@@ -247,14 +236,26 @@ partial interface Element {
};
Element implements ChildNode;
Element implements NonDocumentTypeChildNode;
Element implements ParentNode;
Element implements Animatable;
Element implements GeometryUtils;
-// non-standard: allows passing options to Element.requestFullScreen
+// non-standard: allows passing options to Element.requestFullscreen
dictionary RequestFullscreenOptions {
// Which HMDVRDevice to go full screen on; also enables VR rendering.
// If null, normal fullscreen is entered.
HMDVRDevice? vrDisplay = null;
};
+
+// https://fullscreen.spec.whatwg.org/#api
+partial interface Element {
+ /**
+ * The options parameter is non-standard. In Gecko, it can be:
+ * a RequestFullscreenOptions object
+ */
+ [Throws, UnsafeInPrerendering]
+ void requestFullscreen(optional any options);
+ [Throws, UnsafeInPrerendering, BinaryName="requestFullscreen", Deprecated="PrefixedFullscreenAPI"]
+ void mozRequestFullScreen(optional any options);
+};
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -1661,17 +1661,17 @@ GetPropagatedScrollbarStylesForViewport(
nsIContent*
nsPresContext::UpdateViewportScrollbarStylesOverride()
{
nsIContent* propagatedFrom =
GetPropagatedScrollbarStylesForViewport(this, &mViewportStyleScrollbar);
nsIDocument* document = Document();
- if (Element* fullscreenElement = document->GetFullScreenElement()) {
+ if (Element* fullscreenElement = document->GetFullscreenElement()) {
// If the document is in fullscreen, but the fullscreen element is
// not the root element, we should explicitly suppress the scrollbar
// here. Note that, we still need to return the original element
// the styles are from, so that the state of those elements is not
// affected across fullscreen change.
if (fullscreenElement != document->GetRootElement() &&
fullscreenElement != propagatedFrom) {
mViewportStyleScrollbar = ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN,
--- a/webapprt/locales/en-US/webapprt/overrides/dom.properties
+++ b/webapprt/locales/en-US/webapprt/overrides/dom.properties
@@ -114,16 +114,17 @@ NoExposedPropsWarning=Exposing chrome JS
# LOCALIZATION NOTE: Do not translate "Mutation Event" and "MutationObserver"
MutationEventWarning=Use of Mutation Events is deprecated. Use MutationObserver instead.
# LOCALIZATION NOTE: Do not translate "Components"
ComponentsWarning=The Components object is deprecated. It will soon be removed.
PluginHangUITitle=Warning: Unresponsive plugin
PluginHangUIMessage=%S may be busy, or it may have stopped responding. You can stop the plugin now, or you can continue to see if the plugin will complete.
PluginHangUIWaitButton=Continue
PluginHangUIStopButton=Stop plugin
+PrefixedFullscreenAPIWarning=Prefixed Fullscreen API is deprecated. Please use unprefixed API for fullscreen. For more help https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
# LOCALIZATION NOTE: Do not translate "mozHidden", "mozVisibilityState", "hidden", or "visibilityState"
PrefixedVisibilityAPIWarning='mozHidden' and 'mozVisibilityState' are deprecated. Please use the unprefixed 'hidden' and 'visibilityState' instead.
# LOCALIZATION NOTE: Do not translate "NodeIterator" or "detach()".
NodeIteratorDetachWarning=Calling detach() on a NodeIterator no longer has an effect.
# LOCALIZATION NOTE: Do not translate "LenientThis" and "this"
LenientThisWarning=Ignoring get or set of property that has [LenientThis] because the "this" object is incorrect.
# LOCALIZATION NOTE: Do not translate "nsIDOMWindowUtils", "getWindowWithOuterId", or "nsIWindowMediator"
GetWindowWithOuterIdWarning=Use of nsIDOMWindowUtils.getOuterWindowWithId() is deprecated. Instead, use the nsIWindowMediator method of the same name.