Bug 1168028 part 1 - Ensure to exit document fullscreen state when back from DOM fullscreen to fullscreen mode. r=smaug

--HG--
extra : source : 025b28d1fcf9b44e7ccb25bd336e8935c734777b
This commit is contained in:
Xidorn Quan 2015-06-12 13:24:45 +12:00
parent c0dd3e3556
commit 4d749c589f

View File

@ -6070,6 +6070,21 @@ nsGlobalWindow::SetFullScreen(bool aFullScreen)
return SetFullScreenInternal(aFullScreen, true);
}
void
FinishDOMFullscreenChange(nsIDocument* aDoc, bool aInDOMFullscreen)
{
if (aInDOMFullscreen) {
// Ask the document to handle any pending DOM fullscreen change.
nsIDocument::HandlePendingFullscreenRequests(aDoc);
} else {
// Force exit from DOM full-screen mode. This is so that if we're in
// DOM full-screen mode and the user exits full-screen mode with
// the browser full-screen mode toggle keyboard-shortcut, we'll detect
// that and leave DOM API full-screen mode too.
nsIDocument::ExitFullscreen(aDoc, /* async */ false);
}
}
nsresult
nsGlobalWindow::SetFullScreenInternal(bool aFullScreen, bool aFullscreenMode,
gfx::VRHMDInfo* aHMD)
@ -6111,10 +6126,11 @@ nsGlobalWindow::SetFullScreenInternal(bool aFullScreen, bool aFullscreenMode,
if (aFullscreenMode) {
mFullscreenMode = aFullScreen;
} else {
// If we are exiting from DOM fullscreen while we
// initially make the window fullscreen because of
// fullscreen mode, don't restore the window.
// If we are exiting from DOM fullscreen while we initially make
// the window fullscreen because of fullscreen mode, don't restore
// the window. But we still need to exit the DOM fullscreen state.
if (!aFullScreen && mFullscreenMode) {
FinishDOMFullscreenChange(mDoc, false);
return NS_OK;
}
}
@ -6179,26 +6195,16 @@ nsGlobalWindow::FinishFullscreenChange(bool aIsFullscreen)
return;
}
// Ask the document to handle any pending DOM fullscreen change. Note
// we must make the state changes before dispatching the "fullscreen"
// event below, so that the chrome can distinguish between browser
// fullscreen mode and DOM fullscreen.
if (mFullScreen) {
nsIDocument::HandlePendingFullscreenRequests(mDoc);
}
// Note that we must call this to toggle the DOM fullscreen state
// of the document before dispatching the "fullscreen" event, so
// that the chrome can distinguish between browser fullscreen mode
// and DOM fullscreen.
FinishDOMFullscreenChange(mDoc, mFullScreen);
// dispatch a "fullscreen" DOM event so that XUL apps can
// respond visually if we are kicked into full screen mode
DispatchCustomEvent(NS_LITERAL_STRING("fullscreen"));
if (!mFullScreen) {
// Force exit from DOM full-screen mode. This is so that if we're in
// DOM full-screen mode and the user exits full-screen mode with
// the browser full-screen mode toggle keyboard-shortcut, we'll detect
// that and leave DOM API full-screen mode too.
nsIDocument::ExitFullscreen(mDoc, /* async */ false);
}
if (!mWakeLock && mFullScreen) {
nsRefPtr<power::PowerManagerService> pmService =
power::PowerManagerService::GetInstance();