Skip to content

Commit 1b99540

Browse files
AX: Radio button members are not identified together in all cases
https://bugs.webkit.org/show_bug.cgi?id=155604 <rdar://problem/21186992> Reviewed by Darin Adler. Source/WebCore: Allow aria radio buttons to be grouped together as linked ui elements even if they're not input types of radio button. Modified test: accessibility/radio-button-group-members.html * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::speakProperty): (WebCore::AccessibilityRenderObject::addRadioButtonGroupChildren): (WebCore::AccessibilityRenderObject::addRadioButtonGroupMembers): * accessibility/AccessibilityRenderObject.h: LayoutTests: * accessibility/mac/radio-button-group-members-expected.txt: Added. * accessibility/radio-button-group-members.html: * platform/mac/accessibility/radio-button-group-members-expected.txt: Removed. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@198474 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 5b4f8a8 commit 1b99540

File tree

6 files changed

+83
-16
lines changed

6 files changed

+83
-16
lines changed

LayoutTests/ChangeLog

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2016-03-20 Chris Fleizach <[email protected]>
2+
3+
AX: Radio button members are not identified together in all cases
4+
https://bugs.webkit.org/show_bug.cgi?id=155604
5+
<rdar://problem/21186992>
6+
7+
Reviewed by Darin Adler.
8+
9+
* accessibility/mac/radio-button-group-members-expected.txt: Added.
10+
* accessibility/radio-button-group-members.html:
11+
* platform/mac/accessibility/radio-button-group-members-expected.txt: Removed.
12+
113
2016-03-19 Skachkov Oleksandr <[email protected]>
214

315
[ES6] Arrow function syntax. Update syntax error text 'super is only valid inside functions' to more suitable

LayoutTests/platform/mac/accessibility/radio-button-group-members-expected.txt renamed to LayoutTests/accessibility/mac/radio-button-group-members-expected.txt

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ PASS test3.linkedUIElementAtIndex(1).isEqual(accessibilityController.accessibleE
3939
Radio buttons not in a groups should not have siblings (the first linked element is itself)
4040
PASS test4.linkedUIElementAtIndex(0).isEqual(test4) is true
4141
PASS !test4.linkedUIElementAtIndex(1) || !test4.linkedUIElementAtIndex(1).isValid is true
42+
43+
44+
Radio buttons that just have aria roles should work.
45+
PASS ariaRadio1.linkedUIElementAtIndex(0).isEqual(ariaRadio1) is true
46+
PASS ariaRadio1.linkedUIElementAtIndex(1).isEqual(ariaRadio2) is true
4247
PASS successfullyParsed is true
4348

4449
TEST COMPLETE

LayoutTests/accessibility/radio-button-group-members.html

+16
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@
3535
</form>
3636
<br><br>
3737

38+
<!-- Test radiogroup parentage -->
39+
<div class="radiogroup" role="radiogroup" id="radiogroup">
40+
<div>
41+
<div role="radio" id="ariaradio1" aria-checked="true">Radio 1</div>
42+
<div role="radio" id="ariaradio2" aria-checked="false">Radio 2</div>
43+
<div role="radio" aria-checked="false">Radio 3</div>
44+
</div>
45+
</div>
46+
3847
</div>
3948

4049
<p id="description"></p>
@@ -69,6 +78,13 @@
6978
var test4 = accessibilityController.accessibleElementById("test4_Yes");
7079
shouldBeTrue("test4.linkedUIElementAtIndex(0).isEqual(test4)");
7180
shouldBeTrue("!test4.linkedUIElementAtIndex(1) || !test4.linkedUIElementAtIndex(1).isValid");
81+
debug("\n");
82+
83+
debug("Radio buttons that just have aria roles should work.");
84+
var ariaRadio1 = accessibilityController.accessibleElementById("ariaradio1");
85+
var ariaRadio2 = accessibilityController.accessibleElementById("ariaradio2");
86+
shouldBeTrue("ariaRadio1.linkedUIElementAtIndex(0).isEqual(ariaRadio1)");
87+
shouldBeTrue("ariaRadio1.linkedUIElementAtIndex(1).isEqual(ariaRadio2)");
7288

7389
document.getElementById("content").style.visibility = "hidden";
7490
}

Source/WebCore/ChangeLog

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
2016-03-20 Chris Fleizach <[email protected]>
2+
3+
AX: Radio button members are not identified together in all cases
4+
https://bugs.webkit.org/show_bug.cgi?id=155604
5+
<rdar://problem/21186992>
6+
7+
Reviewed by Darin Adler.
8+
9+
Allow aria radio buttons to be grouped together as linked ui elements even if they're not input types of radio button.
10+
11+
Modified test: accessibility/radio-button-group-members.html
12+
13+
* accessibility/AccessibilityRenderObject.cpp:
14+
(WebCore::AccessibilityRenderObject::speakProperty):
15+
(WebCore::AccessibilityRenderObject::addRadioButtonGroupChildren):
16+
(WebCore::AccessibilityRenderObject::addRadioButtonGroupMembers):
17+
* accessibility/AccessibilityRenderObject.h:
18+
119
2016-03-19 Joonghun Park <[email protected]>
220

321
Purge PassRefPtr from WebCore/html/shadow

Source/WebCore/accessibility/AccessibilityRenderObject.cpp

+31-16
Original file line numberDiff line numberDiff line change
@@ -949,28 +949,43 @@ ESpeak AccessibilityRenderObject::speakProperty() const
949949
return m_renderer->style().speak();
950950
}
951951

952-
void AccessibilityRenderObject::addRadioButtonGroupMembers(AccessibilityChildrenVector& linkedUIElements) const
952+
void AccessibilityRenderObject::addRadioButtonGroupChildren(AccessibilityObject* parent, AccessibilityChildrenVector& linkedUIElements) const
953953
{
954-
if (!m_renderer || roleValue() != RadioButtonRole)
955-
return;
954+
for (const auto& child : parent->children()) {
955+
if (child->roleValue() == RadioButtonRole)
956+
linkedUIElements.append(child);
957+
else
958+
addRadioButtonGroupChildren(child.get(), linkedUIElements);
959+
}
960+
}
956961

957-
Node* node = m_renderer->node();
958-
if (!is<HTMLInputElement>(node))
962+
void AccessibilityRenderObject::addRadioButtonGroupMembers(AccessibilityChildrenVector& linkedUIElements) const
963+
{
964+
if (roleValue() != RadioButtonRole)
959965
return;
960966

961-
HTMLInputElement& input = downcast<HTMLInputElement>(*node);
962-
// if there's a form, then this is easy
963-
if (input.form()) {
964-
for (auto& associateElement : input.form()->namedElements(input.name())) {
965-
if (AccessibilityObject* object = axObjectCache()->getOrCreate(&associateElement.get()))
966-
linkedUIElements.append(object);
967-
}
968-
} else {
969-
for (auto& associateElement : descendantsOfType<HTMLInputElement>(node->document())) {
970-
if (associateElement.isRadioButton() && associateElement.name() == input.name()) {
971-
if (AccessibilityObject* object = axObjectCache()->getOrCreate(&associateElement))
967+
Node* node = this->node();
968+
if (is<HTMLInputElement>(node)) {
969+
HTMLInputElement& input = downcast<HTMLInputElement>(*node);
970+
// if there's a form, then this is easy
971+
if (input.form()) {
972+
for (auto& associateElement : input.form()->namedElements(input.name())) {
973+
if (AccessibilityObject* object = axObjectCache()->getOrCreate(&associateElement.get()))
972974
linkedUIElements.append(object);
973975
}
976+
} else {
977+
for (auto& associateElement : descendantsOfType<HTMLInputElement>(node->document())) {
978+
if (associateElement.isRadioButton() && associateElement.name() == input.name()) {
979+
if (AccessibilityObject* object = axObjectCache()->getOrCreate(&associateElement))
980+
linkedUIElements.append(object);
981+
}
982+
}
983+
}
984+
} else {
985+
// If we didn't find any radio button siblings with the traditional naming, lets search for a radio group role and find its children.
986+
for (AccessibilityObject* parent = parentObject(); parent; parent = parent->parentObject()) {
987+
if (parent->roleValue() == RadioGroupRole)
988+
addRadioButtonGroupChildren(parent, linkedUIElements);
974989
}
975990
}
976991
}

Source/WebCore/accessibility/AccessibilityRenderObject.h

+1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ class AccessibilityRenderObject : public AccessibilityNodeObject {
235235
bool isTabItemSelected() const;
236236
LayoutRect checkboxOrRadioRect() const;
237237
void addRadioButtonGroupMembers(AccessibilityChildrenVector& linkedUIElements) const;
238+
void addRadioButtonGroupChildren(AccessibilityObject*, AccessibilityChildrenVector&) const;
238239
AccessibilityObject* internalLinkElement() const;
239240
AccessibilityObject* accessibilityImageMapHitTest(HTMLAreaElement*, const IntPoint&) const;
240241
AccessibilityObject* accessibilityParentForImageMap(HTMLMapElement*) const;

0 commit comments

Comments
 (0)