Bug 966683 - Australis - automatically toggle accesskey-focuses on Linux to prevent menubar focus stealing, r=Neil,dao
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 18 Feb 2014 17:07:27 +0000
changeset 170187 c9de8e0ce745
parent 170186 5fa7f5df67b3
child 170188 7913b3e61acb
push id40151
push usergijskruitbosch@gmail.com
push dateMon, 24 Feb 2014 15:18:09 +0000
treeherdermozilla-inbound@c9de8e0ce745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil, dao
bugs966683
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 966683 - Australis - automatically toggle accesskey-focuses on Linux to prevent menubar focus stealing, r=Neil,dao
browser/app/profile/firefox.js
browser/base/content/browser.js
layout/build/nsLayoutStatics.cpp
layout/xul/nsMenuBarListener.cpp
layout/xul/nsMenuBarListener.h
modules/libpref/src/init/all.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1376,11 +1376,16 @@ pref("identity.fxaccounts.remote.signin.
 // The URL we take the user to when they opt to "manage" their Firefox Account.
 // Note that this will always need to be in the same TLD as the
 // "identity.fxaccounts.remote.uri" pref.
 pref("identity.fxaccounts.settings.uri", "https://accounts.firefox.com/settings");
 
 // The URL of the Firefox Accounts auth server backend
 pref("identity.fxaccounts.auth.uri", "https://api.accounts.firefox.com/v1");
 
+// On GTK, we now default to showing the menubar only when alt is pressed:
+#ifdef MOZ_WIDGET_GTK
+pref("ui.key.menuAccessKeyFocuses", true);
+#endif
+
 
 // Temporarily turn the new http cache v2 on for Desktop Firefox only
 pref("browser.cache.use_new_backend_temp", true);
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -4273,18 +4273,25 @@ function onViewToolbarsPopupShowing(aEve
 function onViewToolbarCommand(aEvent) {
   var toolbarId = aEvent.originalTarget.getAttribute("toolbarId");
   var toolbar = document.getElementById(toolbarId);
   var isVisible = aEvent.originalTarget.getAttribute("checked") == "true";
   setToolbarVisibility(toolbar, isVisible);
 }
 
 function setToolbarVisibility(toolbar, isVisible) {
-  var hidingAttribute = toolbar.getAttribute("type") == "menubar" ?
-                        "autohide" : "collapsed";
+  let hidingAttribute;
+  if (toolbar.getAttribute("type") == "menubar") {
+    hidingAttribute = "autohide";
+#ifdef MOZ_WIDGET_GTK
+    Services.prefs.setBoolPref("ui.key.menuAccessKeyFocuses", !isVisible);
+#endif
+  } else {
+    hidingAttribute = "collapsed";
+  }
 
   toolbar.setAttribute(hidingAttribute, !isVisible);
   document.persist(toolbar.id, hidingAttribute);
   let eventParams = {
     detail: {
       visible: isVisible
     },
     bubbles: true
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -68,16 +68,18 @@
 
 #ifdef MOZ_XUL
 #include "nsXULPopupManager.h"
 #include "nsXULContentUtils.h"
 #include "nsXULPrototypeCache.h"
 #include "nsXULTooltipListener.h"
 
 #include "inDOMView.h"
+
+#include "nsMenuBarListener.h"
 #endif
 
 #include "nsHTMLEditor.h"
 #include "nsTextServicesDocument.h"
 
 #ifdef MOZ_WEBSPEECH
 #include "nsSynthVoiceRegistry.h"
 #endif
@@ -276,16 +278,20 @@ nsLayoutStatics::Initialize()
   ProcessPriorityManager::Init();
 
   nsPermissionManager::AppClearDataObserverInit();
   nsCookieService::AppClearDataObserverInit();
   nsApplicationCacheService::AppClearDataObserverInit();
 
   HTMLVideoElement::Init();
 
+#ifdef MOZ_XUL
+  nsMenuBarListener::InitializeStatics();
+#endif
+
   CacheObserver::Init();
 
   return NS_OK;
 }
 
 void
 nsLayoutStatics::Shutdown()
 {
--- a/layout/xul/nsMenuBarListener.cpp
+++ b/layout/xul/nsMenuBarListener.cpp
@@ -47,16 +47,23 @@ nsMenuBarListener::nsMenuBarListener(nsM
   mMenuBarFrame = aMenuBar;
 }
 
 ////////////////////////////////////////////////////////////////////////
 nsMenuBarListener::~nsMenuBarListener() 
 {
 }
 
+void
+nsMenuBarListener::InitializeStatics()
+{
+  Preferences::AddBoolVarCache(&mAccessKeyFocuses,
+                               "ui.key.menuAccessKeyFocuses");
+}
+
 nsresult
 nsMenuBarListener::GetMenuAccessKey(int32_t* aAccessKey)
 {
   if (!aAccessKey)
     return NS_ERROR_INVALID_POINTER;
   InitAccessKey();
   *aAccessKey = mAccessKey;
   return NS_OK;
@@ -84,18 +91,16 @@ void nsMenuBarListener::InitAccessKey()
   else if (mAccessKey == nsIDOMKeyEvent::DOM_VK_CONTROL)
     mAccessKeyMask = MODIFIER_CONTROL;
   else if (mAccessKey == nsIDOMKeyEvent::DOM_VK_ALT)
     mAccessKeyMask = MODIFIER_ALT;
   else if (mAccessKey == nsIDOMKeyEvent::DOM_VK_META)
     mAccessKeyMask = MODIFIER_META;
   else if (mAccessKey == nsIDOMKeyEvent::DOM_VK_WIN)
     mAccessKeyMask = MODIFIER_OS;
-
-  mAccessKeyFocuses = Preferences::GetBool("ui.key.menuAccessKeyFocuses");
 }
 
 void
 nsMenuBarListener::ToggleMenuActiveState()
 {
   nsMenuFrame* closemenu = mMenuBarFrame->ToggleMenuActiveState();
   nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
   if (pm && closemenu) {
--- a/layout/xul/nsMenuBarListener.h
+++ b/layout/xul/nsMenuBarListener.h
@@ -22,16 +22,18 @@ class nsMenuBarListener : public nsIDOME
 {
 public:
   /** default constructor
    */
   nsMenuBarListener(nsMenuBarFrame* aMenuBar);
   /** default destructor
    */
   virtual ~nsMenuBarListener();
+
+  static void InitializeStatics();
    
   NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) MOZ_OVERRIDE;
   
   nsresult KeyUp(nsIDOMEvent* aMouseEvent);
   nsresult KeyDown(nsIDOMEvent* aMouseEvent);
   nsresult KeyPress(nsIDOMEvent* aMouseEvent);
   nsresult Blur(nsIDOMEvent* aEvent);
   nsresult MouseDown(nsIDOMEvent* aMouseEvent);
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -3649,18 +3649,16 @@ pref("print.postscript.print_command", "
 // 2 problems:
 // 1. The non-topmost panel steals focus from its parent window at showing.
 // 2. The parent of non-topmost panel is not activated when the panel is hidden.
 // So, we have no reasons we should use non-toplevel window for popup.
 pref("ui.panel.default_level_parent", true);
 
 pref("mousewheel.system_scroll_override_on_root_content.enabled", false);
 
-pref("ui.key.menuAccessKeyFocuses", true);
-
 #if MOZ_WIDGET_GTK == 2
 pref("intl.ime.use_simple_context_on_password_field", true);
 #else
 pref("intl.ime.use_simple_context_on_password_field", false);
 #endif
 
 # XP_UNIX
 #endif