⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 287014 in webkit


Ignore:
Timestamp:
Dec 14, 2021, 12:12:55 AM (5 years ago)
Author:
Carlos Garcia Campos
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):

Location:
trunk/Source
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r287011 r287014  
     12021-12-13  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][a11y] Handle the Embedded method sent by AtkSocket from AccessibilityRootAtspi
     4        https://bugs.webkit.org/show_bug.cgi?id=234233
     5
     6        Reviewed by Adrian Perez de Castro.
     7
     8        * accessibility/atspi/AccessibilityAtspi.cpp:
     9        (WebCore::AccessibilityAtspi::registerRoot):
     10        * accessibility/atspi/AccessibilityRootAtspi.cpp:
     11        (WebCore::AccessibilityRootAtspi::registerObject):
     12        (WebCore::AccessibilityRootAtspi::embedded):
     13        (WebCore::AccessibilityRootAtspi::setParentPath): Deleted.
     14        * accessibility/atspi/AccessibilityRootAtspi.h:
     15        * accessibility/atspi/xml/Socket.xml:
     16
    1172021-12-13  Kate Cheney  <katherine_cheney@apple.com>
    218
  • trunk/Source/WebCore/accessibility/atspi/AccessibilityAtspi.cpp

    r286767 r287014  
    7474            ensureCache();
    7575            String path = makeString("/org/a11y/webkit/accessible/", createCanonicalUUIDString().replace('-', '_'));
    76             Vector<unsigned, 2> registeredObjects;
     76            Vector<unsigned, 3> registeredObjects;
    7777            registeredObjects.reserveInitialCapacity(interfaces.size());
    7878            for (const auto& interface : interfaces) {
  • trunk/Source/WebCore/accessibility/atspi/AccessibilityRootAtspi.cpp

    r286767 r287014  
    4949GDBusInterfaceVTable AccessibilityRootAtspi::s_accessibleFunctions = {
    5050    // method_call
    51     [](GDBusConnection*, const gchar* sender, const gchar*, const gchar*, const gchar* methodName, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer userData) {
     51    [](GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar* methodName, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer userData) {
    5252        RELEASE_ASSERT(!isMainThread());
    5353        auto& rootObject = *static_cast<AccessibilityRootAtspi*>(userData);
     
    5959            g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", _("filler")));
    6060        else if (!g_strcmp0(methodName, "GetState")) {
    61 #if USE(GTK4)
    62             // FIXME: we need a way to get the parent atspi reference in GTK4.
    63 #else
    64             // Since we don't have a way to know the unique name of the UI process, right after calling
    65             // atk_socket_embed() the UI process calls atk_object_ref_state_set() to force a GetState message.
    66             // We use this first GetState message to set the sender as the parent unique name.
    67             if (rootObject.m_parentUniqueName.isNull())
    68                 rootObject.m_parentUniqueName = sender;
    69 #endif
    7061            GVariantBuilder builder = G_VARIANT_BUILDER_INIT(G_VARIANT_TYPE("(au)"));
    7162
     
    155146};
    156147
     148GDBusInterfaceVTable AccessibilityRootAtspi::s_socketFunctions = {
     149    // method_call
     150    [](GDBusConnection*, const gchar* sender, const gchar*, const gchar*, const gchar* methodName, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer userData) {
     151        RELEASE_ASSERT(!isMainThread());
     152        auto& rootObject = *static_cast<AccessibilityRootAtspi*>(userData);
     153        if (!g_strcmp0(methodName, "Embedded")) {
     154            const char* path;
     155            g_variant_get(parameters, "(&s)", &path);
     156            rootObject.embedded(sender, path);
     157            g_dbus_method_invocation_return_value(invocation, nullptr);
     158        }
     159    },
     160    // get_property
     161    nullptr,
     162    // set_property,
     163    nullptr,
     164    // padding
     165    nullptr
     166};
     167
    157168void AccessibilityRootAtspi::registerObject(CompletionHandler<void(const String&)>&& completionHandler)
    158169{
     
    163174    Vector<std::pair<GDBusInterfaceInfo*, GDBusInterfaceVTable*>> interfaces;
    164175    interfaces.append({ const_cast<GDBusInterfaceInfo*>(&webkit_accessible_interface), &s_accessibleFunctions });
     176    interfaces.append({ const_cast<GDBusInterfaceInfo*>(&webkit_socket_interface), &s_socketFunctions });
    165177    interfaces.append({ const_cast<GDBusInterfaceInfo*>(&webkit_component_interface), &s_componentFunctions });
    166178    m_atspi.registerRoot(*this, WTFMove(interfaces), WTFMove(completionHandler));
     
    182194}
    183195
    184 void AccessibilityRootAtspi::setParentPath(String&& path)
    185 {
    186     RELEASE_ASSERT(isMainThread());
    187     m_parentPath = WTFMove(path);
     196void AccessibilityRootAtspi::embedded(const char* parentUniqueName, const char* parentPath)
     197{
     198    RELEASE_ASSERT(!isMainThread());
     199    m_parentUniqueName = parentUniqueName;
     200    m_parentPath = parentPath;
    188201}
    189202
  • trunk/Source/WebCore/accessibility/atspi/AccessibilityRootAtspi.h

    r286767 r287014  
    4242    void unregisterObject();
    4343    void setPath(String&&);
    44     void setParentPath(String&&);
    4544
    4645    const String& path() const { return m_path; }
     
    5655    AccessibilityRootAtspi(Page&, AccessibilityAtspi&);
    5756
     57    void embedded(const char* parentUniqueName, const char* parentPath);
    5858    IntRect frameRect(uint32_t) const;
    5959
    6060    static GDBusInterfaceVTable s_accessibleFunctions;
     61    static GDBusInterfaceVTable s_socketFunctions;
    6162    static GDBusInterfaceVTable s_componentFunctions;
    6263
  • trunk/Source/WebCore/accessibility/atspi/xml/Socket.xml

    r283304 r287014  
    1515  </method>
    1616
     17  <method name="Embedded">
     18    <arg direction="in" name="socketPath" type="s"/>
     19    <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QSpiObjectReference"/>
     20  </method>
     21
    1722  <signal name="Available">
    1823    <arg direction="in" name="socket" type="(so)"/>
  • trunk/Source/WebKit/ChangeLog

    r287013 r287014  
     12021-12-13  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][a11y] Handle the Embedded method sent by AtkSocket from AccessibilityRootAtspi
     4        https://bugs.webkit.org/show_bug.cgi?id=234233
     5
     6        Reviewed by Adrian Perez de Castro.
     7
     8        I added some hacks to send the socket path to the web process using WebKit IPC because Embedded message is not
     9        in the DBus interface. We can simply add the message to the interface definition and handle it instead to
     10        simplify everything.
     11
     12        * UIProcess/ProvisionalPageProxy.cpp:
     13        (WebKit::ProvisionalPageProxy::bindAccessibilityTree):
     14        (WebKit::ProvisionalPageProxy::didReceiveMessage):
     15        * UIProcess/ProvisionalPageProxy.h:
     16        (WebKit::ProvisionalPageProxy::accessibilityPlugID):
     17        (WebKit::ProvisionalPageProxy::CompletionHandler<void): Deleted.
     18        * UIProcess/WebPageProxy.cpp:
     19        (WebKit::WebPageProxy::swapToProvisionalPage):
     20        * UIProcess/WebPageProxy.h:
     21        * UIProcess/WebPageProxy.messages.in:
     22        * UIProcess/gtk/WebPageProxyGtk.cpp:
     23        (WebKit::WebPageProxy::bindAccessibilityTree):
     24        * UIProcess/wpe/WebPageProxyWPE.cpp:
     25        (WebKit::WebPageProxy::bindAccessibilityTree):
     26        * WebProcess/WebPage/gtk/WebPageGtk.cpp:
     27        (WebKit::WebPage::platformInitialize):
     28
    1292021-12-13  John Wilander  <wilander@apple.com>
    230
  • trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp

    r286815 r287014  
    445445
    446446#if PLATFORM(GTK) || PLATFORM(WPE)
    447 void ProvisionalPageProxy::bindAccessibilityTree(const String& plugID, CompletionHandler<void(String&&)>&& completionHandler)
     447void ProvisionalPageProxy::bindAccessibilityTree(const String& plugID)
    448448{
    449449    m_accessibilityPlugID = plugID;
    450     m_accessibilityBindCompletionHandler = WTFMove(completionHandler);
    451450}
    452451#endif
     
    513512#if PLATFORM(GTK) || PLATFORM(WPE)
    514513    if (decoder.messageName() == Messages::WebPageProxy::BindAccessibilityTree::name()) {
    515         IPC::handleMessageAsync<Messages::WebPageProxy::BindAccessibilityTree>(connection, decoder, this, &ProvisionalPageProxy::bindAccessibilityTree);
     514        IPC::handleMessage<Messages::WebPageProxy::BindAccessibilityTree>(connection, decoder, this, &ProvisionalPageProxy::bindAccessibilityTree);
    516515        return;
    517516    }
  • trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h

    r286479 r287014  
    9797#if PLATFORM(GTK) || PLATFORM(WPE)
    9898    const String& accessibilityPlugID() { return m_accessibilityPlugID; }
    99     CompletionHandler<void(String&&)> takeAccessibilityBindCompletionHandler() { return std::exchange(m_accessibilityBindCompletionHandler, nullptr); }
    10099#endif
    101100#if HAVE(VISIBILITY_PROPAGATION_VIEW)
     
    150149#endif
    151150#if PLATFORM(GTK) || PLATFORM(WPE)
    152     void bindAccessibilityTree(const String&, CompletionHandler<void(String&&)>&&);
     151    void bindAccessibilityTree(const String&);
    153152#endif
    154153#if ENABLE(CONTENT_FILTERING)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r286937 r287014  
    989989#endif
    990990#if PLATFORM(GTK) || PLATFORM(WPE)
    991     if (auto completionHandler = provisionalPage->takeAccessibilityBindCompletionHandler())
    992         bindAccessibilityTree(provisionalPage->accessibilityPlugID(), WTFMove(completionHandler));
     991    auto accessibilityPlugID = provisionalPage->accessibilityPlugID();
     992    if (!accessibilityPlugID.isEmpty())
     993        bindAccessibilityTree(accessibilityPlugID);
    993994#endif
    994995}
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r286937 r287014  
    22912291
    22922292#if PLATFORM(GTK) || PLATFORM(WPE)
    2293     void bindAccessibilityTree(const String&, CompletionHandler<void(String&&)>&&);
     2293    void bindAccessibilityTree(const String&);
    22942294#endif
    22952295
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r286825 r287014  
    180180#if PLATFORM(GTK) || PLATFORM(WPE)
    181181    # Support for connecting the Accessibility worlds of the UI and the Web processes
    182     BindAccessibilityTree(String plugID) -> (String socketPath) Async
     182    BindAccessibilityTree(String plugID)
    183183
    184184    SetInputMethodState(std::optional<WebKit::InputMethodState> state);
  • trunk/Source/WebKit/UIProcess/gtk/WebPageProxyGtk.cpp

    r283487 r287014  
    5050}
    5151
    52 void WebPageProxy::bindAccessibilityTree(const String& plugID, CompletionHandler<void(String&&)>&& completionHandler)
     52void WebPageProxy::bindAccessibilityTree(const String& plugID)
    5353{
    5454#if USE(GTK4)
     
    5858    auto* accessible = gtk_widget_get_accessible(viewWidget());
    5959    atk_socket_embed(ATK_SOCKET(accessible), const_cast<char*>(plugID.utf8().data()));
    60 #if USE(ATSPI)
    61     // ATK doesn't have API to get the atspi reference of an object, but we know the id is stored
    62     // as an object user data as "spi-dbus-id". To let the web process know about the unique name, we call
    63     // atk_object_ref_state_set() that sends a GetState message to the web process root object.
    64     g_object_unref(atk_object_ref_state_set(accessible));
    65     completionHandler(makeString("/org/a11y/atspi/accessible/", GPOINTER_TO_INT(g_object_get_data(G_OBJECT(accessible), "spi-dbus-id"))));
    66 #else
    67     completionHandler({ });
    68 #endif
    6960    atk_object_notify_state_change(accessible, ATK_STATE_TRANSIENT, FALSE);
    7061#endif
  • trunk/Source/WebKit/UIProcess/wpe/WebPageProxyWPE.cpp

    r283304 r287014  
    4646}
    4747
    48 void WebPageProxy::bindAccessibilityTree(const String& plugID, CompletionHandler<void(String&&)>&& completionHandler)
     48void WebPageProxy::bindAccessibilityTree(const String& plugID)
    4949{
    5050#if USE(ATK)
     
    5252    atk_socket_embed(ATK_SOCKET(accessible), const_cast<char*>(plugID.utf8().data()));
    5353    atk_object_notify_state_change(accessible, ATK_STATE_TRANSIENT, FALSE);
    54     completionHandler({ });
    5554#endif
    5655}
  • trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp

    r285640 r287014  
    6565    m_accessibilityObject = adoptGRef(webkitWebPageAccessibilityObjectNew(this));
    6666    GUniquePtr<gchar> plugID(atk_plug_get_id(ATK_PLUG(m_accessibilityObject.get())));
    67     sendWithAsyncReply(Messages::WebPageProxy::BindAccessibilityTree(String(plugID.get())), [](String&&) { });
     67    send(Messages::WebPageProxy::BindAccessibilityTree(String(plugID.get())));
    6868#elif USE(ATSPI)
    6969#if USE(GTK4)
     
    7373        m_accessibilityRootObject = AccessibilityRootAtspi::create(*page, WebProcess::singleton().accessibilityAtspi());
    7474        m_accessibilityRootObject->registerObject([&](const String& plugID) {
    75             // ATK uses a custom DBus message to send the socket path to the AtkPlug object. GDBus doesn't allow
    76             // to send a message that is not defined in the interface, so we use the WebKit IPC to get the socket
    77             // path from the UI process.
    78             sendWithAsyncReply(Messages::WebPageProxy::BindAccessibilityTree(plugID), [&](String&& socketPath) {
    79                 m_accessibilityRootObject->setParentPath(WTFMove(socketPath));
    80             });
     75            send(Messages::WebPageProxy::BindAccessibilityTree(plugID));
    8176        });
    8277    }
  • trunk/Source/WebKit/WebProcess/WebPage/wpe/WebPageWPE.cpp

    r283304 r287014  
    4646    m_accessibilityObject = adoptGRef(webkitWebPageAccessibilityObjectNew(this));
    4747    GUniquePtr<gchar> plugID(atk_plug_get_id(ATK_PLUG(m_accessibilityObject.get())));
    48     sendWithAsyncReply(Messages::WebPageProxy::BindAccessibilityTree(String(plugID.get())), [](String&&) { });
     48    send(Messages::WebPageProxy::BindAccessibilityTree(String(plugID.get())));
    4949#endif
    5050}
Note: See TracChangeset for help on using the changeset viewer.