Title: [244029] trunk
Revision
244029
Author
commit-qu...@webkit.org
Date
2019-04-08 11:09:33 -0700 (Mon, 08 Apr 2019)

Log Message

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 <ericli...@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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (244028 => 244029)


--- trunk/LayoutTests/ChangeLog	2019-04-08 18:01:42 UTC (rev 244028)
+++ trunk/LayoutTests/ChangeLog	2019-04-08 18:09:33 UTC (rev 244029)
@@ -1,3 +1,15 @@
+2019-04-08  Eric Liang  <ericli...@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.
+
 2019-04-08  Shawn Roberts  <srobe...@apple.com>
 
         Layout tests imported/w3c/IndexedDB-private-browsing/idbobjectstore_createIndex7-event_order.html

Added: trunk/LayoutTests/accessibility/resources/apple-logo.svg (0 => 244029)


--- 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)
@@ -0,0 +1,21 @@
+<?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>

Added: trunk/LayoutTests/accessibility/svg-shape-labelled-expected.txt (0 => 244029)


--- 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)
@@ -0,0 +1,16 @@
+        
+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
+

Added: trunk/LayoutTests/accessibility/svg-shape-labelled.html (0 => 244029)


--- 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)
@@ -0,0 +1,59 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<style>img {background-color: #000;}</style>
+<script src=""
+<script src=""
+</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=""
+
+<img id="test2" src="" alt="hello" />
+
+<img id="test3" alt="Apple logo" src="" />
+
+<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=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (244028 => 244029)


--- 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)
@@ -1,3 +1,22 @@
+2019-04-08  Eric Liang  <ericli...@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):
+
 2019-04-08  Youenn Fablet  <you...@apple.com>
 
         Make sure UniqueIDBDatabaseConnection unregisters itself even if its database is gone

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (244028 => 244029)


--- 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)
@@ -3263,7 +3263,8 @@
 void AccessibilityRenderObject::updateRoleAfterChildrenCreation()
 {
     // If a menu does not have valid menuitem children, it should not be exposed as a menu.
-    if (roleValue() == AccessibilityRole::Menu) {
+    auto role = roleValue();
+    if (role == AccessibilityRole::Menu) {
         // Elements marked as menus must have at least one menu item child.
         size_t menuItemCount = 0;
         for (const auto& child : children()) {
@@ -3276,6 +3277,8 @@
         if (!menuItemCount)
             m_role = AccessibilityRole::Group;
     }
+    if (role == AccessibilityRole::SVGRoot && !hasChildren())
+        m_role = AccessibilityRole::Image;
 }
     
 void AccessibilityRenderObject::addChildren()

Modified: trunk/Source/WebCore/accessibility/AccessibilitySVGElement.cpp (244028 => 244029)


--- 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)
@@ -245,8 +245,15 @@
 
     // SVG shapes should not be included unless there's a concrete reason for inclusion.
     // https://rawgit.com/w3c/aria/master/svg-aam/svg-aam.html#exclude_elements
-    if (m_renderer->isSVGShape())
-        return !(hasAttributesRequiredForInclusion() || canSetFocusAttribute() || element()->hasEventListeners());
+    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;
+    }
 
     return AccessibilityRenderObject::computeAccessibilityIsIgnored();
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to