Bug 124234. Active Accessibility: doDefaultAction not working on html buttons. r=jkeiser, sr=jst, a=asa

This commit is contained in:
aaronl%netscape.com 2002-04-05 23:49:42 +00:00
Родитель 0498c1ecce
Коммит 837f42b949
3 изменённых файлов: 47 добавлений и 4 удалений

Просмотреть файл

@ -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<nsIDOMHTMLInputElement> 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<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mDOMNode));
if ( inputElement )
nsCOMPtr<nsIDOMNSHTMLButtonElement> buttonElement(do_QueryInterface(mDOMNode));
if ( buttonElement )
{
inputElement->Click();
buttonElement->Click();
return NS_OK;
}
return NS_ERROR_FAILURE;

Просмотреть файл

@ -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<nsIDocument> doc;
GetDocument(*getter_AddRefs(doc));
if (doc) {
PRInt32 numShells = doc->GetNumberOfShells();
nsCOMPtr<nsIPresContext> context;
for (PRInt32 count=0; count < numShells; count++) {
nsCOMPtr<nsIPresShell> 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)
{

Просмотреть файл

@ -45,4 +45,5 @@ interface nsIDOMNSHTMLButtonElement : nsISupports
{
void blur();
void focus();
void click();
};