Bug 194980 Accessible state change events no longer fired for checkboxes and radios

r=aaronl, sr=henry.jia
rewrite nsHTMLInputElement::FireEventForAccessibility() function
This commit is contained in:
kyle.yuan%sun.com 2003-03-05 03:20:17 +00:00
Родитель 7f71c61b64
Коммит 69dac37f2b
2 изменённых файлов: 14 добавлений и 46 удалений

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

@ -580,15 +580,6 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
else if (eventType.EqualsIgnoreCase("change")) {
if (selectElement) // it's a HTML <select>
HandleEvent(nsIAccessibleEventListener::EVENT_ATK_SELECTION_CHANGE, accessible, nsnull);
else {
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(targetNode));
if (inputElement) { // it's a HTML <input>
accessible->GetAccState(&stateData.state);
stateData.enable = (stateData.state & STATE_CHECKED) != 0;
stateData.state = STATE_CHECKED;
HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, accessible, &stateData);
}
}
}
else if (eventType.EqualsIgnoreCase("select")) {
if (selectControl) // it's a XUL <listbox>

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

@ -2171,43 +2171,20 @@ nsresult
nsHTMLInputElement::FireEventForAccessibility(nsIPresContext* aPresContext,
const nsAString& aEventType)
{
nsCOMPtr<nsIEventListenerManager> listenerManager;
nsresult rv = GetListenerManager(getter_AddRefs(listenerManager));
if ( !listenerManager )
return rv;
// Create the DOM event
nsCOMPtr<nsIDOMEvent> domEvent;
rv = listenerManager->CreateEvent(aPresContext,
nsnull,
NS_LITERAL_STRING("MutationEvents"),
getter_AddRefs(domEvent) );
if ( !domEvent )
return NS_ERROR_FAILURE;
// Initialize the mutation event
nsCOMPtr<nsIDOMMutationEvent> mutEvent(do_QueryInterface(domEvent));
if ( !mutEvent )
return NS_ERROR_FAILURE;
nsAutoString empty;
mutEvent->InitMutationEvent( aEventType, PR_TRUE, PR_TRUE, nsnull, empty, empty, empty, nsIDOMMutationEvent::MODIFICATION);
// Set the target of the event to this nsHTMLInputElement, which should be checkbox content??
nsCOMPtr<nsIPrivateDOMEvent> privEvent(do_QueryInterface(domEvent));
if ( ! privEvent )
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMEventTarget> targ(do_QueryInterface(NS_STATIC_CAST(nsIDOMHTMLInputElement *, this)));
if ( ! targ )
return NS_ERROR_FAILURE;
privEvent->SetTarget(targ);
// Dispatch the event
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(listenerManager));
if ( ! eventReceiver )
return NS_ERROR_FAILURE;
PRBool noDefault;
eventReceiver->DispatchEvent(domEvent, &noDefault);
nsCOMPtr<nsIDOMEvent> event;
nsCOMPtr<nsIEventListenerManager> manager;
nsresult rv = GetListenerManager(getter_AddRefs(manager));
if (manager &&
NS_SUCCEEDED(manager->CreateEvent(aPresContext, nsnull, NS_LITERAL_STRING("Events"), getter_AddRefs(event)))) {
event->InitEvent(aEventType, PR_TRUE, PR_TRUE);
PRBool noDefault;
nsCOMPtr<nsIEventStateManager> esm;
aPresContext->GetEventStateManager(getter_AddRefs(esm));
if (esm) {
nsCOMPtr<nsISupports> target(do_QueryInterface(NS_STATIC_CAST(nsIDOMHTMLInputElement *, this)));
esm->DispatchNewEvent(target, event, &noDefault);
}
}
return NS_OK;
}