Title: [287014] trunk/Source
Revision
287014
Author
[email protected]
Date
2021-12-14 00:12:55 -0800 (Tue, 14 Dec 2021)

Log Message

[GTK][a11y] Handle the Embedded method sent by AtkSocket from AccessibilityRootAtspi
https://bugs.webkit.org/show_bug.cgi?id=234233

Reviewed by Adrian Perez de Castro.

Source/WebCore:

* accessibility/atspi/AccessibilityAtspi.cpp:
(WebCore::AccessibilityAtspi::registerRoot):
* accessibility/atspi/AccessibilityRootAtspi.cpp:
(WebCore::AccessibilityRootAtspi::registerObject):
(WebCore::AccessibilityRootAtspi::embedded):
(WebCore::AccessibilityRootAtspi::setParentPath): Deleted.
* accessibility/atspi/AccessibilityRootAtspi.h:
* accessibility/atspi/xml/Socket.xml:

Source/WebKit:

I added some hacks to send the socket path to the web process using WebKit IPC because Embedded message is not
in the DBus interface. We can simply add the message to the interface definition and handle it instead to
simplify everything.

* UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::bindAccessibilityTree):
(WebKit::ProvisionalPageProxy::didReceiveMessage):
* UIProcess/ProvisionalPageProxy.h:
(WebKit::ProvisionalPageProxy::accessibilityPlugID):
(WebKit::ProvisionalPageProxy::CompletionHandler<void): Deleted.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::swapToProvisionalPage):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/gtk/WebPageProxyGtk.cpp:
(WebKit::WebPageProxy::bindAccessibilityTree):
* UIProcess/wpe/WebPageProxyWPE.cpp:
(WebKit::WebPageProxy::bindAccessibilityTree):
* WebProcess/WebPage/gtk/WebPageGtk.cpp:
(WebKit::WebPage::platformInitialize):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287013 => 287014)


--- trunk/Source/WebCore/ChangeLog	2021-12-14 07:56:44 UTC (rev 287013)
+++ trunk/Source/WebCore/ChangeLog	2021-12-14 08:12:55 UTC (rev 287014)
@@ -1,3 +1,19 @@
+2021-12-13  Carlos Garcia Campos  <[email protected]>
+
+        [GTK][a11y] Handle the Embedded method sent by AtkSocket from AccessibilityRootAtspi
+        https://bugs.webkit.org/show_bug.cgi?id=234233
+
+        Reviewed by Adrian Perez de Castro.
+
+        * accessibility/atspi/AccessibilityAtspi.cpp:
+        (WebCore::AccessibilityAtspi::registerRoot):
+        * accessibility/atspi/AccessibilityRootAtspi.cpp:
+        (WebCore::AccessibilityRootAtspi::registerObject):
+        (WebCore::AccessibilityRootAtspi::embedded):
+        (WebCore::AccessibilityRootAtspi::setParentPath): Deleted.
+        * accessibility/atspi/AccessibilityRootAtspi.h:
+        * accessibility/atspi/xml/Socket.xml:
+
 2021-12-13  Kate Cheney  <[email protected]>
 
         WebContent process crashes at ContentSecurityPolicySourceList::matchesAll

Modified: trunk/Source/WebCore/accessibility/atspi/AccessibilityAtspi.cpp (287013 => 287014)


--- trunk/Source/WebCore/accessibility/atspi/AccessibilityAtspi.cpp	2021-12-14 07:56:44 UTC (rev 287013)
+++ trunk/Source/WebCore/accessibility/atspi/AccessibilityAtspi.cpp	2021-12-14 08:12:55 UTC (rev 287014)
@@ -73,7 +73,7 @@
         if (m_connection) {
             ensureCache();
             String path = makeString("/org/a11y/webkit/accessible/", createCanonicalUUIDString().replace('-', '_'));
-            Vector<unsigned, 2> registeredObjects;
+            Vector<unsigned, 3> registeredObjects;
             registeredObjects.reserveInitialCapacity(interfaces.size());
             for (const auto& interface : interfaces) {
                 auto id = g_dbus_connection_register_object(m_connection.get(), path.utf8().data(), interface.first, interface.second, rootObject.ptr(), nullptr, nullptr);

Modified: trunk/Source/WebCore/accessibility/atspi/AccessibilityRootAtspi.cpp (287013 => 287014)


--- trunk/Source/WebCore/accessibility/atspi/AccessibilityRootAtspi.cpp	2021-12-14 07:56:44 UTC (rev 287013)
+++ trunk/Source/WebCore/accessibility/atspi/AccessibilityRootAtspi.cpp	2021-12-14 08:12:55 UTC (rev 287014)
@@ -48,7 +48,7 @@
 
 GDBusInterfaceVTable AccessibilityRootAtspi::s_accessibleFunctions = {
     // method_call
-    [](GDBusConnection*, const gchar* sender, const gchar*, const gchar*, const gchar* methodName, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer userData) {
+    [](GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar* methodName, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer userData) {
         RELEASE_ASSERT(!isMainThread());
         auto& rootObject = *static_cast<AccessibilityRootAtspi*>(userData);
         if (!g_strcmp0(methodName, "GetRole"))
@@ -58,15 +58,6 @@
         else if (!g_strcmp0(methodName, "GetLocalizedRoleName"))
             g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", _("filler")));
         else if (!g_strcmp0(methodName, "GetState")) {
-#if USE(GTK4)
-            // FIXME: we need a way to get the parent atspi reference in GTK4.
-#else
-            // Since we don't have a way to know the unique name of the UI process, right after calling
-            // atk_socket_embed() the UI process calls atk_object_ref_state_set() to force a GetState message.
-            // We use this first GetState message to set the sender as the parent unique name.
-            if (rootObject.m_parentUniqueName.isNull())
-                rootObject.m_parentUniqueName = sender;
-#endif
             GVariantBuilder builder = G_VARIANT_BUILDER_INIT(G_VARIANT_TYPE("(au)"));
 
             uint64_t atspiStates = (G_GUINT64_CONSTANT(1) << Atspi::State::ManagesDescendants);
@@ -154,6 +145,26 @@
     nullptr
 };
 
+GDBusInterfaceVTable AccessibilityRootAtspi::s_socketFunctions = {
+    // method_call
+    [](GDBusConnection*, const gchar* sender, const gchar*, const gchar*, const gchar* methodName, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer userData) {
+        RELEASE_ASSERT(!isMainThread());
+        auto& rootObject = *static_cast<AccessibilityRootAtspi*>(userData);
+        if (!g_strcmp0(methodName, "Embedded")) {
+            const char* path;
+            g_variant_get(parameters, "(&s)", &path);
+            rootObject.embedded(sender, path);
+            g_dbus_method_invocation_return_value(invocation, nullptr);
+        }
+    },
+    // get_property
+    nullptr,
+    // set_property,
+    nullptr,
+    // padding
+    nullptr
+};
+
 void AccessibilityRootAtspi::registerObject(CompletionHandler<void(const String&)>&& completionHandler)
 {
     RELEASE_ASSERT(isMainThread());
@@ -162,6 +173,7 @@
 
     Vector<std::pair<GDBusInterfaceInfo*, GDBusInterfaceVTable*>> interfaces;
     interfaces.append({ const_cast<GDBusInterfaceInfo*>(&webkit_accessible_interface), &s_accessibleFunctions });
+    interfaces.append({ const_cast<GDBusInterfaceInfo*>(&webkit_socket_interface), &s_socketFunctions });
     interfaces.append({ const_cast<GDBusInterfaceInfo*>(&webkit_component_interface), &s_componentFunctions });
     m_atspi.registerRoot(*this, WTFMove(interfaces), WTFMove(completionHandler));
 }
@@ -181,10 +193,11 @@
     m_path = WTFMove(path);
 }
 
-void AccessibilityRootAtspi::setParentPath(String&& path)
+void AccessibilityRootAtspi::embedded(const char* parentUniqueName, const char* parentPath)
 {
-    RELEASE_ASSERT(isMainThread());
-    m_parentPath = WTFMove(path);
+    RELEASE_ASSERT(!isMainThread());
+    m_parentUniqueName = parentUniqueName;
+    m_parentPath = parentPath;
 }
 
 GVariant* AccessibilityRootAtspi::applicationReference() const

Modified: trunk/Source/WebCore/accessibility/atspi/AccessibilityRootAtspi.h (287013 => 287014)


--- trunk/Source/WebCore/accessibility/atspi/AccessibilityRootAtspi.h	2021-12-14 07:56:44 UTC (rev 287013)
+++ trunk/Source/WebCore/accessibility/atspi/AccessibilityRootAtspi.h	2021-12-14 08:12:55 UTC (rev 287014)
@@ -41,7 +41,6 @@
     void registerObject(CompletionHandler<void(const String&)>&&);
     void unregisterObject();
     void setPath(String&&);
-    void setParentPath(String&&);
 
     const String& path() const { return m_path; }
     const String& parentUniqueName() const { return m_parentUniqueName; }
@@ -55,9 +54,11 @@
 private:
     AccessibilityRootAtspi(Page&, AccessibilityAtspi&);
 
+    void embedded(const char* parentUniqueName, const char* parentPath);
     IntRect frameRect(uint32_t) const;
 
     static GDBusInterfaceVTable s_accessibleFunctions;
+    static GDBusInterfaceVTable s_socketFunctions;
     static GDBusInterfaceVTable s_componentFunctions;
 
     AccessibilityAtspi& m_atspi;

Modified: trunk/Source/WebCore/accessibility/atspi/xml/Socket.xml (287013 => 287014)


--- trunk/Source/WebCore/accessibility/atspi/xml/Socket.xml	2021-12-14 07:56:44 UTC (rev 287013)
+++ trunk/Source/WebCore/accessibility/atspi/xml/Socket.xml	2021-12-14 08:12:55 UTC (rev 287014)
@@ -14,6 +14,11 @@
     <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QSpiObjectReference"/>
   </method>
 
+  <method name="Embedded">
+    <arg direction="in" name="socketPath" type="s"/>
+    <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QSpiObjectReference"/>
+  </method>
+
   <signal name="Available">
     <arg direction="in" name="socket" type="(so)"/>
     <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QSpiObjectReference"/>

Modified: trunk/Source/WebKit/ChangeLog (287013 => 287014)


--- trunk/Source/WebKit/ChangeLog	2021-12-14 07:56:44 UTC (rev 287013)
+++ trunk/Source/WebKit/ChangeLog	2021-12-14 08:12:55 UTC (rev 287014)
@@ -1,3 +1,31 @@
+2021-12-13  Carlos Garcia Campos  <[email protected]>
+
+        [GTK][a11y] Handle the Embedded method sent by AtkSocket from AccessibilityRootAtspi
+        https://bugs.webkit.org/show_bug.cgi?id=234233
+
+        Reviewed by Adrian Perez de Castro.
+
+        I added some hacks to send the socket path to the web process using WebKit IPC because Embedded message is not
+        in the DBus interface. We can simply add the message to the interface definition and handle it instead to
+        simplify everything.
+
+        * UIProcess/ProvisionalPageProxy.cpp:
+        (WebKit::ProvisionalPageProxy::bindAccessibilityTree):
+        (WebKit::ProvisionalPageProxy::didReceiveMessage):
+        * UIProcess/ProvisionalPageProxy.h:
+        (WebKit::ProvisionalPageProxy::accessibilityPlugID):
+        (WebKit::ProvisionalPageProxy::CompletionHandler<void): Deleted.
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::swapToProvisionalPage):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/gtk/WebPageProxyGtk.cpp:
+        (WebKit::WebPageProxy::bindAccessibilityTree):
+        * UIProcess/wpe/WebPageProxyWPE.cpp:
+        (WebKit::WebPageProxy::bindAccessibilityTree):
+        * WebProcess/WebPage/gtk/WebPageGtk.cpp:
+        (WebKit::WebPage::platformInitialize):
+
 2021-12-13  John Wilander  <[email protected]>
 
         PCM: Remove old DB update and migration code, and add a unit test for destination token DB columns

Modified: trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp (287013 => 287014)


--- trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp	2021-12-14 07:56:44 UTC (rev 287013)
+++ trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp	2021-12-14 08:12:55 UTC (rev 287014)
@@ -444,10 +444,9 @@
 #endif
 
 #if PLATFORM(GTK) || PLATFORM(WPE)
-void ProvisionalPageProxy::bindAccessibilityTree(const String& plugID, CompletionHandler<void(String&&)>&& completionHandler)
+void ProvisionalPageProxy::bindAccessibilityTree(const String& plugID)
 {
     m_accessibilityPlugID = plugID;
-    m_accessibilityBindCompletionHandler = WTFMove(completionHandler);
 }
 #endif
 
@@ -512,7 +511,7 @@
 
 #if PLATFORM(GTK) || PLATFORM(WPE)
     if (decoder.messageName() == Messages::WebPageProxy::BindAccessibilityTree::name()) {
-        IPC::handleMessageAsync<Messages::WebPageProxy::BindAccessibilityTree>(connection, decoder, this, &ProvisionalPageProxy::bindAccessibilityTree);
+        IPC::handleMessage<Messages::WebPageProxy::BindAccessibilityTree>(connection, decoder, this, &ProvisionalPageProxy::bindAccessibilityTree);
         return;
     }
 #endif

Modified: trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h (287013 => 287014)


--- trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h	2021-12-14 07:56:44 UTC (rev 287013)
+++ trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h	2021-12-14 08:12:55 UTC (rev 287014)
@@ -96,7 +96,6 @@
 #endif
 #if PLATFORM(GTK) || PLATFORM(WPE)
     const String& accessibilityPlugID() { return m_accessibilityPlugID; }
-    CompletionHandler<void(String&&)> takeAccessibilityBindCompletionHandler() { return std::exchange(m_accessibilityBindCompletionHandler, nullptr); }
 #endif
 #if HAVE(VISIBILITY_PROPAGATION_VIEW)
     LayerHostingContextID contextIDForVisibilityPropagationInWebProcess() const { return m_contextIDForVisibilityPropagationInWebProcess; }
@@ -149,7 +148,7 @@
     void registerWebProcessAccessibilityToken(const IPC::DataReference&);
 #endif
 #if PLATFORM(GTK) || PLATFORM(WPE)
-    void bindAccessibilityTree(const String&, CompletionHandler<void(String&&)>&&);
+    void bindAccessibilityTree(const String&);
 #endif
 #if ENABLE(CONTENT_FILTERING)
     void contentFilterDidBlockLoadForFrame(const WebCore::ContentFilterUnblockHandler&, WebCore::FrameIdentifier);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (287013 => 287014)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-12-14 07:56:44 UTC (rev 287013)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-12-14 08:12:55 UTC (rev 287014)
@@ -988,8 +988,9 @@
         registerWebProcessAccessibilityToken({ accessibilityToken.data(), accessibilityToken.size() });
 #endif
 #if PLATFORM(GTK) || PLATFORM(WPE)
-    if (auto completionHandler = provisionalPage->takeAccessibilityBindCompletionHandler())
-        bindAccessibilityTree(provisionalPage->accessibilityPlugID(), WTFMove(completionHandler));
+    auto accessibilityPlugID = provisionalPage->accessibilityPlugID();
+    if (!accessibilityPlugID.isEmpty())
+        bindAccessibilityTree(accessibilityPlugID);
 #endif
 }
 

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (287013 => 287014)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-12-14 07:56:44 UTC (rev 287013)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-12-14 08:12:55 UTC (rev 287014)
@@ -2290,7 +2290,7 @@
 #endif
 
 #if PLATFORM(GTK) || PLATFORM(WPE)
-    void bindAccessibilityTree(const String&, CompletionHandler<void(String&&)>&&);
+    void bindAccessibilityTree(const String&);
 #endif
 
 #if PLATFORM(GTK)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (287013 => 287014)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2021-12-14 07:56:44 UTC (rev 287013)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2021-12-14 08:12:55 UTC (rev 287014)
@@ -179,7 +179,7 @@
 
 #if PLATFORM(GTK) || PLATFORM(WPE)
     # Support for connecting the Accessibility worlds of the UI and the Web processes
-    BindAccessibilityTree(String plugID) -> (String socketPath) Async
+    BindAccessibilityTree(String plugID)
 
     SetInputMethodState(std::optional<WebKit::InputMethodState> state);
 #endif

Modified: trunk/Source/WebKit/UIProcess/gtk/WebPageProxyGtk.cpp (287013 => 287014)


--- trunk/Source/WebKit/UIProcess/gtk/WebPageProxyGtk.cpp	2021-12-14 07:56:44 UTC (rev 287013)
+++ trunk/Source/WebKit/UIProcess/gtk/WebPageProxyGtk.cpp	2021-12-14 08:12:55 UTC (rev 287014)
@@ -49,7 +49,7 @@
     return static_cast<PageClientImpl&>(pageClient()).viewWidget();
 }
 
-void WebPageProxy::bindAccessibilityTree(const String& plugID, CompletionHandler<void(String&&)>&& completionHandler)
+void WebPageProxy::bindAccessibilityTree(const String& plugID)
 {
 #if USE(GTK4)
     // FIXME: We need a way to override accessible interface of WebView and send the atspi reference to the web process.
@@ -57,15 +57,6 @@
 #else
     auto* accessible = gtk_widget_get_accessible(viewWidget());
     atk_socket_embed(ATK_SOCKET(accessible), const_cast<char*>(plugID.utf8().data()));
-#if USE(ATSPI)
-    // ATK doesn't have API to get the atspi reference of an object, but we know the id is stored
-    // as an object user data as "spi-dbus-id". To let the web process know about the unique name, we call
-    // atk_object_ref_state_set() that sends a GetState message to the web process root object.
-    g_object_unref(atk_object_ref_state_set(accessible));
-    completionHandler(makeString("/org/a11y/atspi/accessible/", GPOINTER_TO_INT(g_object_get_data(G_OBJECT(accessible), "spi-dbus-id"))));
-#else
-    completionHandler({ });
-#endif
     atk_object_notify_state_change(accessible, ATK_STATE_TRANSIENT, FALSE);
 #endif
 }

Modified: trunk/Source/WebKit/UIProcess/wpe/WebPageProxyWPE.cpp (287013 => 287014)


--- trunk/Source/WebKit/UIProcess/wpe/WebPageProxyWPE.cpp	2021-12-14 07:56:44 UTC (rev 287013)
+++ trunk/Source/WebKit/UIProcess/wpe/WebPageProxyWPE.cpp	2021-12-14 08:12:55 UTC (rev 287014)
@@ -45,13 +45,12 @@
     return static_cast<PageClientImpl&>(pageClient()).viewBackend();
 }
 
-void WebPageProxy::bindAccessibilityTree(const String& plugID, CompletionHandler<void(String&&)>&& completionHandler)
+void WebPageProxy::bindAccessibilityTree(const String& plugID)
 {
 #if USE(ATK)
     auto* accessible = static_cast<PageClientImpl&>(pageClient()).accessible();
     atk_socket_embed(ATK_SOCKET(accessible), const_cast<char*>(plugID.utf8().data()));
     atk_object_notify_state_change(accessible, ATK_STATE_TRANSIENT, FALSE);
-    completionHandler({ });
 #endif
 }
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp (287013 => 287014)


--- trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp	2021-12-14 07:56:44 UTC (rev 287013)
+++ trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp	2021-12-14 08:12:55 UTC (rev 287014)
@@ -64,7 +64,7 @@
 #if USE(ATK)
     m_accessibilityObject = adoptGRef(webkitWebPageAccessibilityObjectNew(this));
     GUniquePtr<gchar> plugID(atk_plug_get_id(ATK_PLUG(m_accessibilityObject.get())));
-    sendWithAsyncReply(Messages::WebPageProxy::BindAccessibilityTree(String(plugID.get())), [](String&&) { });
+    send(Messages::WebPageProxy::BindAccessibilityTree(String(plugID.get())));
 #elif USE(ATSPI)
 #if USE(GTK4)
     // FIXME: we need a way to connect DOM and app a11y tree in GTK4.
@@ -72,12 +72,7 @@
     if (auto* page = corePage()) {
         m_accessibilityRootObject = AccessibilityRootAtspi::create(*page, WebProcess::singleton().accessibilityAtspi());
         m_accessibilityRootObject->registerObject([&](const String& plugID) {
-            // ATK uses a custom DBus message to send the socket path to the AtkPlug object. GDBus doesn't allow
-            // to send a message that is not defined in the interface, so we use the WebKit IPC to get the socket
-            // path from the UI process.
-            sendWithAsyncReply(Messages::WebPageProxy::BindAccessibilityTree(plugID), [&](String&& socketPath) {
-                m_accessibilityRootObject->setParentPath(WTFMove(socketPath));
-            });
+            send(Messages::WebPageProxy::BindAccessibilityTree(plugID));
         });
     }
 #endif

Modified: trunk/Source/WebKit/WebProcess/WebPage/wpe/WebPageWPE.cpp (287013 => 287014)


--- trunk/Source/WebKit/WebProcess/WebPage/wpe/WebPageWPE.cpp	2021-12-14 07:56:44 UTC (rev 287013)
+++ trunk/Source/WebKit/WebProcess/WebPage/wpe/WebPageWPE.cpp	2021-12-14 08:12:55 UTC (rev 287014)
@@ -45,7 +45,7 @@
     // object there specifically placed for that purpose (the socket).
     m_accessibilityObject = adoptGRef(webkitWebPageAccessibilityObjectNew(this));
     GUniquePtr<gchar> plugID(atk_plug_get_id(ATK_PLUG(m_accessibilityObject.get())));
-    sendWithAsyncReply(Messages::WebPageProxy::BindAccessibilityTree(String(plugID.get())), [](String&&) { });
+    send(Messages::WebPageProxy::BindAccessibilityTree(String(plugID.get())));
 #endif
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to