From 3db7aa16cc3921d62057ef23b7346dddd7454b19 Mon Sep 17 00:00:00 2001 From: "surkov.alexander%gmail.com" Date: Sun, 16 Mar 2008 01:23:41 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20420863=20=C3=A2=C2=80=C2=93=20If=20an=20H?= =?UTF-8?q?TML=20element=20has=20an=20onClick=20attribute,=20expose=20its?= =?UTF-8?q?=20click=20action=20on=20the=20element=20rather=20than=20its=20?= =?UTF-8?q?child=20text=20leaf=20node,=20r=3Daaronlev,=20a=3Ddsicore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://10.0.0.236/trunk@247920 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/accessible/src/base/nsAccessible.cpp | 58 +++++++- .../accessible/tests/mochitest/Makefile.in | 1 + .../tests/mochitest/test_bug420863.html | 126 ++++++++++++++++++ 3 files changed, 179 insertions(+), 6 deletions(-) create mode 100644 mozilla/accessible/tests/mochitest/test_bug420863.html diff --git a/mozilla/accessible/src/base/nsAccessible.cpp b/mozilla/accessible/src/base/nsAccessible.cpp index 2f83c6dd80b..24c9251956f 100644 --- a/mozilla/accessible/src/base/nsAccessible.cpp +++ b/mozilla/accessible/src/base/nsAccessible.cpp @@ -2566,20 +2566,52 @@ NS_IMETHODIMP nsAccessible::GetRole(PRUint32 *aRole) } /* PRUint8 getAccNumActions (); */ -NS_IMETHODIMP nsAccessible::GetNumActions(PRUint8 *aNumActions) +NS_IMETHODIMP +nsAccessible::GetNumActions(PRUint8 *aNumActions) { + NS_ENSURE_ARG_POINTER(aNumActions); *aNumActions = 0; + + if (IsDefunct()) + return NS_ERROR_FAILURE; + + nsCOMPtr content(do_QueryInterface(mDOMNode)); + PRBool isOnclick = nsAccUtils::HasListener(content, + NS_LITERAL_STRING("click")); + + if (isOnclick) + *aNumActions = 1; + return NS_OK; } /* DOMString getAccActionName (in PRUint8 index); */ -NS_IMETHODIMP nsAccessible::GetActionName(PRUint8 index, nsAString& aName) +NS_IMETHODIMP +nsAccessible::GetActionName(PRUint8 aIndex, nsAString& aName) { - return NS_ERROR_FAILURE; + aName.Truncate(); + + if (aIndex != 0) + return NS_ERROR_INVALID_ARG; + + if (IsDefunct()) + return NS_ERROR_FAILURE; + + nsCOMPtr content(do_QueryInterface(mDOMNode)); + PRBool isOnclick = nsAccUtils::HasListener(content, + NS_LITERAL_STRING("click")); + + if (isOnclick) { + aName.AssignLiteral("click"); + return NS_OK; + } + + return NS_ERROR_INVALID_ARG; } /* DOMString getActionDescription (in PRUint8 index); */ -NS_IMETHODIMP nsAccessible::GetActionDescription(PRUint8 aIndex, nsAString& aDescription) +NS_IMETHODIMP +nsAccessible::GetActionDescription(PRUint8 aIndex, nsAString& aDescription) { // default to localized action name. nsAutoString name; @@ -2590,9 +2622,23 @@ NS_IMETHODIMP nsAccessible::GetActionDescription(PRUint8 aIndex, nsAString& aDes } /* void doAction (in PRUint8 index); */ -NS_IMETHODIMP nsAccessible::DoAction(PRUint8 index) +NS_IMETHODIMP +nsAccessible::DoAction(PRUint8 aIndex) { - return NS_ERROR_FAILURE; + if (aIndex != 0) + return NS_ERROR_INVALID_ARG; + + if (IsDefunct()) + return NS_ERROR_FAILURE; + + nsCOMPtr content(do_QueryInterface(mDOMNode)); + PRBool isOnclick = nsAccUtils::HasListener(content, + NS_LITERAL_STRING("click")); + + if (isOnclick) + return DoCommand(content); + + return NS_ERROR_INVALID_ARG; } /* DOMString getHelp (); */ diff --git a/mozilla/accessible/tests/mochitest/Makefile.in b/mozilla/accessible/tests/mochitest/Makefile.in index b29bbced081..ee275ec51a4 100644 --- a/mozilla/accessible/tests/mochitest/Makefile.in +++ b/mozilla/accessible/tests/mochitest/Makefile.in @@ -47,6 +47,7 @@ include $(topsrcdir)/config/rules.mk _TEST_FILES =\ test_bug368835.xul \ + test_bug420863.html \ test_groupattrs.xul \ test_table_indexes.html \ test_nsIAccessibleTable_1.html \ diff --git a/mozilla/accessible/tests/mochitest/test_bug420863.html b/mozilla/accessible/tests/mochitest/test_bug420863.html new file mode 100644 index 00000000000..89f5ca5212e --- /dev/null +++ b/mozilla/accessible/tests/mochitest/test_bug420863.html @@ -0,0 +1,126 @@ + + + + + Table indexes chrome tests + + + + + + + + + + Mozilla Bug 420863 +

+ +
+  
+ + + + + + + +
Can't click this cellCell with 'onclick' attributeCell with registered 'click' event handler
+ + +