Bug 230259

Summary: [GTK][a11y] Add initial WTR accessibility support when building with ATSPI
Product: WebKit Reporter: Carlos Garcia Campos <cgarcia>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: aboxhall, andresg_22, aperez, apinheiro, bugs-noreply, cfleizach, dmazzoni, ews-watchlist, jcraig, jdiggs, samuel_white
Priority: P2 Keywords: Gtk
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 230256, 232141    
Bug Blocks: 230253, 232300    
Attachments:
Description Flags
Patch
none
Patch
none
Patch aperez: review+

Description Carlos Garcia Campos 2021-09-14 05:41:05 PDT
Add WTR support to run the layout tests.
Comment 1 Carlos Garcia Campos 2021-10-25 03:27:12 PDT
Created attachment 442353 [details]
Patch
Comment 2 Andres Gonzalez 2021-10-27 08:52:07 PDT
(In reply to Carlos Garcia Campos from comment #1)
> Created attachment 442353 [details]
> Patch

--- a/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
+++ a/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
@@ -246,7 +246,11 @@ void* WKAccessibilityRootObject(WKBundlePageRef pageRef)
 #if ENABLE(ACCESSIBILITY)
     if (!pageRef)
         return 0;
-
+
+#if USE(ATSPI)
+    return WebKit::toImpl(pageRef)->accessibilityRootObject().child();
+#endif

Why the root obtained down below doesn't work for ATSPI?

    WebCore::AXCoreObject* root = core.document()->axObjectCache()->rootObject();
    if (!root)
        return 0;
    
    return root->wrapper();
Comment 3 Andres Gonzalez 2021-10-27 08:56:40 PDT
@@ -273,7 +277,11 @@ void* WKAccessibilityFocusedObject(WKBundlePageRef pageRef)
 #if ENABLE(ACCESSIBILITY)
     if (!pageRef)
         return 0;
-
+
+#if USE(ATSPI)
+    return WebKit::toImpl(pageRef)->accessibilityRootObject().focusedObject();
+#endif

Same question here. Why this is not good for ATSPI?

    auto* focusedObject = axObjectCache->focusedUIElementForPage(page);
    if (!focusedObject)
        return 0;
    
    return focusedObject->wrapper();
Comment 4 Carlos Garcia Campos 2021-10-28 01:51:16 PDT
(In reply to Andres Gonzalez from comment #2)
> (In reply to Carlos Garcia Campos from comment #1)
> > Created attachment 442353 [details]
> > Patch
> 
> --- a/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
> +++ a/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
> @@ -246,7 +246,11 @@ void* WKAccessibilityRootObject(WKBundlePageRef pageRef)
>  #if ENABLE(ACCESSIBILITY)
>      if (!pageRef)
>          return 0;
> -
> +
> +#if USE(ATSPI)
> +    return WebKit::toImpl(pageRef)->accessibilityRootObject().child();
> +#endif
> 
> Why the root obtained down below doesn't work for ATSPI?
> 
>     WebCore::AXCoreObject* root =
> core.document()->axObjectCache()->rootObject();
>     if (!root)
>         return 0;
>     
>     return root->wrapper();

In the web process the web page has an accessibility object that is the parent of the root object. In case of ATK that's WebKitWebPageAccessibilityObject, in atspi it's WebCore::AccessibilityRootAtspi. When running layout tests we don't really need a parent for the root object, but in atspi WebCore::AccessibilityRootAtspi contains the AccessibilityAtspi object that implements the communication with atspi service. So, all wrappers expect to have a valid root that they use to talk to atspi service. In case of ATK, when tests are run the web page accessibility object is never connected to the root object wrapper, but in atspi we need to make that connection that happens in AccessibilityRootAtspi::child(). That's why we get the root object wrapper as the child of the web page accessibility object (the root of the tree in the web process).
Comment 5 Carlos Garcia Campos 2021-10-29 01:07:42 PDT
Created attachment 442792 [details]
Patch
Comment 6 Carlos Garcia Campos 2021-11-05 03:36:27 PDT
Created attachment 443386 [details]
Patch
Comment 7 Adrian Perez 2021-11-15 02:03:50 PST
Comment on attachment 443386 [details]
Patch

There has not been further comments by Andres, and the patch
and clarifications LGTM, so let's try and get this landed :)
Comment 8 Carlos Garcia Campos 2021-11-18 03:46:20 PST
Committed r285996 (244393@main): <https://commits.webkit.org/244393@main>