Bug 282502. Tree items not returned in get_accFocus(). r=pkw, sr=jst

This commit is contained in:
aaronleventhal%moonset.net 2005-02-18 14:36:28 +00:00
Родитель 03a8934271
Коммит 06db8fa144
8 изменённых файлов: 65 добавлений и 57 удалений

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

@ -637,15 +637,26 @@ NS_IMETHODIMP nsAccessible::GetState(PRUint32 *aState)
/* readonly attribute boolean focusedChild; */ /* readonly attribute boolean focusedChild; */
NS_IMETHODIMP nsAccessible::GetFocusedChild(nsIAccessible **aFocusedChild) NS_IMETHODIMP nsAccessible::GetFocusedChild(nsIAccessible **aFocusedChild)
{ {
*aFocusedChild = nsnull; nsCOMPtr<nsIAccessible> focusedChild;
if (gLastFocusedNode == mDOMNode) {
if (!gLastFocusedNode) { NS_ADDREF(*aFocusedChild = this);
return NS_ERROR_FAILURE; }
else if (gLastFocusedNode) {
nsCOMPtr<nsIAccessibilityService> accService =
do_GetService("@mozilla.org/accessibilityService;1");
accService->GetAccessibleInWeakShell(gLastFocusedNode, mWeakShell,
getter_AddRefs(focusedChild));
if (focusedChild) {
nsCOMPtr<nsIAccessible> focusedParentAccessible;
focusedChild->GetParent(getter_AddRefs(focusedParentAccessible));
if (focusedParentAccessible != this) {
focusedChild = nsnull;
}
}
} }
nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1")); NS_IF_ADDREF(*aFocusedChild = focusedChild);
return accService->GetAccessibleInWeakShell(gLastFocusedNode, mWeakShell, return NS_OK;
aFocusedChild);
} }
/* nsIAccessible getChildAtPoint (in long x, in long y); */ /* nsIAccessible getChildAtPoint (in long x, in long y); */
@ -1342,7 +1353,7 @@ nsRoleMapEntry nsAccessible::gWAIRoleMap[] =
{"checkbox-tristate", ROLE_CHECKBUTTON, eAggregateSubtree, 0, {"checked", "true", STATE_CHECKED}, {"checked", "mixed", STATE_MIXED}, {"readonly", 0, STATE_READONLY}}, {"checkbox-tristate", ROLE_CHECKBUTTON, eAggregateSubtree, 0, {"checked", "true", STATE_CHECKED}, {"checked", "mixed", STATE_MIXED}, {"readonly", 0, STATE_READONLY}},
{"columnheader", ROLE_COLUMNHEADER, eAggregateSubtree, STATE_SELECTABLE, {"selected", 0, STATE_SELECTED}, {0, 0, 0}, {0, 0, 0}}, {"columnheader", ROLE_COLUMNHEADER, eAggregateSubtree, STATE_SELECTABLE, {"selected", 0, STATE_SELECTED}, {0, 0, 0}, {0, 0, 0}},
{"icon", ROLE_ICON, eAggregateSubtree, 0, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, {"icon", ROLE_ICON, eAggregateSubtree, 0, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
{"menu", ROLE_MENUPOPUP, eTitleOnly, 0, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, {"menugroup", ROLE_MENUPOPUP, eTitleOnly, 0, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
{"menupopup", ROLE_MENUPOPUP, eTitleOnly, 0, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, {"menupopup", ROLE_MENUPOPUP, eTitleOnly, 0, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
{"menubar", ROLE_MENUBAR, eTitleOnly, 0, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, {"menubar", ROLE_MENUBAR, eTitleOnly, 0, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
{"menuitem", ROLE_MENUITEM, eAggregateSubtree, 0, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, {"menuitem", ROLE_MENUITEM, eAggregateSubtree, 0, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},

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

@ -180,6 +180,19 @@ NS_IMETHODIMP nsDocAccessible::GetState(PRUint32 *aState)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocAccessible::GetFocusedChild(nsIAccessible **aFocusedChild)
{
if (!gLastFocusedNode) {
*aFocusedChild = nsnull;
return NS_OK;
}
nsCOMPtr<nsIAccessibilityService> accService =
do_GetService("@mozilla.org/accessibilityService;1");
return accService->GetAccessibleInWeakShell(gLastFocusedNode, mWeakShell,
aFocusedChild);
}
// ------- nsIAccessibleDocument Methods (5) --------------- // ------- nsIAccessibleDocument Methods (5) ---------------
NS_IMETHODIMP nsDocAccessible::GetURL(nsAString& aURL) NS_IMETHODIMP nsDocAccessible::GetURL(nsAString& aURL)
@ -530,17 +543,6 @@ nsresult nsDocAccessible::AddEventListeners()
mIsNewDocument = PR_TRUE; mIsNewDocument = PR_TRUE;
mBusy = eBusyStateLoading; mBusy = eBusyStateLoading;
if (!isLoading) {
// If already loaded, fire "done loading" event after short timeout
// If we fired the event here, we'd get reentrancy problems
// Otherwise, if the doc is still loading,
// the event will be fired from OnStateChange when the load is done
mDocLoadTimer = do_CreateInstance("@mozilla.org/timer;1");
if (mDocLoadTimer) {
mDocLoadTimer->InitWithFuncCallback(DocLoadCallback, this, 1,
nsITimer::TYPE_ONE_SHOT);
}
}
// add ourself as a mutation event listener // add ourself as a mutation event listener
// (this slows down mozilla about 3%, but only used when accessibility APIs active) // (this slows down mozilla about 3%, but only used when accessibility APIs active)
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(mDocument)); nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(mDocument));

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

@ -80,6 +80,7 @@ class nsDocAccessible : public nsBlockAccessible,
NS_IMETHOD GetName(nsAString& aName); NS_IMETHOD GetName(nsAString& aName);
NS_IMETHOD GetValue(nsAString& aValue); NS_IMETHOD GetValue(nsAString& aValue);
NS_IMETHOD GetState(PRUint32 *aState); NS_IMETHOD GetState(PRUint32 *aState);
NS_IMETHOD GetFocusedChild(nsIAccessible **aFocusedChild);
// ----- nsIScrollPositionListener --------------------------- // ----- nsIScrollPositionListener ---------------------------
NS_IMETHOD ScrollPositionWillChange(nsIScrollableView *aView, nscoord aX, nscoord aY); NS_IMETHOD ScrollPositionWillChange(nsIScrollableView *aView, nscoord aX, nscoord aY);

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

@ -397,22 +397,20 @@ STDMETHODIMP nsAccessibleWrap::get_accFocus(
} }
VariantInit(pvarChild); VariantInit(pvarChild);
if (mDOMNode == gLastFocusedNode) {
pvarChild->vt = VT_I4;
pvarChild->lVal = CHILDID_SELF;
return S_OK;
}
// Return the current IAccessible child that has focus // Return the current IAccessible child that has focus
pvarChild->vt = VT_EMPTY; // Fallback when focus isn't a child of this
nsCOMPtr<nsIAccessible> focusedAccessible; nsCOMPtr<nsIAccessible> focusedAccessible;
if (NS_SUCCEEDED(GetFocusedChild(getter_AddRefs(focusedAccessible)))) { GetFocusedChild(getter_AddRefs(focusedAccessible));
nsCOMPtr<nsIAccessible> parentAccessible; if (focusedAccessible == this) {
focusedAccessible->GetParent(getter_AddRefs(parentAccessible)); pvarChild->vt = VT_I4;
if (parentAccessible == this) { pvarChild->lVal = CHILDID_SELF;
pvarChild->vt = VT_DISPATCH; }
pvarChild->pdispVal = NativeAccessible(focusedAccessible); else if (focusedAccessible) {
} pvarChild->vt = VT_DISPATCH;
pvarChild->pdispVal = NativeAccessible(focusedAccessible);
}
else {
pvarChild->vt = VT_EMPTY; // No focus or focus is not a child
} }
return S_OK; return S_OK;

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

@ -161,27 +161,6 @@ STDMETHODIMP nsDocAccessibleWrap::get_accChild(
return nsAccessibleWrap::get_accChild(varChild, ppdispChild); return nsAccessibleWrap::get_accChild(varChild, ppdispChild);
} }
STDMETHODIMP nsDocAccessibleWrap::get_accFocus(
/* [retval][out] */ VARIANT __RPC_FAR *pvarChild)
{
// Return the current IAccessible child that has focus
VariantInit(pvarChild);
pvarChild->vt = VT_EMPTY;
nsCOMPtr<nsIAccessible> accessible;
if (NS_SUCCEEDED(GetFocusedChild(getter_AddRefs(accessible)))) {
if (accessible == (nsIAccessible*)this) {
pvarChild->vt = VT_I4;
pvarChild->lVal = CHILDID_SELF;
}
else {
pvarChild->vt = VT_DISPATCH;
pvarChild->pdispVal = NativeAccessible(accessible);
}
}
return S_OK;
}
STDMETHODIMP nsDocAccessibleWrap::get_accParent( IDispatch __RPC_FAR *__RPC_FAR *ppdispParent) STDMETHODIMP nsDocAccessibleWrap::get_accParent( IDispatch __RPC_FAR *__RPC_FAR *ppdispParent)
{ {
// MSAA expects that client area accessibles return the native accessible for // MSAA expects that client area accessibles return the native accessible for

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

@ -88,9 +88,6 @@ public:
/* [in] */ VARIANT varChild, /* [in] */ VARIANT varChild,
/* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *ppdispChild); /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *ppdispChild);
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accFocus(
/* [retval][out] */ VARIANT __RPC_FAR *pvarChild);
// Override get_accParent so that native accessible for window is // Override get_accParent so that native accessible for window is
// returned as parent, otherwise WindowFromAccessibleObject() doesn't work. // returned as parent, otherwise WindowFromAccessibleObject() doesn't work.
// Also necessary for MSAA SDK's accexplore.exe testing tool to work. // Also necessary for MSAA SDK's accexplore.exe testing tool to work.

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

@ -222,6 +222,24 @@ NS_IMETHODIMP nsXULTreeAccessible::GetChildCount(PRInt32 *aAccChildCount)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsXULTreeAccessible::GetFocusedChild(nsIAccessible **aFocusedChild)
{
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelect =
do_QueryInterface(mDOMNode);
if (multiSelect) {
PRInt32 row;
multiSelect->GetCurrentIndex(&row);
if (row >= 0) {
GetCachedTreeitemAccessible(row, nsnull, aFocusedChild);
if (*aFocusedChild) {
return NS_OK; // Already addref'd by getter
}
}
}
NS_ADDREF(*aFocusedChild = this);
return NS_OK;
}
// Ask treeselection to get all selected children // Ask treeselection to get all selected children
NS_IMETHODIMP nsXULTreeAccessible::GetSelectedChildren(nsIArray **_retval) NS_IMETHODIMP nsXULTreeAccessible::GetSelectedChildren(nsIArray **_retval)
{ {
@ -374,8 +392,9 @@ NS_IMETHODIMP nsXULTreeAccessible::SelectAllSelection(PRBool *_retval)
NS_IMETHODIMP nsXULTreeAccessible::GetCachedTreeitemAccessible(PRInt32 aRow, nsITreeColumn* aColumn, nsIAccessible** aAccessible) NS_IMETHODIMP nsXULTreeAccessible::GetCachedTreeitemAccessible(PRInt32 aRow, nsITreeColumn* aColumn, nsIAccessible** aAccessible)
{ {
NS_ASSERTION(mAccessNodeCache, "No accessibility cache for tree"); *aAccessible = nsnull;
NS_ASSERTION(mAccessNodeCache, "No accessibility cache for tree");
NS_ASSERTION(mTree && mTreeView, "Can't get mTree or mTreeView!\n"); NS_ASSERTION(mTree && mTreeView, "Can't get mTree or mTreeView!\n");
nsCOMPtr<nsITreeColumn> col = aColumn; nsCOMPtr<nsITreeColumn> col = aColumn;

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

@ -71,6 +71,7 @@ public:
NS_IMETHOD GetFirstChild(nsIAccessible **_retval); NS_IMETHOD GetFirstChild(nsIAccessible **_retval);
NS_IMETHOD GetLastChild(nsIAccessible **_retval); NS_IMETHOD GetLastChild(nsIAccessible **_retval);
NS_IMETHOD GetChildCount(PRInt32 *_retval); NS_IMETHOD GetChildCount(PRInt32 *_retval);
NS_IMETHOD GetFocusedChild(nsIAccessible **aFocusedChild);
static void GetTreeBoxObject(nsIDOMNode* aDOMNode, nsITreeBoxObject** aBoxObject); static void GetTreeBoxObject(nsIDOMNode* aDOMNode, nsITreeBoxObject** aBoxObject);
static nsresult GetColumnCount(nsITreeBoxObject* aBoxObject, PRInt32 *aCount); static nsresult GetColumnCount(nsITreeBoxObject* aBoxObject, PRInt32 *aCount);