зеркало из https://github.com/mozilla/pjs.git
Fix for bug 370790 - implement IAccessibleAction, r=aaronlev, ginn.chen
This commit is contained in:
Родитель
69f700eee8
Коммит
1d27f5bb84
|
@ -57,7 +57,7 @@ interface nsIDOMDOMStringList;
|
|||
*
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
[scriptable, uuid(79fa0a81-5acb-4549-94bd-5ad179616a59)]
|
||||
[scriptable, uuid(6ff04a18-a66c-4e50-9099-8e46eca181f6)]
|
||||
interface nsIAccessible : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -132,9 +132,11 @@ interface nsIAccessible : nsISupports
|
|||
|
||||
/**
|
||||
* Provides array of localized string of global keyboard accelerator for
|
||||
* all actions supported by accessible.
|
||||
* the given action index supported by accessible.
|
||||
*
|
||||
* @param aActionIndex - index of the given action
|
||||
*/
|
||||
readonly attribute nsIDOMDOMStringList keyBindings;
|
||||
nsIDOMDOMStringList getKeyBindings(in PRUint8 aActionIndex);
|
||||
|
||||
/**
|
||||
* Natural enumerated accessible role for the associated element.
|
||||
|
|
|
@ -164,7 +164,7 @@ getKeyBindingCB(AtkAction *aAction, gint aActionIndex)
|
|||
//get shortcut
|
||||
nsAutoString subShortcut;
|
||||
nsCOMPtr<nsIDOMDOMStringList> keyBindings;
|
||||
rv = accWrap->GetKeyBindings(getter_AddRefs(keyBindings));
|
||||
rv = accWrap->GetKeyBindings(aActionIndex, getter_AddRefs(keyBindings));
|
||||
|
||||
if (NS_SUCCEEDED(rv) && keyBindings) {
|
||||
PRUint32 length = 0;
|
||||
|
|
|
@ -2271,12 +2271,15 @@ nsAccessible::GetDefaultKeyBinding(nsAString& aKeyBinding)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessible::GetKeyBindings(nsIDOMDOMStringList **aKeyBindings)
|
||||
nsAccessible::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);
|
||||
|
||||
// Currently we support only unique key binding on element.
|
||||
nsAutoString defaultKey;
|
||||
nsresult rv = GetDefaultKeyBinding(defaultKey);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -40,6 +40,10 @@
|
|||
#include "nsAccessibilityAtoms.h"
|
||||
#include "nsIAccessibleSelectable.h"
|
||||
#include "nsIAccessibleWin32Object.h"
|
||||
|
||||
#include "Accessible2_i.c"
|
||||
#include "AccessibleAction_i.c"
|
||||
|
||||
#include "nsIMutableArray.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIFrame.h"
|
||||
|
@ -110,10 +114,12 @@ STDMETHODIMP nsAccessibleWrap::QueryInterface(REFIID iid, void** ppv)
|
|||
get_accChildCount(&numChildren);
|
||||
if (numChildren > 0) // Don't support this interface for leaf elements
|
||||
*ppv = NS_STATIC_CAST(IEnumVARIANT*, this);
|
||||
}
|
||||
else if (IID_IServiceProvider == iid) {
|
||||
} else if (IID_IServiceProvider == iid)
|
||||
*ppv = NS_STATIC_CAST(IServiceProvider*, this);
|
||||
}
|
||||
else if (IID_IAccessible2 == iid)
|
||||
*ppv = NS_STATIC_CAST(IAccessible2*, this);
|
||||
else if (IID_IAccessibleAction == iid)
|
||||
*ppv = NS_STATIC_CAST(IAccessibleAction*, this);
|
||||
|
||||
if (NULL == *ppv)
|
||||
return nsAccessNodeWrap::QueryInterface(iid, ppv);
|
||||
|
@ -1249,6 +1255,102 @@ nsAccessibleWrap::get_attributes(BSTR *attributes)
|
|||
}
|
||||
|
||||
|
||||
// IAccessibleAction
|
||||
|
||||
STDMETHODIMP
|
||||
nsAccessibleWrap::nActions(long *aNumActions)
|
||||
{
|
||||
PRUint8 count = 0;
|
||||
nsresult rv = GetNumActions(&count);
|
||||
*aNumActions = count;
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return NS_OK;
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
nsAccessibleWrap::doAction(long aActionIndex)
|
||||
{
|
||||
PRUint8 index = NS_STATIC_CAST(PRUint8, aActionIndex);
|
||||
if (NS_SUCCEEDED(DoAction(index)))
|
||||
return S_OK;
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
nsAccessibleWrap::get_description(long aActionIndex, BSTR *aDescription)
|
||||
{
|
||||
*aDescription = NULL;
|
||||
|
||||
nsAutoString description;
|
||||
PRUint8 index = NS_STATIC_CAST(PRUint8, aActionIndex);
|
||||
if (NS_FAILED(GetActionDescription(index, description)))
|
||||
return E_FAIL;
|
||||
|
||||
if (!description.IsVoid())
|
||||
*aDescription = ::SysAllocString(description.get());
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
nsAccessibleWrap::get_keyBinding(long aActionIndex, long aNumMaxBinding,
|
||||
BSTR **aKeyBinding,
|
||||
long *aNumBinding)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDOMStringList> keys;
|
||||
PRUint8 index = NS_STATIC_CAST(PRUint8, aActionIndex);
|
||||
nsresult rv = GetKeyBindings(index, getter_AddRefs(keys));
|
||||
if (NS_FAILED(rv))
|
||||
return E_FAIL;
|
||||
|
||||
PRUint32 length = 0;
|
||||
keys->GetLength(&length);
|
||||
|
||||
PRBool aUseNumMaxBinding = length > NS_STATIC_CAST(PRUint32, aNumMaxBinding);
|
||||
|
||||
PRUint32 maxBinding = NS_STATIC_CAST(PRUint32, aNumMaxBinding);
|
||||
|
||||
PRUint32 numBinding = length > maxBinding ? maxBinding : length;
|
||||
*aNumBinding = numBinding;
|
||||
|
||||
*aKeyBinding = new BSTR[numBinding];
|
||||
if (!*aKeyBinding)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
for (PRUint32 i = 0; i < numBinding; i++) {
|
||||
nsAutoString key;
|
||||
keys->Item(i, key);
|
||||
*aKeyBinding[i] = ::SysAllocString(key.get());
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
nsAccessibleWrap::get_name(long aActionIndex, BSTR *aName)
|
||||
{
|
||||
*aName = NULL;
|
||||
|
||||
nsAutoString name;
|
||||
PRUint8 index = NS_STATIC_CAST(PRUint8, aActionIndex);
|
||||
if (NS_FAILED(GetActionName(index, name)))
|
||||
return E_FAIL;
|
||||
|
||||
if (!name.IsVoid())
|
||||
*aName = ::SysAllocString(name.get());
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
nsAccessibleWrap::get_localizedName(long aActionIndex, BSTR *aLocalizedName)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP
|
||||
nsAccessibleWrap::Clone(IEnumVARIANT FAR* FAR* ppenum)
|
||||
{
|
||||
|
|
|
@ -46,9 +46,11 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsAccessible.h"
|
||||
#include "Accessible2.h"
|
||||
#include "AccessibleAction.h"
|
||||
|
||||
class nsAccessibleWrap : public nsAccessible,
|
||||
public IAccessible2,
|
||||
public IAccessibleAction,
|
||||
public IEnumVARIANT,
|
||||
public IServiceProvider
|
||||
{
|
||||
|
@ -222,6 +224,31 @@ class nsAccessibleWrap : public nsAccessible,
|
|||
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_attributes(
|
||||
/* [retval][out] */ BSTR *attributes);
|
||||
|
||||
public: // IAccessibleAction
|
||||
virtual HRESULT STDMETHODCALLTYPE nActions(
|
||||
/* [retval][out] */ long *nActions);
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE doAction(
|
||||
/* [in] */ long actionIndex);
|
||||
|
||||
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_description(
|
||||
/* [in] */ long actionIndex,
|
||||
/* [retval][out] */ BSTR *description);
|
||||
|
||||
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_keyBinding(
|
||||
/* [in] */ long actionIndex,
|
||||
/* [in] */ long nMaxBinding,
|
||||
/* [length_is][length_is][size_is][size_is][out] */ BSTR **keyBinding,
|
||||
/* [retval][out] */ long *nBinding);
|
||||
|
||||
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_name(
|
||||
/* [in] */ long actionIndex,
|
||||
/* [retval][out] */ BSTR *name);
|
||||
|
||||
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_localizedName(
|
||||
/* [in] */ long actionIndex,
|
||||
/* [retval][out] */ BSTR *localizedName);
|
||||
|
||||
public: // IEnumVariantMethods
|
||||
virtual /* [local] */ HRESULT STDMETHODCALLTYPE Next(
|
||||
/* [in] */ ULONG celt,
|
||||
|
|
Загрузка…
Ссылка в новой задаче