<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[281556] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/281556">281556</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2021-08-25 09:38:23 -0700 (Wed, 25 Aug 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>AX: Return radiobuttons part of ad-hoc radiogroups from AX search queries
https://bugs.webkit.org/show_bug.cgi?id=229415

Patch by Tyler Wilcock <tyler_w@apple.com> on 2021-08-25
Reviewed by Chris Fleizach.

Source/WebCore:

Test: accessibility/mac/search-predicate-for-adhoc-radio-groups.html

Enable the ability for WebKit UI element accessibility searches to find
ad-hoc radiogroups. An ad-hoc radiogroup is a group of radiobuttons
connected only by `name` attribute, missing an appropriate role="radiogroup"
container.

* accessibility/AccessibilityObject.cpp:
(WebCore::Accessibility::isRadioButtonInDifferentAdhocGroup): Added.
(WebCore::Accessibility::isAccessibilityObjectSearchMatchAtIndex):
When searching for radiogroups, also return radiobuttons in different
ad-hoc radiogroups.

LayoutTests:

Add test to ensure WebKit UI element accessibility searches can find
ad-hoc radiogroups. An ad-hoc radiogroup is a group of radiobuttons
connected only by `name` attributes, missing an appropriate role="radiogroup"
container.

* accessibility/mac/search-predicate-for-adhoc-radio-groups-expected.txt: Added.
* accessibility/mac/search-predicate-for-adhoc-radio-groups.html: Added.
* platform/mac-wk1/TestExpectations: Skip new test due to lack of
AccessibilityUIElement::domIdentifier implementation.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk1TestExpectations">trunk/LayoutTests/platform/mac-wk1/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAccessibilityObjectcpp">trunk/Source/WebCore/accessibility/AccessibilityObject.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsaccessibilitymacsearchpredicateforadhocradiogroupsexpectedtxt">trunk/LayoutTests/accessibility/mac/search-predicate-for-adhoc-radio-groups-expected.txt</a></li>
<li><a href="#trunkLayoutTestsaccessibilitymacsearchpredicateforadhocradiogroupshtml">trunk/LayoutTests/accessibility/mac/search-predicate-for-adhoc-radio-groups.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (281555 => 281556)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2021-08-25 14:49:34 UTC (rev 281555)
+++ trunk/LayoutTests/ChangeLog 2021-08-25 16:38:23 UTC (rev 281556)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2021-08-25  Tyler Wilcock  <tyler_w@apple.com>
+
+        AX: Return radiobuttons part of ad-hoc radiogroups from AX search queries
+        https://bugs.webkit.org/show_bug.cgi?id=229415
+
+        Reviewed by Chris Fleizach.
+
+        Add test to ensure WebKit UI element accessibility searches can find
+        ad-hoc radiogroups. An ad-hoc radiogroup is a group of radiobuttons
+        connected only by `name` attributes, missing an appropriate role="radiogroup"
+        container.
+
+        * accessibility/mac/search-predicate-for-adhoc-radio-groups-expected.txt: Added.
+        * accessibility/mac/search-predicate-for-adhoc-radio-groups.html: Added.
+        * platform/mac-wk1/TestExpectations: Skip new test due to lack of
+        AccessibilityUIElement::domIdentifier implementation.
+
</ins><span class="cx"> 2021-08-25  Arcady Goldmints-Orlov  <agoldmints@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         [GLIB] Mark wide gamut canvas tests as unsupported
</span></span></pre></div>
<a id="trunkLayoutTestsaccessibilitymacsearchpredicateforadhocradiogroupsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/accessibility/mac/search-predicate-for-adhoc-radio-groups-expected.txt (0 => 281556)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/accessibility/mac/search-predicate-for-adhoc-radio-groups-expected.txt                         (rev 0)
+++ trunk/LayoutTests/accessibility/mac/search-predicate-for-adhoc-radio-groups-expected.txt    2021-08-25 16:38:23 UTC (rev 281556)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+This test ensures WebKit can search for ad-hoc radiogroups. An ad-hoc radiogroup is a set of radiobuttons connected by `name` attribute alone, without an appropriate `role="radiogroup"` container.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS resultElement.role is 'AXRole: AXRadioButton'
+PASS resultElement.domIdentifier is 'circle'
+PASS resultElement.role is 'AXRole: AXRadioButton'
+PASS resultElement.domIdentifier is 'red'
+PASS resultElement.role is 'AXRole: AXRadioButton'
+PASS resultElement.domIdentifier is 'small'
+PASS resultElement.role is 'AXRole: AXRadioButton'
+PASS resultElement.domIdentifier is 'green'
+PASS resultElement.role is 'AXRole: AXRadioButton'
+PASS resultElement.domIdentifier is 'triangle'
+PASS resultElement.role is 'AXRole: AXRadioButton'
+PASS resultElement.domIdentifier is 'red'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Shape
+
+ Circle
+ Square
+ Triangle
+Color
+
+ Red
+ Blue
+ Green
+Size
+
+ Small
+Unrelated content separating ad-hoc radio group items
+
+ Medium
+Unrelated content separating ad-hoc radio group items
+
+ Large
</ins></span></pre></div>
<a id="trunkLayoutTestsaccessibilitymacsearchpredicateforadhocradiogroupshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/accessibility/mac/search-predicate-for-adhoc-radio-groups.html (0 => 281556)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/accessibility/mac/search-predicate-for-adhoc-radio-groups.html                         (rev 0)
+++ trunk/LayoutTests/accessibility/mac/search-predicate-for-adhoc-radio-groups.html    2021-08-25 16:38:23 UTC (rev 281556)
</span><span class="lines">@@ -0,0 +1,102 @@
</span><ins>+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test.js"></script>
+<script src="../../resources/accessibility-helper.js"></script>
+</head>
+<body id="body" role="group">
+    
+<p>Shape</p>
+<div>
+  <input type="radio" id="circle" name="shape" value="circle">
+  <label for="circle">Circle</label>
+</div>
+
+<div>
+  <input type="radio" id="square" name="shape" value="square">
+  <label for="square">Square</label>
+</div>
+
+<div>
+  <input type="radio" id="triangle" name="shape" value="triangle">
+  <label for="triangle">Triangle</label>
+</div>
+
+<p>Color</p>
+<div>
+  <input type="radio" id="red" name="color" value="red">
+  <label for="red">Red</label>
+</div>
+
+<div>
+  <input type="radio" id="blue" name="color" value="blue">
+  <label for="blue">Blue</label>
+</div>
+
+<div>
+  <input type="radio" id="green" name="color" value="green">
+  <label for="green">Green</label>
+</div>
+
+<p>Size</p>
+<div>
+  <input type="radio" id="small" name="size" value="small">
+  <label for="small">Small</label>
+</div>
+
+<p>
+  Unrelated content separating ad-hoc radio group items
+</p>
+
+<div>
+  <input type="radio" id="medium" name="size" value="medium">
+  <label for="medium">Medium</label>
+</div>
+
+<p>
+  Unrelated content separating ad-hoc radio group items
+</p>
+
+<div>
+  <input type="radio" id="large" name="size" value="large">
+  <label for="large">Large</label>
+</div>
+
+<script>
+    description("This test ensures WebKit can search for ad-hoc radiogroups. An ad-hoc radiogroup is a set of radiobuttons connected by `name` attribute alone, without an appropriate `role=\"radiogroup\"` container.")
+
+    if (window.accessibilityController) {
+        window.containerElement = accessibilityController.accessibleElementById("body");
+        
+        startElement = containerElement.childAtIndex(0);
+        startElement = resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXRadioGroupSearchKey", "", false);
+        shouldBe("resultElement.role", "'AXRole: AXRadioButton'");
+        shouldBe("resultElement.domIdentifier", "'circle'");
+        
+        startElement = resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXRadioGroupSearchKey", "", false);
+        shouldBe("resultElement.role", "'AXRole: AXRadioButton'");
+        shouldBe("resultElement.domIdentifier", "'red'");
+        
+        startElement = resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXRadioGroupSearchKey", "", false);
+        shouldBe("resultElement.role", "'AXRole: AXRadioButton'");
+        shouldBe("resultElement.domIdentifier", "'small'");
+        
+        // Now search backwards up the ad-hoc radiogroups.
+        
+        startElement = resultElement = containerElement.uiElementForSearchPredicate(startElement, false, "AXRadioGroupSearchKey", "", false);
+        shouldBe("resultElement.role", "'AXRole: AXRadioButton'");
+        shouldBe("resultElement.domIdentifier", "'green'");
+        
+        startElement = resultElement = containerElement.uiElementForSearchPredicate(startElement, false, "AXRadioGroupSearchKey", "", false);
+        shouldBe("resultElement.role", "'AXRole: AXRadioButton'");
+        shouldBe("resultElement.domIdentifier", "'triangle'");
+        
+        // And finally search forward once more.
+        
+        startElement = resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXRadioGroupSearchKey", "", false, false);
+        shouldBe("resultElement.role", "'AXRole: AXRadioButton'");
+        shouldBe("resultElement.domIdentifier", "'red'");
+    }
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (281555 => 281556)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/TestExpectations      2021-08-25 14:49:34 UTC (rev 281555)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations 2021-08-25 16:38:23 UTC (rev 281556)
</span><span class="lines">@@ -566,6 +566,9 @@
</span><span class="cx"> editing/spelling/spellcheck-async.html [ Failure ]
</span><span class="cx"> editing/spelling/spelling-unified-emulation.html [ Failure ]
</span><span class="cx"> 
</span><ins>+# Skip due to lack of DumpRenderTree `AccessibilityUIElement::domIdentifer` implementation.
+accessibility/mac/search-predicate-for-adhoc-radio-groups.html [ Skip ]
+
</ins><span class="cx"> # <rdar://problem/26050923> The result is probably still a pass, but we don't have a way
</span><span class="cx"> # to have platform specific results that are different between WK1 and WK2.
</span><span class="cx"> accessibility/mac/document-attributes.html [ Failure ]
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (281555 => 281556)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-08-25 14:49:34 UTC (rev 281555)
+++ trunk/Source/WebCore/ChangeLog      2021-08-25 16:38:23 UTC (rev 281556)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2021-08-25  Tyler Wilcock  <tyler_w@apple.com>
+
+        AX: Return radiobuttons part of ad-hoc radiogroups from AX search queries
+        https://bugs.webkit.org/show_bug.cgi?id=229415
+
+        Reviewed by Chris Fleizach.
+
+        Test: accessibility/mac/search-predicate-for-adhoc-radio-groups.html
+
+        Enable the ability for WebKit UI element accessibility searches to find
+        ad-hoc radiogroups. An ad-hoc radiogroup is a group of radiobuttons
+        connected only by `name` attribute, missing an appropriate role="radiogroup"
+        container.
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::Accessibility::isRadioButtonInDifferentAdhocGroup): Added.
+        (WebCore::Accessibility::isAccessibilityObjectSearchMatchAtIndex):
+        When searching for radiogroups, also return radiobuttons in different
+        ad-hoc radiogroups.
+
</ins><span class="cx"> 2021-08-25  Kate Cheney  <katherine_cheney@apple.com>
</span><span class="cx"> 
</span><span class="cx">         WebCrypto uses deprecated CCKeyDerivationHMac
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAccessibilityObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (281555 => 281556)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp       2021-08-25 14:49:34 UTC (rev 281555)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp  2021-08-25 16:38:23 UTC (rev 281556)
</span><span class="lines">@@ -3639,6 +3639,21 @@
</span><span class="cx">     return roleMap->get(static_cast<unsigned>(role));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// This function determines if the given `axObject` is a radio button part of a different ad-hoc radio group
+// than `referenceObject`, where ad-hoc radio group membership is determined by comparing `name` attributes.
+static bool isRadioButtonInDifferentAdhocGroup(AXCoreObject* axObject, AXCoreObject* referenceObject)
+{
+    if (!axObject || !axObject->isRadioButton())
+        return false;
+
+    // If the `referenceObject` is not a radio button and this `axObject` is, their radio group membership is different because
+    // `axObject` belongs to a group and `referenceObject` doesn't.
+    if (!referenceObject || !referenceObject->isRadioButton())
+        return true;
+
+    return axObject->element()->getNameAttribute() != referenceObject->element()->getNameAttribute();
+}
+
</ins><span class="cx"> static bool isAccessibilityObjectSearchMatchAtIndex(AXCoreObject* axObject, AccessibilitySearchCriteria const& criteria, size_t index)
</span><span class="cx"> {
</span><span class="cx">     switch (criteria.searchKeys[index]) {
</span><span class="lines">@@ -3719,7 +3734,7 @@
</span><span class="cx">     case AccessibilitySearchKey::PlainText:
</span><span class="cx">         return axObject->hasPlainText();
</span><span class="cx">     case AccessibilitySearchKey::RadioGroup:
</span><del>-        return axObject->isRadioGroup();
</del><ins>+        return axObject->isRadioGroup() || isRadioButtonInDifferentAdhocGroup(axObject, criteria.startObject);
</ins><span class="cx">     case AccessibilitySearchKey::SameType:
</span><span class="cx">         return criteria.startObject
</span><span class="cx">             && axObject->roleValue() == criteria.startObject->roleValue();
</span></span></pre>
</div>
</div>

</body>
</html>