Bug 847233 - Fix a11y with <input type='file'> changes. r=surkov

This commit is contained in:
Mounir Lamouri 2013-03-27 11:35:22 +00:00
parent 598ed4adc1
commit 815d90f4bf
7 changed files with 20 additions and 46 deletions

View File

@ -369,25 +369,6 @@ HTMLTextFieldAccessible::ApplyARIAState(uint64_t* aState) const
aria::MapToState(aria::eARIAAutoComplete, mContent->AsElement(), aState);
}
uint64_t
HTMLTextFieldAccessible::State()
{
uint64_t state = HyperTextAccessibleWrap::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()) {
uint64_t parentState = mParent->State();
state |= parentState & (states::BUSY | states::REQUIRED |
states::HASPOPUP | states::INVALID);
}
return state;
}
uint64_t
HTMLTextFieldAccessible::NativeState()
{
@ -555,24 +536,17 @@ HTMLFileInputAccessible::HandleAccEvent(AccEvent* aEvent)
event->GetState() == states::REQUIRED ||
event->GetState() == states::HASPOPUP ||
event->GetState() == states::INVALID)) {
Accessible* input = GetChildAt(0);
if (input && input->Role() == roles::ENTRY) {
nsRefPtr<AccStateChangeEvent> childEvent =
new AccStateChangeEvent(input, event->GetState(),
event->IsStateEnabled(),
(event->IsFromUserInput() ? eFromUserInput : eNoUserInput));
nsEventShell::FireEvent(childEvent);
}
Accessible* button = GetChildAt(1);
Accessible* button = GetChildAt(0);
if (button && button->Role() == roles::PUSHBUTTON) {
nsRefPtr<AccStateChangeEvent> childEvent =
new AccStateChangeEvent(button, event->GetState(),
event->IsStateEnabled(),
(event->IsFromUserInput() ? eFromUserInput : eNoUserInput));
(event->IsFromUserInput() ? eFromUserInput
: eNoUserInput));
nsEventShell::FireEvent(childEvent);
}
}
return NS_OK;
}

View File

@ -117,7 +117,6 @@ public:
virtual void Value(nsString& aValue);
virtual void ApplyARIAState(uint64_t* aState) const;
virtual mozilla::a11y::role NativeRole();
virtual uint64_t State();
virtual uint64_t NativeState();
// ActionAccessible

View File

@ -77,8 +77,8 @@
{
this.fileControlNode = getNode(aID);
this.fileControl = getAccessible(this.fileControlNode);
this.textEntry = this.fileControl.firstChild;
this.browseButton = this.fileControl.lastChild;
this.browseButton = this.fileControl.firstChild;
// No state change events on the label.
this.invoke = function stateChangeOnFileInput_invoke()
{
@ -87,7 +87,6 @@
this.eventSeq = [
new stateChangeChecker(aState, aIsExtraState, aIsEnabled, this.fileControl),
new stateChangeChecker(aState, aIsExtraState, aIsEnabled, this.textEntry),
new stateChangeChecker(aState, aIsExtraState, aIsEnabled, this.browseButton)
];

View File

@ -132,12 +132,10 @@
testStates("as_item2", 0, 0, 0, EXT_STATE_ACTIVE);
// universal ARIA properties inherited from file input control
var fileTextField = getAccessible("fileinput").firstChild;
testStates(fileTextField,
STATE_BUSY | STATE_UNAVAILABLE | STATE_REQUIRED | STATE_HASPOPUP | STATE_INVALID);
var fileBrowseButton = getAccessible("fileinput").lastChild;
var fileBrowseButton = getAccessible("fileinput").firstChild;
testStates(fileBrowseButton,
STATE_BUSY | STATE_UNAVAILABLE | STATE_REQUIRED | STATE_HASPOPUP | STATE_INVALID);
// No states on the label.
// offscreen test
testStates("aria_offscreen_textbox", STATE_OFFSCREEN);

View File

@ -67,10 +67,9 @@
////////////////////////////////////////////////////////////////////////////
// inherited from file control
var fileTextField = getAccessible("file").firstChild;
testStates(fileTextField, STATE_UNAVAILABLE | STATE_REQUIRED);
var fileBrowseButton = getAccessible("file").lastChild;
var fileBrowseButton = getAccessible("file").firstChild;
testStates(fileBrowseButton, STATE_UNAVAILABLE | STATE_REQUIRED);
// No states on the label.
////////////////////////////////////////////////////////////////////////////
// 'invalid' state

View File

@ -22,11 +22,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=483573
role: ROLE_TEXT_CONTAINER,
children: [
{
role: ROLE_ENTRY
role: ROLE_PUSHBUTTON
},
{
role: ROLE_PUSHBUTTON
}
role: ROLE_LABEL,
children: [
{
role: ROLE_TEXT_LEAF,
}
],
},
]
};
testAccessibleTree("filectrl", accTree);

View File

@ -90,8 +90,8 @@ nsFileControlFrame::DestroyFrom(nsIFrame* aDestructRoot)
mMouseListener, false);
}
nsContentUtils::DestroyAnonymousContent(&mBrowse);
nsContentUtils::DestroyAnonymousContent(&mTextContent);
nsContentUtils::DestroyAnonymousContent(&mBrowse);
mMouseListener->ForgetFrame();
nsBlockFrame::DestroyFrom(aDestructRoot);
@ -171,8 +171,8 @@ void
nsFileControlFrame::AppendAnonymousContentTo(nsBaseContentList& aElements,
uint32_t aFilter)
{
aElements.MaybeAppendElement(mTextContent);
aElements.MaybeAppendElement(mBrowse);
aElements.MaybeAppendElement(mTextContent);
}
NS_QUERYFRAME_HEAD(nsFileControlFrame)