Bug 672514 - Smooth out nsIAccessible keyboard shortcuts methods, r=surkov

This commit is contained in:
Oussama BADR 2012-06-09 18:49:21 +09:00
Родитель 4fd9707a31
Коммит e9b0a16f39
4 изменённых файлов: 13 добавлений и 42 удалений

Просмотреть файл

@ -23,7 +23,7 @@ interface nsIAccessibleRelation;
* Mozilla creates the implementations of nsIAccessible on demand.
* See http://www.mozilla.org/projects/ui/accessibility for more information.
*/
[scriptable, uuid(45ce2c92-4d92-49d2-bff1-855934443261)]
[scriptable, uuid(45600c50-b06a-11e1-afa6-0800200c9a66)]
interface nsIAccessible : nsISupports
{
/**
@ -115,21 +115,13 @@ interface nsIAccessible : nsISupports
* The modifier may be affected by user and platform preferences.
* Usually alt+letter, or just the letter alone for menu items.
*/
readonly attribute AString keyboardShortcut;
readonly attribute AString accessKey;
/**
* Provides localized string of global keyboard accelerator for default
* action, such as Ctrl+O for Open file
*/
readonly attribute AString defaultKeyBinding;
/**
* Provides array of localized string of global keyboard accelerator for
* the given action index supported by accessible.
*
* @param aActionIndex - index of the given action
*/
nsIDOMDOMStringList getKeyBindings(in PRUint8 aActionIndex);
readonly attribute AString keyboardShortcut;
/**
* Enumerated accessible role (see the constants defined in nsIAccessibleRole).

Просмотреть файл

@ -345,7 +345,7 @@ Accessible::Description(nsString& aDescription)
}
NS_IMETHODIMP
Accessible::GetKeyboardShortcut(nsAString& aAccessKey)
Accessible::GetAccessKey(nsAString& aAccessKey)
{
aAccessKey.Truncate();
@ -1753,7 +1753,7 @@ Accessible::SetName(const nsAString& aName)
}
NS_IMETHODIMP
Accessible::GetDefaultKeyBinding(nsAString& aKeyBinding)
Accessible::GetKeyboardShortcut(nsAString& aKeyBinding)
{
aKeyBinding.Truncate();
if (IsDefunct())
@ -1763,27 +1763,6 @@ Accessible::GetDefaultKeyBinding(nsAString& aKeyBinding)
return NS_OK;
}
NS_IMETHODIMP
Accessible::GetKeyBindings(PRUint8 aActionIndex,
nsIDOMDOMStringList** aKeyBindings)
{
// Currently we support only unique key binding on element for default action.
NS_ENSURE_TRUE(aActionIndex == 0, NS_ERROR_INVALID_ARG);
nsAccessibleDOMStringList* keyBindings = new nsAccessibleDOMStringList();
NS_ENSURE_TRUE(keyBindings, NS_ERROR_OUT_OF_MEMORY);
nsAutoString defaultKey;
nsresult rv = GetDefaultKeyBinding(defaultKey);
NS_ENSURE_SUCCESS(rv, rv);
if (!defaultKey.IsEmpty())
keyBindings->Add(defaultKey);
NS_ADDREF(*aKeyBindings = keyBindings);
return NS_OK;
}
role
Accessible::ARIATransformRole(role aRole)
{

Просмотреть файл

@ -13,21 +13,21 @@
src="../common.js"></script>
<script type="application/javascript">
function testKeyboardShortcut(aAccOrElmOrID, aKey)
function testAcessKey(aAccOrElmOrID, aKey)
{
var acc = getAccessible(aAccOrElmOrID);
if (!acc)
return;
is(acc.keyboardShortcut, aKey,
is(acc.accessKey, aKey,
"Wrong keyboard shortcut on " + prettyName(aAccOrElmOrID));
}
function doTest()
{
testKeyboardShortcut("input1", "");
testKeyboardShortcut("input2", MAC ? "⌃⌥b" : "Alt+Shift+b");
testKeyboardShortcut("link", MAC ? "⌃⌥l" : "Alt+Shift+l");
testAcessKey("input1", "");
testAcessKey("input2", MAC ? "⌃⌥b" : "Alt+Shift+b");
testAcessKey("link", MAC ? "⌃⌥l" : "Alt+Shift+l");
SimpleTest.finish();
}

Просмотреть файл

@ -34,13 +34,13 @@
this.finalCheck = function openMenu_finalCheck()
{
var menu = getAccessible(aMenuID);
is(menu.keyboardShortcut, (MAC ? "u" : "Alt+u"),
is(menu.accessKey, (MAC ? "u" : "Alt+u"),
"Wrong accesskey on " + prettyName(this.menuitemNode));
var menuitem = getAccessible(aMenuitemID);
is(menuitem.keyboardShortcut, "p",
is(menuitem.accessKey, "p",
"Wrong accesskey on " + prettyName(this.menuitemNode));
is(menuitem.defaultKeyBinding, (MAC ? "⌃l" : "Ctrl+l"),
is(menuitem.keyboardShortcut, (MAC ? "⌃l" : "Ctrl+l"),
"Wrong keyboard shortcut on " + prettyName(this.menuitemNode));
}