diff --git a/accessible/src/xul/nsXULSelectAccessible.cpp b/accessible/src/xul/nsXULSelectAccessible.cpp index 153e906283f..60303bc3432 100644 --- a/accessible/src/xul/nsXULSelectAccessible.cpp +++ b/accessible/src/xul/nsXULSelectAccessible.cpp @@ -86,38 +86,35 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsXULSelectableAccessible, nsAccessible, nsIAccessi NS_IMETHODIMP nsXULSelectableAccessible::ChangeSelection(PRInt32 aIndex, PRUint8 aMethod, PRBool *aSelState) { + nsCOMPtr childAcc; + GetChildAt(aIndex, getter_AddRefs(childAcc)); + nsCOMPtr accNode = do_QueryInterface(childAcc); + NS_ENSURE_TRUE(accNode, NS_ERROR_FAILURE); + + nsCOMPtr childNode; + accNode->GetDOMNode(getter_AddRefs(childNode)); + nsCOMPtr item(do_QueryInterface(childNode)); + NS_ENSURE_TRUE(item, NS_ERROR_FAILURE); + *aSelState = PR_FALSE; - nsCOMPtr xulMultiSelect(do_QueryInterface(mDOMNode)); - if (xulMultiSelect) { - nsCOMPtr nodeList; - xulMultiSelect->GetChildNodes(getter_AddRefs(nodeList)); - if (nodeList) { - nsCOMPtr node; - nodeList->Item(aIndex, getter_AddRefs(node)); - nsCOMPtr item(do_QueryInterface(node)); - item->GetSelected(aSelState); - if (eSelection_Add == aMethod && !(*aSelState)) - xulMultiSelect->AddItemToSelection(item); - else if (eSelection_Remove == aMethod && (*aSelState)) - xulMultiSelect->RemoveItemFromSelection(item); - } - return NS_OK; - } - nsCOMPtr xulSelect(do_QueryInterface(mDOMNode)); - if (xulSelect) { - nsresult rv = NS_OK; - PRInt32 selIndex; - xulSelect->GetSelectedIndex(&selIndex); - if (selIndex == aIndex) - *aSelState = PR_TRUE; - if (eSelection_Add == aMethod && !(*aSelState)) - rv = xulSelect->SetSelectedIndex(aIndex); - else if (eSelection_Remove == aMethod && (*aSelState)) { - rv = xulSelect->SetSelectedIndex(-1); - } - return rv; + nsCOMPtr xulMultiSelect(do_QueryInterface(mDOMNode)); + + if (xulSelect || xulMultiSelect) { + item->GetSelected(aSelState); + if (eSelection_Add == aMethod && !(*aSelState)) { + if (xulMultiSelect) + return xulMultiSelect->AddItemToSelection(item); + else if (xulSelect) + return xulSelect->SetSelectedItem(item); + } + else if (eSelection_Remove == aMethod && (*aSelState)) { + if (xulMultiSelect) + return xulMultiSelect->RemoveItemFromSelection(item); + else if (xulSelect) + return xulSelect->SetSelectedIndex(-1); + } } return NS_ERROR_FAILURE; diff --git a/accessible/src/xul/nsXULTabAccessible.cpp b/accessible/src/xul/nsXULTabAccessible.cpp index d624f824ace..f239a352001 100644 --- a/accessible/src/xul/nsXULTabAccessible.cpp +++ b/accessible/src/xul/nsXULTabAccessible.cpp @@ -127,6 +127,15 @@ NS_IMETHODIMP nsXULTabAccessible::GetState(PRUint32 *_retval) *_retval |= STATE_FOCUSABLE; } } + // Check whether the tab is selected + *_retval |= STATE_SELECTABLE; + *_retval &= ~STATE_SELECTED; + nsCOMPtr tab(do_QueryInterface(mDOMNode)); + if (tab) { + PRBool selected = PR_FALSE; + if (NS_SUCCEEDED(tab->GetSelected(&selected)) && selected) + *_retval |= STATE_SELECTED; + } return NS_OK; } @@ -222,7 +231,7 @@ NS_IMETHODIMP nsXULTabPanelsAccessible::GetName(nsAString& _retval) /** Constructor */ nsXULTabsAccessible::nsXULTabsAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell): -nsAccessibleWrap(aNode, aShell) +nsXULSelectableAccessible(aNode, aShell) { } diff --git a/accessible/src/xul/nsXULTabAccessible.h b/accessible/src/xul/nsXULTabAccessible.h index 96327688d27..d79152039ca 100644 --- a/accessible/src/xul/nsXULTabAccessible.h +++ b/accessible/src/xul/nsXULTabAccessible.h @@ -41,6 +41,7 @@ // NOTE: alphabetically ordered #include "nsBaseWidgetAccessible.h" +#include "nsXULSelectAccessible.h" /** An individual tab */ class nsXULTabAccessible : public nsLeafAccessible @@ -90,7 +91,7 @@ protected: }; /** merely a container of tab obejcts */ -class nsXULTabsAccessible : public nsAccessibleWrap +class nsXULTabsAccessible : public nsXULSelectableAccessible { public: nsXULTabsAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);