Title: [284844] trunk
Revision
284844
Author
[email protected]
Date
2021-10-25 16:20:28 -0700 (Mon, 25 Oct 2021)

Log Message

WebKit should use img@title as label even if img@alt is exlicitly empty
https://bugs.webkit.org/show_bug.cgi?id=173870
<rdar://problem/33010427>

Reviewed by Andres Gonzalez.

Source/WebCore:

alt="" usually means to ignore an image. However, when it also carries other
descriptive attributes, that is probably the wrong decision.
Other browsers are not ignoring these images, WebKit should follow suit.

This issue has been raised with
https://github.com/w3c/accname/issues/27

Test: accessibility/img-no-alt-not-ignored-with-title.html

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

LayoutTests:

* accessibility/img-no-alt-not-ignored-with-title-expected.txt: Added.
* accessibility/img-no-alt-not-ignored-with-title.html: Added.
* platform/ios-simulator/TestExpectations:
* platform/win/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (284843 => 284844)


--- trunk/LayoutTests/ChangeLog	2021-10-25 23:10:41 UTC (rev 284843)
+++ trunk/LayoutTests/ChangeLog	2021-10-25 23:20:28 UTC (rev 284844)
@@ -1,3 +1,16 @@
+2021-10-25  Chris Fleizach  <[email protected]>
+
+        WebKit should use img@title as label even if img@alt is exlicitly empty
+        https://bugs.webkit.org/show_bug.cgi?id=173870
+        <rdar://problem/33010427>
+
+        Reviewed by Andres Gonzalez.
+
+        * accessibility/img-no-alt-not-ignored-with-title-expected.txt: Added.
+        * accessibility/img-no-alt-not-ignored-with-title.html: Added.
+        * platform/ios-simulator/TestExpectations:
+        * platform/win/TestExpectations:
+
 2021-10-25  Eric Hutchison  <[email protected]>
 
         Update test expectations for fast/scrolling/mac/scrollbars/overlay-scrollbar-hovered.html.

Added: trunk/LayoutTests/accessibility/img-no-alt-not-ignored-with-title-expected.txt (0 => 284844)


--- trunk/LayoutTests/accessibility/img-no-alt-not-ignored-with-title-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/img-no-alt-not-ignored-with-title-expected.txt	2021-10-25 23:20:28 UTC (rev 284844)
@@ -0,0 +1,11 @@
+This tests that if an image has an empty alt tag, but it has title or aria-label, we will NOT ignore it.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS platformValueForW3CName(image1) is 'Image1'
+PASS platformValueForW3CName(image2) is 'Image2'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/img-no-alt-not-ignored-with-title.html (0 => 284844)


--- trunk/LayoutTests/accessibility/img-no-alt-not-ignored-with-title.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/img-no-alt-not-ignored-with-title.html	2021-10-25 23:20:28 UTC (rev 284844)
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+
+<img alt="" title="Image1" src="" id="image1">
+<img alt="" aria-label="Image2" src="" id="image2">
+
+<script>
+    description("This tests that if an image has an empty alt tag, but it has title or aria-label, we will NOT ignore it.");
+
+    if (window.accessibilityController) {
+        var image1 = accessibilityController.accessibleElementById("image1");
+        shouldBe("platformValueForW3CName(image1)", "'Image1'");
+
+        var image2 = accessibilityController.accessibleElementById("image2");
+        shouldBe("platformValueForW3CName(image2)", "'Image2'");
+    }
+</script>
+</body>
+</html>
+

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (284843 => 284844)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2021-10-25 23:10:41 UTC (rev 284843)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2021-10-25 23:20:28 UTC (rev 284844)
@@ -3,6 +3,7 @@
 # See http://trac.webkit.org/wiki/TestExpectations for more information on this file.
 #
 
+accessibility/img-no-alt-not-ignored-with-title.html [ Pass ]
 accessibility/insert-newline.html [ Pass ]
 accessibility/url-test.html [ Pass ]
 accessibility/keyevents-posted-for-dismiss-action.html [ Pass ]

Modified: trunk/LayoutTests/platform/win/TestExpectations (284843 => 284844)


--- trunk/LayoutTests/platform/win/TestExpectations	2021-10-25 23:10:41 UTC (rev 284843)
+++ trunk/LayoutTests/platform/win/TestExpectations	2021-10-25 23:20:28 UTC (rev 284844)
@@ -274,6 +274,7 @@
 accessibility/aria-listbox-clear-selection-crash.html [ Skip ]
 accessibility/listbox-clear-selection.html [ Skip ]
 accessibility/embedded-image-description.html [ Skip ]
+accessibility/img-no-alt-not-ignored-with-title.html [ Skip ]
 
 # TODO Conic gradients
 http/wpt/css/css-images-4/conic-gradient-parsing.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (284843 => 284844)


--- trunk/Source/WebCore/ChangeLog	2021-10-25 23:10:41 UTC (rev 284843)
+++ trunk/Source/WebCore/ChangeLog	2021-10-25 23:20:28 UTC (rev 284844)
@@ -1,3 +1,23 @@
+2021-10-25  Chris Fleizach  <[email protected]>
+
+        WebKit should use img@title as label even if img@alt is exlicitly empty
+        https://bugs.webkit.org/show_bug.cgi?id=173870
+        <rdar://problem/33010427>
+
+        Reviewed by Andres Gonzalez.
+
+        alt="" usually means to ignore an image. However, when it also carries other
+        descriptive attributes, that is probably the wrong decision.
+        Other browsers are not ignoring these images, WebKit should follow suit.
+        
+        This issue has been raised with
+        https://github.com/w3c/accname/issues/27
+
+        Test: accessibility/img-no-alt-not-ignored-with-title.html
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored const):
+
 2021-10-25  Ayumi Kojima  <[email protected]>
 
         Unreviewed, reverting r284742.

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (284843 => 284844)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2021-10-25 23:10:41 UTC (rev 284843)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2021-10-25 23:20:28 UTC (rev 284844)
@@ -1443,6 +1443,13 @@
         if (canSetFocusAttribute())
             return false;
 
+        // webkit.org/b/173870 - If an image has other alternative text, don't ignore it if alt text is empty.
+        // This means we should process title and aria-label first.
+        
+        // If an image has the title or label attributes, accessibility should be lenient and allow it to appear in the hierarchy (according to WAI-ARIA).
+        if (!getAttribute(titleAttr).isEmpty() || !getAttribute(aria_labelAttr).isEmpty())
+            return false;
+
         // First check the RenderImage's altText (which can be set through a style sheet, or come from the Element).
         // However, if this is not a native image, fallback to the attribute on the Element.
         AccessibilityObjectInclusion altTextInclusion = AccessibilityObjectInclusion::DefaultBehavior;
@@ -1457,10 +1464,6 @@
         if (altTextInclusion == AccessibilityObjectInclusion::IncludeObject)
             return false;
 
-        // If an image has the title or label attributes, accessibility should be lenient and allow it to appear in the hierarchy (according to WAI-ARIA).
-        if (!getAttribute(titleAttr).isEmpty() || !getAttribute(aria_labelAttr).isEmpty())
-            return false;
-
         if (isRenderImage) {
             // check for one-dimensional image
             RenderImage& image = downcast<RenderImage>(*m_renderer);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to