Bug 1168028 - Revert DOM fullscreen state after window finish resizing if we need to. r=smaug,dao

This commit is contained in:
Xidorn Quan 2015-06-11 09:45:06 +12:00
parent e893390672
commit 0a01203568
5 changed files with 38 additions and 30 deletions

View File

@ -9,7 +9,7 @@ var FullScreen = {
_MESSAGES: [
"DOMFullscreen:Request",
"DOMFullscreen:NewOrigin",
"DOMFullscreen:Exited",
"DOMFullscreen:Exit",
],
init: function() {
@ -157,13 +157,8 @@ var FullScreen = {
this.showWarning(aMessage.data.originNoSuffix);
break;
}
case "DOMFullscreen:Exited": {
// Like entering DOM fullscreen, we also need to exit fullscreen
// at the operating system level in the parent process here.
if (this._isRemoteBrowser(browser)) {
this._windowUtils.remoteFrameFullscreenReverted();
}
this.cleanupDomFullscreen();
case "DOMFullscreen:Exit": {
this._windowUtils.remoteFrameFullscreenReverted();
break;
}
}

View File

@ -594,7 +594,7 @@ let DOMFullscreenHandler = {
addMessageListener("DOMFullscreen:CleanUp", this);
addEventListener("MozDOMFullscreen:Request", this);
addEventListener("MozDOMFullscreen:NewOrigin", this);
addEventListener("MozDOMFullscreen:Exited", this);
addEventListener("MozDOMFullscreen:Exit", this);
},
get _windowUtils() {
@ -610,7 +610,7 @@ let DOMFullscreenHandler = {
// If we don't actually have any pending fullscreen request
// to handle, neither we have been in fullscreen, tell the
// parent to just exit.
sendAsyncMessage("DOMFullscreen:Exited");
sendAsyncMessage("DOMFullscreen:Exit");
}
break;
}
@ -643,8 +643,8 @@ let DOMFullscreenHandler = {
});
break;
}
case "MozDOMFullscreen:Exited": {
sendAsyncMessage("DOMFullscreen:Exited");
case "MozDOMFullscreen:Exit": {
sendAsyncMessage("DOMFullscreen:Exit");
break;
}
}

View File

@ -11209,6 +11209,27 @@ nsDocument::RestorePreviousFullScreenState()
return;
}
// Check whether we are restoring to non-fullscreen state.
bool exitingFullscreen = true;
for (nsIDocument* doc = this; doc; doc = doc->GetParentDocument()) {
if (static_cast<nsDocument*>(doc)->mFullScreenStack.Length() > 1) {
exitingFullscreen = false;
break;
}
}
if (exitingFullscreen) {
// If we are fully exiting fullscreen, don't touch anything here,
// just wait for the window to get out from fullscreen first.
if (XRE_GetProcessType() == GeckoProcessType_Content) {
(new AsyncEventDispatcher(
this, NS_LITERAL_STRING("MozDOMFullscreen:Exit"),
/* Bubbles */ true, /* ChromeOnly */ true))->PostDOMEvent();
} else {
SetWindowFullScreen(this, false);
}
return;
}
// If fullscreen mode is updated the pointer should be unlocked
UnlockPointer();
@ -11256,17 +11277,9 @@ nsDocument::RestorePreviousFullScreenState()
}
}
if (doc == nullptr) {
// We moved all documents in this doctree out of fullscreen mode,
// move the top-level window out of fullscreen mode.
NS_ASSERTION(!nsContentUtils::GetRootDocument(this)->IsFullScreenDoc(),
"Should have cleared all docs' stacks");
nsRefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher(
this, NS_LITERAL_STRING("MozDOMFullscreen:Exited"), true, true);
asyncDispatcher->PostDOMEvent();
FullscreenRoots::Remove(this);
SetWindowFullScreen(this, false);
}
MOZ_ASSERT(doc, "If we were going to exit from fullscreen on all documents "
"in this doctree, we should've asked the window to exit first "
"instead of reaching here.");
}
bool

View File

@ -154,8 +154,8 @@ BrowserElementChild.prototype = {
/* useCapture = */ true,
/* wantsUntrusted = */ false);
addEventListener("MozDOMFullscreen:Exited",
this._mozExitedDomFullscreen.bind(this),
addEventListener("MozDOMFullscreen:Exit",
this._mozExitDomFullscreen.bind(this),
/* useCapture = */ true,
/* wantsUntrusted = */ false);
@ -447,7 +447,7 @@ BrowserElementChild.prototype = {
// If we don't actually have any pending fullscreen request
// to handle, neither we have been in fullscreen, tell the
// parent to just exit.
sendAsyncMsg("exited-dom-fullscreen");
sendAsyncMsg("exit-dom-fullscreen");
}
},
@ -994,8 +994,8 @@ BrowserElementChild.prototype = {
});
},
_mozExitedDomFullscreen: function(e) {
sendAsyncMsg("exited-dom-fullscreen");
_mozExitDomFullscreen: function(e) {
sendAsyncMsg("exit-dom-fullscreen");
},
_getContentDimensions: function() {

View File

@ -199,7 +199,7 @@ BrowserElementParent.prototype = {
"got-can-go-forward": this._gotDOMRequestResult,
"requested-dom-fullscreen": this._requestedDOMFullscreen,
"fullscreen-origin-change": this._fullscreenOriginChange,
"exited-dom-fullscreen": this._exitedDomFullscreen,
"exit-dom-fullscreen": this._exitDomFullscreen,
"got-visible": this._gotDOMRequestResult,
"visibilitychange": this._childVisibilityChange,
"got-set-input-method-active": this._gotDOMRequestResult,
@ -981,7 +981,7 @@ BrowserElementParent.prototype = {
this._frameElement, "fullscreen-origin-change", data.json.originNoSuffix);
},
_exitedDomFullscreen: function(data) {
_exitDomFullscreen: function(data) {
this._windowUtils.remoteFrameFullscreenReverted();
},