[Webkit-unassigned] [Bug 229556] AX: Make PDFs loaded via <embed> accessible

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Sep 13 06:41:24 PDT 2021


https://bugs.webkit.org/show_bug.cgi?id=229556

--- Comment #29 from Andres Gonzalez <andresg_22 at apple.com> ---
(In reply to Tyler Wilcock from comment #28)
> Created attachment 437998 [details]
> Patch

--- a/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm
+++ a/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm
@@ -143,10 +143,34 @@ id attributeValue(id element, NSString *attribute)
 {
     RetainPtr<id> value;

+    // The given `element` may not respond to `accessibilityAttributeValue`, so first check to see if it responds to the attribute-specific selector.
     BEGIN_AX_OBJC_EXCEPTIONS
-    AccessibilityUIElement::s_controller->executeOnAXThreadAndWait([&element, &attribute, &value] {
-        value = [element accessibilityAttributeValue:attribute];
-    });
+    if ([attribute isEqual:NSAccessibilityChildrenAttribute] && [element respondsToSelector:@selector(accessibilityChildren)]) {
+        AccessibilityUIElement::s_controller->executeOnAXThreadAndWait([&element, &value] {
+            value = [element accessibilityChildren];
+        });
+    } else if ([attribute isEqual:NSAccessibilityDescriptionAttribute] && [element respondsToSelector:@selector(accessibilityLabel)]) {
+        AccessibilityUIElement::s_controller->executeOnAXThreadAndWait([&element, &value] {
+            value = [element accessibilityLabel];
+        });
+    } else if ([attribute isEqual:NSAccessibilityParentAttribute] && [element respondsToSelector:@selector(accessibilityParent)]) {
+        AccessibilityUIElement::s_controller->executeOnAXThreadAndWait([&element, &value] {
+            value = [element accessibilityParent];
+        });
+    } else if ([attribute isEqual:NSAccessibilityRoleAttribute] && [element respondsToSelector:@selector(accessibilityRole)]) {
+        AccessibilityUIElement::s_controller->executeOnAXThreadAndWait([&element, &value] {
+            value = [element accessibilityRole];
+        });
+    } else if ([attribute isEqual:NSAccessibilityValueAttribute] && [element respondsToSelector:@selector(accessibilityValue)]) {
+        AccessibilityUIElement::s_controller->executeOnAXThreadAndWait([&element, &value] {
+            value = [element accessibilityValue];
+        });
+    } else {
+        // Fallback to calling `accessibilityAttributeValue`.
+        AccessibilityUIElement::s_controller->executeOnAXThreadAndWait([&element, &attribute, &value] {
+            value = [element accessibilityAttributeValue:attribute];
+        });
+    }

I think you can have just one executeOnAXThreadAndWait and do all the selector checks in one lambda. Also move the comment inside the lambda.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20210913/d3f4a12c/attachment-0001.htm>


More information about the webkit-unassigned mailing list