diff --git a/accessible/src/html/nsHTMLFormControlAccessible.cpp b/accessible/src/html/nsHTMLFormControlAccessible.cpp
index ec48a487cad..49874ff1f7e 100644
--- a/accessible/src/html/nsHTMLFormControlAccessible.cpp
+++ b/accessible/src/html/nsHTMLFormControlAccessible.cpp
@@ -45,6 +45,7 @@
#include "nsIDOMHTMLButtonElement.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsIDOMHTMLInputElement.h"
+#include "nsIDOMNSHTMLButtonElement.h"
#include "nsIDOMHTMLLabelElement.h"
#include "nsIDOMHTMLTextAreaElement.h"
#include "nsIDOMXULCheckboxElement.h"
@@ -179,7 +180,7 @@ NS_IMETHODIMP nsHTMLButtonAccessible::GetAccActionName(PRUint8 index, nsAString&
NS_IMETHODIMP nsHTMLButtonAccessible::AccDoAction(PRUint8 index)
{
- if (index == 0) {
+ if (index == eAction_Click) {
nsCOMPtr element(do_QueryInterface(mDOMNode));
if (element) {
element->Click();
@@ -250,10 +251,10 @@ NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccActionName(PRUint8 index, nsAString
NS_IMETHODIMP nsHTML4ButtonAccessible::AccDoAction(PRUint8 index)
{
if (index == 0) {
- nsCOMPtr inputElement(do_QueryInterface(mDOMNode));
- if ( inputElement )
+ nsCOMPtr buttonElement(do_QueryInterface(mDOMNode));
+ if ( buttonElement )
{
- inputElement->Click();
+ buttonElement->Click();
return NS_OK;
}
return NS_ERROR_FAILURE;
diff --git a/content/html/content/src/nsHTMLButtonElement.cpp b/content/html/content/src/nsHTMLButtonElement.cpp
index f0f262f24cc..c7cf6636074 100644
--- a/content/html/content/src/nsHTMLButtonElement.cpp
+++ b/content/html/content/src/nsHTMLButtonElement.cpp
@@ -118,6 +118,7 @@ public:
protected:
PRInt8 mType;
+ PRPackedBool mHandlingClick;
private:
// The analogue of defaultValue in the DOM for input and textarea
@@ -158,6 +159,7 @@ NS_NewHTMLButtonElement(nsIHTMLContent** aInstancePtrResult,
nsHTMLButtonElement::nsHTMLButtonElement()
{
mType = NS_FORM_BUTTON_SUBMIT; // default
+ mHandlingClick = PR_FALSE;
}
nsHTMLButtonElement::~nsHTMLButtonElement()
@@ -282,6 +284,45 @@ nsHTMLButtonElement::Focus()
return SetElementFocus(PR_TRUE);
}
+NS_IMETHODIMP
+nsHTMLButtonElement::Click()
+{
+ if (mHandlingClick)
+ return NS_OK;
+
+ mHandlingClick = PR_TRUE;
+ nsCOMPtr doc;
+ GetDocument(*getter_AddRefs(doc));
+
+ if (doc) {
+ PRInt32 numShells = doc->GetNumberOfShells();
+ nsCOMPtr context;
+ for (PRInt32 count=0; count < numShells; count++) {
+ nsCOMPtr shell;
+ doc->GetShellAt(count, getter_AddRefs(shell));
+ if (shell) {
+ shell->GetPresContext(getter_AddRefs(context));
+ if (context) {
+ nsEventStatus status = nsEventStatus_eIgnore;
+ nsMouseEvent event;
+ event.eventStructType = NS_MOUSE_EVENT;
+ event.message = NS_MOUSE_LEFT_CLICK;
+ event.isShift = PR_FALSE;
+ event.isControl = PR_FALSE;
+ event.isAlt = PR_FALSE;
+ event.isMeta = PR_FALSE;
+ event.clickCount = 0;
+ event.widget = nsnull;
+ HandleDOMEvent(context, &event, nsnull,
+ NS_EVENT_FLAG_INIT, &status);
+ }
+ }
+ }
+ }
+ mHandlingClick = PR_FALSE;
+ return NS_OK;
+}
+
NS_IMETHODIMP
nsHTMLButtonElement::SetFocus(nsIPresContext* aPresContext)
{
diff --git a/dom/public/idl/html/nsIDOMNSHTMLButtonElement.idl b/dom/public/idl/html/nsIDOMNSHTMLButtonElement.idl
index 90b1818e9e0..8107d49cf4a 100644
--- a/dom/public/idl/html/nsIDOMNSHTMLButtonElement.idl
+++ b/dom/public/idl/html/nsIDOMNSHTMLButtonElement.idl
@@ -45,4 +45,5 @@ interface nsIDOMNSHTMLButtonElement : nsISupports
{
void blur();
void focus();
+ void click();
};