Bug 1270648 part 3 - Make document state not affect the value of fullscreenEnabled. r?smaug
The function GetFullscreenError() is only used in fullscreen element
ready check and computing value of fullscreenEnabled attribute. And for
the latter case, the state of the document (visibility and subdocument
fullscreen) should not be considered as a factor per spec.
In addition, allowing chrome to enter fullscreen when the document is
invisible or already has a fullscreen subdocument would likely ruin
things, as we have assumptions elsewhere those should not happen at all.
MozReview-Commit-ID: ETSBQMQpJPv
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -11729,22 +11729,16 @@ GetFullscreenError(nsIDocument* aDoc, bo
// in a Runnable, so don't use GetMozFullScreenEnabled() from a
// Runnable!
return nullptr;
}
if (!nsContentUtils::IsFullScreenApiEnabled()) {
return "FullscreenDeniedDisabled";
}
- if (!aDoc->IsVisible()) {
- return "FullscreenDeniedHidden";
- }
- if (HasFullScreenSubDocument(aDoc)) {
- return "FullscreenDeniedSubDocFullScreen";
- }
// Ensure that all containing elements are <iframe> and have
// allowfullscreen attribute set.
nsCOMPtr<nsIDocShell> docShell(aDoc->GetDocShell());
if (!docShell || !docShell->GetFullscreenAllowed()) {
return "FullscreenDeniedContainerNotAllowed";
}
@@ -11771,16 +11765,24 @@ nsDocument::FullscreenElementReadyCheck(
if (!GetWindow()) {
DispatchFullscreenError("FullscreenDeniedLostWindow");
return false;
}
if (const char* msg = GetFullscreenError(this, aWasCallerChrome)) {
DispatchFullscreenError(msg);
return false;
}
+ if (!IsVisible()) {
+ DispatchFullscreenError("FullscreenDeniedHidden");
+ return false;
+ }
+ if (HasFullScreenSubDocument(this)) {
+ DispatchFullscreenError("FullscreenDeniedSubDocFullScreen");
+ return false;
+ }
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.
DispatchFullscreenError("FullscreenDeniedNotDescendant");
return false;
}
if (!nsContentUtils::IsChromeDoc(this) && !IsInActiveTab(this)) {