diff --git a/mozilla/content/base/public/nsIContent.h b/mozilla/content/base/public/nsIContent.h index 506ba4a5ae7..8d4cb7d843f 100644 --- a/mozilla/content/base/public/nsIContent.h +++ b/mozilla/content/base/public/nsIContent.h @@ -665,6 +665,9 @@ public: // Tab focus model bit field: static PRInt32 sTabFocusModel; + // accessibility.tabfocus_applies_to_xul pref - if it is set to true, + // the tabfocus bit field applies to xul elements. + static PRBool sTabFocusModelAppliesToXUL; protected: typedef PRWord PtrBits; diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index bd71ffc1a44..39c24ae3683 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -125,6 +125,7 @@ DebugListContentTree(nsIContent* aElement) PLDHashTable nsGenericElement::sRangeListsHash; PLDHashTable nsGenericElement::sEventListenerManagersHash; PRInt32 nsIContent::sTabFocusModel = eTabFocus_any; +PRBool nsIContent::sTabFocusModelAppliesToXUL = PR_FALSE; //---------------------------------------------------------------------- nsChildContentList::nsChildContentList(nsIContent *aContent) diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 0eba014f2cb..a00364a5155 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -226,9 +226,14 @@ nsEventStateManager::Init() sGeneralAccesskeyModifier = nsContentUtils::GetIntPref("ui.key.generalAccessKey", sGeneralAccesskeyModifier); + + nsIContent::sTabFocusModelAppliesToXUL = + nsContentUtils::GetBoolPref("accessibility.tabfocus_applies_to_xul", + nsIContent::sTabFocusModelAppliesToXUL); } prefBranch->AddObserver("accessibility.accesskeycausesactivation", this, PR_TRUE); prefBranch->AddObserver("accessibility.browsewithcaret", this, PR_TRUE); + prefBranch->AddObserver("accessibility.tabfocus_applies_to_xul", this, PR_TRUE); prefBranch->AddObserver("nglayout.events.dispatchLeftClickOnly", this, PR_TRUE); prefBranch->AddObserver("ui.key.generalAccessKey", this, PR_TRUE); #if 0 @@ -305,6 +310,7 @@ nsEventStateManager::Shutdown() if (prefBranch) { prefBranch->RemoveObserver("accessibility.accesskeycausesactivation", this); prefBranch->RemoveObserver("accessibility.browsewithcaret", this); + prefBranch->RemoveObserver("accessibility.tabfocus_applies_to_xul", this); prefBranch->RemoveObserver("nglayout.events.dispatchLeftClickOnly", this); prefBranch->RemoveObserver("ui.key.generalAccessKey", this); #if 0 @@ -347,6 +353,10 @@ nsEventStateManager::Observe(nsISupports *aSubject, sKeyCausesActivation); } else if (data.EqualsLiteral("accessibility.browsewithcaret")) { ResetBrowseWithCaret(); + } else if (data.EqualsLiteral("accessibility.tabfocus_applies_to_xul")) { + nsIContent::sTabFocusModelAppliesToXUL = + nsContentUtils::GetBoolPref("accessibility.tabfocus_applies_to_xul", + nsIContent::sTabFocusModelAppliesToXUL); } else if (data.EqualsLiteral("nglayout.events.dispatchLeftClickOnly")) { sLeftClickOnly = nsContentUtils::GetBoolPref("nglayout.events.dispatchLeftClickOnly", diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index a69fd322f5a..994032f1335 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -686,6 +686,16 @@ nsXULElement::IsFocusable(PRInt32 *aTabIndex) // If attribute not set, will use default value passed in xulControl->GetTabIndex(&tabIndex); } + if (tabIndex != -1 && sTabFocusModelAppliesToXUL && + !(sTabFocusModel & eTabFocus_formElementsMask)) { + // By default, the tab focus model doesn't apply to xul element on any system but OS X. + // on OS X we're following it for UI elements (XUL) as sTabFocusModel is based on + // "Full Keyboard Access" system setting (see mac/nsILookAndFeel). + // both textboxes and list elements (i.e. trees and list) should always be focusable + // (textboxes are handled as html:input) + if (!mNodeInfo->Equals(nsXULAtoms::tree) && !mNodeInfo->Equals(nsXULAtoms::listbox)) + tabIndex = -1; + } } if (aTabIndex) { diff --git a/mozilla/modules/libpref/src/init/all.js b/mozilla/modules/libpref/src/init/all.js index 93df2479ddb..299bb8bbc07 100644 --- a/mozilla/modules/libpref/src/init/all.js +++ b/mozilla/modules/libpref/src/init/all.js @@ -107,6 +107,10 @@ pref("accessibility.warn_on_browsewithcaret", true); // On OS X, we use Full Keyboard Access system preference, // unless accessibility.tabfocus is set by the user. pref("accessibility.tabfocus", 7); +pref("accessibility.tabfocus_applies_to_xul", false); +#else +// Only on mac tabfocus is expected to handle UI widgets as well as web content +pref("accessibility.tabfocus_applies_to_xul", true); #endif pref("accessibility.usetexttospeech", "");