<!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>[244029] 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/244029">244029</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2019-04-08 11:09:33 -0700 (Mon, 08 Apr 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>AX: <svg> elements with labels and no accessible contents are exposed as empty AXGroups
https://bugs.webkit.org/show_bug.cgi?id=156774

Patch by Eric Liang <ericliang@apple.com> on 2019-04-08
Reviewed by Chris Fleizach.

Source/WebCore:

Labelled SVGs without accessible descendants are exposed as AXImage rather than groups.

Unlabelled equivalents are not exposed. Otherwise, SVGs with accessible descendants are exposed as AXGroup.
Also added back functionalities from last patch of determining whether a SVG element should be ignored.

Test: accessibility/svg-shape-labelled.html

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::updateRoleAfterChildrenCreation):
* accessibility/AccessibilitySVGElement.cpp:
(WebCore::AccessibilitySVGElement::computeAccessibilityIsIgnored const):

LayoutTests:

Added tests that verify svgs shapes that are labelled are exposed as images.
* accessibility/resources/apple-logo.svg: Added.
* accessibility/svg-shape-labelled-expected.txt: Added.
* accessibility/svg-shape-labelled.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAccessibilityRenderObjectcpp">trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAccessibilitySVGElementcpp">trunk/Source/WebCore/accessibility/AccessibilitySVGElement.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsaccessibilityresourcesapplelogosvg">trunk/LayoutTests/accessibility/resources/apple-logo.svg</a></li>
<li><a href="#trunkLayoutTestsaccessibilitysvgshapelabelledexpectedtxt">trunk/LayoutTests/accessibility/svg-shape-labelled-expected.txt</a></li>
<li><a href="#trunkLayoutTestsaccessibilitysvgshapelabelledhtml">trunk/LayoutTests/accessibility/svg-shape-labelled.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (244028 => 244029)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2019-04-08 18:01:42 UTC (rev 244028)
+++ trunk/LayoutTests/ChangeLog 2019-04-08 18:09:33 UTC (rev 244029)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2019-04-08  Eric Liang  <ericliang@apple.com>
+
+        AX: <svg> elements with labels and no accessible contents are exposed as empty AXGroups
+        https://bugs.webkit.org/show_bug.cgi?id=156774
+
+        Reviewed by Chris Fleizach.
+
+        Added tests that verify svgs shapes that are labelled are exposed as images.
+        * accessibility/resources/apple-logo.svg: Added.
+        * accessibility/svg-shape-labelled-expected.txt: Added.
+        * accessibility/svg-shape-labelled.html: Added.
+
</ins><span class="cx"> 2019-04-08  Shawn Roberts  <sroberts@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Layout tests imported/w3c/IndexedDB-private-browsing/idbobjectstore_createIndex7-event_order.html
</span></span></pre></div>
<a id="trunkLayoutTestsaccessibilityresourcesapplelogosvg"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/accessibility/resources/apple-logo.svg (0 => 244029)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/accessibility/resources/apple-logo.svg                         (rev 0)
+++ trunk/LayoutTests/accessibility/resources/apple-logo.svg    2019-04-08 18:09:33 UTC (rev 244029)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 19.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<svg version="1.1" id="GLYPHS" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+        width="20px" height="44px" viewBox="0 0 20 44" style="enable-background:new 0 0 20 44;" xml:space="preserve">
+<g id="Mac">
+       <g id="Apple_2_">
+               <path style="fill:#FFFFFF;" d="M18.1,24.23c-0.11,0.31-0.22,0.6-0.33,0.88c-0.29,0.66-0.63,1.27-1.02,1.84
+                       c-0.54,0.77-0.98,1.3-1.32,1.59c-0.52,0.48-1.09,0.73-1.69,0.74c-0.43,0-0.95-0.12-1.56-0.37c-0.61-0.25-1.17-0.37-1.68-0.37
+                       c-0.54,0-1.11,0.12-1.73,0.37c-0.62,0.25-1.11,0.38-1.49,0.39c-0.58,0.02-1.15-0.23-1.73-0.76c-0.37-0.32-0.83-0.87-1.38-1.65
+                       C3.58,26.06,3.09,25.1,2.71,24C2.3,22.81,2.1,21.66,2.1,20.55c0-1.27,0.28-2.37,0.83-3.29c0.43-0.74,1.01-1.32,1.73-1.75
+                       c0.72-0.43,1.5-0.65,2.34-0.66c0.46,0,1.06,0.14,1.81,0.42c0.75,0.28,1.23,0.42,1.44,0.42c0.16,0,0.69-0.17,1.59-0.5
+                       c0.85-0.31,1.57-0.43,2.16-0.38c1.6,0.13,2.8,0.76,3.6,1.89c-1.43,0.87-2.14,2.08-2.12,3.64c0.01,1.21,0.45,2.22,1.32,3.02
+                       C17.18,23.74,17.61,24.02,18.1,24.23z M14.08,10.31c0.01,0.13,0.02,0.25,0.02,0.38c0,0.95-0.35,1.84-1.04,2.66
+                       c-0.84,0.98-1.85,1.54-2.94,1.45c-0.01-0.11-0.02-0.23-0.02-0.36c0-0.91,0.4-1.89,1.1-2.69c0.35-0.4,0.8-0.74,1.34-1.01
+                       C13.09,10.48,13.6,10.33,14.08,10.31z"/>
+       </g>
+       <g>
+               <rect style="fill:none;" width="20" height="44"/>
+       </g>
+</g>
+</svg>
</ins></span></pre></div>
<a id="trunkLayoutTestsaccessibilitysvgshapelabelledexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/accessibility/svg-shape-labelled-expected.txt (0 => 244029)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/accessibility/svg-shape-labelled-expected.txt                          (rev 0)
+++ trunk/LayoutTests/accessibility/svg-shape-labelled-expected.txt     2019-04-08 18:09:33 UTC (rev 244029)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+        
+This tests that SVG shapes are exposed to ax tree as images if there are labels describing them.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+circle1: AXRole: AXImage
+circle2: AXRole: AXImage
+circle3: Element not exposed
+PASS !image1 is true
+PASS image2.role is 'AXRole: AXImage'
+PASS image3.role is 'AXRole: AXImage'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsaccessibilitysvgshapelabelledhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/accessibility/svg-shape-labelled.html (0 => 244029)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/accessibility/svg-shape-labelled.html                          (rev 0)
+++ trunk/LayoutTests/accessibility/svg-shape-labelled.html     2019-04-08 18:09:33 UTC (rev 244029)
</span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<style>img {background-color: #000;}</style>
+<script src="../resources/js-test-pre.js"></script>
+<script src="../resources/accessibility-helper.js"></script>
+</head>
+<body id="body">
+
+<svg aria-label="Bar" height="100" width="100">
+    <circle id="circle1" cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
+</svg>
+
+<svg height="100" width="100">
+    <circle id="circle2" aria-label="Bar" cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
+</svg>
+
+<svg height="100" width="100">
+    <circle id="circle3" cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
+</svg>
+
+<img id="test1" src="resources/apple-logo.svg"/>
+
+<img id="test2" src="resources/apple-logo.svg" alt="hello" />
+
+<img id="test3" alt="Apple logo" src="resources/apple-logo.svg" />
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that SVG shapes are exposed to ax tree as images if there are labels describing them.");
+
+    if (window.accessibilityController) {
+        var circle1 = accessibilityController.accessibleElementById("circle1");
+        debug("circle1: " + (circle1 ? circle1.role : "Element not exposed"));
+
+        var circle2 = accessibilityController.accessibleElementById("circle2");
+        debug("circle2: " + (circle2 ? circle2.role : "Element not exposed"));
+
+        var circle3 = accessibilityController.accessibleElementById("circle3");
+        debug("circle3: " + (circle3 ? circle3.role : "Element not exposed"));
+
+        var image1 = accessibilityController.accessibleElementById("test1");
+        shouldBeTrue("!image1");
+
+        var image2 = accessibilityController.accessibleElementById("test2");
+        shouldBe("image2.role", "'AXRole: AXImage'");
+
+        var image3 = accessibilityController.accessibleElementById("test3");
+        shouldBe("image3.role", "'AXRole: AXImage'");
+    }
+
+</script>
+
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (244028 => 244029)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-04-08 18:01:42 UTC (rev 244028)
+++ trunk/Source/WebCore/ChangeLog      2019-04-08 18:09:33 UTC (rev 244029)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2019-04-08  Eric Liang  <ericliang@apple.com>
+
+        AX: <svg> elements with labels and no accessible contents are exposed as empty AXGroups
+        https://bugs.webkit.org/show_bug.cgi?id=156774
+
+        Reviewed by Chris Fleizach.
+
+        Labelled SVGs without accessible descendants are exposed as AXImage rather than groups.
+
+        Unlabelled equivalents are not exposed. Otherwise, SVGs with accessible descendants are exposed as AXGroup. 
+        Also added back functionalities from last patch of determining whether a SVG element should be ignored.
+        
+        Test: accessibility/svg-shape-labelled.html
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::updateRoleAfterChildrenCreation):
+        * accessibility/AccessibilitySVGElement.cpp:
+        (WebCore::AccessibilitySVGElement::computeAccessibilityIsIgnored const):
+
</ins><span class="cx"> 2019-04-08  Youenn Fablet  <youenn@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Make sure UniqueIDBDatabaseConnection unregisters itself even if its database is gone
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAccessibilityRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (244028 => 244029)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2019-04-08 18:01:42 UTC (rev 244028)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp    2019-04-08 18:09:33 UTC (rev 244029)
</span><span class="lines">@@ -3263,7 +3263,8 @@
</span><span class="cx"> void AccessibilityRenderObject::updateRoleAfterChildrenCreation()
</span><span class="cx"> {
</span><span class="cx">     // If a menu does not have valid menuitem children, it should not be exposed as a menu.
</span><del>-    if (roleValue() == AccessibilityRole::Menu) {
</del><ins>+    auto role = roleValue();
+    if (role == AccessibilityRole::Menu) {
</ins><span class="cx">         // Elements marked as menus must have at least one menu item child.
</span><span class="cx">         size_t menuItemCount = 0;
</span><span class="cx">         for (const auto& child : children()) {
</span><span class="lines">@@ -3276,6 +3277,8 @@
</span><span class="cx">         if (!menuItemCount)
</span><span class="cx">             m_role = AccessibilityRole::Group;
</span><span class="cx">     }
</span><ins>+    if (role == AccessibilityRole::SVGRoot && !hasChildren())
+        m_role = AccessibilityRole::Image;
</ins><span class="cx"> }
</span><span class="cx">     
</span><span class="cx"> void AccessibilityRenderObject::addChildren()
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAccessibilitySVGElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AccessibilitySVGElement.cpp (244028 => 244029)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/AccessibilitySVGElement.cpp   2019-04-08 18:01:42 UTC (rev 244028)
+++ trunk/Source/WebCore/accessibility/AccessibilitySVGElement.cpp      2019-04-08 18:09:33 UTC (rev 244029)
</span><span class="lines">@@ -245,8 +245,15 @@
</span><span class="cx"> 
</span><span class="cx">     // SVG shapes should not be included unless there's a concrete reason for inclusion.
</span><span class="cx">     // https://rawgit.com/w3c/aria/master/svg-aam/svg-aam.html#exclude_elements
</span><del>-    if (m_renderer->isSVGShape())
-        return !(hasAttributesRequiredForInclusion() || canSetFocusAttribute() || element()->hasEventListeners());
</del><ins>+    if (m_renderer->isSVGShape()) {
+        if (canSetFocusAttribute() || element()->hasEventListeners())
+            return false;
+        if (auto svgParent = AccessibilityObject::matchedParent(*this, true, [] (const AccessibilityObject& object) {
+            return object.hasAttributesRequiredForInclusion() || object.isAccessibilitySVGRoot();
+        }))
+            return !svgParent->hasAttributesRequiredForInclusion();
+        return true;
+    }
</ins><span class="cx"> 
</span><span class="cx">     return AccessibilityRenderObject::computeAccessibilityIsIgnored();
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>