From a5449b88191b5a554ce7bfff0cd6d3c1d10ed4f6 Mon Sep 17 00:00:00 2001 From: "aaronleventhal@moonset.net" Date: Thu, 15 Nov 2007 11:53:40 -0800 Subject: [PATCH] Bug 403794. GetState() cleanup to fix some crashes on defunct objects and some incorrect states, and remove some code that is no longer necessary. r=surkov, a=dsicore --- accessible/src/base/nsAccessible.cpp | 12 ++--- .../src/base/nsBaseWidgetAccessible.cpp | 2 + accessible/src/base/nsDocAccessible.cpp | 2 + accessible/src/base/nsRootAccessible.cpp | 2 + accessible/src/html/nsHTMLImageAccessible.cpp | 2 + accessible/src/html/nsHTMLLinkAccessible.cpp | 2 + .../src/html/nsHTMLSelectAccessible.cpp | 14 ++++-- accessible/src/html/nsHTMLTableAccessible.cpp | 15 ------- accessible/src/html/nsHTMLTableAccessible.h | 1 - accessible/src/html/nsHTMLTextAccessible.cpp | 22 ++++----- accessible/src/html/nsHTMLTextAccessible.h | 1 - accessible/src/html/nsHyperTextAccessible.cpp | 3 +- accessible/src/xforms/nsXFormsAccessible.cpp | 11 ++++- .../xforms/nsXFormsFormControlsAccessible.cpp | 17 ++++++- .../src/xforms/nsXFormsWidgetsAccessible.cpp | 10 ++++- accessible/src/xul/nsXULAlertAccessible.cpp | 6 +-- .../src/xul/nsXULColorPickerAccessible.cpp | 4 ++ .../src/xul/nsXULFormControlAccessible.cpp | 45 ++++++++----------- .../src/xul/nsXULFormControlAccessible.h | 2 - accessible/src/xul/nsXULMenuAccessible.cpp | 12 +++++ accessible/src/xul/nsXULSelectAccessible.cpp | 31 +++++++++---- accessible/src/xul/nsXULTabAccessible.cpp | 21 ++------- accessible/src/xul/nsXULTabAccessible.h | 3 -- accessible/src/xul/nsXULTreeAccessible.cpp | 10 +++-- 24 files changed, 140 insertions(+), 110 deletions(-) diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index 7d4a7c1761e5..bf35cf609903 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -995,14 +995,16 @@ nsAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { *aState = 0; - if (aExtraState) - *aExtraState = 0; - - if (!mDOMNode && aExtraState) { - *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; + if (!mDOMNode) { + if (aExtraState) { + *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; + } return NS_OK; // Node shut down } + if (aExtraState) + *aExtraState = 0; + nsCOMPtr content(do_QueryInterface(mDOMNode)); if (!content) { return NS_OK; // On document, this is not an error diff --git a/accessible/src/base/nsBaseWidgetAccessible.cpp b/accessible/src/base/nsBaseWidgetAccessible.cpp index c54b243afc18..ccfbdb9ad8bd 100644 --- a/accessible/src/base/nsBaseWidgetAccessible.cpp +++ b/accessible/src/base/nsBaseWidgetAccessible.cpp @@ -121,6 +121,8 @@ nsLinkableAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsHyperTextAccessibleWrap::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; if (mIsLink) { *aState |= nsIAccessibleStates::STATE_LINKED; diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp index 5f1b0825c36e..6f4bf7e3de6a 100644 --- a/accessible/src/base/nsDocAccessible.cpp +++ b/accessible/src/base/nsDocAccessible.cpp @@ -235,6 +235,8 @@ nsDocAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { // nsAccessible::GetState() always fail for document accessible. nsAccessible::GetState(aState, aExtraState); + if (!mDOMNode) + return NS_OK; #ifdef MOZ_XUL nsCOMPtr xulDoc(do_QueryInterface(mDocument)); diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index 1b5554aa25f3..ceeb89a311ee 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -212,6 +212,8 @@ nsRootAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsDocAccessibleWrap::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; #ifdef MOZ_XUL PRUint32 chromeFlags = GetChromeFlags(); diff --git a/accessible/src/html/nsHTMLImageAccessible.cpp b/accessible/src/html/nsHTMLImageAccessible.cpp index 915cfb83d131..586e7e3df76c 100644 --- a/accessible/src/html/nsHTMLImageAccessible.cpp +++ b/accessible/src/html/nsHTMLImageAccessible.cpp @@ -94,6 +94,8 @@ nsHTMLImageAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) nsresult rv = nsLinkableAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; nsCOMPtr content(do_QueryInterface(mDOMNode)); nsCOMPtr imageRequest; diff --git a/accessible/src/html/nsHTMLLinkAccessible.cpp b/accessible/src/html/nsHTMLLinkAccessible.cpp index 5af8e7e7b816..b448a2be2c5c 100644 --- a/accessible/src/html/nsHTMLLinkAccessible.cpp +++ b/accessible/src/html/nsHTMLLinkAccessible.cpp @@ -70,6 +70,8 @@ nsHTMLLinkAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsLinkableAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; *aState &= ~nsIAccessibleStates::STATE_READONLY; diff --git a/accessible/src/html/nsHTMLSelectAccessible.cpp b/accessible/src/html/nsHTMLSelectAccessible.cpp index 5e895304e09d..68c2bfcd09aa 100644 --- a/accessible/src/html/nsHTMLSelectAccessible.cpp +++ b/accessible/src/html/nsHTMLSelectAccessible.cpp @@ -330,6 +330,8 @@ nsHTMLSelectListAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsHTMLSelectableAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; nsCOMPtr select (do_QueryInterface(mDOMNode)); if (select) { @@ -614,9 +616,9 @@ nsHTMLSelectOptionAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) // Upcall to nsAccessible, but skip nsHyperTextAccessible impl // because we don't want EXT_STATE_EDITABLE or EXT_STATE_SELECTABLE_TEXT nsresult rv = nsAccessible::GetState(aState, aExtraState); - if (NS_FAILED(rv)) { - return rv; - } + NS_ENSURE_TRUE(rv, rv); + if (!mDOMNode) + return NS_OK; PRUint32 selectState, selectExtState; nsCOMPtr selectContent = GetSelectState(&selectState, @@ -1075,6 +1077,8 @@ nsHTMLComboboxAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) // Get focus status from base class nsresult rv = nsAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; nsIFrame *frame = GetBoundsFrame(); nsIComboboxControlFrame *comboFrame = nsnull; @@ -1393,6 +1397,8 @@ nsHTMLComboboxButtonAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState // Get focus status from base class nsresult rv = nsAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; nsIFrame *boundsFrame = GetBoundsFrame(); nsIComboboxControlFrame* comboFrame = nsnull; @@ -1450,6 +1456,8 @@ nsHTMLComboboxListAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) // Get focus status from base class nsresult rv = nsAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; nsIFrame *boundsFrame = GetBoundsFrame(); nsIComboboxControlFrame* comboFrame = nsnull; diff --git a/accessible/src/html/nsHTMLTableAccessible.cpp b/accessible/src/html/nsHTMLTableAccessible.cpp index 571c88a90563..2f419347ad75 100644 --- a/accessible/src/html/nsHTMLTableAccessible.cpp +++ b/accessible/src/html/nsHTMLTableAccessible.cpp @@ -74,18 +74,6 @@ NS_IMETHODIMP nsHTMLTableCellAccessible::GetRole(PRUint32 *aResult) return NS_OK; } -NS_IMETHODIMP -nsHTMLTableCellAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) -{ - nsresult rv = nsAccessible::GetState(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - - // Inherit all states except focusable state since table cells cannot be - // focused. - *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE; - return NS_OK; -} - NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLTableAccessible, nsAccessible, nsIAccessibleTable) nsHTMLTableAccessible::nsHTMLTableAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell): @@ -146,10 +134,7 @@ nsHTMLTableAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv= nsAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); - *aState |= nsIAccessibleStates::STATE_READONLY; - // Inherit all states except focusable state since tables cannot be focused. - *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE; return NS_OK; } diff --git a/accessible/src/html/nsHTMLTableAccessible.h b/accessible/src/html/nsHTMLTableAccessible.h index c4eb65e324fe..a27668028df9 100644 --- a/accessible/src/html/nsHTMLTableAccessible.h +++ b/accessible/src/html/nsHTMLTableAccessible.h @@ -49,7 +49,6 @@ public: nsHTMLTableCellAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell); NS_IMETHOD GetRole(PRUint32 *aResult); - NS_IMETHOD GetState(PRUint32 *aState, PRUint32 *aExtraState); }; class nsITableLayout; diff --git a/accessible/src/html/nsHTMLTextAccessible.cpp b/accessible/src/html/nsHTMLTextAccessible.cpp index a29b8d7ad18e..adde6f1990ac 100644 --- a/accessible/src/html/nsHTMLTextAccessible.cpp +++ b/accessible/src/html/nsHTMLTextAccessible.cpp @@ -77,6 +77,8 @@ nsHTMLTextAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsTextAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; nsCOMPtr docAccessible = do_QueryInterface(nsCOMPtr(GetDocAccessible())); @@ -120,16 +122,6 @@ NS_IMETHODIMP nsHTMLHRAccessible::GetRole(PRUint32 *aRole) return NS_OK; } -NS_IMETHODIMP -nsHTMLHRAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) -{ - nsresult rv = nsLeafAccessible::GetState(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - - *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE; - return NS_OK; -} - nsHTMLBRAccessible::nsHTMLBRAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell): nsLeafAccessible(aDomNode, aShell) { @@ -145,6 +137,9 @@ NS_IMETHODIMP nsHTMLBRAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { *aState = nsIAccessibleStates::STATE_READONLY; + if (aExtraState) { + *aExtraState = mDOMNode ? 0 : nsIAccessibleStates::EXT_STATE_DEFUNCT; + } return NS_OK; } @@ -188,9 +183,10 @@ nsHTMLLabelAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsTextAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); - - *aState &= (nsIAccessibleStates::STATE_LINKED | - nsIAccessibleStates::STATE_TRAVERSED); // Only use link states + if (mDOMNode) { + *aState &= (nsIAccessibleStates::STATE_LINKED | + nsIAccessibleStates::STATE_TRAVERSED); // Only use link states + } return NS_OK; } diff --git a/accessible/src/html/nsHTMLTextAccessible.h b/accessible/src/html/nsHTMLTextAccessible.h index 6684e3d5baa3..f97f9a8bfc2f 100644 --- a/accessible/src/html/nsHTMLTextAccessible.h +++ b/accessible/src/html/nsHTMLTextAccessible.h @@ -63,7 +63,6 @@ class nsHTMLHRAccessible : public nsLeafAccessible public: nsHTMLHRAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell); NS_IMETHOD GetRole(PRUint32 *aRole); - NS_IMETHOD GetState(PRUint32 *aState, PRUint32 *aExtraState); }; class nsHTMLBRAccessible : public nsLeafAccessible diff --git a/accessible/src/html/nsHyperTextAccessible.cpp b/accessible/src/html/nsHyperTextAccessible.cpp index 04579a6e041e..960d653b391f 100644 --- a/accessible/src/html/nsHyperTextAccessible.cpp +++ b/accessible/src/html/nsHyperTextAccessible.cpp @@ -166,8 +166,7 @@ nsHyperTextAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsAccessibleWrap::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); - - if (!aExtraState) + if (!mDOMNode || !aExtraState) return NS_OK; nsCOMPtr editor; diff --git a/accessible/src/xforms/nsXFormsAccessible.cpp b/accessible/src/xforms/nsXFormsAccessible.cpp index c0a4c81ddcd8..c054e896dc0d 100755 --- a/accessible/src/xforms/nsXFormsAccessible.cpp +++ b/accessible/src/xforms/nsXFormsAccessible.cpp @@ -175,6 +175,14 @@ nsXFormsAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { NS_ENSURE_ARG_POINTER(aState); *aState = 0; + if (!mDOMNode) { + if (aExtraState) { + *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; + } + return NS_OK; + } + if (aExtraState) + *aExtraState = 0; NS_ENSURE_TRUE(sXFormsService, NS_ERROR_FAILURE); @@ -308,8 +316,7 @@ nsXFormsEditableAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) nsresult rv = nsXFormsAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); - - if (!aExtraState) + if (!mDOMNode || !aExtraState) return NS_OK; PRBool isReadonly = PR_FALSE; diff --git a/accessible/src/xforms/nsXFormsFormControlsAccessible.cpp b/accessible/src/xforms/nsXFormsFormControlsAccessible.cpp index c4fec6cc104b..6077de1699d1 100755 --- a/accessible/src/xforms/nsXFormsFormControlsAccessible.cpp +++ b/accessible/src/xforms/nsXFormsFormControlsAccessible.cpp @@ -211,6 +211,8 @@ nsXFormsInputBooleanAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState { nsresult rv = nsXFormsAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; nsAutoString value; rv = sXFormsService->GetValue(mDOMNode, value); @@ -297,6 +299,8 @@ nsXFormsSecretAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsXFormsInputAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; *aState |= nsIAccessibleStates::STATE_PROTECTED; return NS_OK; @@ -331,6 +335,8 @@ nsXFormsRangeAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsXFormsAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; PRUint32 isInRange = nsIXFormsUtilityService::STATE_NOT_A_RANGE; rv = sXFormsService->IsInRange(mDOMNode, &isInRange); @@ -412,6 +418,8 @@ nsXFormsSelectAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsXFormsContainerAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; PRUint32 isInRange = nsIXFormsUtilityService::STATE_NOT_A_RANGE; rv = sXFormsService->IsInRange(mDOMNode, &isInRange); @@ -503,6 +511,8 @@ nsXFormsItemCheckgroupAccessible::GetState(PRUint32 *aState, { nsresult rv = nsXFormsSelectableItemAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; if (IsItemSelected()) *aState |= nsIAccessibleStates::STATE_CHECKED; @@ -548,6 +558,8 @@ nsXFormsItemRadiogroupAccessible::GetState(PRUint32 *aState, { nsresult rv = nsXFormsSelectableItemAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; if (IsItemSelected()) *aState |= nsIAccessibleStates::STATE_CHECKED; @@ -589,6 +601,8 @@ nsXFormsSelectComboboxAccessible::GetState(PRUint32 *aState, { nsresult rv = nsXFormsSelectableAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; PRBool isOpen = PR_FALSE; rv = sXFormsService->IsDropmarkerOpen(mDOMNode, &isOpen); @@ -637,8 +651,7 @@ nsXFormsItemComboboxAccessible::GetState(PRUint32 *aState, { nsresult rv = nsXFormsSelectableItemAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); - - if (*aState & nsIAccessibleStates::STATE_UNAVAILABLE) + if (!mDOMNode || (*aState & nsIAccessibleStates::STATE_UNAVAILABLE)) return NS_OK; *aState |= nsIAccessibleStates::STATE_SELECTABLE; diff --git a/accessible/src/xforms/nsXFormsWidgetsAccessible.cpp b/accessible/src/xforms/nsXFormsWidgetsAccessible.cpp index 7f516a912150..9c8fcea11471 100644 --- a/accessible/src/xforms/nsXFormsWidgetsAccessible.cpp +++ b/accessible/src/xforms/nsXFormsWidgetsAccessible.cpp @@ -60,8 +60,14 @@ nsXFormsDropmarkerWidgetAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { NS_ENSURE_ARG_POINTER(aState); - *aState = 0; + if (!mDOMNode) { + if (aExtraState) { + *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; + } + return NS_OK; + } + if (aExtraState) *aExtraState = 0; @@ -156,6 +162,8 @@ nsXFormsComboboxPopupWidgetAccessible::GetState(PRUint32 *aState, nsresult rv = nsXFormsAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; PRBool isOpen = PR_FALSE; rv = sXFormsService->IsDropmarkerOpen(mDOMNode, &isOpen); diff --git a/accessible/src/xul/nsXULAlertAccessible.cpp b/accessible/src/xul/nsXULAlertAccessible.cpp index 40d5cda95514..f757e8e694be 100644 --- a/accessible/src/xul/nsXULAlertAccessible.cpp +++ b/accessible/src/xul/nsXULAlertAccessible.cpp @@ -58,9 +58,9 @@ nsXULAlertAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); - - *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE; - *aState |= nsIAccessibleStates::STATE_ALERT_MEDIUM; // XUL has no markup for low, medium or high + if (mDOMNode) { + *aState |= nsIAccessibleStates::STATE_ALERT_MEDIUM; // XUL has no markup for low, medium or high + } return NS_OK; } diff --git a/accessible/src/xul/nsXULColorPickerAccessible.cpp b/accessible/src/xul/nsXULColorPickerAccessible.cpp index 75a16b9feeb5..23b252666bba 100644 --- a/accessible/src/xul/nsXULColorPickerAccessible.cpp +++ b/accessible/src/xul/nsXULColorPickerAccessible.cpp @@ -71,6 +71,8 @@ nsXULColorPickerTileAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState // get focus and disable status from base class nsresult rv = nsFormControlAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; *aState |= nsIAccessibleStates::STATE_FOCUSABLE; @@ -126,6 +128,8 @@ nsXULColorPickerAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) // get focus and disable status from base class nsresult rv = nsFormControlAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; *aState |= nsIAccessibleStates::STATE_FOCUSABLE | nsIAccessibleStates::STATE_HASPOPUP; diff --git a/accessible/src/xul/nsXULFormControlAccessible.cpp b/accessible/src/xul/nsXULFormControlAccessible.cpp index cfb024ce614d..5b710c4a24a1 100644 --- a/accessible/src/xul/nsXULFormControlAccessible.cpp +++ b/accessible/src/xul/nsXULFormControlAccessible.cpp @@ -120,6 +120,8 @@ nsXULButtonAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) // get focus and disable status from base class nsresult rv = nsAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; PRBool disabled = PR_FALSE; nsCOMPtr xulFormElement(do_QueryInterface(mDOMNode)); @@ -293,6 +295,12 @@ NS_IMETHODIMP nsXULDropmarkerAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { *aState = 0; + if (!mDOMNode) { + if (aExtraState) { + *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; + } + return NS_OK; + } if (aExtraState) *aExtraState = 0; @@ -372,6 +380,8 @@ nsXULCheckboxAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) // Get focus and disable status from base class nsresult rv = nsFormControlAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; *aState |= nsIAccessibleStates::STATE_CHECKABLE; @@ -473,16 +483,6 @@ NS_IMETHODIMP nsXULProgressMeterAccessible::GetRole(PRUint32 *_retval) return NS_OK; } -NS_IMETHODIMP -nsXULProgressMeterAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) -{ - nsresult rv = nsAccessible::GetState(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - - *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE; // Progress meters are not focusable - return NS_OK; -} - NS_IMETHODIMP nsXULProgressMeterAccessible::GetValue(nsAString& aValue) { aValue.Truncate(); @@ -557,6 +557,8 @@ nsXULRadioButtonAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsFormControlAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) + return NS_OK; *aState |= nsIAccessibleStates::STATE_CHECKABLE; @@ -616,9 +618,10 @@ nsXULRadioGroupAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) // That means that the actual selected radio button should be considered focused nsresult rv = nsAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); - - *aState &= ~(nsIAccessibleStates::STATE_FOCUSABLE | - nsIAccessibleStates::STATE_FOCUSED); + if (mDOMNode) { + *aState &= ~(nsIAccessibleStates::STATE_FOCUSABLE | + nsIAccessibleStates::STATE_FOCUSED); + } return NS_OK; } @@ -719,16 +722,6 @@ NS_IMETHODIMP nsXULToolbarAccessible::GetRole(PRUint32 *_retval) return NS_OK; } -NS_IMETHODIMP -nsXULToolbarAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) -{ - nsresult rv = nsAccessible::GetState(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - - *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE; // toolbar is not focusable - return NS_OK; -} - /** * XUL Toolbar Separator */ @@ -749,9 +742,9 @@ nsXULToolbarSeparatorAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { *aState = 0; // no special state flags for toolbar separator - if (aExtraState) - *aExtraState = 0; - + if (aExtraState) { + *aExtraState = mDOMNode ? 0 : nsIAccessibleStates::EXT_STATE_DEFUNCT; + } return NS_OK; } diff --git a/accessible/src/xul/nsXULFormControlAccessible.h b/accessible/src/xul/nsXULFormControlAccessible.h index a6f8f4e107ac..912d7956b645 100644 --- a/accessible/src/xul/nsXULFormControlAccessible.h +++ b/accessible/src/xul/nsXULFormControlAccessible.h @@ -104,7 +104,6 @@ class nsXULProgressMeterAccessible : public nsFormControlAccessible public: nsXULProgressMeterAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell); NS_IMETHOD GetRole(PRUint32 *aRole); - NS_IMETHOD GetState(PRUint32 *aState, PRUint32 *aExtraState); NS_IMETHOD GetValue(nsAString &aValue); }; @@ -145,7 +144,6 @@ class nsXULToolbarAccessible : public nsAccessibleWrap public: nsXULToolbarAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell); NS_IMETHOD GetRole(PRUint32 *_retval); - NS_IMETHOD GetState(PRUint32 *aState, PRUint32 *aExtraState); }; class nsXULToolbarSeparatorAccessible : public nsLeafAccessible diff --git a/accessible/src/xul/nsXULMenuAccessible.cpp b/accessible/src/xul/nsXULMenuAccessible.cpp index 921f1c8aecaa..9d832c4790fe 100644 --- a/accessible/src/xul/nsXULMenuAccessible.cpp +++ b/accessible/src/xul/nsXULMenuAccessible.cpp @@ -275,6 +275,9 @@ nsXULMenuitemAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) { + return NS_OK; + } // Focused? nsCOMPtr element(do_QueryInterface(mDOMNode)); @@ -549,6 +552,9 @@ nsXULMenuSeparatorAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) // Isn't focusable, but can be offscreen/invisible -- only copy those states nsresult rv = nsXULMenuitemAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) { + return NS_OK; + } *aState &= (nsIAccessibleStates::STATE_OFFSCREEN | nsIAccessibleStates::STATE_INVISIBLE); @@ -598,6 +604,9 @@ nsXULMenupopupAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) { + return NS_OK; + } #ifdef DEBUG_A11Y // We are onscreen if our parent is active @@ -712,6 +721,9 @@ nsXULMenubarAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) { + return NS_OK; + } // Menu bar iteself is not actually focusable *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE; diff --git a/accessible/src/xul/nsXULSelectAccessible.cpp b/accessible/src/xul/nsXULSelectAccessible.cpp index 65b382031eae..d8622b223205 100644 --- a/accessible/src/xul/nsXULSelectAccessible.cpp +++ b/accessible/src/xul/nsXULSelectAccessible.cpp @@ -70,11 +70,10 @@ NS_IMETHODIMP nsXULColumnsAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { NS_ENSURE_ARG_POINTER(aState); - - if (aExtraState) - *aExtraState = 0; - *aState = nsIAccessibleStates::STATE_READONLY; + if (aExtraState) { + *aExtraState = mDOMNode ? 0 : nsIAccessibleStates::EXT_STATE_DEFUNCT ; + } return NS_OK; } @@ -100,11 +99,10 @@ NS_IMETHODIMP nsXULColumnItemAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { NS_ENSURE_ARG_POINTER(aState); - - if (aExtraState) - *aExtraState = 0; - *aState = nsIAccessibleStates::STATE_READONLY; + if (aExtraState) { + *aExtraState = mDOMNode ? 0 : nsIAccessibleStates::EXT_STATE_DEFUNCT ; + } return NS_OK; } @@ -163,6 +161,9 @@ nsXULListboxAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) // Get focus status from base class nsresult rv = nsAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) { + return NS_OK; + } // see if we are multiple select if so set ourselves as such nsCOMPtr element (do_QueryInterface(mDOMNode)); @@ -261,9 +262,18 @@ NS_IMETHODIMP nsXULListitemAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { if (mIsCheckbox) { - nsXULMenuitemAccessible::GetState(aState, aExtraState); + return nsXULMenuitemAccessible::GetState(aState, aExtraState); + } + + *aState = 0; + if (!mDOMNode) { + if (aExtraState) { + *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; + } return NS_OK; } + if (aExtraState) + *aExtraState = 0; *aState = nsIAccessibleStates::STATE_FOCUSABLE | nsIAccessibleStates::STATE_SELECTABLE; @@ -357,6 +367,9 @@ nsXULComboboxAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) // Get focus status from base class nsresult rv = nsAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); + if (!mDOMNode) { + return NS_OK; + } nsCOMPtr menuList(do_QueryInterface(mDOMNode)); if (menuList) { diff --git a/accessible/src/xul/nsXULTabAccessible.cpp b/accessible/src/xul/nsXULTabAccessible.cpp index e0545b3cce58..97046275901b 100644 --- a/accessible/src/xul/nsXULTabAccessible.cpp +++ b/accessible/src/xul/nsXULTabAccessible.cpp @@ -101,6 +101,9 @@ nsXULTabAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { // get focus and disable status from base class nsresult rv = nsLeafAccessible::GetState(aState, aExtraState); + if (!mDOMNode) { + return NS_OK; + } NS_ENSURE_SUCCESS(rv, rv); // In the past, tabs have been focusable in classic theme @@ -254,17 +257,6 @@ NS_IMETHODIMP nsXULTabBoxAccessible::GetRole(PRUint32 *_retval) return NS_OK; } -/** Possible states: normal */ -NS_IMETHODIMP -nsXULTabBoxAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) -{ - nsresult rv = nsAccessible::GetState(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - - *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE; - return NS_OK; -} - #ifdef NEVER /** 2 children, tabs, tabpanels */ NS_IMETHODIMP nsXULTabBoxAccessible::GetChildCount(PRInt32 *_retval) @@ -298,13 +290,6 @@ NS_IMETHODIMP nsXULTabsAccessible::GetNumActions(PRUint8 *_retval) return NS_OK; } -/** no state -- normal */ -NS_IMETHODIMP -nsXULTabsAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) -{ - return nsAccessible::GetState(aState, aExtraState); -} - /** no value */ NS_IMETHODIMP nsXULTabsAccessible::GetValue(nsAString& _retval) { diff --git a/accessible/src/xul/nsXULTabAccessible.h b/accessible/src/xul/nsXULTabAccessible.h index fb05fbd024ed..12c3f2e2b97f 100644 --- a/accessible/src/xul/nsXULTabAccessible.h +++ b/accessible/src/xul/nsXULTabAccessible.h @@ -76,8 +76,6 @@ class nsXULTabBoxAccessible : public nsAccessibleWrap public: nsXULTabBoxAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell); NS_IMETHOD GetRole(PRUint32 *_retval); - NS_IMETHOD GetState(PRUint32 *aState, PRUint32 *aExtraState); - //NS_IMETHOD GetChildCount(PRInt32 *_retval); // aaronl remove this? }; /** @@ -89,7 +87,6 @@ public: nsXULTabsAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell); NS_IMETHOD GetRole(PRUint32 *_retval); NS_IMETHOD GetNumActions(PRUint8 *_retval); - NS_IMETHOD GetState(PRUint32 *aState, PRUint32 *aExtraState); NS_IMETHOD GetValue(nsAString& _retval); NS_IMETHOD GetName(nsAString& _retval); }; diff --git a/accessible/src/xul/nsXULTreeAccessible.cpp b/accessible/src/xul/nsXULTreeAccessible.cpp index e75334a84a73..9305fe582bd5 100644 --- a/accessible/src/xul/nsXULTreeAccessible.cpp +++ b/accessible/src/xul/nsXULTreeAccessible.cpp @@ -177,7 +177,9 @@ nsXULTreeAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) // Get focus status from base class nsresult rv = nsAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); - + if (!mDOMNode) + return NS_OK; + // see if we are multiple select if so set ourselves as such nsCOMPtr element (do_QueryInterface(mDOMNode)); if (element) { @@ -601,9 +603,9 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetName(nsAString& aName) mTreeView->GetCellText(mRow, mColumn, aName); // If there is still no name try the cell value: - // This is for graphical cells. We need tree/table view implementors to implement - // FooView::GetCellValue to return a meaningful string for cases where there is - // something shown in the cell (non-text) such as a star icon; in which case + // This is for graphical cells. We need tree/table view implementors to implement + // FooView::GetCellValue to return a meaningful string for cases where there is + // something shown in the cell (non-text) such as a star icon; in which case // GetCellValue for that cell would return "starred" or "flagged" for example. if (aName.IsEmpty()) { mTreeView->GetCellValue(mRow, mColumn, aName);