diff --git a/accessible/src/xul/nsXULTreeAccessible.cpp b/accessible/src/xul/nsXULTreeAccessible.cpp index 7aca06bfabd..374df10309f 100644 --- a/accessible/src/xul/nsXULTreeAccessible.cpp +++ b/accessible/src/xul/nsXULTreeAccessible.cpp @@ -62,9 +62,6 @@ NS_IMPL_ISUPPORTS_INHERITED0(nsXULTreeAccessible, nsXULSelectableAccessible) NS_IMETHODIMP nsXULTreeAccessible::GetAccState(PRUint32 *_retval) { - // Get focus status from base class - nsAccessible::GetAccState(_retval); - // see if we are multiple select if so set ourselves as such nsCOMPtr element (do_QueryInterface(mDOMNode)); if (element) { @@ -75,7 +72,7 @@ NS_IMETHODIMP nsXULTreeAccessible::GetAccState(PRUint32 *_retval) *_retval |= STATE_MULTISELECTABLE; } - *_retval |= STATE_READONLY | STATE_FOCUSABLE; + *_retval |= STATE_READONLY; return NS_OK; } @@ -414,7 +411,7 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetAccState(PRUint32 *_retval) { NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE); - *_retval = STATE_FOCUSABLE; + *_retval = STATE_FOCUSABLE | STATE_SELECTABLE; // get expanded/collapsed state PRBool isContainer, isContainerOpen; @@ -597,6 +594,51 @@ NS_IMETHODIMP nsXULTreeitemAccessible::AccGetBounds(PRInt32 *x, PRInt32 *y, PRIn return NS_OK; } +NS_IMETHODIMP nsXULTreeitemAccessible::AccRemoveSelection() +{ + NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE); + + nsCOMPtr selection; + mTree->GetSelection(getter_AddRefs(selection)); + if (selection) { + PRBool isSelected; + selection->IsSelected(mRow, &isSelected); + if (isSelected) + selection->ToggleSelect(mRow); + } + + return NS_OK; +} + +NS_IMETHODIMP nsXULTreeitemAccessible::AccTakeSelection() +{ + NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE); + + nsCOMPtr selection; + mTree->GetSelection(getter_AddRefs(selection)); + if (selection) { + PRBool isSelected; + selection->IsSelected(mRow, &isSelected); + if (! isSelected) + selection->ToggleSelect(mRow); + } + + return NS_OK; +} + +NS_IMETHODIMP nsXULTreeitemAccessible::AccTakeFocus() +{ + NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE); + + nsCOMPtr selection; + mTree->GetSelection(getter_AddRefs(selection)); + if (selection) + selection->SetCurrentIndex(mRow); + + // focus event will be fired here + return nsAccessible::AccTakeFocus(); +} + // ---------- nsXULTreeColumnsAccessible ---------- nsXULTreeColumnsAccessible::nsXULTreeColumnsAccessible(nsIDOMNode *aDOMNode, nsIWeakReference *aShell): diff --git a/accessible/src/xul/nsXULTreeAccessible.h b/accessible/src/xul/nsXULTreeAccessible.h index e04b3cabe99..deece0bc815 100644 --- a/accessible/src/xul/nsXULTreeAccessible.h +++ b/accessible/src/xul/nsXULTreeAccessible.h @@ -104,6 +104,9 @@ public: NS_IMETHOD AccDoAction(PRUint8 index); NS_IMETHOD AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height); + NS_IMETHOD AccRemoveSelection(void); + NS_IMETHOD AccTakeSelection(void); + NS_IMETHOD AccTakeFocus(void); private: nsCOMPtr mTree;