WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
wcore-atspi-action.diff (text/plain), 15.41 KB, created by
Carlos Garcia Campos
on 2021-11-19 02:05:15 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Carlos Garcia Campos
Created:
2021-11-19 02:05:15 PST
Size:
15.41 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index fd9276579687..b42fbda566de 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,22 @@ >+2021-11-05 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [GTK][a11y] Add implementation of action interface when building with ATSPI >+ https://bugs.webkit.org/show_bug.cgi?id=232749 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * SourcesGTK.txt: >+ * accessibility/atspi/AccessibilityObjectActionAtspi.cpp: Added. >+ (WebCore::AccessibilityObjectAtspi::actionName const): >+ (WebCore::AccessibilityObjectAtspi::localizedActionName const): >+ (WebCore::AccessibilityObjectAtspi::actionKeyBinding const): >+ (WebCore::AccessibilityObjectAtspi::doAction const): >+ * accessibility/atspi/AccessibilityObjectAtspi.cpp: >+ (WebCore::AccessibilityObjectAtspi::interfacesForObject): >+ (WebCore::AccessibilityObjectAtspi::path): >+ (WebCore::AccessibilityObjectAtspi::buildInterfaces const): >+ * accessibility/atspi/AccessibilityObjectAtspi.h: >+ > 2021-11-04 Carlos Garcia Campos <cgarcia@igalia.com> > > [GTK][a11y] Add implementation of hypertext interface when building with ATSPI >diff --git a/Source/WebCore/SourcesGTK.txt b/Source/WebCore/SourcesGTK.txt >index 6e4414d5802a..407f3d64d97b 100644 >--- a/Source/WebCore/SourcesGTK.txt >+++ b/Source/WebCore/SourcesGTK.txt >@@ -41,6 +41,7 @@ accessibility/atk/WebKitAccessibleUtil.cpp > > accessibility/atspi/AccessibilityAtspi.cpp > accessibility/atspi/AccessibilityObjectAtspi.cpp >+accessibility/atspi/AccessibilityObjectActionAtspi.cpp > accessibility/atspi/AccessibilityObjectComponentAtspi.cpp > accessibility/atspi/AccessibilityObjectHyperlinkAtspi.cpp > accessibility/atspi/AccessibilityObjectHypertextAtspi.cpp >diff --git a/Source/WebCore/accessibility/atspi/AccessibilityObjectActionAtspi.cpp b/Source/WebCore/accessibility/atspi/AccessibilityObjectActionAtspi.cpp >new file mode 100644 >index 000000000000..bbc130254568 >--- /dev/null >+++ b/Source/WebCore/accessibility/atspi/AccessibilityObjectActionAtspi.cpp >@@ -0,0 +1,107 @@ >+/* >+ * Copyright (C) 2021 Igalia S.L. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ */ >+ >+#include "config.h" >+#include "AccessibilityObjectAtspi.h" >+ >+#if ENABLE(ACCESSIBILITY) && USE(ATSPI) >+ >+#include "AccessibilityRootAtspi.h" >+#include <gio/gio.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+GDBusInterfaceVTable AccessibilityObjectAtspi::s_actionFunctions = { >+ // method_call >+ [](GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar* methodName, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer userData) { >+ RELEASE_ASSERT(!isMainThread()); >+ auto atspiObject = Ref { *static_cast<AccessibilityObjectAtspi*>(userData) }; >+ atspiObject->updateBackingStore(); >+ >+ if (!g_strcmp0(methodName, "GetDescription")) >+ g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", "")); >+ else if (!g_strcmp0(methodName, "GetName")) { >+ int index; >+ g_variant_get(parameters, "(i)", &index); >+ g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", !index ? atspiObject->actionName().utf8().data() : "")); >+ } else if (!g_strcmp0(methodName, "GetLocalizedName")) { >+ int index; >+ g_variant_get(parameters, "(i)", &index); >+ g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", !index ? atspiObject->localizedActionName().utf8().data() : "")); >+ } else if (!g_strcmp0(methodName, "GetKeyBinding")) { >+ int index; >+ g_variant_get(parameters, "(i)", &index); >+ g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", !index ? atspiObject->actionKeyBinding().utf8().data() : "")); >+ } else if (!g_strcmp0(methodName, "DoAction")) { >+ int index; >+ g_variant_get(parameters, "(i)", &index); >+ g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", !index ? atspiObject->doAction() : FALSE)); >+ } >+ }, >+ // get_property >+ [](GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar* propertyName, GError** error, gpointer userData) -> GVariant* { >+ RELEASE_ASSERT(!isMainThread()); >+ auto atspiObject = Ref { *static_cast<AccessibilityObjectAtspi*>(userData) }; >+ atspiObject->updateBackingStore(); >+ >+ if (!g_strcmp0(propertyName, "NActions")) >+ return g_variant_new_int32(1); >+ >+ g_set_error(error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Unknown property '%s'", propertyName); >+ return nullptr; >+ }, >+ // set_property, >+ nullptr, >+ // padding >+ nullptr >+}; >+ >+String AccessibilityObjectAtspi::actionName() const >+{ >+ AXCoreObject* axObject = isMainThread() ? m_coreObject : m_axObject; >+ return axObject ? axObject->actionVerb() : String(); >+} >+ >+String AccessibilityObjectAtspi::localizedActionName() const >+{ >+ return m_axObject ? m_axObject->localizedActionVerb() : String(); >+} >+ >+String AccessibilityObjectAtspi::actionKeyBinding() const >+{ >+ return m_axObject ? m_axObject->accessKey() : String(); >+} >+ >+bool AccessibilityObjectAtspi::doAction() const >+{ >+ return Accessibility::retrieveValueFromMainThread<bool>([this]() -> bool { >+ if (m_coreObject) >+ m_coreObject->updateBackingStore(); >+ >+ if (!m_coreObject) >+ return false; >+ >+ return m_coreObject->performDefaultAction(); >+ }); >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(ACCESSIBILITY) && USE(ATSPI) >diff --git a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp b/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp >index b3b8f9dbef4c..e875e4945a2e 100644 >--- a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp >+++ b/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp >@@ -60,7 +60,7 @@ static inline bool roleIsTextType(AccessibilityRole role) > > OptionSet<AccessibilityObjectAtspi::Interface> AccessibilityObjectAtspi::interfacesForObject(AXCoreObject& coreObject) > { >- OptionSet<Interface> interfaces = { Interface::Accessible, Interface::Component }; >+ OptionSet<Interface> interfaces = { Interface::Accessible, Interface::Component, Interface::Action }; > > RenderObject* renderer = coreObject.isAccessibilityRenderObject() ? coreObject.renderer() : nullptr; > if (coreObject.roleValue() == AccessibilityRole::StaticText || coreObject.roleValue() == AccessibilityRole::ColorWell) >@@ -483,6 +483,8 @@ const String& AccessibilityObjectAtspi::path() > interfaces.append({ const_cast<GDBusInterfaceInfo*>(&webkit_hyperlink_interface), &s_hyperlinkFunctions }); > if (m_interfaces.contains(Interface::Hypertext)) > interfaces.append({ const_cast<GDBusInterfaceInfo*>(&webkit_hypertext_interface), &s_hypertextFunctions }); >+ if (m_interfaces.contains(Interface::Action)) >+ interfaces.append({ const_cast<GDBusInterfaceInfo*>(&webkit_action_interface), &s_actionFunctions }); > m_path = atspiRoot->atspi().registerObject(*this, WTFMove(interfaces)); > } > >@@ -1115,6 +1117,8 @@ void AccessibilityObjectAtspi::buildInterfaces(GVariantBuilder* builder) const > g_variant_builder_add(builder, "s", webkit_hyperlink_interface.name); > if (m_interfaces.contains(Interface::Hypertext)) > g_variant_builder_add(builder, "s", webkit_hypertext_interface.name); >+ if (m_interfaces.contains(Interface::Action)) >+ g_variant_builder_add(builder, "s", webkit_action_interface.name); > } > > void AccessibilityObjectAtspi::serialize(GVariantBuilder* builder) const >diff --git a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.h b/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.h >index 07e6802ca192..043ab2b27fff 100644 >--- a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.h >+++ b/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.h >@@ -48,7 +48,8 @@ public: > Text = 1 << 2, > Value = 1 << 3, > Hyperlink = 1 << 4, >- Hypertext = 1 << 5 >+ Hypertext = 1 << 5, >+ Action = 1 << 6 > }; > const OptionSet<Interface>& interfaces() const { return m_interfaces; } > >@@ -122,6 +123,9 @@ public: > > WEBCORE_EXPORT URL url() const; > >+ WEBCORE_EXPORT String actionName() const; >+ WEBCORE_EXPORT bool doAction() const; >+ > private: > explicit AccessibilityObjectAtspi(AXCoreObject*); > >@@ -161,6 +165,9 @@ private: > AccessibilityObjectAtspi* hyperlink(unsigned) const; > std::optional<unsigned> hyperlinkIndex(unsigned) const; > >+ String localizedActionName() const; >+ String actionKeyBinding() const; >+ > static OptionSet<Interface> interfacesForObject(AXCoreObject&); > > static GDBusInterfaceVTable s_accessibleFunctions; >@@ -169,6 +176,7 @@ private: > static GDBusInterfaceVTable s_valueFunctions; > static GDBusInterfaceVTable s_hyperlinkFunctions; > static GDBusInterfaceVTable s_hypertextFunctions; >+ static GDBusInterfaceVTable s_actionFunctions; > > AXCoreObject* m_axObject { nullptr }; > AXCoreObject* m_coreObject { nullptr }; >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 746776f45225..678196821fd3 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,19 @@ >+2021-11-05 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [GTK][a11y] Add implementation of action interface when building with ATSPI >+ https://bugs.webkit.org/show_bug.cgi?id=232749 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a unit test for the action interface and WTR implementation. >+ >+ * TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp: >+ (testActionBasic): >+ (beforeAll): >+ * WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp: >+ (WTR::AccessibilityUIElement::isPressActionSupported): >+ (WTR::AccessibilityUIElement::press): >+ > 2021-11-04 Carlos Garcia Campos <cgarcia@igalia.com> > > [GTK][a11y] Add implementation of hypertext interface when building with ATSPI >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp b/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp >index 417fc36d9eb0..9656608b9e43 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp >@@ -1869,6 +1869,61 @@ static void testHypertextBasic(AccessibilityTest* test, gconstpointer) > g_assert_cmpint(atspi_hypertext_get_link_index(ATSPI_HYPERTEXT(p.get()), 15, nullptr), ==, -1); > } > >+static void testActionBasic(AccessibilityTest* test, gconstpointer) >+{ >+ test->showInWindow(800, 600); >+ test->loadHtml( >+ "<html>" >+ " <body>" >+ " <p>This is <button accessKey='p'>button</button> and <a href='https://www.webkitgtk.org'>link</a> in a paragraph</p>" >+ " </body>" >+ "</html>", >+ nullptr); >+ test->waitUntilLoadFinished(); >+ >+ auto testApp = test->findTestApplication(); >+ g_assert_true(ATSPI_IS_ACCESSIBLE(testApp.get())); >+ >+ auto documentWeb = test->findDocumentWeb(testApp.get()); >+ g_assert_true(ATSPI_IS_ACCESSIBLE(documentWeb.get())); >+ g_assert_cmpint(atspi_accessible_get_child_count(documentWeb.get(), nullptr), ==, 1); >+ >+ auto p = adoptGRef(atspi_accessible_get_child_at_index(documentWeb.get(), 0, nullptr)); >+ g_assert_true(ATSPI_IS_ACTION(p.get())); >+ // Paragraph implements action interface, but it does nothing. >+ g_assert_cmpint(atspi_action_get_n_actions(ATSPI_ACTION(p.get()), nullptr), ==, 1); >+ GUniquePtr<char> name(atspi_action_get_action_name(ATSPI_ACTION(p.get()), 0, nullptr)); >+ g_assert_cmpstr(name.get(), ==, ""); >+ GUniquePtr<char> localizedName(atspi_action_get_localized_name(ATSPI_ACTION(p.get()), 0, nullptr)); >+ g_assert_cmpstr(localizedName.get(), ==, ""); >+ GUniquePtr<char> keyBinding(atspi_action_get_key_binding(ATSPI_ACTION(p.get()), 0, nullptr)); >+ g_assert_cmpstr(keyBinding.get(), ==, ""); >+ >+ auto button = adoptGRef(atspi_accessible_get_child_at_index(p.get(), 0, nullptr)); >+ g_assert_true(ATSPI_IS_ACTION(button.get())); >+ g_assert_cmpint(atspi_action_get_n_actions(ATSPI_ACTION(button.get()), nullptr), ==, 1); >+ name.reset(atspi_action_get_action_name(ATSPI_ACTION(button.get()), 0, nullptr)); >+ g_assert_cmpstr(name.get(), ==, "press"); >+#if USE(ATSPI) >+ localizedName.reset(atspi_action_get_localized_name(ATSPI_ACTION(button.get()), 0, nullptr)); >+ g_assert_cmpstr(localizedName.get(), ==, "press"); >+#endif >+ keyBinding.reset(atspi_action_get_key_binding(ATSPI_ACTION(button.get()), 0, nullptr)); >+ g_assert_cmpstr(keyBinding.get(), ==, "p"); >+ >+ auto a = adoptGRef(atspi_accessible_get_child_at_index(p.get(), 1, nullptr)); >+ g_assert_true(ATSPI_IS_ACTION(a.get())); >+ g_assert_cmpint(atspi_action_get_n_actions(ATSPI_ACTION(a.get()), nullptr), ==, 1); >+ name.reset(atspi_action_get_action_name(ATSPI_ACTION(a.get()), 0, nullptr)); >+ g_assert_cmpstr(name.get(), ==, "jump"); >+#if USE(ATSPI) >+ localizedName.reset(atspi_action_get_localized_name(ATSPI_ACTION(a.get()), 0, nullptr)); >+ g_assert_cmpstr(localizedName.get(), ==, "jump"); >+#endif >+ keyBinding.reset(atspi_action_get_key_binding(ATSPI_ACTION(a.get()), 0, nullptr)); >+ g_assert_cmpstr(keyBinding.get(), ==, ""); >+} >+ > void beforeAll() > { > AccessibilityTest::add("WebKitAccessibility", "accessible/basic-hierarchy", testAccessibleBasicHierarchy); >@@ -1892,6 +1947,7 @@ void beforeAll() > AccessibilityTest::add("WebKitAccessibility", "value/basic", testValueBasic); > AccessibilityTest::add("WebKitAccessibility", "hyperlink/basic", testHyperlinkBasic); > AccessibilityTest::add("WebKitAccessibility", "hypertext/basic", testHypertextBasic); >+ AccessibilityTest::add("WebKitAccessibility", "action/basic", testActionBasic); > } > > void afterAll() >diff --git a/Tools/WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp b/Tools/WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp >index 0d587f593871..8fec62d38833 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp >@@ -794,7 +794,9 @@ int AccessibilityUIElement::insertionPointLineNumber() > > bool AccessibilityUIElement::isPressActionSupported() > { >- return false; >+ m_element->updateBackingStore(); >+ auto name = m_element->actionName(); >+ return name == "press" || name == "jump"; > } > > bool AccessibilityUIElement::isIncrementActionSupported() >@@ -1094,6 +1096,7 @@ void AccessibilityUIElement::showMenu() > > void AccessibilityUIElement::press() > { >+ m_element->doAction(); > } > > void AccessibilityUIElement::setSelectedChild(AccessibilityUIElement* element) const
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 232749
:
443384
|
444793
|
444808