зеркало из https://github.com/mozilla/gecko-dev.git
Bug 819273 - ARIA combobox should have accessible value, r=tbsaunde
This commit is contained in:
Родитель
ec1be4c9ac
Коммит
beb64f76b4
|
@ -249,7 +249,7 @@ static nsRoleMapEntry sWAIRoleMaps[] =
|
|||
eNoValue,
|
||||
eNoAction,
|
||||
eNoLiveAttr,
|
||||
eSelect,
|
||||
eListControl | eSelect,
|
||||
kNoReqStates,
|
||||
eARIAMultiSelectable,
|
||||
eARIAReadonly
|
||||
|
|
|
@ -804,7 +804,7 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
|
|||
newAcc = new ARIAGridCellAccessibleWrap(content, document);
|
||||
}
|
||||
|
||||
} else if ((roleMapEntry->accTypes & eTable) &&
|
||||
} else if ((roleMapEntry->IsOfType(eTable)) &&
|
||||
frame->AccessibleType() != eHTMLTableType) {
|
||||
newAcc = new ARIAGridAccessibleWrap(content, document);
|
||||
}
|
||||
|
@ -824,7 +824,7 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
|
|||
if (!roleMapEntry && newAcc) {
|
||||
if (frame->AccessibleType() == eHTMLTableRowType) {
|
||||
nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
|
||||
if (contextRoleMap && !(contextRoleMap->accTypes & eTable))
|
||||
if (contextRoleMap && !(contextRoleMap->IsOfType(eTable)))
|
||||
roleMapEntry = &nsARIAMap::gEmptyRoleMap;
|
||||
|
||||
} else if (frame->AccessibleType() == eHTMLTableCellType &&
|
||||
|
@ -836,7 +836,7 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
|
|||
content->Tag() == nsGkAtoms::dd ||
|
||||
frame->AccessibleType() == eHTMLLiType) {
|
||||
nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
|
||||
if (contextRoleMap && !(contextRoleMap->accTypes & eList))
|
||||
if (contextRoleMap && !(contextRoleMap->IsOfType(eList)))
|
||||
roleMapEntry = &nsARIAMap::gEmptyRoleMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1589,17 +1589,44 @@ Accessible::GetValue(nsAString& aValue)
|
|||
void
|
||||
Accessible::Value(nsString& aValue)
|
||||
{
|
||||
if (mRoleMapEntry) {
|
||||
if (mRoleMapEntry->valueRule == eNoValue)
|
||||
return;
|
||||
if (!mRoleMapEntry)
|
||||
return;
|
||||
|
||||
// aria-valuenow is a number, and aria-valuetext is the optional text equivalent
|
||||
// For the string value, we will try the optional text equivalent first
|
||||
if (mRoleMapEntry->valueRule != eNoValue) {
|
||||
// aria-valuenow is a number, and aria-valuetext is the optional text
|
||||
// equivalent. For the string value, we will try the optional text
|
||||
// equivalent first.
|
||||
if (!mContent->GetAttr(kNameSpaceID_None,
|
||||
nsGkAtoms::aria_valuetext, aValue)) {
|
||||
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::aria_valuenow,
|
||||
aValue);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Value of combobox is a text of current or selected item.
|
||||
if (mRoleMapEntry->Is(nsGkAtoms::combobox)) {
|
||||
Accessible* option = CurrentItem();
|
||||
if (!option) {
|
||||
Accessible* listbox = nullptr;
|
||||
IDRefsIterator iter(mDoc, mContent, nsGkAtoms::aria_owns);
|
||||
while ((listbox = iter.Next()) && !listbox->IsListControl());
|
||||
|
||||
if (!listbox) {
|
||||
uint32_t childCount = ChildCount();
|
||||
for (uint32_t idx = 0; idx < childCount; idx++) {
|
||||
Accessible* child = mChildren.ElementAt(idx);
|
||||
if (child->IsListControl())
|
||||
listbox = child;
|
||||
}
|
||||
}
|
||||
|
||||
if (listbox)
|
||||
option = listbox->GetSelectedItem(0);
|
||||
}
|
||||
|
||||
if (option)
|
||||
nsTextEquivUtils::GetNameFromSubtree(option, aValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -358,7 +358,7 @@ HTMLTextFieldAccessible::Value(nsString& aValue)
|
|||
textArea->GetValue(aValue);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
nsHTMLInputElement* input = nsHTMLInputElement::FromContent(mContent);
|
||||
if (input)
|
||||
input->GetValue(aValue);
|
||||
|
|
|
@ -50,6 +50,21 @@
|
|||
testValue("aria_main_link", href);
|
||||
testValue("aria_navigation_link", href);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ARIA comboboxes
|
||||
|
||||
// aria-activedescendant defines a current item the value is computed from
|
||||
testValue("aria_combobox1", kDiscBulletText + "Zoom");
|
||||
|
||||
// aria-selected defines a selected item the value is computed from,
|
||||
// list control is pointed by aria-owns relation.
|
||||
testValue("aria_combobox2", kDiscBulletText + "Zoom");
|
||||
|
||||
// aria-selected defines a selected item the value is computed from,
|
||||
// list control is a child of combobox.
|
||||
testValue("aria_combobox3", kDiscBulletText + "2");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// HTML controls
|
||||
testValue("combobox1", "item1");
|
||||
testValue("combobox2", "item2");
|
||||
|
@ -69,7 +84,12 @@
|
|||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=494807"
|
||||
title="Do not expose a11y info specific to hyperlinks when role is overridden using ARIA">
|
||||
Mozilla Bug 494807
|
||||
</a><br />
|
||||
</a>
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=819273"
|
||||
title=" ARIA combobox should have accessible value">
|
||||
Mozilla Bug 819273
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
|
@ -88,6 +108,32 @@
|
|||
<!-- strange edge case: please don't do this in the wild -->
|
||||
<a id="aria_link_link" role="link" href="foo">link</a>
|
||||
|
||||
<div id="aria_combobox1" role="combobox"
|
||||
aria-owns="aria_combobox1_owned_listbox"
|
||||
aria-activedescendant="aria_combobox1_selected_option">
|
||||
</div>
|
||||
<ul role="listbox" id="aria_combobox1_owned_listbox">
|
||||
<li role="option">Zebra</li>
|
||||
<li role="option" id="aria_combobox1_selected_option">Zoom</li>
|
||||
</ul>
|
||||
|
||||
<div id="aria_combobox2" role="combobox"
|
||||
aria-owns="aria_combobox2_owned_listbox">
|
||||
</div>
|
||||
<ul role="listbox" id="aria_combobox2_owned_listbox">
|
||||
<li role="option">Zebra</li>
|
||||
<li role="option" aria-selected="true">Zoom</li>
|
||||
</ul>
|
||||
|
||||
<div id="aria_combobox3" role="combobox">
|
||||
<div role="textbox"></div>
|
||||
<ul role="listbox">
|
||||
<li role="option">1</li>
|
||||
<li role="option" aria-selected="true">2</li>
|
||||
<li role="option">3</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<select id="combobox1">
|
||||
<option id="cb1_item1">item1</option>
|
||||
<option id="cb1_item2">item2</option>
|
||||
|
|
Загрузка…
Ссылка в новой задаче