Bug 541108 - nsAccessible::DoCommand shouldn't return value, r=davidb
authorAlexander Surkov <surkov.alexander@gmail.com>
Mon, 25 Jan 2010 23:09:25 +0800
changeset 37481 0235fc257969646a5bcc3dbdc227103b40d9f090
parent 37480 b8a1a64e36e0d6c72ddb1f0cf6bc3d4bbaef3f33
child 37482 b5a9cb0708ac2822002fa0ac46df0a6031329e5b
push id11326
push usersurkov.alexander@gmail.com
push dateMon, 25 Jan 2010 15:10:11 +0000
treeherdermozilla-central@0235fc257969 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavidb
bugs541108
milestone1.9.3a1pre
Bug 541108 - nsAccessible::DoCommand shouldn't return value, r=davidb
accessible/src/base/nsAccessible.cpp
accessible/src/base/nsAccessible.h
accessible/src/base/nsFormControlAccessible.cpp
accessible/src/html/nsHTMLFormControlAccessible.cpp
accessible/src/html/nsHTMLLinkAccessible.cpp
accessible/src/xforms/nsXFormsAccessible.cpp
accessible/src/xforms/nsXFormsFormControlsAccessible.cpp
accessible/src/xul/nsXULFormControlAccessible.cpp
accessible/src/xul/nsXULListboxAccessible.cpp
accessible/src/xul/nsXULSliderAccessible.cpp
accessible/src/xul/nsXULTextAccessible.cpp
accessible/src/xul/nsXULTreeAccessible.cpp
accessible/src/xul/nsXULTreeGridAccessible.cpp
--- a/accessible/src/base/nsAccessible.cpp
+++ b/accessible/src/base/nsAccessible.cpp
@@ -2114,18 +2114,18 @@ nsAccessible::DoAction(PRUint8 aIndex)
 {
   if (aIndex != 0)
     return NS_ERROR_INVALID_ARG;
 
   if (IsDefunct())
     return NS_ERROR_FAILURE;
 
   if (GetActionRule(nsAccUtils::State(this)) != eNoAction) {
-    nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
-    return DoCommand(content);
+    DoCommand();
+    return NS_OK;
   }
 
   return NS_ERROR_INVALID_ARG;
 }
 
 /* DOMString getHelp (); */
 NS_IMETHODIMP nsAccessible::GetHelp(nsAString& _retval)
 {
@@ -2486,27 +2486,25 @@ NS_IMETHODIMP nsAccessible::ExtendSelect
 }
 
 /* [noscript] void getNativeInterface(out voidPtr aOutAccessible); */
 NS_IMETHODIMP nsAccessible::GetNativeInterface(void **aOutAccessible)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-nsresult
+void
 nsAccessible::DoCommand(nsIContent *aContent, PRUint32 aActionIndex)
 {
   nsCOMPtr<nsIContent> content = aContent;
   if (!content)
     content = do_QueryInterface(mDOMNode);
 
   NS_DISPATCH_RUNNABLEMETHOD_ARG2(DispatchClickEvent, this,
                                   content, aActionIndex)
-
-  return NS_OK;
 }
 
 void
 nsAccessible::DispatchClickEvent(nsIContent *aContent, PRUint32 aActionIndex)
 {
   if (IsDefunct())
     return;
 
--- a/accessible/src/base/nsAccessible.h
+++ b/accessible/src/base/nsAccessible.h
@@ -381,17 +381,17 @@ protected:
    *  command opens a modal dialog/window, it won't return until the
    *  dialog/window is closed. If executing action command directly in
    *  nsIAccessible::DoAction() method, it will block AT tools (e.g. GOK) that
    *  invoke action of mozilla accessibles direclty (see bug 277888 for details).
    *
    * @param  aContent      [in, optional] element to click
    * @param  aActionIndex  [in, optional] index of accessible action
    */
-  nsresult DoCommand(nsIContent *aContent = nsnull, PRUint32 aActionIndex = 0);
+  void DoCommand(nsIContent *aContent = nsnull, PRUint32 aActionIndex = 0);
 
   /**
    * Dispatch click event.
    */
   virtual void DispatchClickEvent(nsIContent *aContent, PRUint32 aActionIndex);
 
   NS_DECL_RUNNABLEMETHOD_ARG2(nsAccessible, DispatchClickEvent,
                               nsCOMPtr<nsIContent>, PRUint32)
--- a/accessible/src/base/nsFormControlAccessible.cpp
+++ b/accessible/src/base/nsFormControlAccessible.cpp
@@ -69,23 +69,24 @@ NS_IMETHODIMP nsRadioButtonAccessible::G
 {
   if (aIndex == eAction_Click) {
     aName.AssignLiteral("select"); 
     return NS_OK;
   }
   return NS_ERROR_INVALID_ARG;
 }
 
-/** Our only action is to click */
-NS_IMETHODIMP nsRadioButtonAccessible::DoAction(PRUint8 aIndex)
+NS_IMETHODIMP
+nsRadioButtonAccessible::DoAction(PRUint8 aIndex)
 {
-  if (aIndex == eAction_Click) {
-    return DoCommand();
-  }
-  return NS_ERROR_INVALID_ARG;
+  if (aIndex != eAction_Click)
+    return NS_ERROR_INVALID_ARG;
+
+  DoCommand();
+  return NS_OK;
 }
 
 nsresult
 nsRadioButtonAccessible::GetRoleInternal(PRUint32 *aRole)
 {
   *aRole = nsIAccessibleRole::ROLE_RADIOBUTTON;
   return NS_OK;
 }
--- a/accessible/src/html/nsHTMLFormControlAccessible.cpp
+++ b/accessible/src/html/nsHTMLFormControlAccessible.cpp
@@ -93,22 +93,24 @@ NS_IMETHODIMP nsHTMLCheckboxAccessible::
     else
       aName.AssignLiteral("check"); 
 
     return NS_OK;
   }
   return NS_ERROR_INVALID_ARG;
 }
 
-NS_IMETHODIMP nsHTMLCheckboxAccessible::DoAction(PRUint8 index)
+NS_IMETHODIMP
+nsHTMLCheckboxAccessible::DoAction(PRUint8 aIndex)
 {
-  if (index == 0) {   // 0 is the magic value for default action
-    return DoCommand();
-  }
-  return NS_ERROR_INVALID_ARG;
+  if (aIndex != 0)
+    return NS_ERROR_INVALID_ARG;
+
+  DoCommand();
+  return NS_OK;
 }
 
 nsresult
 nsHTMLCheckboxAccessible::GetStateInternal(PRUint32 *aState,
                                            PRUint32 *aExtraState)
 {
   nsresult rv = nsFormControlAccessible::GetStateInternal(aState, aExtraState);
   NS_ENSURE_A11Y_SUCCESS(rv, rv);
@@ -251,22 +253,24 @@ NS_IMETHODIMP nsHTMLButtonAccessible::Ge
 {
   if (aIndex == eAction_Click) {
     aName.AssignLiteral("press"); 
     return NS_OK;
   }
   return NS_ERROR_INVALID_ARG;
 }
 
-NS_IMETHODIMP nsHTMLButtonAccessible::DoAction(PRUint8 index)
+NS_IMETHODIMP
+nsHTMLButtonAccessible::DoAction(PRUint8 aIndex)
 {
-  if (index == eAction_Click) {
-    return DoCommand();
-  }
-  return NS_ERROR_INVALID_ARG;
+  if (aIndex != eAction_Click)
+    return NS_ERROR_INVALID_ARG;
+
+  DoCommand();
+  return NS_OK;
 }
 
 nsresult
 nsHTMLButtonAccessible::GetStateInternal(PRUint32 *aState,
                                          PRUint32 *aExtraState)
 {
   nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState,
                                                             aExtraState);
@@ -344,22 +348,24 @@ NS_IMETHODIMP nsHTML4ButtonAccessible::G
 {
   if (aIndex == eAction_Click) {
     aName.AssignLiteral("press"); 
     return NS_OK;
   }
   return NS_ERROR_INVALID_ARG;
 }
 
-NS_IMETHODIMP nsHTML4ButtonAccessible::DoAction(PRUint8 index)
+NS_IMETHODIMP
+nsHTML4ButtonAccessible::DoAction(PRUint8 aIndex)
 {
-  if (index == 0) {
-    return DoCommand();
-  }
-  return NS_ERROR_INVALID_ARG;
+  if (aIndex != 0)
+    return NS_ERROR_INVALID_ARG;
+
+  DoCommand();
+  return NS_OK;
 }
 
 nsresult
 nsHTML4ButtonAccessible::GetRoleInternal(PRUint32 *aRole)
 {
   *aRole = nsIAccessibleRole::ROLE_PUSHBUTTON;
   return NS_OK;
 }
--- a/accessible/src/html/nsHTMLLinkAccessible.cpp
+++ b/accessible/src/html/nsHTMLLinkAccessible.cpp
@@ -155,18 +155,18 @@ nsHTMLLinkAccessible::DoAction(PRUint8 a
 
   // Action 0 (default action): Jump to link
   if (aIndex != eAction_Jump)
     return NS_ERROR_INVALID_ARG;
 
   if (IsDefunct())
     return NS_ERROR_FAILURE;
 
-  nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
-  return DoCommand(content);
+  DoCommand();
+  return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIAccessibleHyperLink
 
 NS_IMETHODIMP
 nsHTMLLinkAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
 {
--- a/accessible/src/xforms/nsXFormsAccessible.cpp
+++ b/accessible/src/xforms/nsXFormsAccessible.cpp
@@ -621,17 +621,18 @@ nsXFormsSelectableItemAccessible::GetNum
 }
 
 NS_IMETHODIMP
 nsXFormsSelectableItemAccessible::DoAction(PRUint8 aIndex)
 {
   if (aIndex != eAction_Click)
     return NS_ERROR_INVALID_ARG;
 
-  return DoCommand();
+  DoCommand();
+  return NS_OK;
 }
 
 PRBool
 nsXFormsSelectableItemAccessible::IsItemSelected()
 {
   nsresult rv;
 
   nsCOMPtr<nsINode> parent = do_QueryInterface(mDOMNode);
--- a/accessible/src/xforms/nsXFormsFormControlsAccessible.cpp
+++ b/accessible/src/xforms/nsXFormsFormControlsAccessible.cpp
@@ -125,20 +125,21 @@ nsXFormsTriggerAccessible::GetActionName
     return NS_OK;
   }
   return NS_ERROR_INVALID_ARG;
 }
 
 NS_IMETHODIMP
 nsXFormsTriggerAccessible::DoAction(PRUint8 aIndex)
 {
-  if (aIndex == eAction_Click)
-    return DoCommand();
+  if (aIndex != eAction_Click)
+    return NS_ERROR_INVALID_ARG;
 
-  return NS_ERROR_INVALID_ARG;
+  DoCommand();
+  return NS_OK;
 }
 
 // nsXFormsInputAccessible
 
 nsXFormsInputAccessible::
   nsXFormsInputAccessible(nsIDOMNode *aNode, nsIWeakReference *aShell):
   nsXFormsEditableAccessible(aNode, aShell)
 {
@@ -241,17 +242,18 @@ nsXFormsInputBooleanAccessible::GetActio
 }
 
 NS_IMETHODIMP
 nsXFormsInputBooleanAccessible::DoAction(PRUint8 aIndex)
 {
   if (aIndex != eAction_Click)
     return NS_ERROR_INVALID_ARG;
 
-  return DoCommand();
+  DoCommand();
+  return NS_OK;
 }
 
 // nsXFormsInputDateAccessible
 
 nsXFormsInputDateAccessible::
   nsXFormsInputDateAccessible(nsIDOMNode *aNode, nsIWeakReference *aShell):
   nsXFormsContainerAccessible(aNode, aShell)
 {
--- a/accessible/src/xul/nsXULFormControlAccessible.cpp
+++ b/accessible/src/xul/nsXULFormControlAccessible.cpp
@@ -91,20 +91,21 @@ nsXULButtonAccessible::GetActionName(PRU
     return NS_OK;
   }
   return NS_ERROR_INVALID_ARG;
 }
 
 NS_IMETHODIMP
 nsXULButtonAccessible::DoAction(PRUint8 aIndex)
 {
-  if (aIndex == 0)
-    return DoCommand();
+  if (aIndex != 0)
+    return NS_ERROR_INVALID_ARG;
 
-  return NS_ERROR_INVALID_ARG;
+  DoCommand();
+  return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsXULButtonAccessible: nsAccessNode
 
 nsresult
 nsXULButtonAccessible::Init()
 {
@@ -414,22 +415,24 @@ NS_IMETHODIMP nsXULCheckboxAccessible::G
     return NS_OK;
   }
   return NS_ERROR_INVALID_ARG;
 }
 
 /**
   * Tell the checkbox to do its only action -- check( or uncheck) itself
   */
-NS_IMETHODIMP nsXULCheckboxAccessible::DoAction(PRUint8 index)
+NS_IMETHODIMP
+nsXULCheckboxAccessible::DoAction(PRUint8 aIndex)
 {
-  if (index == eAction_Click) {
-   return DoCommand();
-  }
-  return NS_ERROR_INVALID_ARG;
+  if (aIndex != eAction_Click)
+    return NS_ERROR_INVALID_ARG;
+
+  DoCommand();
+  return NS_OK;
 }
 
 /**
   * Possible states: focused, focusable, unavailable(disabled), checked
   */
 nsresult
 nsXULCheckboxAccessible::GetStateInternal(PRUint32 *aState,
                                           PRUint32 *aExtraState)
--- a/accessible/src/xul/nsXULListboxAccessible.cpp
+++ b/accessible/src/xul/nsXULListboxAccessible.cpp
@@ -142,17 +142,18 @@ nsXULColumnItemAccessible::GetActionName
 }
 
 NS_IMETHODIMP
 nsXULColumnItemAccessible::DoAction(PRUint8 aIndex)
 {
   if (aIndex != eAction_Click)
     return NS_ERROR_INVALID_ARG;
 
-  return DoCommand();
+  DoCommand();
+  return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsXULListboxAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 nsXULListboxAccessible::
   nsXULListboxAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell) :
--- a/accessible/src/xul/nsXULSliderAccessible.cpp
+++ b/accessible/src/xul/nsXULSliderAccessible.cpp
@@ -115,17 +115,18 @@ nsXULSliderAccessible::GetActionName(PRU
 NS_IMETHODIMP
 nsXULSliderAccessible::DoAction(PRUint8 aIndex)
 {
   NS_ENSURE_ARG(aIndex == 0);
 
   nsCOMPtr<nsIContent> sliderContent(GetSliderNode());
   NS_ENSURE_STATE(sliderContent);
 
-  return DoCommand(sliderContent);
+  DoCommand(sliderContent);
+  return NS_OK;
 }
 
 // nsIAccessibleValue
 
 NS_IMETHODIMP
 nsXULSliderAccessible::GetMaximumValue(double *aValue)
 {
   nsresult rv = nsAccessibleWrap::GetMaximumValue(aValue);
--- a/accessible/src/xul/nsXULTextAccessible.cpp
+++ b/accessible/src/xul/nsXULTextAccessible.cpp
@@ -228,18 +228,18 @@ NS_IMETHODIMP
 nsXULLinkAccessible::DoAction(PRUint8 aIndex)
 {
   if (aIndex != eAction_Jump)
     return NS_ERROR_INVALID_ARG;
 
   if (IsDefunct())
     return NS_ERROR_FAILURE;
 
-  nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
-  return DoCommand(content);
+  DoCommand();
+  return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsXULLinkAccessible. nsIAccessibleHyperLink
 
 NS_IMETHODIMP
 nsXULLinkAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
 {
--- a/accessible/src/xul/nsXULTreeAccessible.cpp
+++ b/accessible/src/xul/nsXULTreeAccessible.cpp
@@ -930,17 +930,18 @@ nsXULTreeItemAccessibleBase::DoAction(PR
 {
   if (IsDefunct())
     return NS_ERROR_FAILURE;
 
   if (aIndex != eAction_Click &&
       (aIndex != eAction_Expand || !IsExpandable()))
     return NS_ERROR_INVALID_ARG;
 
-  return DoCommand(nsnull, aIndex);
+  DoCommand(nsnull, aIndex);
+  return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsXULTreeItemAccessibleBase: nsAccessNode implementation
 
 PRBool
 nsXULTreeItemAccessibleBase::IsDefunct()
 {
--- a/accessible/src/xul/nsXULTreeGridAccessible.cpp
+++ b/accessible/src/xul/nsXULTreeGridAccessible.cpp
@@ -968,23 +968,27 @@ nsXULTreeGridCellAccessible::DoAction(PR
   if (aIndex != eAction_Click)
     return NS_ERROR_INVALID_ARG;
 
   if (IsDefunct())
     return NS_ERROR_FAILURE;
 
   PRBool isCycler = PR_FALSE;
   mColumn->GetCycler(&isCycler);
-  if (isCycler)
-    return DoCommand();
+  if (isCycler) {
+    DoCommand();
+    return NS_OK;
+  }
 
   PRInt16 type;
   mColumn->GetType(&type);
-  if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable())
-    return DoCommand();
+  if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable()) {
+    DoCommand();
+    return NS_OK;
+  }
 
   return NS_ERROR_INVALID_ARG;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsXULTreeGridCellAccessible: nsIAccessibleTableCell implementation
 
 NS_IMETHODIMP