From cc672241dd36ed329a828799db32645c758ef7f9 Mon Sep 17 00:00:00 2001 From: Alexander Surkov Date: Thu, 27 Nov 2008 12:04:05 +0800 Subject: [PATCH] Bug 416872 - Simplify GetState() impl's for defunct objects, r=david.bolter, sr=neil, a=beltzner --- accessible/src/base/nsAccessNode.h | 14 +++++ accessible/src/base/nsAccessible.cpp | 10 ++-- .../src/base/nsBaseWidgetAccessible.cpp | 2 +- accessible/src/base/nsDocAccessible.cpp | 6 +-- accessible/src/base/nsOuterDocAccessible.cpp | 2 +- accessible/src/base/nsRootAccessible.cpp | 4 +- .../src/html/nsHTMLFormControlAccessible.cpp | 20 ++----- accessible/src/html/nsHTMLImageAccessible.cpp | 4 +- accessible/src/html/nsHTMLLinkAccessible.cpp | 4 +- .../src/html/nsHTMLSelectAccessible.cpp | 22 +++----- accessible/src/html/nsHTMLTableAccessible.cpp | 2 +- accessible/src/html/nsHTMLTextAccessible.cpp | 35 +++++++----- accessible/src/html/nsHyperTextAccessible.cpp | 5 +- accessible/src/xforms/nsXFormsAccessible.cpp | 15 +++--- .../xforms/nsXFormsFormControlsAccessible.cpp | 33 ++++-------- .../src/xforms/nsXFormsWidgetsAccessible.cpp | 13 +++-- accessible/src/xul/nsXULAlertAccessible.cpp | 8 +-- .../src/xul/nsXULColorPickerAccessible.cpp | 8 +-- .../src/xul/nsXULFormControlAccessible.cpp | 53 ++++++++++--------- accessible/src/xul/nsXULMenuAccessible.cpp | 20 ++----- accessible/src/xul/nsXULSelectAccessible.cpp | 50 ++++++++++------- accessible/src/xul/nsXULTabAccessible.cpp | 5 +- accessible/src/xul/nsXULTextAccessible.cpp | 6 +-- accessible/src/xul/nsXULTreeAccessible.cpp | 6 +-- 24 files changed, 162 insertions(+), 185 deletions(-) diff --git a/accessible/src/base/nsAccessNode.h b/accessible/src/base/nsAccessNode.h index 49f38b5038b..050e73d2b27 100755 --- a/accessible/src/base/nsAccessNode.h +++ b/accessible/src/base/nsAccessNode.h @@ -74,6 +74,20 @@ class nsIDocShellTreeItem; typedef nsInterfaceHashtable nsAccessNodeHashtable; +#define NS_OK_DEFUNCT_OBJECT \ +NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_GENERAL, 0x22) + +#define NS_ENSURE_A11Y_SUCCESS(res, ret) \ + PR_BEGIN_MACRO \ + nsresult __rv = res; /* Don't evaluate |res| more than once */ \ + if (NS_FAILED(__rv)) { \ + NS_ENSURE_SUCCESS_BODY(res, ret) \ + return ret; \ + } \ + if (__rv == NS_OK_DEFUNCT_OBJECT) \ + return ret; \ + PR_END_MACRO + #define NS_ACCESSNODE_IMPL_CID \ { /* 13555f6e-0c0f-4002-84f6-558d47b8208e */ \ 0x13555f6e, \ diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index aafe470afd9..5931eb135d7 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -948,11 +948,11 @@ nsAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { *aState = 0; - if (!mDOMNode) { - if (aExtraState) { + if (IsDefunct()) { + if (aExtraState) *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; - } - return NS_OK; // Node shut down + + return NS_OK_DEFUNCT_OBJECT; } if (aExtraState) @@ -2274,7 +2274,7 @@ nsAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) NS_ENSURE_ARG_POINTER(aState); nsresult rv = GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_A11Y_SUCCESS(rv, rv); // Apply ARIA states to be sure accessible states will be overriden. GetARIAState(aState); diff --git a/accessible/src/base/nsBaseWidgetAccessible.cpp b/accessible/src/base/nsBaseWidgetAccessible.cpp index 9f632cee4e1..015c6c1389b 100644 --- a/accessible/src/base/nsBaseWidgetAccessible.cpp +++ b/accessible/src/base/nsBaseWidgetAccessible.cpp @@ -126,7 +126,7 @@ nsLinkableAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_A11Y_SUCCESS(rv, rv); if (mIsLink) { *aState |= nsIAccessibleStates::STATE_LINKED; diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp index 11d5b0d1d94..91809990fdf 100644 --- a/accessible/src/base/nsDocAccessible.cpp +++ b/accessible/src/base/nsDocAccessible.cpp @@ -273,10 +273,8 @@ nsDocAccessible::GetDescription(nsAString& aDescription) nsresult nsDocAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { - // nsAccessible::GetStateInternal() always fail for document accessible. - nsAccessible::GetStateInternal(aState, aExtraState); - if (!mDOMNode) - return NS_OK; + nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); + NS_ENSURE_A11Y_SUCCESS(rv, rv); #ifdef MOZ_XUL nsCOMPtr xulDoc(do_QueryInterface(mDocument)); diff --git a/accessible/src/base/nsOuterDocAccessible.cpp b/accessible/src/base/nsOuterDocAccessible.cpp index 1f39ff0595a..f31baf5b212 100644 --- a/accessible/src/base/nsOuterDocAccessible.cpp +++ b/accessible/src/base/nsOuterDocAccessible.cpp @@ -63,7 +63,7 @@ nsresult nsOuterDocAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_A11Y_SUCCESS(rv, rv); *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE; return NS_OK; diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index f41991b775b..896a7ed61e6 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -214,9 +214,7 @@ nsresult nsRootAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsDocAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); #ifdef MOZ_XUL PRUint32 chromeFlags = GetChromeFlags(); diff --git a/accessible/src/html/nsHTMLFormControlAccessible.cpp b/accessible/src/html/nsHTMLFormControlAccessible.cpp index 36a750c3dff..e5e6118654f 100644 --- a/accessible/src/html/nsHTMLFormControlAccessible.cpp +++ b/accessible/src/html/nsHTMLFormControlAccessible.cpp @@ -107,9 +107,7 @@ nsHTMLCheckboxAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsFormControlAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); *aState |= nsIAccessibleStates::STATE_CHECKABLE; @@ -137,9 +135,7 @@ nsHTMLRadioButtonAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); *aState |= nsIAccessibleStates::STATE_CHECKABLE; @@ -259,9 +255,7 @@ nsHTMLButtonAccessible::GetStateInternal(PRUint32 *aState, { nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); nsCOMPtr element(do_QueryInterface(mDOMNode)); NS_ENSURE_TRUE(element, NS_ERROR_FAILURE); @@ -360,9 +354,7 @@ nsHTML4ButtonAccessible::GetStateInternal(PRUint32 *aState, { nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); nsCOMPtr element(do_QueryInterface(mDOMNode)); NS_ASSERTION(element, "No element for button's dom node!"); @@ -455,9 +447,7 @@ nsHTMLTextFieldAccessible::GetStateInternal(PRUint32 *aState, { nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); // can be focusable, focused, protected. readonly, unavailable, selected nsCOMPtr content(do_QueryInterface(mDOMNode)); diff --git a/accessible/src/html/nsHTMLImageAccessible.cpp b/accessible/src/html/nsHTMLImageAccessible.cpp index fdafef756f8..36e4942d7de 100644 --- a/accessible/src/html/nsHTMLImageAccessible.cpp +++ b/accessible/src/html/nsHTMLImageAccessible.cpp @@ -101,9 +101,7 @@ nsHTMLImageAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) // STATE_ANIMATED if this is an animated image. nsresult rv = nsLinkableAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); nsCOMPtr content(do_QueryInterface(mDOMNode)); nsCOMPtr imageRequest; diff --git a/accessible/src/html/nsHTMLLinkAccessible.cpp b/accessible/src/html/nsHTMLLinkAccessible.cpp index feac2f29f40..9d7cd3e2a8f 100644 --- a/accessible/src/html/nsHTMLLinkAccessible.cpp +++ b/accessible/src/html/nsHTMLLinkAccessible.cpp @@ -87,9 +87,7 @@ nsHTMLLinkAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); *aState &= ~nsIAccessibleStates::STATE_READONLY; diff --git a/accessible/src/html/nsHTMLSelectAccessible.cpp b/accessible/src/html/nsHTMLSelectAccessible.cpp index 962891b52e4..f96a887e48e 100644 --- a/accessible/src/html/nsHTMLSelectAccessible.cpp +++ b/accessible/src/html/nsHTMLSelectAccessible.cpp @@ -331,9 +331,7 @@ nsHTMLSelectListAccessible::GetStateInternal(PRUint32 *aState, { nsresult rv = nsHTMLSelectableAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); nsCOMPtr select (do_QueryInterface(mDOMNode)); if (select) { @@ -613,9 +611,7 @@ nsHTMLSelectOptionAccessible::GetStateInternal(PRUint32 *aState, // Upcall to nsAccessible, but skip nsHyperTextAccessible impl // because we don't want EXT_STATE_EDITABLE or EXT_STATE_SELECTABLE_TEXT nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); PRUint32 selectState, selectExtState; nsCOMPtr selectContent = GetSelectState(&selectState, @@ -922,7 +918,7 @@ nsHTMLSelectOptGroupAccessible::GetStateInternal(PRUint32 *aState, { nsresult rv = nsHTMLSelectOptionAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_A11Y_SUCCESS(rv, rv); *aState &= ~(nsIAccessibleStates::STATE_FOCUSABLE | nsIAccessibleStates::STATE_SELECTABLE); @@ -1077,9 +1073,7 @@ nsHTMLComboboxAccessible::GetStateInternal(PRUint32 *aState, { // Get focus status from base class nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); nsIFrame *frame = GetBoundsFrame(); nsIComboboxControlFrame *comboFrame = nsnull; @@ -1398,9 +1392,7 @@ nsHTMLComboboxButtonAccessible::GetStateInternal(PRUint32 *aState, { // Get focus status from base class nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); nsIFrame *boundsFrame = GetBoundsFrame(); nsIComboboxControlFrame* comboFrame = nsnull; @@ -1459,9 +1451,7 @@ nsHTMLComboboxListAccessible::GetStateInternal(PRUint32 *aState, { // Get focus status from base class nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); nsIFrame *boundsFrame = GetBoundsFrame(); nsIComboboxControlFrame* comboFrame = nsnull; diff --git a/accessible/src/html/nsHTMLTableAccessible.cpp b/accessible/src/html/nsHTMLTableAccessible.cpp index f3a8532e48b..13b56c4c42d 100644 --- a/accessible/src/html/nsHTMLTableAccessible.cpp +++ b/accessible/src/html/nsHTMLTableAccessible.cpp @@ -199,7 +199,7 @@ nsresult nsHTMLTableAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv= nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_A11Y_SUCCESS(rv, rv); *aState |= nsIAccessibleStates::STATE_READONLY; return NS_OK; diff --git a/accessible/src/html/nsHTMLTextAccessible.cpp b/accessible/src/html/nsHTMLTextAccessible.cpp index 18ef2454453..69b815e373d 100644 --- a/accessible/src/html/nsHTMLTextAccessible.cpp +++ b/accessible/src/html/nsHTMLTextAccessible.cpp @@ -78,9 +78,7 @@ nsresult nsHTMLTextAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsTextAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); nsCOMPtr docAccessible = do_QueryInterface(nsCOMPtr(GetDocAccessible())); @@ -138,10 +136,19 @@ NS_IMETHODIMP nsHTMLBRAccessible::GetRole(PRUint32 *aRole) nsresult nsHTMLBRAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { - *aState = nsIAccessibleStates::STATE_READONLY; - if (aExtraState) { - *aExtraState = mDOMNode ? 0 : nsIAccessibleStates::EXT_STATE_DEFUNCT; + *aState = 0; + + if (IsDefunct()) { + if (aExtraState) + *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; + + return NS_OK_DEFUNCT_OBJECT; } + + *aState = nsIAccessibleStates::STATE_READONLY; + if (aExtraState) + *aExtraState = 0; + return NS_OK; } @@ -190,11 +197,11 @@ nsresult nsHTMLLabelAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsTextAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (mDOMNode) { - *aState &= (nsIAccessibleStates::STATE_LINKED | - nsIAccessibleStates::STATE_TRAVERSED); // Only use link states - } + NS_ENSURE_A11Y_SUCCESS(rv, rv); + + *aState &= (nsIAccessibleStates::STATE_LINKED | + nsIAccessibleStates::STATE_TRAVERSED); // Only use link states + return NS_OK; } @@ -246,7 +253,7 @@ nsresult nsHTMLLIAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_A11Y_SUCCESS(rv, rv); *aState |= nsIAccessibleStates::STATE_READONLY; return NS_OK; @@ -331,7 +338,7 @@ nsresult nsHTMLListBulletAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsLeafAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_A11Y_SUCCESS(rv, rv); *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE; *aState |= nsIAccessibleStates::STATE_READONLY; @@ -372,7 +379,7 @@ nsHTMLListAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_A11Y_SUCCESS(rv, rv); *aState |= nsIAccessibleStates::STATE_READONLY; return NS_OK; diff --git a/accessible/src/html/nsHyperTextAccessible.cpp b/accessible/src/html/nsHyperTextAccessible.cpp index ae27e664218..1ae5238adc6 100644 --- a/accessible/src/html/nsHyperTextAccessible.cpp +++ b/accessible/src/html/nsHyperTextAccessible.cpp @@ -173,8 +173,9 @@ nsresult nsHyperTextAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode || !aExtraState) + NS_ENSURE_A11Y_SUCCESS(rv, rv); + + if (!aExtraState) return NS_OK; nsCOMPtr editor; diff --git a/accessible/src/xforms/nsXFormsAccessible.cpp b/accessible/src/xforms/nsXFormsAccessible.cpp index ffb290df024..a5c738c51e7 100755 --- a/accessible/src/xforms/nsXFormsAccessible.cpp +++ b/accessible/src/xforms/nsXFormsAccessible.cpp @@ -176,12 +176,14 @@ nsXFormsAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { NS_ENSURE_ARG_POINTER(aState); *aState = 0; - if (!mDOMNode) { - if (aExtraState) { + + if (IsDefunct()) { + if (aExtraState) *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; - } - return NS_OK; + + return NS_OK_DEFUNCT_OBJECT; } + if (aExtraState) *aExtraState = 0; @@ -310,8 +312,9 @@ nsXFormsEditableAccessible::GetStateInternal(PRUint32 *aState, NS_ENSURE_ARG_POINTER(aState); nsresult rv = nsXFormsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode || !aExtraState) + NS_ENSURE_A11Y_SUCCESS(rv, rv); + + if (!aExtraState) return NS_OK; PRBool isReadonly = PR_FALSE; diff --git a/accessible/src/xforms/nsXFormsFormControlsAccessible.cpp b/accessible/src/xforms/nsXFormsFormControlsAccessible.cpp index da46f7e910f..86b2fc4824f 100755 --- a/accessible/src/xforms/nsXFormsFormControlsAccessible.cpp +++ b/accessible/src/xforms/nsXFormsFormControlsAccessible.cpp @@ -209,9 +209,7 @@ nsXFormsInputBooleanAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsXFormsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); nsAutoString value; rv = sXFormsService->GetValue(mDOMNode, value); @@ -298,9 +296,7 @@ nsXFormsSecretAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsXFormsInputAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); *aState |= nsIAccessibleStates::STATE_PROTECTED; return NS_OK; @@ -335,9 +331,7 @@ nsXFormsRangeAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsXFormsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); PRUint32 isInRange = nsIXFormsUtilityService::STATE_NOT_A_RANGE; rv = sXFormsService->IsInRange(mDOMNode, &isInRange); @@ -420,9 +414,7 @@ nsXFormsSelectAccessible::GetStateInternal(PRUint32 *aState, { nsresult rv = nsXFormsContainerAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); PRUint32 isInRange = nsIXFormsUtilityService::STATE_NOT_A_RANGE; rv = sXFormsService->IsInRange(mDOMNode, &isInRange); @@ -514,9 +506,7 @@ nsXFormsItemCheckgroupAccessible::GetStateInternal(PRUint32 *aState, { nsresult rv = nsXFormsSelectableItemAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); if (IsItemSelected()) *aState |= nsIAccessibleStates::STATE_CHECKED; @@ -562,9 +552,7 @@ nsXFormsItemRadiogroupAccessible::GetStateInternal(PRUint32 *aState, { nsresult rv = nsXFormsSelectableItemAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); if (IsItemSelected()) *aState |= nsIAccessibleStates::STATE_CHECKED; @@ -606,9 +594,7 @@ nsXFormsSelectComboboxAccessible::GetStateInternal(PRUint32 *aState, { nsresult rv = nsXFormsSelectableAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); PRBool isOpen = PR_FALSE; rv = sXFormsService->IsDropmarkerOpen(mDOMNode, &isOpen); @@ -657,8 +643,9 @@ nsXFormsItemComboboxAccessible::GetStateInternal(PRUint32 *aState, { nsresult rv = nsXFormsSelectableItemAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode || (*aState & nsIAccessibleStates::STATE_UNAVAILABLE)) + NS_ENSURE_A11Y_SUCCESS(rv, rv); + + if (*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 e7f8fe0cc58..1a37dc11c81 100644 --- a/accessible/src/xforms/nsXFormsWidgetsAccessible.cpp +++ b/accessible/src/xforms/nsXFormsWidgetsAccessible.cpp @@ -61,11 +61,12 @@ nsXFormsDropmarkerWidgetAccessible::GetStateInternal(PRUint32 *aState, { NS_ENSURE_ARG_POINTER(aState); *aState = 0; - if (!mDOMNode) { - if (aExtraState) { + + if (IsDefunct()) { + if (aExtraState) *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; - } - return NS_OK; + + return NS_OK_DEFUNCT_OBJECT; } if (aExtraState) @@ -161,9 +162,7 @@ nsXFormsComboboxPopupWidgetAccessible::GetStateInternal(PRUint32 *aState, NS_ENSURE_ARG_POINTER(aState); nsresult rv = nsXFormsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); PRBool isOpen = PR_FALSE; rv = sXFormsService->IsDropmarkerOpen(mDOMNode, &isOpen); diff --git a/accessible/src/xul/nsXULAlertAccessible.cpp b/accessible/src/xul/nsXULAlertAccessible.cpp index cc9df0e621c..8fdc7426f9f 100644 --- a/accessible/src/xul/nsXULAlertAccessible.cpp +++ b/accessible/src/xul/nsXULAlertAccessible.cpp @@ -57,10 +57,10 @@ nsresult nsXULAlertAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (mDOMNode) { - *aState |= nsIAccessibleStates::STATE_ALERT_MEDIUM; // XUL has no markup for low, medium or high - } + NS_ENSURE_A11Y_SUCCESS(rv, rv); + + // XUL has no markup for low, medium or high + *aState |= nsIAccessibleStates::STATE_ALERT_MEDIUM; return NS_OK; } diff --git a/accessible/src/xul/nsXULColorPickerAccessible.cpp b/accessible/src/xul/nsXULColorPickerAccessible.cpp index e9f6de0727a..502320a57bd 100644 --- a/accessible/src/xul/nsXULColorPickerAccessible.cpp +++ b/accessible/src/xul/nsXULColorPickerAccessible.cpp @@ -71,9 +71,7 @@ nsXULColorPickerTileAccessible::GetStateInternal(PRUint32 *aState, { // get focus and disable status from base class nsresult rv = nsFormControlAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); *aState |= nsIAccessibleStates::STATE_FOCUSABLE; @@ -130,9 +128,7 @@ nsXULColorPickerAccessible::GetStateInternal(PRUint32 *aState, { // get focus and disable status from base class nsresult rv = nsFormControlAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); *aState |= nsIAccessibleStates::STATE_FOCUSABLE | nsIAccessibleStates::STATE_HASPOPUP; diff --git a/accessible/src/xul/nsXULFormControlAccessible.cpp b/accessible/src/xul/nsXULFormControlAccessible.cpp index 779fc39a909..f73e937b155 100644 --- a/accessible/src/xul/nsXULFormControlAccessible.cpp +++ b/accessible/src/xul/nsXULFormControlAccessible.cpp @@ -119,9 +119,7 @@ nsXULButtonAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { // get focus and disable status from base class nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); PRBool disabled = PR_FALSE; nsCOMPtr xulFormElement(do_QueryInterface(mDOMNode)); @@ -296,12 +294,14 @@ nsXULDropmarkerAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { *aState = 0; - if (!mDOMNode) { - if (aExtraState) { + + if (IsDefunct()) { + if (aExtraState) *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; - } - return NS_OK; + + return NS_OK_DEFUNCT_OBJECT; } + if (aExtraState) *aExtraState = 0; @@ -382,9 +382,7 @@ nsXULCheckboxAccessible::GetStateInternal(PRUint32 *aState, { // Get focus and disable status from base class nsresult rv = nsFormControlAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); *aState |= nsIAccessibleStates::STATE_CHECKABLE; @@ -558,9 +556,7 @@ nsXULRadioButtonAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsFormControlAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); *aState |= nsIAccessibleStates::STATE_CHECKABLE; @@ -616,15 +612,14 @@ nsresult nsXULRadioGroupAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { - // The radio group is not focusable. - // Sometimes the focus controller will report that it is focused. - // That means that the actual selected radio button should be considered focused nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (mDOMNode) { - *aState &= ~(nsIAccessibleStates::STATE_FOCUSABLE | - nsIAccessibleStates::STATE_FOCUSED); - } + NS_ENSURE_A11Y_SUCCESS(rv, rv); + + // The radio group is not focusable. Sometimes the focus controller will + // report that it is focused. That means that the actual selected radio button + // should be considered focused. + *aState &= ~(nsIAccessibleStates::STATE_FOCUSABLE | + nsIAccessibleStates::STATE_FOCUSED); return NS_OK; } @@ -745,9 +740,17 @@ nsXULToolbarSeparatorAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { *aState = 0; // no special state flags for toolbar separator - if (aExtraState) { - *aExtraState = mDOMNode ? 0 : nsIAccessibleStates::EXT_STATE_DEFUNCT; + + if (IsDefunct()) { + if (aExtraState) + *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; + + return NS_OK_DEFUNCT_OBJECT; } + + if (aExtraState) + *aExtraState = 0; + return NS_OK; } @@ -804,9 +807,7 @@ nsXULTextFieldAccessible::GetStateInternal(PRUint32 *aState, { nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); nsCOMPtr inputField = GetInputField(); NS_ENSURE_TRUE(inputField, NS_ERROR_FAILURE); diff --git a/accessible/src/xul/nsXULMenuAccessible.cpp b/accessible/src/xul/nsXULMenuAccessible.cpp index 4903a9717bf..f407b788633 100644 --- a/accessible/src/xul/nsXULMenuAccessible.cpp +++ b/accessible/src/xul/nsXULMenuAccessible.cpp @@ -282,10 +282,7 @@ nsXULMenuitemAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) { - return NS_OK; - } + NS_ENSURE_A11Y_SUCCESS(rv, rv); // Focused? nsCOMPtr element(do_QueryInterface(mDOMNode)); @@ -566,10 +563,7 @@ nsXULMenuSeparatorAccessible::GetStateInternal(PRUint32 *aState, { // Isn't focusable, but can be offscreen/invisible -- only copy those states nsresult rv = nsXULMenuitemAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) { - return NS_OK; - } + NS_ENSURE_A11Y_SUCCESS(rv, rv); *aState &= (nsIAccessibleStates::STATE_OFFSCREEN | nsIAccessibleStates::STATE_INVISIBLE); @@ -619,10 +613,7 @@ nsXULMenupopupAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) { - return NS_OK; - } + NS_ENSURE_A11Y_SUCCESS(rv, rv); #ifdef DEBUG_A11Y // We are onscreen if our parent is active @@ -737,10 +728,7 @@ nsXULMenubarAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) { - return NS_OK; - } + NS_ENSURE_A11Y_SUCCESS(rv, rv); // 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 33850fb0521..0cfaf0b78f7 100644 --- a/accessible/src/xul/nsXULSelectAccessible.cpp +++ b/accessible/src/xul/nsXULSelectAccessible.cpp @@ -72,10 +72,20 @@ nsXULColumnsAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { NS_ENSURE_ARG_POINTER(aState); - *aState = nsIAccessibleStates::STATE_READONLY; - if (aExtraState) { - *aExtraState = mDOMNode ? 0 : nsIAccessibleStates::EXT_STATE_DEFUNCT ; + *aState = 0; + + if (IsDefunct()) { + if (aExtraState) + *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; + + return NS_OK_DEFUNCT_OBJECT; } + + *aState = nsIAccessibleStates::STATE_READONLY; + + if (aExtraState) + *aExtraState = 0; + return NS_OK; } @@ -102,10 +112,18 @@ nsXULColumnItemAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { NS_ENSURE_ARG_POINTER(aState); - *aState = nsIAccessibleStates::STATE_READONLY; - if (aExtraState) { - *aExtraState = mDOMNode ? 0 : nsIAccessibleStates::EXT_STATE_DEFUNCT ; + + if (IsDefunct()) { + if (aExtraState) + *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; + + return NS_OK_DEFUNCT_OBJECT; } + + *aState = nsIAccessibleStates::STATE_READONLY; + if (aExtraState) + *aExtraState = 0; + return NS_OK; } @@ -196,10 +214,7 @@ nsXULListboxAccessible::GetStateInternal(PRUint32 *aState, // Get focus status from base class nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) { - return NS_OK; - } + NS_ENSURE_A11Y_SUCCESS(rv, rv); // see if we are multiple select if so set ourselves as such nsCOMPtr element (do_QueryInterface(mDOMNode)); @@ -909,12 +924,14 @@ nsXULListitemAccessible::GetStateInternal(PRUint32 *aState, } *aState = 0; - if (!mDOMNode) { - if (aExtraState) { + + if (IsDefunct()) { + if (aExtraState) *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; - } - return NS_OK; + + return NS_OK_DEFUNCT_OBJECT; } + if (aExtraState) *aExtraState = 0; @@ -1045,10 +1062,7 @@ nsXULComboboxAccessible::GetStateInternal(PRUint32 *aState, { // Get focus status from base class nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) { - return NS_OK; - } + NS_ENSURE_A11Y_SUCCESS(rv, rv); nsCOMPtr menuList(do_QueryInterface(mDOMNode)); if (menuList) { diff --git a/accessible/src/xul/nsXULTabAccessible.cpp b/accessible/src/xul/nsXULTabAccessible.cpp index 7d8973393fb..1a84c8b4bbc 100644 --- a/accessible/src/xul/nsXULTabAccessible.cpp +++ b/accessible/src/xul/nsXULTabAccessible.cpp @@ -101,10 +101,7 @@ nsXULTabAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { // get focus and disable status from base class nsresult rv = nsLeafAccessible::GetStateInternal(aState, aExtraState); - if (!mDOMNode) { - return NS_OK; - } - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_A11Y_SUCCESS(rv, rv); // In the past, tabs have been focusable in classic theme // They may be again in the future diff --git a/accessible/src/xul/nsXULTextAccessible.cpp b/accessible/src/xul/nsXULTextAccessible.cpp index 54bfbbbf7e2..e2000519ff8 100644 --- a/accessible/src/xul/nsXULTextAccessible.cpp +++ b/accessible/src/xul/nsXULTextAccessible.cpp @@ -72,7 +72,7 @@ nsXULTextAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_A11Y_SUCCESS(rv, rv); // Labels and description have read only state // They are not focusable or selectable @@ -128,7 +128,7 @@ nsXULTooltipAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsLeafAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_A11Y_SUCCESS(rv, rv); *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE; *aState |= nsIAccessibleStates::STATE_READONLY; @@ -196,7 +196,7 @@ nsXULLinkAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_A11Y_SUCCESS(rv, rv); *aState |= nsIAccessibleStates::STATE_LINKED; return NS_OK; diff --git a/accessible/src/xul/nsXULTreeAccessible.cpp b/accessible/src/xul/nsXULTreeAccessible.cpp index c6ac2e8f93d..260e02524a1 100644 --- a/accessible/src/xul/nsXULTreeAccessible.cpp +++ b/accessible/src/xul/nsXULTreeAccessible.cpp @@ -174,9 +174,7 @@ nsXULTreeAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { // Get focus status from base class nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); - if (!mDOMNode) - return NS_OK; + NS_ENSURE_A11Y_SUCCESS(rv, rv); // see if we are multiple select if so set ourselves as such nsCOMPtr element (do_QueryInterface(mDOMNode)); @@ -861,7 +859,7 @@ nsXULTreeitemAccessible::GetStateInternal(PRUint32 *aState, if (IsDefunct()) { if (aExtraState) *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; - return NS_OK; + return NS_OK_DEFUNCT_OBJECT; } *aState = nsIAccessibleStates::STATE_FOCUSABLE |