[tor-commits] [tor-browser] 09/43: Bug 1756388; r=smaug, a=tjr
gitolite role
git at cupani.torproject.org
Tue May 31 07:06:52 UTC 2022
This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch tor-browser-91.10.0esr-11.0-1
in repository tor-browser.
commit f503b52cc5b4b330fb2c06d06150bf57c6fba615
Author: Edgar Chen <echen at mozilla.com>
AuthorDate: Tue May 3 19:11:30 2022 +0000
Bug 1756388; r=smaug, a=tjr
Differential Revision: https://phabricator.services.mozilla.com/D144193
---
browser/actors/DOMFullscreenParent.jsm | 39 ++++++++++++++------
.../content/browser-fullScreenAndPointerLock.js | 41 ++++++++++++++--------
2 files changed, 54 insertions(+), 26 deletions(-)
diff --git a/browser/actors/DOMFullscreenParent.jsm b/browser/actors/DOMFullscreenParent.jsm
index d08a161e07d4d..a6b94f113ee95 100644
--- a/browser/actors/DOMFullscreenParent.jsm
+++ b/browser/actors/DOMFullscreenParent.jsm
@@ -48,20 +48,38 @@ class DOMFullscreenParent extends JSWindowActorParent {
}
}
+ /**
+ * Clean up fullscreen state and resume chrome UI if window is in fullscreen
+ * and this actor is the one where the original fullscreen enter or
+ * exit request comes.
+ */
+ _cleanupFullscreenStateAndResumeChromeUI(aWindow) {
+ this.cleanupDomFullscreen(aWindow);
+ if (this.requestOrigin == this && aWindow.document.fullscreen) {
+ aWindow.windowUtils.remoteFrameFullscreenReverted();
+ }
+ }
+
didDestroy() {
this._didDestroy = true;
let window = this._fullscreenWindow;
if (!window) {
- if (this.waitingForChildExitFullscreen) {
+ let topBrowsingContext = this.browsingContext.top;
+ let browser = topBrowsingContext.embedderElement;
+ if (!browser) {
+ return;
+ }
+
+ if (
+ this.waitingForChildExitFullscreen ||
+ this.waitingForChildEnterFullscreen
+ ) {
this.waitingForChildExitFullscreen = false;
+ this.waitingForChildEnterFullscreen = false;
// We were destroyed while waiting for our DOMFullscreenChild to exit
- // and have exited fullscreen, run cleanup steps anyway.
- let topBrowsingContext = this.browsingContext.top;
- let browser = topBrowsingContext.embedderElement;
- if (browser) {
- this.cleanupDomFullscreen(browser.ownerGlobal);
- }
+ // or enter fullscreen, run cleanup steps anyway.
+ this._cleanupFullscreenStateAndResumeChromeUI(browser.ownerGlobal);
}
return;
}
@@ -93,9 +111,9 @@ class DOMFullscreenParent extends JSWindowActorParent {
}
} else if (this.waitingForChildExitFullscreen) {
this.waitingForChildExitFullscreen = false;
- // We were destroyed while waiting for our DOMFullscreenChild to exit and
- // have exited fullscreen, run cleanup steps anyway.
- this.cleanupDomFullscreen(window);
+ // We were destroyed while waiting for our DOMFullscreenChild to exit
+ // run cleanup steps anyway.
+ this._cleanupFullscreenStateAndResumeChromeUI(window);
}
this.updateFullscreenWindowReference(window);
}
@@ -114,7 +132,6 @@ class DOMFullscreenParent extends JSWindowActorParent {
switch (aMessage.name) {
case "DOMFullscreen:Request": {
this.waitingForChildExitFullscreen = false;
- this.nextMsgRecipient = null;
this.requestOrigin = this;
this.addListeners(window);
window.windowUtils.remoteFrameFullscreenChanged(browser);
diff --git a/browser/base/content/browser-fullScreenAndPointerLock.js b/browser/base/content/browser-fullScreenAndPointerLock.js
index bdc9f7bacbe3f..30de12392d270 100644
--- a/browser/base/content/browser-fullScreenAndPointerLock.js
+++ b/browser/base/content/browser-fullScreenAndPointerLock.js
@@ -471,7 +471,12 @@ var FullScreen = {
// before the check is fine since we also check the activeness of
// the requesting document in content-side handling code.
if (this._isRemoteBrowser(aBrowser)) {
- let [targetActor, inProcessBC] = this._getNextMsgRecipientActor(aActor);
+ // The cached message recipient in actor is used for fullscreen state
+ // cleanup, we should not use it while entering fullscreen.
+ let [targetActor, inProcessBC] = this._getNextMsgRecipientActor(
+ aActor,
+ false /* aUseCache */
+ );
if (!targetActor) {
// If there is no appropriate actor to send the message we have
// no way to complete the transition and should abort by exiting
@@ -479,14 +484,14 @@ var FullScreen = {
this._abortEnterFullscreen();
return;
}
+ // Record that the actor is waiting for its child to enter
+ // fullscreen so that if it dies we can abort.
+ targetActor.waitingForChildEnterFullscreen = true;
targetActor.sendAsyncMessage("DOMFullscreen:Entered", {
remoteFrameBC: inProcessBC,
});
if (inProcessBC) {
- // Record that the actor is waiting for its child to enter
- // fullscreen so that if it dies we can abort.
- targetActor.waitingForChildEnterFullscreen = true;
// We aren't messaging the request origin yet, skip this time.
return;
}
@@ -563,17 +568,21 @@ var FullScreen = {
*/
cleanupDomFullscreen(aActor) {
let needToWaitForChildExit = false;
- let [target, inProcessBC] = this._getNextMsgRecipientActor(aActor);
+ // Use the message recipient cached in the actor if possible, especially for
+ // the case that actor is destroyed, which we are unable to find it by
+ // walking up the browsing context tree.
+ let [target, inProcessBC] = this._getNextMsgRecipientActor(
+ aActor,
+ true /* aUseCache */
+ );
if (target) {
needToWaitForChildExit = true;
- if (!target.waitingForChildExitFullscreen) {
- // Record that the actor is waiting for its child to exit fullscreen so
- // that if it dies we can continue cleanup.
- target.waitingForChildExitFullscreen = true;
- target.sendAsyncMessage("DOMFullscreen:CleanUp", {
- remoteFrameBC: inProcessBC,
- });
- }
+ // Record that the actor is waiting for its child to exit fullscreen so
+ // that if it dies we can continue cleanup.
+ target.waitingForChildExitFullscreen = true;
+ target.sendAsyncMessage("DOMFullscreen:CleanUp", {
+ remoteFrameBC: inProcessBC,
+ });
if (inProcessBC) {
return needToWaitForChildExit;
}
@@ -618,6 +627,8 @@ var FullScreen = {
*
* @param {JSWindowActorParent} aActor
* The actor that called this function.
+ * @param {bool} aUseCache
+ * Use the recipient cached in the aActor if available.
*
* @return {[JSWindowActorParent, BrowsingContext]}
* The parent actor which should be sent the next msg and the
@@ -627,10 +638,10 @@ var FullScreen = {
* the calling actor has been destroyed or its associated
* WindowContext is in BFCache.
*/
- _getNextMsgRecipientActor(aActor) {
+ _getNextMsgRecipientActor(aActor, aUseCache) {
// Walk up the cached nextMsgRecipient to find the next available actor if
// any.
- if (aActor.nextMsgRecipient) {
+ if (aUseCache && aActor.nextMsgRecipient) {
let nextMsgRecipient = aActor.nextMsgRecipient;
while (nextMsgRecipient) {
let [actor] = nextMsgRecipient;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the tor-commits
mailing list