Bug 699017 - aria-required attribute on file input not read by JAWS, r=tbsaunde, marcoz, roc

This commit is contained in:
Alexander Surkov
2011-11-30 20:36:20 +08:00
parent 2149e480c2
commit 220eb40bbe
13 changed files with 225 additions and 20 deletions

View File

@@ -272,6 +272,25 @@ nsHTMLButtonAccessible::DoAction(PRUint8 aIndex)
return NS_OK;
}
PRUint64
nsHTMLButtonAccessible::State()
{
PRUint64 state = nsHyperTextAccessibleWrap::State();
if (state == states::DEFUNCT)
return state;
// Inherit states from input@type="file" suitable for the button. Note,
// no special processing for unavailable state since inheritance is supplied
// other code paths.
if (mParent && mParent->IsHTMLFileInput()) {
PRUint64 parentState = mParent->State();
state |= parentState & (states::BUSY | states::REQUIRED |
states::HASPOPUP | states::INVALID);
}
return state;
}
PRUint64
nsHTMLButtonAccessible::NativeState()
{
@@ -477,7 +496,25 @@ nsHTMLTextFieldAccessible::ApplyARIAState(PRUint64* aState)
nsHyperTextAccessibleWrap::ApplyARIAState(aState);
nsStateMapEntry::MapToStates(mContent, aState, eARIAAutoComplete);
}
PRUint64
nsHTMLTextFieldAccessible::State()
{
PRUint64 state = nsHyperTextAccessibleWrap::State();
if (state & states::DEFUNCT)
return state;
// Inherit states from input@type="file" suitable for the button. Note,
// no special processing for unavailable state since inheritance is supplied
// by other code paths.
if (mParent && mParent->IsHTMLFileInput()) {
PRUint64 parentState = mParent->State();
state |= parentState & (states::BUSY | states::REQUIRED |
states::HASPOPUP | states::INVALID);
}
return state;
}
PRUint64
@@ -612,6 +649,61 @@ nsHTMLTextFieldAccessible::ContainerWidget() const
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLGroupboxAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLFileInputAccessible::
nsHTMLFileInputAccessible(nsIContent* aContent, nsIWeakReference* aShell) :
nsHyperTextAccessibleWrap(aContent, aShell)
{
mFlags |= eHTMLFileInputAccessible;
}
PRUint32
nsHTMLFileInputAccessible::NativeRole()
{
// JAWS wants a text container, others don't mind. No specific role in
// AT APIs.
return nsIAccessibleRole::ROLE_TEXT_CONTAINER;
}
nsresult
nsHTMLFileInputAccessible::HandleAccEvent(AccEvent* aEvent)
{
nsresult rv = nsHyperTextAccessibleWrap::HandleAccEvent(aEvent);
NS_ENSURE_SUCCESS(rv, rv);
// Redirect state change events for inherited states to child controls. Note,
// unavailable state is not redirected. That's a standard for unavailable
// state handling.
AccStateChangeEvent* event = downcast_accEvent(aEvent);
if (event &&
(event->GetState() == states::BUSY ||
event->GetState() == states::REQUIRED ||
event->GetState() == states::HASPOPUP ||
event->GetState() == states::INVALID)) {
nsAccessible* input = GetChildAt(0);
if (input && input->Role() == nsIAccessibleRole::ROLE_ENTRY) {
nsRefPtr<AccStateChangeEvent> childEvent =
new AccStateChangeEvent(input, event->GetState(),
event->IsStateEnabled(),
(event->IsFromUserInput() ? eFromUserInput : eNoUserInput));
nsEventShell::FireEvent(childEvent);
}
nsAccessible* button = GetChildAt(1);
if (button && button->Role() == nsIAccessibleRole::ROLE_PUSHBUTTON) {
nsRefPtr<AccStateChangeEvent> childEvent =
new AccStateChangeEvent(button, event->GetState(),
event->IsStateEnabled(),
(event->IsFromUserInput() ? eFromUserInput : eNoUserInput));
nsEventShell::FireEvent(childEvent);
}
}
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLGroupboxAccessible
////////////////////////////////////////////////////////////////////////////////