Bug 948238 - Read browser.tabs.remote once at startup and never again (r=bsmedberg)

This commit is contained in:
Bill McCloskey 2013-12-12 14:13:20 -08:00
parent 6c0a7b39d8
commit e3463fe50e
14 changed files with 56 additions and 18 deletions

View File

@ -58,7 +58,7 @@ nsWinUtils::MaybeStartWindowEmulation()
// with tabs.
if (Compatibility::IsJAWS() || Compatibility::IsWE() ||
Compatibility::IsDolphin() ||
Preferences::GetBool("browser.tabs.remote")) {
BrowserTabsRemote()) {
RegisterNativeWindow(kClassNameTabContent);
sHWNDCache = new nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible>(4);
return true;

View File

@ -742,7 +742,7 @@ var gBrowserInit = {
delayedStartupFinished: false,
onLoad: function() {
gMultiProcessBrowser = gPrefService.getBoolPref("browser.tabs.remote");
gMultiProcessBrowser = Services.appinfo.browserTabsRemote;
var mustLoadSidebar = false;

View File

@ -3037,7 +3037,7 @@
"-moz-default-background-color" :
Services.prefs.getCharPref("browser.display.background_color");
if (Services.prefs.getBoolPref("browser.tabs.remote")) {
if (Services.appinfo.browserTabsRemote) {
messageManager.addMessageListener("DOMTitleChanged", this);
messageManager.addMessageListener("contextmenu", this);
}
@ -3103,7 +3103,7 @@
document.removeEventListener("keypress", this, false);
window.removeEventListener("sizemodechange", this, false);
if (Services.prefs.getBoolPref("browser.tabs.remote")) {
if (Services.appinfo.browserTabsRemote) {
messageManager.removeMessageListener("DOMTitleChanged", this);
messageManager.removeMessageListener("contextmenu", this);
}

View File

@ -481,7 +481,7 @@ BrowserGlue.prototype = {
SessionStore.init();
BrowserUITelemetry.init();
if (Services.prefs.getBoolPref("browser.tabs.remote"))
if (Services.appinfo.browserTabsRemote)
ContentClick.init();
Services.obs.notifyObservers(null, "browser-ui-startup-complete", "");

View File

@ -389,7 +389,7 @@ let SessionStoreInternal = {
throw new Error("SessionStore.init() must only be called once!");
}
this._disabledForMultiProcess = Services.prefs.getBoolPref("browser.tabs.remote");
this._disabledForMultiProcess = Services.appinfo.browserTabsRemote;
if (this._disabledForMultiProcess) {
this._deferredInitialized.resolve();
return;

View File

@ -1429,7 +1429,7 @@ Tab.prototype = {
browser.setAttribute("type", "content");
let useRemote = Services.prefs.getBoolPref("browser.tabs.remote");
let useRemote = Services.appinfo.browserTabsRemote;
let useLocal = Util.isLocalScheme(aURI);
browser.setAttribute("remote", (!useLocal && useRemote) ? "true" : "false");

View File

@ -79,6 +79,7 @@
#include "nsISupportsPrimitives.h"
#include "nsIURIFixup.h"
#include "nsIWindowWatcher.h"
#include "nsIXULRuntime.h"
#include "nsMemoryReporterManager.h"
#include "nsServiceManagerUtils.h"
#include "nsStyleSheetService.h"
@ -3113,7 +3114,7 @@ ContentParent::ShouldContinueFromReplyTimeout()
{
// The only time ContentParent sends blocking messages is for CPOWs, so
// timeouts should only ever occur in electrolysis-enabled sessions.
MOZ_ASSERT(Preferences::GetBool("browser.tabs.remote", false));
MOZ_ASSERT(BrowserTabsRemote());
return false;
}

View File

@ -55,6 +55,7 @@
#include "nsIWebBrowserFocus.h"
#include "nsIWebBrowserSetup.h"
#include "nsIWebProgress.h"
#include "nsIXULRuntime.h"
#include "nsInterfaceHashtable.h"
#include "nsPIDOMWindow.h"
#include "nsPIWindowRoot.h"
@ -2314,8 +2315,8 @@ TabChild::InitRenderingState()
false);
}
// This state can't really change during the lifetime of the child.
sCpowsEnabled = Preferences::GetBool("browser.tabs.remote", false);
// This state can't change during the lifetime of the child.
sCpowsEnabled = BrowserTabsRemote();
if (Preferences::GetBool("dom.ipc.cpows.force-enabled", false))
sCpowsEnabled = true;

View File

@ -85,6 +85,7 @@
#include "mozilla/Mutex.h"
#include "nsIGfxInfo.h"
#include "nsIXULRuntime.h"
using namespace mozilla;
using namespace mozilla::layers;
@ -2075,7 +2076,7 @@ InitLayersAccelerationPrefs()
sPrefLayoutFrameRate = Preferences::GetInt("layout.frame_rate", -1);
sBufferRotationEnabled = Preferences::GetBool("layers.bufferrotation.enabled", true);
sComponentAlphaEnabled = Preferences::GetBool("layers.componentalpha.enabled", true);
sPrefBrowserTabsRemote = Preferences::GetBool("browser.tabs.remote", false);
sPrefBrowserTabsRemote = BrowserTabsRemote();
#ifdef XP_WIN
if (sPrefLayersAccelerationForceEnabled) {

View File

@ -16,6 +16,7 @@
#include "nsIPresShell.h"
#include "nsEventStateManager.h"
#include "nsIDOMMouseEvent.h"
#include "nsIXULRuntime.h"
#include "nsFontMetrics.h"
#include "nsIScrollableFrame.h"
#include "nsCSSRendering.h"
@ -1806,8 +1807,7 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
} else {
// NOTE: the combo box is responsible for dropping it down
if (mComboboxFrame) {
if (XRE_GetProcessType() == GeckoProcessType_Content &&
Preferences::GetBool("browser.tabs.remote", false)) {
if (XRE_GetProcessType() == GeckoProcessType_Content && BrowserTabsRemote()) {
nsContentUtils::DispatchChromeEvent(mContent->OwnerDoc(), mContent,
NS_LITERAL_STRING("mozshowdropdown"), true,
false);

View File

@ -488,9 +488,8 @@ FormAutoCompleteResult.prototype = {
};
if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT &&
Services.prefs.prefHasUserValue("browser.tabs.remote") &&
Services.prefs.getBoolPref("browser.tabs.remote")) {
let remote = Services.appinfo.browserTabsRemote;
if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT && remote) {
// Register the stub FormAutoComplete module in the child which will
// forward messages to the parent through the process message manager.
let component = [FormAutoCompleteChild];

View File

@ -789,6 +789,16 @@ nsXULAppInfo::GetProcessType(uint32_t* aResult)
return NS_OK;
}
static bool gBrowserTabsRemote = false;
static bool gBrowserTabsRemoteInitialized = false;
NS_IMETHODIMP
nsXULAppInfo::GetBrowserTabsRemote(bool* aResult)
{
*aResult = BrowserTabsRemote();
return NS_OK;
}
NS_IMETHODIMP
nsXULAppInfo::EnsureContentProcess()
{
@ -4368,6 +4378,17 @@ XRE_GetProcessType()
return mozilla::startup::sChildProcessType;
}
bool
mozilla::BrowserTabsRemote()
{
if (!gBrowserTabsRemoteInitialized) {
gBrowserTabsRemote = Preferences::GetBool("browser.tabs.remote", false);
gBrowserTabsRemoteInitialized = true;
}
return gBrowserTabsRemote;
}
void
SetupErrorHandling(const char* progname)
{

View File

@ -935,7 +935,7 @@ CheckForBasicBackends(nsTArray<LayersBackend>& aHints)
for (size_t i = 0; i < aHints.Length(); ++i) {
if (aHints[i] == LAYERS_BASIC &&
!Preferences::GetBool("layers.offmainthreadcomposition.force-basic", false) &&
!Preferences::GetBool("browser.tabs.remote", false)) {
!BrowserTabsRemote()) {
// basic compositor is not stable enough for regular use
aHints[i] = LAYERS_NONE;
}

View File

@ -4,6 +4,15 @@
#include "nsISupports.idl"
%{C++
namespace mozilla {
// Simple C++ getter for nsIXULRuntime::browserTabsRemote
bool BrowserTabsRemote();
}
%}
/**
* Provides information about the XUL runtime.
* @status UNSTABLE - This interface is not frozen and will probably change in
@ -11,7 +20,7 @@
* stable/frozen, please contact Benjamin Smedberg.
*/
[scriptable, uuid(cb0b8eda-4c83-4d0e-a63c-d3b65714bc85)]
[scriptable, uuid(33bd1630-611e-11e3-949a-0800200c9a66)]
interface nsIXULRuntime : nsISupports
{
/**
@ -67,6 +76,12 @@ interface nsIXULRuntime : nsISupports
*/
readonly attribute unsigned long processType;
/**
* If true, browser tabs may be opened in a different process from the main
* browser UI.
*/
readonly attribute boolean browserTabsRemote;
/**
* Signal the apprunner to invalidate caches on the next restart.
* This will cause components to be autoregistered and all