Bug 960783 - Support "new out-of-process window" menu item in nightly (r=felipe,bsmedberg,trevor,ted)

This commit is contained in:
Bill McCloskey 2014-02-11 09:01:08 -08:00
parent 84c750bcb9
commit f68b403891
12 changed files with 75 additions and 14 deletions

View File

@ -16,7 +16,7 @@
#include "nsIArray.h"
#include "nsIDocument.h"
#include "nsIDocShellTreeItem.h"
#include "nsIXULRuntime.h"
#include "nsXULAppAPI.h"
using namespace mozilla;
using namespace mozilla::a11y;
@ -59,7 +59,7 @@ nsWinUtils::MaybeStartWindowEmulation()
// with tabs.
if (Compatibility::IsJAWS() || Compatibility::IsWE() ||
Compatibility::IsDolphin() ||
BrowserTabsRemote()) {
XRE_GetProcessType() == GeckoProcessType_Content) {
RegisterNativeWindow(kClassNameTabContent);
sHWNDCache = new nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible>(4);
return true;

View File

@ -978,7 +978,16 @@ pref("dom.ipc.plugins.enabled.x86_64", true);
pref("dom.ipc.plugins.enabled", true);
#endif
#if defined(NIGHTLY_BUILD) && defined(XP_MACOSX)
// In Nightly, browser.tabs.remote is enabled on platforms that
// support OMTC. However, users won't actually get remote tabs unless
// they enable browser.tabs.remote.autostart or they use the "New OOP
// Window" menu option.
pref("browser.tabs.remote", true);
#else
pref("browser.tabs.remote", false);
#endif
pref("browser.tabs.remote.autostart", false);
// This pref governs whether we attempt to work around problems caused by
// plugins using OS calls to manipulate the cursor while running out-of-

View File

@ -27,6 +27,14 @@
accesskey="&newPrivateWindow.accesskey;"
command="Tools:PrivateBrowsing"
key="key_privatebrowsing"/>
<menuitem id="menu_newRemoteWindow"
label="New OOP Window"
hidden="true"
command="Tools:RemoteWindow"/>
<menuitem id="menu_newNonRemoteWindow"
label="New In-process Window"
hidden="true"
command="Tools:NonRemoteWindow"/>
<menuitem id="menu_openFile"
label="&openFileCmd.label;"
command="Browser:OpenFile"

View File

@ -106,6 +106,10 @@
oncommand="Cc['@mozilla.org/browser/browserglue;1'].getService(Ci.nsIBrowserGlue).sanitize(window);"/>
<command id="Tools:PrivateBrowsing"
oncommand="OpenBrowserWindow({private: true});"/>
<command id="Tools:RemoteWindow"
oncommand="OpenBrowserWindow({remote: true});"/>
<command id="Tools:NonRemoteWindow"
oncommand="OpenBrowserWindow({remote: false});"/>
<command id="History:UndoCloseTab" oncommand="undoCloseTab();"/>
<command id="History:UndoCloseWindow" oncommand="undoCloseWindow();"/>
<command id="Social:SharePage" oncommand="SocialShare.sharePage();" disabled="true"/>

View File

@ -757,7 +757,11 @@ var gBrowserInit = {
delayedStartupFinished: false,
onLoad: function() {
gMultiProcessBrowser = Services.appinfo.browserTabsRemote;
gMultiProcessBrowser =
window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsILoadContext)
.useRemoteTabs;
var mustLoadSidebar = false;
@ -1023,6 +1027,7 @@ var gBrowserInit = {
IndexedDBPromptHelper.init();
gFormSubmitObserver.init();
SocialUI.init();
gRemoteTabsUI.init();
// Initialize the full zoom setting.
// We do this before the session restore service gets initialized so we can
@ -3186,6 +3191,12 @@ function OpenBrowserWindow(options)
extraFeatures = ",non-private";
}
if (options && options.remote) {
extraFeatures += ",remote";
} else if (options && options.remote === false) {
extraFeatures += ",non-remote";
}
// if and only if the current window is a browser window and it has a document with a character
// set, then extract the current charset menu setting from the current document and use it to
// initialize the new browser window...
@ -6866,6 +6877,28 @@ let gPrivateBrowsingUI = {
}
};
let gRemoteTabsUI = {
init: function() {
if (window.location.href != getBrowserURL()) {
return;
}
let remoteTabs = gPrefService.getBoolPref("browser.tabs.remote");
let autostart = gPrefService.getBoolPref("browser.tabs.remote.autostart");
let newRemoteWindow = document.getElementById("menu_newRemoteWindow");
let newNonRemoteWindow = document.getElementById("menu_newNonRemoteWindow");
if (!remoteTabs) {
newRemoteWindow.hidden = true;
newNonRemoteWindow.hidden = true;
return;
}
newRemoteWindow.hidden = autostart;
newNonRemoteWindow.hidden = !autostart;
}
};
/**
* Switch to a tab that has a given URI, and focusses its browser window.

View File

@ -35,7 +35,7 @@ addMessageListener("Browser:HideSessionRestoreButton", function (message) {
}
});
if (Services.prefs.getBoolPref("browser.tabs.remote")) {
if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT) {
addEventListener("contextmenu", function (event) {
sendAsyncMessage("contextmenu", {}, { event: event });
}, false);

View File

@ -3054,7 +3054,11 @@
"-moz-default-background-color" :
Services.prefs.getCharPref("browser.display.background_color");
if (Services.appinfo.browserTabsRemote) {
let remote = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsILoadContext)
.useRemoteTabs;
if (remote) {
messageManager.addMessageListener("DOMTitleChanged", this);
messageManager.addMessageListener("contextmenu", this);
}
@ -3121,7 +3125,7 @@
document.removeEventListener("keypress", this, false);
window.removeEventListener("sizemodechange", this, false);
if (Services.appinfo.browserTabsRemote) {
if (gMultiProcessBrowser) {
messageManager.removeMessageListener("DOMTitleChanged", this);
messageManager.removeMessageListener("contextmenu", this);
}

View File

@ -2258,6 +2258,13 @@ nsDocShell::GetUseRemoteTabs(bool* aUseRemoteTabs)
NS_IMETHODIMP
nsDocShell::SetRemoteTabs(bool aUseRemoteTabs)
{
#ifdef MOZ_CRASHREPORTER
if (aUseRemoteTabs) {
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("DOMIPCEnabled"),
NS_LITERAL_CSTRING("1"));
}
#endif
mUseRemoteTabs = aUseRemoteTabs;
return NS_OK;
}

View File

@ -239,7 +239,7 @@ this.OnRefTestLoad = function OnRefTestLoad(win)
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch);
try {
gBrowserIsRemote = prefs.getBoolPref("browser.tabs.remote");
gBrowserIsRemote = prefs.getBoolPref("browser.tabs.remote.autostart");
} catch (e) {
gBrowserIsRemote = false;
}

View File

@ -582,6 +582,7 @@ class Mochitest(MochitestUtilsMixin):
if options.browserChrome and options.timeout:
options.extraPrefs.append("testing.browserTestHarness.timeout=%d" % options.timeout)
options.extraPrefs.append("browser.tabs.remote=%s" % ('true' if options.e10s else 'false'))
options.extraPrefs.append("browser.tabs.remote.autostart=%s" % ('true' if options.e10s else 'false'))
# get extensions to install
extensions = self.getExtensionsToInstall(options)

View File

@ -203,10 +203,10 @@ RUN_REFTEST_B2G = rm -f ./$@.log && $(PYTHON) _tests/reftest/runreftestb2g.py \
ifeq ($(OS_ARCH),WINNT) #{
# GPU-rendered shadow layers are unsupported here
OOP_CONTENT = --setpref=browser.tabs.remote=true --setpref=layers.acceleration.disabled=true
OOP_CONTENT = --setpref=browser.tabs.remote=true --setpref=browser.tabs.remote.autostart=true --setpref=layers.acceleration.disabled=true
GPU_RENDERING =
else
OOP_CONTENT = --setpref=browser.tabs.remote=true
OOP_CONTENT = --setpref=browser.tabs.remote=true --setpref=browser.tabs.remote.autostart=true
GPU_RENDERING = --setpref=layers.acceleration.force-enabled=true
endif #}

View File

@ -3846,11 +3846,6 @@ XREMain::XRE_mainRun()
mDirProvider.DoStartup();
#ifdef MOZ_CRASHREPORTER
if (BrowserTabsRemote()) {
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("DOMIPCEnabled"),
NS_LITERAL_CSTRING("1"));
}
nsCString userAgentLocale;
if (NS_SUCCEEDED(Preferences::GetCString("general.useragent.locale", &userAgentLocale))) {
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("useragent_locale"), userAgentLocale);