Bug 277516 - Add a hidden pref to follow accessibility.tabfocus for xul elements; default to true on mac, false everywhere else. r=aaronlev sr=bzbarksky

git-svn-id: svn://10.0.0.236/trunk@168512 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mozilla.mano%sent.com
2005-01-29 23:47:35 +00:00
parent 5467609b38
commit 3ffad7b2f3
5 changed files with 28 additions and 0 deletions

View File

@@ -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;

View File

@@ -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)

View File

@@ -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",

View File

@@ -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) {

View File

@@ -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", "");