Title: [287454] trunk/Tools
Revision
287454
Author
[email protected]
Date
2021-12-26 23:34:58 -0800 (Sun, 26 Dec 2021)

Log Message

[GTK][a11y] WTR: handle xml-roles attributes to return the right role for landmark with ATSPI
https://bugs.webkit.org/show_bug.cgi?id=234638

Reviewed by Adrian Perez de Castro.

* WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp:
(WTR::xmlRoleValueString):
(WTR::AccessibilityUIElement::role):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (287453 => 287454)


--- trunk/Tools/ChangeLog	2021-12-27 06:43:31 UTC (rev 287453)
+++ trunk/Tools/ChangeLog	2021-12-27 07:34:58 UTC (rev 287454)
@@ -1,3 +1,14 @@
+2021-12-26  Carlos Garcia Campos  <[email protected]>
+
+        [GTK][a11y] WTR: handle xml-roles attributes to return the right role for landmark with ATSPI
+        https://bugs.webkit.org/show_bug.cgi?id=234638
+
+        Reviewed by Adrian Perez de Castro.
+
+        * WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp:
+        (WTR::xmlRoleValueString):
+        (WTR::AccessibilityUIElement::role):
+
 2021-12-26  Sam Weinig  <[email protected]>
 
         Replace WebKit/CocoaColor.h with WebCore/ColorCocoa.h, not confusing at all

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp (287453 => 287454)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp	2021-12-27 06:43:31 UTC (rev 287453)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp	2021-12-27 07:34:58 UTC (rev 287454)
@@ -35,6 +35,8 @@
 #include <WebCore/AccessibilityAtspiEnums.h>
 #include <WebCore/AccessibilityObjectAtspi.h>
 #include <WebKit/WKBundleFrame.h>
+#include <wtf/HashSet.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/URL.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/StringBuilder.h>
@@ -564,6 +566,52 @@
     return JSStringCreateWithCharacters(nullptr, 0);
 }
 
+static String xmlRoleValueString(const String& xmlRoles)
+{
+    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> regionRoles = HashSet<String, ASCIICaseInsensitiveHash>({
+        "doc-acknowledgments",
+        "doc-afterword",
+        "doc-appendix",
+        "doc-bibliography",
+        "doc-chapter",
+        "doc-conclusion",
+        "doc-credits",
+        "doc-endnotes",
+        "doc-epilogue",
+        "doc-errata",
+        "doc-foreword",
+        "doc-glossary",
+        "doc-glossref",
+        "doc-index",
+        "doc-introduction",
+        "doc-pagelist",
+        "doc-part",
+        "doc-preface",
+        "doc-prologue",
+        "doc-toc",
+        "region"
+    });
+
+    if (regionRoles->contains(xmlRoles))
+        return "AXLandmarkRegion"_s;
+    if (equalLettersIgnoringASCIICase(xmlRoles, "banner"))
+        return "AXLandmarkBanner"_s;
+    if (equalLettersIgnoringASCIICase(xmlRoles, "complementary"))
+        return "AXLandmarkComplementary"_s;
+    if (equalLettersIgnoringASCIICase(xmlRoles, "contentinfo"))
+        return "AXLandmarkContentInfo"_s;
+    if (equalLettersIgnoringASCIICase(xmlRoles, "form"))
+        return "AXLandmarkForm"_s;
+    if (equalLettersIgnoringASCIICase(xmlRoles, "main"))
+        return "AXLandmarkMain"_s;
+    if (equalLettersIgnoringASCIICase(xmlRoles, "navigation"))
+        return "AXLandmarkNavigation"_s;
+    if (equalLettersIgnoringASCIICase(xmlRoles, "search"))
+        return "AXLandmarkSearch"_s;
+
+    return { };
+}
+
 static String roleValueToString(unsigned roleValue)
 {
     switch (roleValue) {
@@ -742,7 +790,8 @@
         m_element->updateBackingStore();
         roleValue = m_element->role();
     });
-    auto roleValueString = roleValueToString(roleValue);
+
+    auto roleValueString = roleValue == WebCore::Atspi::Role::Landmark ? xmlRoleValueString(m_element->attributes().get("xml-roles")) : roleValueToString(roleValue);
     if (roleValueString.isEmpty())
         return JSStringCreateWithCharacters(nullptr, 0);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to