Changeset 287071 in webkit
- Timestamp:
- Dec 15, 2021, 6:15:06 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/accessibility/atspi/AXObjectCacheAtspi.cpp (modified) (1 diff)
-
Source/WebCore/accessibility/atspi/AccessibilityAtspi.cpp (modified) (1 diff)
-
Source/WebCore/accessibility/atspi/AccessibilityAtspi.h (modified) (1 diff)
-
Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp (modified) (1 diff)
-
Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.h (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r287070 r287071 1 2021-12-15 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK][a11y] Add support for loading events when building with ATSPI 4 https://bugs.webkit.org/show_bug.cgi?id=234344 5 6 Reviewed by Joanmarie Diggs. 7 8 Emit document:load-complete, document:reload, document:load-stopped and object:state-changed:busy. 9 10 * accessibility/atspi/AXObjectCacheAtspi.cpp: 11 (WebCore::AXObjectCache::frameLoadingEventPlatformNotification): 12 * accessibility/atspi/AccessibilityAtspi.cpp: 13 (WebCore::AccessibilityAtspi::loadEvent): 14 * accessibility/atspi/AccessibilityAtspi.h: 15 * accessibility/atspi/AccessibilityObjectAtspi.cpp: 16 (WebCore::AccessibilityObjectAtspi::loadEvent): 17 * accessibility/atspi/AccessibilityObjectAtspi.h: 18 1 19 2021-12-15 Carlos Garcia Campos <cgarcia@igalia.com> 2 20 -
trunk/Source/WebCore/accessibility/atspi/AXObjectCacheAtspi.cpp
r287020 r287071 306 306 } 307 307 308 void AXObjectCache::frameLoadingEventPlatformNotification(AccessibilityObject* object, AXLoadingEvent loadingEvent) 309 { 308 void AXObjectCache::frameLoadingEventPlatformNotification(AccessibilityObject* coreObject, AXLoadingEvent loadingEvent) 309 { 310 RELEASE_ASSERT(isMainThread()); 311 if (!coreObject) 312 return; 313 314 if (coreObject->roleValue() != AccessibilityRole::WebArea) 315 return; 316 317 auto* wrapper = coreObject->wrapper(); 318 if (!wrapper) 319 return; 320 321 switch (loadingEvent) { 322 case AXObjectCache::AXLoadingStarted: 323 wrapper->stateChanged("busy", true); 324 break; 325 case AXObjectCache::AXLoadingReloaded: 326 wrapper->stateChanged("busy", true); 327 wrapper->loadEvent("Reload"); 328 break; 329 case AXObjectCache::AXLoadingFailed: 330 wrapper->stateChanged("busy", false); 331 wrapper->loadEvent("LoadStopped"); 332 break; 333 case AXObjectCache::AXLoadingFinished: 334 wrapper->stateChanged("busy", false); 335 wrapper->loadEvent("LoadComplete"); 336 break; 337 } 310 338 } 311 339 -
trunk/Source/WebCore/accessibility/atspi/AccessibilityAtspi.cpp
r287070 r287071 461 461 462 462 g_dbus_connection_emit_signal(m_connection.get(), nullptr, atspiObject->path().utf8().data(), "org.a11y.atspi.Event.Object", "SelectionChanged", 463 g_variant_new("(siiva{sv})", "", 0, 0, g_variant_new_string(""), nullptr), nullptr); 464 }); 465 } 466 467 void AccessibilityAtspi::loadEvent(AccessibilityObjectAtspi& atspiObject, CString&& event) 468 { 469 RELEASE_ASSERT(isMainThread()); 470 m_queue->dispatch([this, atspiObject = Ref { atspiObject }, event = WTFMove(event)] { 471 if (!m_connection) 472 return; 473 474 if (!shouldEmitSignal("Document", event.data())) 475 return; 476 477 g_dbus_connection_emit_signal(m_connection.get(), nullptr, atspiObject->path().utf8().data(), "org.a11y.atspi.Event.Document", event.data(), 463 478 g_variant_new("(siiva{sv})", "", 0, 0, g_variant_new_string(""), nullptr), nullptr); 464 479 }); -
trunk/Source/WebCore/accessibility/atspi/AccessibilityAtspi.h
r287070 r287071 73 73 void selectionChanged(AccessibilityObjectAtspi&); 74 74 75 void loadEvent(AccessibilityObjectAtspi&, CString&&); 76 75 77 static const char* localizedRoleName(AccessibilityRole); 76 78 -
trunk/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp
r287070 r287071 1238 1238 } 1239 1239 1240 void AccessibilityObjectAtspi::loadEvent(const char* event) 1241 { 1242 RELEASE_ASSERT(isMainThread()); 1243 m_root.atspi().loadEvent(*this, event); 1244 } 1245 1240 1246 unsigned AccessibilityObjectAtspi::role() const 1241 1247 { -
trunk/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.h
r287020 r287071 136 136 137 137 WEBCORE_EXPORT String documentAttribute(const String&) const; 138 void loadEvent(const char*); 138 139 139 140 WEBCORE_EXPORT unsigned selectionCount() const; -
trunk/Tools/ChangeLog
r287070 r287071 1 2021-12-15 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK][a11y] Add support for loading events when building with ATSPI 4 https://bugs.webkit.org/show_bug.cgi?id=234344 5 6 Reviewed by Joanmarie Diggs. 7 8 Add a test case to check loading events. 9 10 * TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp: 11 (AccessibilityTest::shouldProcessEvent): Helper to make the filters conditions easier to read. 12 (AccessibilityTest::startEventMonitor): Make it possible to use the monitor without filtering events. 13 (testDocumentLoadEvents): 14 (beforeAll): 15 1 16 2021-12-15 Carlos Garcia Campos <cgarcia@igalia.com> 2 17 -
trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp
r287070 r287071 115 115 } 116 116 117 void startEventMonitor(AtspiAccessible* source, Vector<CString>&& events) 117 bool shouldProcessEvent(AtspiEvent* event) 118 { 119 // source = std::nullopt -> no filter. 120 if (!m_eventMonitor.source) 121 return true; 122 123 // source = nullptr -> filter by application. 124 if (!m_eventMonitor.source.value()) 125 return accessibleApplicationIsTestProgram(event->source); 126 127 // source != nullptr -> filter by accessible. 128 return m_eventMonitor.source.value() == event->source; 129 } 130 131 void startEventMonitor(std::optional<AtspiAccessible*> source, Vector<CString>&& events) 118 132 { 119 133 m_eventMonitor.source = source; … … 121 135 m_eventMonitor.listener = adoptGRef(atspi_event_listener_new([](AtspiEvent* event, gpointer userData) { 122 136 auto* test = static_cast<AccessibilityTest*>(userData); 123 if ((test->m_eventMonitor.source && event->source == test->m_eventMonitor.source) 124 || (!test->m_eventMonitor.source && accessibleApplicationIsTestProgram(event->source))) { 137 if (test->shouldProcessEvent(event)) 125 138 test->m_eventMonitor.events.append(static_cast<AtspiEvent*>(g_boxed_copy(ATSPI_TYPE_EVENT, event))); 126 }127 139 }, this, nullptr)); 128 140 … … 176 188 Vector<CString> eventTypes; 177 189 Vector<UniqueAtspiEvent> events; 178 AtspiAccessible* source { nullptr };190 std::optional<AtspiAccessible*> source; 179 191 } m_eventMonitor; 180 192 }; … … 2117 2129 g_assert_cmpstr(value.get(), ==, "Document attributes"); 2118 2130 #endif 2131 } 2132 2133 static void testDocumentLoadEvents(AccessibilityTest* test, gconstpointer) 2134 { 2135 test->showInWindow(); 2136 test->loadURI("about:blank"); 2137 test->waitUntilLoadFinished(); 2138 test->startEventMonitor(std::nullopt, { "document:", "object:state-changed:busy" }); 2139 test->loadHtml( 2140 "<html>" 2141 " <body>" 2142 " <p>Loading events test</p>" 2143 " </body>" 2144 "</html>", 2145 nullptr); 2146 test->waitUntilLoadFinished(); 2147 auto events = test->stopEventMonitor(3); 2148 g_assert_cmpuint(events.size(), ==, 3); 2149 g_assert_cmpstr(events[0]->type, ==, "object:state-changed:busy"); 2150 g_assert_cmpuint(events[0]->detail1, ==, 1); 2151 g_assert_cmpstr(events[1]->type, ==, "object:state-changed:busy"); 2152 g_assert_cmpuint(events[1]->detail1, ==, 0); 2153 g_assert_false(events[0]->source == events[1]->source); 2154 g_assert_true(ATSPI_IS_ACCESSIBLE(events[0]->source)); 2155 g_assert_cmpint(atspi_accessible_get_role(events[0]->source, nullptr), ==, ATSPI_ROLE_DOCUMENT_WEB); 2156 g_assert_cmpstr(events[2]->type, ==, "document:load-complete"); 2157 g_assert_true(events[1]->source == events[2]->source); 2158 g_assert_true(ATSPI_IS_ACCESSIBLE(events[1]->source)); 2159 g_assert_cmpint(atspi_accessible_get_role(events[1]->source, nullptr), ==, ATSPI_ROLE_DOCUMENT_WEB); 2160 events = { }; 2161 2162 test->startEventMonitor(std::nullopt, { "document:", "object:state-changed:busy" }); 2163 webkit_web_view_reload(test->m_webView); 2164 test->waitUntilLoadFinished(); 2165 events = test->stopEventMonitor(4); 2166 g_assert_cmpuint(events.size(), ==, 4); 2167 g_assert_cmpstr(events[0]->type, ==, "object:state-changed:busy"); 2168 g_assert_cmpuint(events[0]->detail1, ==, 1); 2169 g_assert_cmpstr(events[1]->type, ==, "document:reload"); 2170 g_assert_true(events[0]->source == events[1]->source); 2171 g_assert_true(ATSPI_IS_ACCESSIBLE(events[0]->source)); 2172 g_assert_cmpint(atspi_accessible_get_role(events[0]->source, nullptr), ==, ATSPI_ROLE_DOCUMENT_WEB); 2173 g_assert_cmpstr(events[2]->type, ==, "object:state-changed:busy"); 2174 g_assert_cmpuint(events[2]->detail1, ==, 0); 2175 g_assert_false(events[1]->source == events[2]->source); 2176 g_assert_cmpstr(events[3]->type, ==, "document:load-complete"); 2177 g_assert_true(events[2]->source == events[3]->source); 2178 g_assert_true(ATSPI_IS_ACCESSIBLE(events[2]->source)); 2179 g_assert_cmpint(atspi_accessible_get_role(events[2]->source, nullptr), ==, ATSPI_ROLE_DOCUMENT_WEB); 2180 events = { }; 2119 2181 } 2120 2182 … … 2820 2882 AccessibilityTest::add("WebKitAccessibility", "action/basic", testActionBasic); 2821 2883 AccessibilityTest::add("WebKitAccessibility", "document/basic", testDocumentBasic); 2884 AccessibilityTest::add("WebKitAccessibility", "document/load-events", testDocumentLoadEvents); 2822 2885 AccessibilityTest::add("WebKitAccessibility", "image/basic", testImageBasic); 2823 2886 AccessibilityTest::add("WebKitAccessibility", "selection/listbox", testSelectionListBox);
Note:
See TracChangeset
for help on using the changeset viewer.