Bug 1260190 - Disable e10s for accessibility users on OS X. r=jimm
MozReview-Commit-ID: 35KZiKcSFqL
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1243,17 +1243,18 @@ BrowserGlue.prototype = {
DefaultBrowserCheck.prompt(RecentWindow.getMostRecentBrowserWindow());
}.bind(this), Ci.nsIThread.DISPATCH_NORMAL);
}
}
if (AppConstants.E10S_TESTING_ONLY) {
E10SUINotification.checkStatus();
}
- if (AppConstants.platform == "win") {
+ if (AppConstants.platform == "win" ||
+ AppConstants.platform == "macosx") {
// Handles prompting to inform about incompatibilites when accessibility
// and e10s are active together.
E10SAccessibilityCheck.init();
}
},
_createExtraDefaultProfile: function () {
if (!AppConstants.MOZ_DEV_EDITION) {
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -4658,31 +4658,31 @@ enum {
// kE10sDisabledInSafeMode = 3, was removed in bug 1172491.
kE10sDisabledForAccessibility = 4,
// kE10sDisabledForMacGfx = 5, was removed in bug 1068674.
kE10sDisabledForBidi = 6,
kE10sDisabledForAddons = 7,
kE10sForceDisabled = 8,
};
-#ifdef XP_WIN
+#if defined(XP_WIN) || defined(XP_MACOSX)
const char* kAccessibilityLastRunDatePref = "accessibility.lastLoadDate";
const char* kAccessibilityLoadedLastSessionPref = "accessibility.loadedInLastSession";
-#endif // XP_WIN
-const char* kForceEnableE10sPref = "browser.tabs.remote.force-enable";
-const char* kForceDisableE10sPref = "browser.tabs.remote.force-disable";
-
-#ifdef XP_WIN
+
static inline uint32_t
PRTimeToSeconds(PRTime t_usec)
{
PRTime usec_per_sec = PR_USEC_PER_SEC;
return uint32_t(t_usec /= usec_per_sec);
}
-#endif // XP_WIN
+#endif // XP_WIN || XP_MACOSX
+
+const char* kForceEnableE10sPref = "browser.tabs.remote.force-enable";
+const char* kForceDisableE10sPref = "browser.tabs.remote.force-disable";
+
uint32_t
MultiprocessBlockPolicy() {
if (gMultiprocessBlockPolicyInitialized) {
return gMultiprocessBlockPolicy;
}
gMultiprocessBlockPolicyInitialized = true;
@@ -4699,17 +4699,17 @@ MultiprocessBlockPolicy() {
#endif
if (addonsCanDisable && disabledByAddons) {
gMultiprocessBlockPolicy = kE10sDisabledForAddons;
return gMultiprocessBlockPolicy;
}
bool disabledForA11y = false;
-#ifdef XP_WIN
+#if defined(XP_WIN) || defined(XP_MACOSX)
/**
* Avoids enabling e10s if accessibility has recently loaded. Performs the
* following checks:
* 1) Checks a pref indicating if a11y loaded in the last session. This pref
* is set in nsBrowserGlue.js. If a11y was loaded in the last session we
* do not enable e10s in this session.
* 2) Accessibility stores a last run date (PR_IntervalNow) when it is
* initialized (see nsBaseWidget.cpp). We check if this pref exists and
@@ -4726,17 +4726,17 @@ MultiprocessBlockPolicy() {
uint32_t now = PRTimeToSeconds(PR_Now());
uint32_t difference = now - a11yRunDate;
if (difference > ONE_WEEK_IN_SECONDS || !a11yRunDate) {
Preferences::ClearUser(kAccessibilityLastRunDatePref);
} else {
disabledForA11y = true;
}
}
-#endif // XP_WIN
+#endif // XP_WIN || XP_MACOSX
if (disabledForA11y) {
gMultiprocessBlockPolicy = kE10sDisabledForAccessibility;
return gMultiprocessBlockPolicy;
}
/**
* Avoids enabling e10s for certain locales that require bidi selection,
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -164,17 +164,17 @@ nsBaseWidget::nsBaseWidget()
, mOriginalBounds(nullptr)
, mClipRectCount(0)
, mSizeMode(nsSizeMode_Normal)
, mPopupLevel(ePopupLevelTop)
, mPopupType(ePopupTypeAny)
, mUpdateCursor(true)
, mUseAttachedEvents(false)
, mIMEHasFocus(false)
-#ifdef XP_WIN
+#if defined(XP_WIN) || defined(XP_MACOSX)
, mAccessibilityInUseFlag(false)
#endif
{
#ifdef NOISY_WIDGET_LEAKS
gNumWidgets++;
printf("WIDGETS+ = %d\n", gNumWidgets);
#endif
@@ -232,17 +232,17 @@ WidgetShutdownObserver::Unregister()
{
if (mRegistered) {
mWidget = nullptr;
nsContentUtils::UnregisterShutdownObserver(this);
mRegistered = false;
}
}
-#ifdef XP_WIN
+#if defined(XP_WIN) || defined(XP_MACOSX)
// defined in nsAppRunner.cpp
extern const char* kAccessibilityLastRunDatePref;
static inline uint32_t
PRTimeToSeconds(PRTime t_usec)
{
PRTime usec_per_sec = PR_USEC_PER_SEC;
return uint32_t(t_usec /= usec_per_sec);
@@ -254,22 +254,16 @@ nsBaseWidget::Shutdown()
{
DestroyCompositor();
FreeShutdownObserver();
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
if (sPluginWidgetList) {
delete sPluginWidgetList;
sPluginWidgetList = nullptr;
}
-#if defined(XP_WIN)
- if (mAccessibilityInUseFlag) {
- uint32_t now = PRTimeToSeconds(PR_Now());
- Preferences::SetInt(kAccessibilityLastRunDatePref, now);
- }
-#endif
#endif
}
void nsBaseWidget::DestroyCompositor()
{
if (mCompositorBridgeChild) {
// XXX CompositorBridgeChild and CompositorBridgeParent might be re-created in
// ClientLayerManager destructor. See bug 1133426.
@@ -1870,18 +1864,22 @@ nsBaseWidget::GetRootAccessible()
nsPresContext* presContext = presShell->GetPresContext();
NS_ENSURE_TRUE(presContext->GetContainerWeak(), nullptr);
// Accessible creation might be not safe so use IsSafeToRunScript to
// make sure it's not created at unsafe times.
nsCOMPtr<nsIAccessibilityService> accService =
services::GetAccessibilityService();
if (accService) {
-#ifdef XP_WIN
- mAccessibilityInUseFlag = true;
+#if defined(XP_WIN) || defined(XP_MACOSX)
+ if (!mAccessibilityInUseFlag) {
+ mAccessibilityInUseFlag = true;
+ uint32_t now = PRTimeToSeconds(PR_Now());
+ Preferences::SetInt(kAccessibilityLastRunDatePref, now);
+ }
#endif
return accService->GetRootDocumentAccessible(presShell, nsContentUtils::IsSafeToRunScript());
}
return nullptr;
}
#endif // ACCESSIBILITY
--- a/widget/nsBaseWidget.h
+++ b/widget/nsBaseWidget.h
@@ -543,17 +543,17 @@ protected:
nsSizeMode mSizeMode;
nsPopupLevel mPopupLevel;
nsPopupType mPopupType;
SizeConstraints mSizeConstraints;
bool mUpdateCursor;
bool mUseAttachedEvents;
bool mIMEHasFocus;
-#ifdef XP_WIN
+#if defined(XP_WIN) || defined(XP_MACOSX)
bool mAccessibilityInUseFlag;
#endif
static nsIRollupListener* gRollupListener;
// the last rolled up popup. Only set this when an nsAutoRollup is in scope,
// so it can be cleared automatically.
static nsIContent* mLastRollup;