зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1472491: Part 5m - Add DOMFullscreenChild actor. r=felipe
MozReview-Commit-ID: JwJNUieHp5d --HG-- rename : browser/base/content/tab-content.js => browser/actors/DOMFullscreenChild.jsm extra : rebase_source : 7add7da8aa314786db0bca4ac3f7bee2d12b80d6
This commit is contained in:
Родитель
68a10a9e01
Коммит
0e0b74319e
|
@ -0,0 +1,81 @@
|
|||
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["DOMFullscreenChild"];
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
||||
|
||||
class DOMFullscreenChild extends ActorChild {
|
||||
receiveMessage(aMessage) {
|
||||
let windowUtils = this.content && this.content.windowUtils;
|
||||
switch (aMessage.name) {
|
||||
case "DOMFullscreen:Entered": {
|
||||
this._lastTransactionId = windowUtils.lastTransactionId;
|
||||
if (!windowUtils.handleFullscreenRequests() &&
|
||||
!this.content.document.fullscreenElement) {
|
||||
// If we don't actually have any pending fullscreen request
|
||||
// to handle, neither we have been in fullscreen, tell the
|
||||
// parent to just exit.
|
||||
this.mm.sendAsyncMessage("DOMFullscreen:Exit");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "DOMFullscreen:CleanUp": {
|
||||
// If we've exited fullscreen at this point, no need to record
|
||||
// transaction id or call exit fullscreen. This is especially
|
||||
// important for non-e10s, since in that case, it is possible
|
||||
// that no more paint would be triggered after this point.
|
||||
if (this.content.document.fullscreenElement && windowUtils) {
|
||||
this._lastTransactionId = windowUtils.lastTransactionId;
|
||||
windowUtils.exitFullscreen();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handleEvent(aEvent) {
|
||||
switch (aEvent.type) {
|
||||
case "MozDOMFullscreen:Request": {
|
||||
this.mm.sendAsyncMessage("DOMFullscreen:Request");
|
||||
break;
|
||||
}
|
||||
case "MozDOMFullscreen:NewOrigin": {
|
||||
this.mm.sendAsyncMessage("DOMFullscreen:NewOrigin", {
|
||||
originNoSuffix: aEvent.target.nodePrincipal.originNoSuffix,
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "MozDOMFullscreen:Exit": {
|
||||
this.mm.sendAsyncMessage("DOMFullscreen:Exit");
|
||||
break;
|
||||
}
|
||||
case "MozDOMFullscreen:Entered":
|
||||
case "MozDOMFullscreen:Exited": {
|
||||
this.mm.addEventListener("MozAfterPaint", this);
|
||||
if (!this.content || !this.content.document.fullscreenElement) {
|
||||
// If we receive any fullscreen change event, and find we are
|
||||
// actually not in fullscreen, also ask the parent to exit to
|
||||
// ensure that the parent always exits fullscreen when we do.
|
||||
this.mm.sendAsyncMessage("DOMFullscreen:Exit");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "MozAfterPaint": {
|
||||
// Only send Painted signal after we actually finish painting
|
||||
// the transition for the fullscreen change.
|
||||
// Note that this._lastTransactionId is not set when in non-e10s
|
||||
// mode, so we need to check that explicitly.
|
||||
if (!this._lastTransactionId ||
|
||||
aEvent.transactionId > this._lastTransactionId) {
|
||||
this.mm.removeEventListener("MozAfterPaint", this);
|
||||
this.mm.sendAsyncMessage("DOMFullscreen:Painted");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ FINAL_TARGET_FILES.actors += [
|
|||
'ClickHandlerChild.jsm',
|
||||
'ContentSearchChild.jsm',
|
||||
'ContextMenuChild.jsm',
|
||||
'DOMFullscreenChild.jsm',
|
||||
'LightWeightThemeInstallChild.jsm',
|
||||
'NetErrorChild.jsm',
|
||||
'OfflineAppsChild.jsm',
|
||||
|
|
|
@ -123,92 +123,6 @@ if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT) {
|
|||
tabchild.webBrowserChrome = WebBrowserChrome;
|
||||
}
|
||||
|
||||
|
||||
var DOMFullscreenHandler = {
|
||||
|
||||
init() {
|
||||
addMessageListener("DOMFullscreen:Entered", this);
|
||||
addMessageListener("DOMFullscreen:CleanUp", this);
|
||||
addEventListener("MozDOMFullscreen:Request", this);
|
||||
addEventListener("MozDOMFullscreen:Entered", this);
|
||||
addEventListener("MozDOMFullscreen:NewOrigin", this);
|
||||
addEventListener("MozDOMFullscreen:Exit", this);
|
||||
addEventListener("MozDOMFullscreen:Exited", this);
|
||||
this.init = null;
|
||||
},
|
||||
|
||||
receiveMessage(aMessage) {
|
||||
let windowUtils = content && content.windowUtils;
|
||||
switch (aMessage.name) {
|
||||
case "DOMFullscreen:Entered": {
|
||||
this._lastTransactionId = windowUtils.lastTransactionId;
|
||||
if (!windowUtils.handleFullscreenRequests() &&
|
||||
!content.document.fullscreenElement) {
|
||||
// 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:Exit");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "DOMFullscreen:CleanUp": {
|
||||
// If we've exited fullscreen at this point, no need to record
|
||||
// transaction id or call exit fullscreen. This is especially
|
||||
// important for non-e10s, since in that case, it is possible
|
||||
// that no more paint would be triggered after this point.
|
||||
if (content.document.fullscreenElement && windowUtils) {
|
||||
this._lastTransactionId = windowUtils.lastTransactionId;
|
||||
windowUtils.exitFullscreen();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
handleEvent(aEvent) {
|
||||
switch (aEvent.type) {
|
||||
case "MozDOMFullscreen:Request": {
|
||||
sendAsyncMessage("DOMFullscreen:Request");
|
||||
break;
|
||||
}
|
||||
case "MozDOMFullscreen:NewOrigin": {
|
||||
sendAsyncMessage("DOMFullscreen:NewOrigin", {
|
||||
originNoSuffix: aEvent.target.nodePrincipal.originNoSuffix,
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "MozDOMFullscreen:Exit": {
|
||||
sendAsyncMessage("DOMFullscreen:Exit");
|
||||
break;
|
||||
}
|
||||
case "MozDOMFullscreen:Entered":
|
||||
case "MozDOMFullscreen:Exited": {
|
||||
addEventListener("MozAfterPaint", this);
|
||||
if (!content || !content.document.fullscreenElement) {
|
||||
// If we receive any fullscreen change event, and find we are
|
||||
// actually not in fullscreen, also ask the parent to exit to
|
||||
// ensure that the parent always exits fullscreen when we do.
|
||||
sendAsyncMessage("DOMFullscreen:Exit");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "MozAfterPaint": {
|
||||
// Only send Painted signal after we actually finish painting
|
||||
// the transition for the fullscreen change.
|
||||
// Note that this._lastTransactionId is not set when in non-e10s
|
||||
// mode, so we need to check that explicitly.
|
||||
if (!this._lastTransactionId ||
|
||||
aEvent.transactionId > this._lastTransactionId) {
|
||||
removeEventListener("MozAfterPaint", this);
|
||||
sendAsyncMessage("DOMFullscreen:Painted");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
DOMFullscreenHandler.init();
|
||||
|
||||
Services.obs.notifyObservers(this, "tab-content-frameloader-created");
|
||||
|
||||
// Remove this once bug 1397365 is fixed.
|
||||
|
|
|
@ -102,6 +102,24 @@ let ACTORS = {
|
|||
},
|
||||
},
|
||||
|
||||
DOMFullscreen: {
|
||||
child: {
|
||||
module: "resource:///actors/DOMFullscreenChild.jsm",
|
||||
group: "browsers",
|
||||
events: {
|
||||
"MozDOMFullscreen:Request": {},
|
||||
"MozDOMFullscreen:Entered": {},
|
||||
"MozDOMFullscreen:NewOrigin": {},
|
||||
"MozDOMFullscreen:Exit": {},
|
||||
"MozDOMFullscreen:Exited": {},
|
||||
},
|
||||
messages: [
|
||||
"DOMFullscreen:Entered",
|
||||
"DOMFullscreen:CleanUp",
|
||||
]
|
||||
},
|
||||
},
|
||||
|
||||
LightWeightThemeInstall: {
|
||||
child: {
|
||||
module: "resource:///actors/LightWeightThemeInstallChild.jsm",
|
||||
|
|
Загрузка…
Ссылка в новой задаче