Bug 1270648 part 3 - Make document state not affect the value of fullscreenEnabled. r?smaug draft
authorXidorn Quan <me@upsuper.org>
Mon, 16 May 2016 10:12:11 +1000
changeset 367717 9030af8d17e288251956d1837f7a96f10d56c31e
parent 367716 3d3af3823970d5d49f659aa7cb49fb5460c6beed
child 367718 69f0f4754620ec47fcb050818d16d95a237f3f0b
push id18336
push userxquan@mozilla.com
push dateTue, 17 May 2016 09:32:49 +0000
reviewerssmaug
bugs1270648
milestone49.0a1
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
dom/base/nsDocument.cpp
--- 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)) {