Bug 1190669 part 3 - Introduce new fullscreen reason which exits fullscreen without fullscreen transition, and use it for ExitFullscreenInDocTree. r=smaug
authorXidorn Quan <quanxunzhen@gmail.com>
Thu, 06 Aug 2015 15:37:48 +1000
changeset 288147 e3e4870fd88547dcce694d0ad09debe8a9409045
parent 288146 f278dbd163fae58402630e36109fd4cc7cec9132
child 288148 70a60348507ef8af0e6eee965cfc183b8ed0e2bf
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1190669
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1190669 part 3 - Introduce new fullscreen reason which exits fullscreen without fullscreen transition, and use it for ExitFullscreenInDocTree. r=smaug
dom/base/nsDocument.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsPIDOMWindow.h
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -11112,17 +11112,17 @@ public:
     // MozDOMFullscreen:Entered dispatched.
     nsIDocument* lastDocument = mDocuments[mDocuments.Length() - 1];
     nsContentUtils::DispatchEventOnlyToChrome(
       lastDocument, ToSupports(lastDocument),
       NS_LITERAL_STRING("MozDOMFullscreen:Exited"),
       /* Bubbles */ true, /* Cancelable */ false, /* DefaultAction */ nullptr);
     // Ensure the window exits fullscreen.
     if (nsPIDOMWindow* win = mDocuments[0]->GetWindow()) {
-      win->SetFullscreenInternal(nsPIDOMWindow::eForFullscreenAPI, false);
+      win->SetFullscreenInternal(nsPIDOMWindow::eForForceExitFullscreen, false);
     }
     return NS_OK;
   }
 
 private:
   nsCOMArray<nsIDocument> mDocuments;
 };
 
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -6297,21 +6297,28 @@ public:
                            nsISupports* aTransitionData)
     : mWindow(aWindow)
     , mWidget(aWidget)
     , mScreen(aScreen)
     , mTransitionData(aTransitionData)
     , mDuration(aDuration)
     , mStage(eBeforeToggle)
     , mFullscreen(aFullscreen)
-  {}
+  {
+    MOZ_COUNT_CTOR(FullscreenTransitionTask);
+  }
 
   NS_IMETHOD Run() override;
 
 private:
+  virtual ~FullscreenTransitionTask()
+  {
+    MOZ_COUNT_DTOR(FullscreenTransitionTask);
+  }
+
   enum Stage {
     // BeforeToggle stage happens before we enter or leave fullscreen
     // state. In this stage, the task triggers the pre-toggle fullscreen
     // transition on the widget.
     eBeforeToggle,
     // ToggleFullscreen stage actually executes the fullscreen toggle,
     // and wait for the next paint on the content to continue.
     eToggleFullscreen,
@@ -6481,16 +6488,20 @@ nsGlobalWindow::SetFullscreenInternal(Fu
 {
   MOZ_ASSERT(IsOuterWindow());
   MOZ_ASSERT(nsContentUtils::IsSafeToRunScript(),
              "Requires safe to run script as it "
              "may call FinishDOMFullscreenChange");
 
   NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
 
+  MOZ_ASSERT(aReason != eForForceExitFullscreen || !aFullScreen,
+             "FullscreenReason::eForForceExitFullscreen can "
+             "only be used with exiting fullscreen");
+
   // Only chrome can change our fullscreen mode. Otherwise, the state
   // can only be changed for DOM fullscreen.
   if (aReason == eForFullscreenMode && !nsContentUtils::IsCallerChrome()) {
     return NS_OK;
   }
 
   // SetFullScreen needs to be called on the root window, so get that
   // via the DocShell tree, and if we are not already the root,
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -462,17 +462,21 @@ public:
     }
   }
 
   enum FullscreenReason
   {
     // Toggling the fullscreen mode requires trusted context.
     eForFullscreenMode,
     // Fullscreen API is the API provided to untrusted content.
-    eForFullscreenAPI
+    eForFullscreenAPI,
+    // This reason can only be used with exiting fullscreen.
+    // It is otherwise identical to eForFullscreenAPI except it would
+    // suppress the fullscreen transition.
+    eForForceExitFullscreen
   };
 
   /**
    * Moves the top-level window into fullscreen mode if aIsFullScreen is true,
    * otherwise exits fullscreen.
    *
    * If aHMD is not null, the window is made full screen on the given VR HMD
    * device instead of its currrent display.