зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1367234 - 1. Support fullscreen for e10s GeckoView; r=droeh
Add event listeners and implement basic messages between chrome and content so let e10s content in GeckoView request/exit fullscreen. Once we're on the parent side, we still go through the normal fullscreen flow so there is no platform or Java change involved. MozReview-Commit-ID: G1tBIOoFqkB
This commit is contained in:
Родитель
c4f7fca79b
Коммит
a96d808466
|
@ -15,10 +15,34 @@ function debug(aMsg) {
|
|||
var DOMTitleChangedListener = {
|
||||
init: function() {
|
||||
addEventListener("DOMTitleChanged", this, false);
|
||||
addEventListener("MozDOMFullscreen:Entered", this, false);
|
||||
addEventListener("MozDOMFullscreen:Exit", this, false);
|
||||
addEventListener("MozDOMFullscreen:Exited", this, false);
|
||||
addEventListener("MozDOMFullscreen:Request", this, false);
|
||||
|
||||
addMessageListener("GeckoView:DOMFullscreenEntered", this);
|
||||
addMessageListener("GeckoView:DOMFullscreenExited", this);
|
||||
},
|
||||
|
||||
receiveMessage: function(aMsg) {
|
||||
debug("receiveMessage " + aMsg.name);
|
||||
|
||||
switch (aMsg.name) {
|
||||
case "GeckoView:DOMFullscreenEntered":
|
||||
if (content) {
|
||||
content.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils)
|
||||
.handleFullscreenRequests();
|
||||
}
|
||||
break;
|
||||
case "GeckoView:DOMFullscreenExited":
|
||||
if (content) {
|
||||
content.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils)
|
||||
.exitFullscreen();
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
handleEvent: function(aEvent) {
|
||||
|
@ -29,6 +53,21 @@ var DOMTitleChangedListener = {
|
|||
debug("handleEvent " + aEvent.type);
|
||||
|
||||
switch (aEvent.type) {
|
||||
case "MozDOMFullscreen:Request":
|
||||
sendAsyncMessage("GeckoView:DOMFullscreenRequest");
|
||||
break;
|
||||
case "MozDOMFullscreen:Entered":
|
||||
case "MozDOMFullscreen:Exited":
|
||||
// Content may change fullscreen state by itself, and we should ensure
|
||||
// that the parent always exits fullscreen when content has left
|
||||
// full screen mode.
|
||||
if (content && content.document.fullscreenElement) {
|
||||
break;
|
||||
}
|
||||
// fall-through
|
||||
case "MozDOMFullscreen:Exit":
|
||||
sendAsyncMessage("GeckoView:DOMFullscreenExit");
|
||||
break;
|
||||
case "DOMTitleChanged":
|
||||
sendAsyncMessage("GeckoView:DOMTitleChanged",
|
||||
{ title: content.document.title });
|
||||
|
|
|
@ -20,11 +20,30 @@ function debug(aMsg) {
|
|||
class GeckoViewContent extends GeckoViewModule {
|
||||
init() {
|
||||
this.messageManager.loadFrameScript("chrome://geckoview/content/GeckoViewContent.js", true);
|
||||
this.messageManager.addMessageListener("GeckoView:DOMFullscreenExit", this);
|
||||
this.messageManager.addMessageListener("GeckoView:DOMFullscreenRequest", this);
|
||||
this.messageManager.addMessageListener("GeckoView:DOMTitleChanged", this);
|
||||
|
||||
this.window.addEventListener("MozDOMFullscreen:Entered", this,
|
||||
/* capture */ true, /* untrusted */ false);
|
||||
this.window.addEventListener("MozDOMFullscreen:Exited", this,
|
||||
/* capture */ true, /* untrusted */ false);
|
||||
}
|
||||
|
||||
handleEvent(aEvent) {
|
||||
debug("handleEvent: aEvent.type=" + aEvent.type);
|
||||
|
||||
switch (aEvent.type) {
|
||||
case "MozDOMFullscreen:Entered":
|
||||
if (this.browser == aEvent.target) {
|
||||
// Remote browser; dispatch to content process.
|
||||
this.browser.messageManager.sendAsyncMessage("GeckoView:DOMFullscreenEntered");
|
||||
}
|
||||
break;
|
||||
case "MozDOMFullscreen:Exited":
|
||||
this.browser.messageManager.sendAsyncMessage("GeckoView:DOMFullscreenExited");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Message manager event handler.
|
||||
|
@ -32,6 +51,16 @@ class GeckoViewContent extends GeckoViewModule {
|
|||
debug("receiveMessage " + aMsg.name);
|
||||
|
||||
switch (aMsg.name) {
|
||||
case "GeckoView:DOMFullscreenExit":
|
||||
this.window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils)
|
||||
.remoteFrameFullscreenReverted();
|
||||
break;
|
||||
case "GeckoView:DOMFullscreenRequest":
|
||||
this.window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils)
|
||||
.remoteFrameFullscreenChanged(aMsg.target);
|
||||
break;
|
||||
case "GeckoView:DOMTitleChanged":
|
||||
this.eventDispatcher.sendRequest({
|
||||
type: "GeckoView:DOMTitleChanged",
|
||||
|
|
Загрузка…
Ссылка в новой задаче