зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1472491: Part 5a - Add BrowserTabChild actor. r=felipe
MozReview-Commit-ID: 38Y1xwkgxCx --HG-- extra : rebase_source : 61a85af58f9f16b8e39b716e3df2d09b788fcb1a
This commit is contained in:
Родитель
e8a71658c6
Коммит
30986431c7
|
@ -0,0 +1,112 @@
|
|||
/* 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 = ["BrowserTabChild"];
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "E10SUtils",
|
||||
"resource://gre/modules/E10SUtils.jsm");
|
||||
|
||||
class BrowserTabChild extends ActorChild {
|
||||
handleEvent(event) {
|
||||
switch (event.type) {
|
||||
case "DOMWindowCreated":
|
||||
let loadContext = this.mm.docShell.QueryInterface(Ci.nsILoadContext);
|
||||
let userContextId = loadContext.originAttributes.userContextId;
|
||||
|
||||
this.mm.sendAsyncMessage("Browser:WindowCreated", { userContextId });
|
||||
break;
|
||||
|
||||
case "MozAfterPaint":
|
||||
this.mm.sendAsyncMessage("Browser:FirstPaint");
|
||||
break;
|
||||
|
||||
case "MozDOMPointerLock:Entered":
|
||||
this.mm.sendAsyncMessage("PointerLock:Entered", {
|
||||
originNoSuffix: event.target.nodePrincipal.originNoSuffix
|
||||
});
|
||||
break;
|
||||
|
||||
case "MozDOMPointerLock:Exited":
|
||||
this.mm.sendAsyncMessage("PointerLock:Exited");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switchDocumentDirection(window = this.content) {
|
||||
// document.dir can also be "auto", in which case it won't change
|
||||
if (window.document.dir == "ltr" || window.document.dir == "") {
|
||||
window.document.dir = "rtl";
|
||||
} else if (window.document.dir == "rtl") {
|
||||
window.document.dir = "ltr";
|
||||
}
|
||||
for (let i = 0; i < window.frames.length; i++) {
|
||||
this.switchDocumentDirection(window.frames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
receiveMessage(message) {
|
||||
switch (message.name) {
|
||||
case "AllowScriptsToClose":
|
||||
this.content.windowUtils.allowScriptsToClose();
|
||||
break;
|
||||
|
||||
case "Browser:AppTab":
|
||||
if (this.docShell) {
|
||||
this.docShell.isAppTab = message.data.isAppTab;
|
||||
}
|
||||
break;
|
||||
|
||||
case "Browser:HasSiblings":
|
||||
try {
|
||||
let tabChild = this.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsITabChild);
|
||||
let hasSiblings = message.data;
|
||||
tabChild.hasSiblings = hasSiblings;
|
||||
} catch (e) {
|
||||
}
|
||||
break;
|
||||
|
||||
// XXX(nika): Should we try to call this in the parent process instead?
|
||||
case "Browser:Reload":
|
||||
/* First, we'll try to use the session history object to reload so
|
||||
* that framesets are handled properly. If we're in a special
|
||||
* window (such as view-source) that has no session history, fall
|
||||
* back on using the web navigation's reload method.
|
||||
*/
|
||||
|
||||
let webNav = this.docShell.QueryInterface(Ci.nsIWebNavigation);
|
||||
try {
|
||||
if (webNav.sessionHistory) {
|
||||
webNav = webNav.sessionHistory;
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
let reloadFlags = message.data.flags;
|
||||
try {
|
||||
E10SUtils.wrapHandlingUserInput(this.content, message.data.handlingUserInput,
|
||||
() => webNav.reload(reloadFlags));
|
||||
} catch (e) {
|
||||
}
|
||||
break;
|
||||
|
||||
case "MixedContent:ReenableProtection":
|
||||
this.docShell.mixedContentChannel = null;
|
||||
break;
|
||||
|
||||
case "SwitchDocumentDirection":
|
||||
this.switchDocumentDirection();
|
||||
break;
|
||||
|
||||
case "UpdateCharacterSet":
|
||||
this.docShell.charset = message.data.value;
|
||||
this.docShell.gatherCharsetMenuTelemetry();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
FINAL_TARGET_FILES.actors += [
|
||||
'BrowserTabChild.jsm',
|
||||
]
|
|
@ -28,18 +28,6 @@ ActorManagerChild.attach(this, "browsers");
|
|||
// TabChildGlobal
|
||||
var global = this;
|
||||
|
||||
|
||||
addEventListener("MozDOMPointerLock:Entered", function(aEvent) {
|
||||
sendAsyncMessage("PointerLock:Entered", {
|
||||
originNoSuffix: aEvent.target.nodePrincipal.originNoSuffix
|
||||
});
|
||||
});
|
||||
|
||||
addEventListener("MozDOMPointerLock:Exited", function(aEvent) {
|
||||
sendAsyncMessage("PointerLock:Exited");
|
||||
});
|
||||
|
||||
|
||||
addMessageListener("Browser:HideSessionRestoreButton", function(message) {
|
||||
// Hide session restore button on about:home
|
||||
let doc = content.document;
|
||||
|
@ -50,43 +38,6 @@ addMessageListener("Browser:HideSessionRestoreButton", function(message) {
|
|||
}
|
||||
});
|
||||
|
||||
if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT) {
|
||||
addMessageListener("Browser:HasSiblings", function(message) {
|
||||
let tabChild = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsITabChild);
|
||||
let hasSiblings = message.data;
|
||||
tabChild.hasSiblings = hasSiblings;
|
||||
});
|
||||
}
|
||||
|
||||
// XXX(nika): Should we try to call this in the parent process instead?
|
||||
addMessageListener("Browser:Reload", function(message) {
|
||||
/* First, we'll try to use the session history object to reload so
|
||||
* that framesets are handled properly. If we're in a special
|
||||
* window (such as view-source) that has no session history, fall
|
||||
* back on using the web navigation's reload method.
|
||||
*/
|
||||
|
||||
let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
|
||||
try {
|
||||
if (webNav.sessionHistory) {
|
||||
webNav = webNav.sessionHistory;
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
let reloadFlags = message.data.flags;
|
||||
try {
|
||||
E10SUtils.wrapHandlingUserInput(content, message.data.handlingUserInput,
|
||||
() => webNav.reload(reloadFlags));
|
||||
} catch (e) {
|
||||
}
|
||||
});
|
||||
|
||||
addMessageListener("MixedContent:ReenableProtection", function() {
|
||||
docShell.mixedContentChannel = null;
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyProxy(this, "LightweightThemeChildHelper",
|
||||
"resource:///modules/LightweightThemeChildHelper.jsm");
|
||||
|
||||
|
@ -353,12 +304,6 @@ addEventListener("unload", () => {
|
|||
Services.obs.removeObserver(gKeywordURIFixup, "keyword-uri-fixup");
|
||||
}, false);
|
||||
|
||||
addMessageListener("Browser:AppTab", function(message) {
|
||||
if (docShell) {
|
||||
docShell.isAppTab = message.data.isAppTab;
|
||||
}
|
||||
});
|
||||
|
||||
var WebBrowserChrome = {
|
||||
onBeforeLinkTraversal(originalTarget, linkURI, linkNode, isAppTab) {
|
||||
return BrowserUtils.onBeforeLinkTraversal(originalTarget, linkURI, linkNode, isAppTab);
|
||||
|
@ -477,45 +422,8 @@ var DOMFullscreenHandler = {
|
|||
};
|
||||
DOMFullscreenHandler.init();
|
||||
|
||||
var UserContextIdNotifier = {
|
||||
init() {
|
||||
addEventListener("DOMWindowCreated", this);
|
||||
this.init = null;
|
||||
},
|
||||
|
||||
uninit() {
|
||||
removeEventListener("DOMWindowCreated", this);
|
||||
},
|
||||
|
||||
handleEvent(aEvent) {
|
||||
// When the window is created, we want to inform the tabbrowser about
|
||||
// the userContextId in use in order to update the UI correctly.
|
||||
// Just because we cannot change the userContextId from an active docShell,
|
||||
// we don't need to check DOMContentLoaded again.
|
||||
this.uninit();
|
||||
|
||||
// We use the docShell because content.document can have been loaded before
|
||||
// setting the originAttributes.
|
||||
let loadContext = docShell.QueryInterface(Ci.nsILoadContext);
|
||||
let userContextId = loadContext.originAttributes.userContextId;
|
||||
|
||||
sendAsyncMessage("Browser:WindowCreated", { userContextId });
|
||||
}
|
||||
};
|
||||
|
||||
UserContextIdNotifier.init();
|
||||
|
||||
Services.obs.notifyObservers(this, "tab-content-frameloader-created");
|
||||
|
||||
addMessageListener("AllowScriptsToClose", () => {
|
||||
content.windowUtils.allowScriptsToClose();
|
||||
});
|
||||
|
||||
addEventListener("MozAfterPaint", function onFirstPaint() {
|
||||
removeEventListener("MozAfterPaint", onFirstPaint);
|
||||
sendAsyncMessage("Browser:FirstPaint");
|
||||
});
|
||||
|
||||
// Remove this once bug 1397365 is fixed.
|
||||
addEventListener("MozAfterPaint", function onFirstNonBlankPaint() {
|
||||
if (content.document.documentURI == "about:blank" && !content.opener)
|
||||
|
|
|
@ -48,6 +48,7 @@ const whitelist = {
|
|||
"resource://formautofill/FormAutofillContent.jsm",
|
||||
|
||||
// Browser front-end
|
||||
"resource:///actors/BrowserTabChild.jsm",
|
||||
"resource:///modules/ContentLinkHandler.jsm",
|
||||
"resource:///modules/ContentMetaHandler.jsm",
|
||||
"resource:///modules/PageStyleHandler.jsm",
|
||||
|
|
|
@ -12,6 +12,29 @@ ChromeUtils.defineModuleGetter(this, "ActorManagerParent",
|
|||
"resource://gre/modules/ActorManagerParent.jsm");
|
||||
|
||||
let ACTORS = {
|
||||
BrowserTab: {
|
||||
child: {
|
||||
module: "resource:///actors/BrowserTabChild.jsm",
|
||||
group: "browsers",
|
||||
|
||||
events: {
|
||||
"DOMWindowCreated": {once: true},
|
||||
"MozAfterPaint": {once: true},
|
||||
"MozDOMPointerLock:Entered": {},
|
||||
"MozDOMPointerLock:Exited": {},
|
||||
},
|
||||
|
||||
messages: [
|
||||
"AllowScriptsToClose",
|
||||
"Browser:AppTab",
|
||||
"Browser:HasSiblings",
|
||||
"Browser:Reload",
|
||||
"MixedContent:ReenableProtection",
|
||||
"SwitchDocumentDirection",
|
||||
"UpdateCharacterSet",
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
(function earlyBlankFirstPaint() {
|
||||
|
|
|
@ -381,6 +381,7 @@
|
|||
; Modules
|
||||
@RESPATH@/browser/modules/*
|
||||
@RESPATH@/modules/*
|
||||
@RESPATH@/browser/actors/*
|
||||
|
||||
; Safe Browsing
|
||||
@RESPATH@/components/nsURLClassifier.manifest
|
||||
|
|
|
@ -12,6 +12,7 @@ with Files('docs/**'):
|
|||
SCHEDULES.exclusive = ['docs']
|
||||
|
||||
DIRS += [
|
||||
'actors',
|
||||
'base',
|
||||
'components',
|
||||
'fonts',
|
||||
|
|
|
@ -336,6 +336,7 @@ class OmniJarSubFormatter(PiecemealFormatter):
|
|||
path[1] in ['pref', 'preferences'])
|
||||
return path[0] in [
|
||||
'modules',
|
||||
'actors',
|
||||
'dictionaries',
|
||||
'greprefs.js',
|
||||
'hyphenation',
|
||||
|
|
|
@ -121,22 +121,6 @@ var Printing = {
|
|||
};
|
||||
Printing.init();
|
||||
|
||||
function SwitchDocumentDirection(aWindow) {
|
||||
// document.dir can also be "auto", in which case it won't change
|
||||
if (aWindow.document.dir == "ltr" || aWindow.document.dir == "") {
|
||||
aWindow.document.dir = "rtl";
|
||||
} else if (aWindow.document.dir == "rtl") {
|
||||
aWindow.document.dir = "ltr";
|
||||
}
|
||||
for (let run = 0; run < aWindow.frames.length; run++) {
|
||||
SwitchDocumentDirection(aWindow.frames[run]);
|
||||
}
|
||||
}
|
||||
|
||||
addMessageListener("SwitchDocumentDirection", () => {
|
||||
SwitchDocumentDirection(content.window);
|
||||
});
|
||||
|
||||
var FindBar = {
|
||||
/**
|
||||
* _findKey and _findModifiers are used to determine whether a keypress
|
||||
|
|
Загрузка…
Ссылка в новой задаче