<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>227528</bug_id>
          
          <creation_ts>2021-06-30 07:53:48 -0700</creation_ts>
          <short_desc>[GTK] Support a11y with GTK 4</short_desc>
          <delta_ts>2024-02-08 06:40:29 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Accessibility</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>210100</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Catanzaro">mcatanzaro</reporter>
          <assigned_to name="Diego Pino">dpino</assigned_to>
          <cc>alicem</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>cgarcia</cc>
    
    <cc>dpino</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>sonny</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1773740</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2021-06-30 07:53:48 -0700</bug_when>
    <thetext>Currently GTK 4 has no support for a11y. We should start by documenting what would be required to make this work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1773741</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-06-30 07:53:58 -0700</bug_when>
    <thetext>&lt;rdar://problem/79966537&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1774088</commentid>
    <comment_count>2</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2021-07-01 06:23:16 -0700</bug_when>
    <thetext>What we currently have is a an a11y tree in the UI process built by GTK until WebKitWebView. The web view has is own accessible derived from AtkSocket. In the web process we have another a11y tree, coming from the DOM, so not associated to any GTK widget and it&apos;s built by WebKit using ATK API. The root of web process a11y tree is an AtkPlug. So, we use the ATK Socket/Plug API to connect the UI process tree with the web process one.

In GTK4 most of the a11y APIs are private, internally implemented by GtkWidgets, so our WebKitWebView has a GtkAtContext by default. We need a way to override the WebKitWebView a11y implementation, or at least some of the methods. For example GetChildren returns the references to the widgets that are children of WebKitWebView, but we need to include there the root object of the DOM a11y tree. Ideally, I think it should be enough if we could override GetChildren and GetChildAtIndex methods and ChildCount property somehow. Then we would need a way to get the WebKitWebView a11y object path, so that the root of DOM a11y tree can set the Parent property accordingly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1867302</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2022-05-06 12:14:22 -0700</bug_when>
    <thetext>Is this fixed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1867453</commentid>
    <comment_count>4</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2022-05-07 01:01:20 -0700</bug_when>
    <thetext>No, we still need a way to override the WebKitWebView a11y implementation. See comment #2</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1889676</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2022-08-08 08:36:53 -0700</bug_when>
    <thetext>This depends on: https://gitlab.gnome.org/GNOME/gtk/-/issues/3597</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1898533</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2022-09-14 13:54:44 -0700</bug_when>
    <thetext>Looks like https://gitlab.gnome.org/GNOME/gtk/-/issues/5162 will provide a path forward here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1930833</commentid>
    <comment_count>7</comment_count>
    <who name="Alice Mikhaylenko">alicem</who>
    <bug_when>2023-02-03 05:43:45 -0800</bug_when>
    <thetext>https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5470 is in now, so we should be able to have it. 🎉</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1930838</commentid>
    <comment_count>8</comment_count>
    <who name="Alice Mikhaylenko">alicem</who>
    <bug_when>2023-02-03 05:51:10 -0800</bug_when>
    <thetext>Update: it doesn&apos;t seem to be enough for anything except entries. :(</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1930841</commentid>
    <comment_count>9</comment_count>
    <who name="Alice Mikhaylenko">alicem</who>
    <bug_when>2023-02-03 05:57:12 -0800</bug_when>
    <thetext>Nevermind, should be fine.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1930847</commentid>
    <comment_count>10</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2023-02-03 06:16:27 -0800</bug_when>
    <thetext>It&apos;s not enough for our case that dom a11y tree is in a different process. See https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5032#note_1638061</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2006900</commentid>
    <comment_count>11</comment_count>
    <who name="Sonny Piers">sonny</who>
    <bug_when>2024-01-23 09:12:30 -0800</bug_when>
    <thetext>For information / the record

GNOME Foundation via STF¹ and Igalia are funding the work to solve this and Georges at Igalia is currently working on this. 


¹ https://foundation.gnome.org/2023/11/09/gnome-recognized-as-public-interest-infrastructure/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2011023</commentid>
    <comment_count>12</comment_count>
    <who name="Georges Basile Stavracas Neto">feaneron</who>
    <bug_when>2024-02-06 09:04:43 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/23926</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2011323</commentid>
    <comment_count>13</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-02-07 00:38:31 -0800</bug_when>
    <thetext>Committed 274201@main (da96990ed73d): &lt;https://commits.webkit.org/274201@main&gt;

Reviewed commits have been landed. Closing PR #23926 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2011382</commentid>
    <comment_count>14</comment_count>
    <who name="Diego Pino">dpino</who>
    <bug_when>2024-02-07 06:19:17 -0800</bug_when>
    <thetext>This patch broke the build for GTK-Linux-64-bit-Release-Ubuntu-LTS-Build.

https://build.webkit.org/#/builders/68/builds/31562

The build error is the following:

```
/home/buildbot/worker/GTK-Linux-64-bit-Release-Ubuntu-LTS-Build/build/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:420:10: error: invalid use of incomplete type ‘GtkAccessibleInterface’
  420 |     iface-&gt;get_first_accessible_child = webkitWebViewBaseAccessibleGetFirstAccessibleChild;
      |          ^~
In file included from /usr/include/glib-2.0/gobject/gobject.h:24,
                 from /usr/include/glib-2.0/gobject/gbinding.h:29,
                 from /usr/include/glib-2.0/glib-object.h:22,
                 from /usr/include/gtk-4.0/gtk/css/gtkcssenumtypes.h:11,
                 from /usr/include/gtk-4.0/gtk/css/gtkcss.h:34,
                 from /usr/include/gtk-4.0/gtk/gtk.h:30,
                 from /home/buildbot/worker/GTK-Linux-64-bit-Release-Ubuntu-LTS-Build/build/WebKitBuild/GTK/Release/WebKitGTK/DerivedSources/webkit/WebKitWebViewBase.h:35,
                 from /home/buildbot/worker/GTK-Linux-64-bit-Release-Ubuntu-LTS-Build/build/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:30:
/usr/include/gtk-4.0/gtk/gtkaccessible.h:36:1: note: forward declaration of ‘GtkAccessibleInterface’
   36 | G_DECLARE_INTERFACE (GtkAccessible, gtk_accessible, GTK, ACCESSIBLE, GObject)
      | ^~~~~~~~~~~~~~~~~~~
```

I took a look at the error and I think the problem is that `GtkAccessibleInterface` is not available in the GTK4 version used by the Ubuntu-LTS build bot (22.04):

```
$ apt-cache madison libgtk-4-dev
libgtk-4-dev | 4.6.9+ds-0ubuntu0.22.04.1 | http://mirrors.kernel.org/ubuntu jammy-updates/main amd64 Packages
libgtk-4-dev | 4.6.2+ds-1ubuntu2 | http://mirrors.kernel.org/ubuntu jammy/main amd64 Packages
```

**NOTE**: The Ubuntu and Debian build bots build with `--no-experimental-features` flag enabled and they do not use Flatpak SDK neither JHBuild. They build using only system libraries.

GtkAccessibleInterface is available since 4.10 (https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/gtkaccessible.h?ref_type=heads#L56).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2011385</commentid>
    <comment_count>15</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2024-02-07 06:52:27 -0800</bug_when>
    <thetext>This might work (untested, please check):

diff --git a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
index bbe3b935d788..0c1beb0a678a 100644
--- a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
+++ b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
@@ -304,7 +304,7 @@ struct _WebKitWebViewBasePrivate {
     CString tooltipText;
     IntRect tooltipArea;
     WebHitTestResultData::IsScrollbar mouseIsOverScrollbar;
-#if USE(GTK4)
+#if USE(GTK4) &amp;&amp; GTK_CHECK_VERSION(4, 10, 0)
 #ifdef GTK_ACCESSIBILITY_ATSPI
     GRefPtr&lt;GtkAccessible&gt; socketAccessible;
 #endif
@@ -398,7 +398,7 @@ static void webkitWebViewBaseDidExitFullScreen(WebKitWebViewBase*);
 static void webkitWebViewBaseRequestExitFullScreen(WebKitWebViewBase*);
 #endif
 
-#if USE(GTK4)
+#if USE(GTK4) &amp;&amp; GTK_CHECK_VERSION(4, 10, 0)
 static GtkAccessible* webkitWebViewBaseAccessibleGetFirstAccessibleChild(GtkAccessible* accessible)
 {
     WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(accessible);
@@ -3475,7 +3475,7 @@ void webkitWebViewBaseCallAfterNextPresentationUpdate(WebKitWebViewBase* webView
     webkitWebViewBaseNextPresentationUpdateMonitorStart(webViewBase, WTFMove(callback));
 }
 
-#if USE(GTK4)
+#if USE(GTK4) &amp;&amp; GTK_CHECK_VERSION(4, 10, 0)
 void webkitWebViewBaseSetPlugID(WebKitWebViewBase* webViewBase, const String&amp; plugID)
 {
 #ifdef GTK_ACCESSIBILITY_ATSPI</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2011421</commentid>
    <comment_count>16</comment_count>
    <who name="Diego Pino">dpino</who>
    <bug_when>2024-02-07 09:01:18 -0800</bug_when>
    <thetext>After applying the patch I got this other error:

/home/buildbot/worker/GTK-Linux-64-bit-Release-Ubuntu-LTS-Build/build/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:312:13: error: ‘AtkObject’ was not declared in this scope; did you mean ‘GtkObject’?
  312 |     GRefPtr&lt;AtkObject&gt; accessible;
      |             ^~~~~~~~~
      |             GtkObject
/home/buildbot/worker/GTK-Linux-64-bit-Release-Ubuntu-LTS-Build/build/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:312:22: error: template argument 1 is invalid
  312 |     GRefPtr&lt;AtkObject&gt; accessible;
      |                      ^
/home/buildbot/worker/GTK-Linux-64-bit-Release-Ubuntu-LTS-Build/build/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:387:13: warning: ‘void webkitWebViewBaseAccessibleInterfaceInit(GtkAccessibleInterface*)’ declared ‘static’ but never defined [-Wunused-function]
  387 | static void webkitWebViewBaseAccessibleInterfaceInit(GtkAccessibleInterface*);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/buildbot/worker/GTK-Linux-64-bit-Release-Ubuntu-LTS-Build/build/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:387:13: warning: ‘void webkitWebViewBaseAccessibleInterfaceInit(GtkAccessibleInterface*)’ used but never defined</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2011481</commentid>
    <comment_count>17</comment_count>
    <who name="Diego Pino">dpino</who>
    <bug_when>2024-02-07 11:58:14 -0800</bug_when>
    <thetext>Pull request: https://github.com/webkit/webkit/pull/24020</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2011721</commentid>
    <comment_count>18</comment_count>
    <who name="Georges Basile Stavracas Neto">feaneron</who>
    <bug_when>2024-02-08 06:14:40 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/24066</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2011723</commentid>
    <comment_count>19</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-02-08 06:40:26 -0800</bug_when>
    <thetext>Committed 274284@main (4aa6d217eac5): &lt;https://commits.webkit.org/274284@main&gt;

Reviewed commits have been landed. Closing PR #24066 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>