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-option-state-changed.diff (text/plain), 15.23 KB, created by
Carlos Garcia Campos
on 2021-11-26 05:41:10 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Carlos Garcia Campos
Created:
2021-11-26 05:41:10 PST
Size:
15.23 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index a6109aaf021d..20cf2bb8d11e 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,17 @@ >+2021-11-26 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [GTK][a11y] Signal state-changed:selected is not emitted for listbox elements when building with ATSPI >+ https://bugs.webkit.org/show_bug.cgi?id=233521 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Post a selected change notification for option elements when the state changes. >+ >+ * accessibility/atspi/AXObjectCacheAtspi.cpp: >+ (WebCore::AXObjectCache::postPlatformNotification): >+ * html/HTMLOptionElement.cpp: >+ (WebCore::HTMLOptionElement::setSelectedState): >+ > 2021-11-26 Carlos Garcia Campos <cgarcia@igalia.com> > > [GTK][a11y] MenuListPopup elements should implement selection interface too when building with ATSPI >diff --git a/Source/WebCore/accessibility/atspi/AXObjectCacheAtspi.cpp b/Source/WebCore/accessibility/atspi/AXObjectCacheAtspi.cpp >index 6b81c6f42237..80fb6e85a322 100644 >--- a/Source/WebCore/accessibility/atspi/AXObjectCacheAtspi.cpp >+++ b/Source/WebCore/accessibility/atspi/AXObjectCacheAtspi.cpp >@@ -80,9 +80,15 @@ void AXObjectCache::postPlatformNotification(AXCoreObject* coreObject, AXNotific > wrapper->stateChanged("checked", coreObject->isChecked()); > break; > case AXSelectedStateChanged: >- case AXMenuListItemSelected: > wrapper->stateChanged("selected", coreObject->isSelected()); > break; >+ case AXMenuListItemSelected: { >+ // Menu list popup items are handled by AXSelectedStateChanged. >+ auto* parent = coreObject->parentObjectUnignored(); >+ if (parent && !parent->isMenuListPopup()) >+ wrapper->stateChanged("selected", coreObject->isSelected()); >+ break; >+ } > case AXSelectedChildrenChanged: > wrapper->selectionChanged(); > break; >diff --git a/Source/WebCore/html/HTMLOptionElement.cpp b/Source/WebCore/html/HTMLOptionElement.cpp >index b725de241d32..077d72a0e6b2 100644 >--- a/Source/WebCore/html/HTMLOptionElement.cpp >+++ b/Source/WebCore/html/HTMLOptionElement.cpp >@@ -27,7 +27,9 @@ > #include "config.h" > #include "HTMLOptionElement.h" > >+#include "AXObjectCache.h" > #include "Document.h" >+#include "DocumentInlines.h" > #include "ElementAncestorIterator.h" > #include "HTMLDataListElement.h" > #include "HTMLNames.h" >@@ -234,6 +236,11 @@ void HTMLOptionElement::setSelectedState(bool selected) > > m_isSelected = selected; > invalidateStyleForSubtree(); >+ >+#if ENABLE(ACCESSIBILITY) && USE(ATSPI) >+ if (auto* cache = document().existingAXObjectCache()) >+ cache->postNotification(this, AXObjectCache::AXSelectedStateChanged); >+#endif > } > > void HTMLOptionElement::childrenChanged(const ChildChange& change) >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 0717a186d224..d0a3b48cfd7d 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,18 @@ >+2021-11-26 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [GTK][a11y] Signal state-changed:selected is not emitted for listbox elements when building with ATSPI >+ https://bugs.webkit.org/show_bug.cgi?id=233521 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add test cases to check that the signal is now emitted as expected. >+ >+ * TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp: >+ (AccessibilityTest::isSelected): >+ (testAccessibleStateChanged): >+ (testSelectionListBox): >+ (testSelectionMenuList): >+ > 2021-11-26 Carlos Garcia Campos <cgarcia@igalia.com> > > [GTK][a11y] MenuListPopup elements should implement selection interface too when building with ATSPI >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp b/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp >index 5efb443f2210..e928621462fb 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp >@@ -152,6 +152,12 @@ public: > return length; > } > >+ static bool isSelected(AtspiAccessible* element) >+ { >+ GRefPtr<AtspiStateSet> set = adoptGRef(atspi_accessible_get_state_set(element)); >+ return atspi_state_set_contains(set.get(), ATSPI_STATE_SELECTED); >+ } >+ > private: > AtspiAccessible* m_eventSource { nullptr }; > >@@ -668,13 +674,15 @@ static void testAccessibleState(AccessibilityTest* test, gconstpointer) > > static void testAccessibleStateChanged(AccessibilityTest* test, gconstpointer) > { >- test->showInWindow(); >+ test->showInWindow(800, 600); > test->loadHtml( > "<html>" > " <body>" > " <input id='check' type='checkbox'/>Checkbox" > " <button id='toggle' aria-pressed='true'>Toggle button</button>" > " <input id='entry' value='Entry'>" >+ " <select id='list' size='2'><option>1</option><option>2</option></select>" >+ " <select id='combo'><option>1</option><option>2</option></select>" > " </body>" > "</html>", > nullptr); >@@ -689,7 +697,7 @@ static void testAccessibleStateChanged(AccessibilityTest* test, gconstpointer) > > auto section = adoptGRef(atspi_accessible_get_child_at_index(documentWeb.get(), 0, nullptr)); > g_assert_true(ATSPI_IS_ACCESSIBLE(section.get())); >- g_assert_cmpint(atspi_accessible_get_child_count(section.get(), nullptr), ==, 3); >+ g_assert_cmpint(atspi_accessible_get_child_count(section.get(), nullptr), ==, 5); > > unsigned nextChild = 0; > auto checkbox = adoptGRef(atspi_accessible_get_child_at_index(section.get(), nextChild++, nullptr)); >@@ -741,6 +749,66 @@ static void testAccessibleStateChanged(AccessibilityTest* test, gconstpointer) > } else > g_assert_not_reached(); > events = { }; >+ >+ test->runJavaScriptAndWaitUntilFinished("document.getElementById('list').focus();", nullptr); >+ auto listBox = adoptGRef(atspi_accessible_get_child_at_index(section.get(), nextChild++, nullptr)); >+ g_assert_true(ATSPI_IS_ACCESSIBLE(listBox.get())); >+ auto option1 = adoptGRef(atspi_accessible_get_child_at_index(listBox.get(), 0, nullptr)); >+ g_assert_true(ATSPI_IS_ACCESSIBLE(option1.get())); >+ auto option2 = adoptGRef(atspi_accessible_get_child_at_index(listBox.get(), 1, nullptr)); >+ g_assert_true(ATSPI_IS_ACCESSIBLE(option2.get())); >+ g_assert_false(AccessibilityTest::isSelected(option1.get())); >+ g_assert_false(AccessibilityTest::isSelected(option2.get())); >+ test->startEventMonitor(option1.get(), { "object:state-changed" }); >+ test->runJavaScriptAndWaitUntilFinished("document.getElementById('list').selectedIndex = 0;", nullptr); >+ events = test->stopEventMonitor(1); >+ g_assert_cmpuint(events.size(), ==, 1); >+ g_assert_cmpstr(events[0]->type, ==, "object:state-changed:selected"); >+ g_assert_cmpuint(events[0]->detail1, ==, 1); >+ events = { }; >+ g_assert_true(AccessibilityTest::isSelected(option1.get())); >+ g_assert_false(AccessibilityTest::isSelected(option2.get())); >+ test->startEventMonitor(option1.get(), { "object:state-changed" }); >+ test->runJavaScriptAndWaitUntilFinished("document.getElementById('list').selectedIndex = 1;", nullptr); >+ events = test->stopEventMonitor(1); >+ g_assert_cmpuint(events.size(), ==, 1); >+ g_assert_cmpstr(events[0]->type, ==, "object:state-changed:selected"); >+ g_assert_cmpuint(events[0]->detail1, ==, 0); >+ events = { }; >+ g_assert_false(AccessibilityTest::isSelected(option1.get())); >+ g_assert_true(AccessibilityTest::isSelected(option2.get())); >+ >+#if USE(ATSPI) >+ test->runJavaScriptAndWaitUntilFinished("document.getElementById('combo').focus();", nullptr); >+ auto combo = adoptGRef(atspi_accessible_get_child_at_index(section.get(), nextChild++, nullptr)); >+ g_assert_true(ATSPI_IS_ACCESSIBLE(combo.get())); >+ auto menuList = adoptGRef(atspi_accessible_get_child_at_index(combo.get(), 0, nullptr)); >+ g_assert_true(ATSPI_IS_ACCESSIBLE(menuList.get())); >+ option1 = adoptGRef(atspi_accessible_get_child_at_index(menuList.get(), 0, nullptr)); >+ g_assert_true(ATSPI_IS_ACCESSIBLE(option1.get())); >+ option2 = adoptGRef(atspi_accessible_get_child_at_index(menuList.get(), 1, nullptr)); >+ g_assert_true(ATSPI_IS_ACCESSIBLE(option2.get())); >+ g_assert_true(AccessibilityTest::isSelected(option1.get())); >+ g_assert_false(AccessibilityTest::isSelected(option2.get())); >+ test->startEventMonitor(option2.get(), { "object:state-changed" }); >+ test->runJavaScriptAndWaitUntilFinished("document.getElementById('combo').selectedIndex = 1;", nullptr); >+ events = test->stopEventMonitor(1); >+ g_assert_cmpuint(events.size(), ==, 1); >+ g_assert_cmpstr(events[0]->type, ==, "object:state-changed:selected"); >+ g_assert_cmpuint(events[0]->detail1, ==, 1); >+ events = { }; >+ g_assert_true(AccessibilityTest::isSelected(option2.get())); >+ g_assert_false(AccessibilityTest::isSelected(option1.get())); >+ test->startEventMonitor(option2.get(), { "object:state-changed" }); >+ test->runJavaScriptAndWaitUntilFinished("document.getElementById('combo').selectedIndex = 0", nullptr); >+ events = test->stopEventMonitor(1); >+ g_assert_cmpuint(events.size(), ==, 1); >+ g_assert_cmpstr(events[0]->type, ==, "object:state-changed:selected"); >+ g_assert_cmpuint(events[0]->detail1, ==, 0); >+ events = { }; >+ g_assert_true(AccessibilityTest::isSelected(option1.get())); >+ g_assert_false(AccessibilityTest::isSelected(option2.get())); >+#endif > } > > static void testComponentHitTest(AccessibilityTest* test, gconstpointer) >@@ -2104,6 +2172,7 @@ static void testSelectionListBox(AccessibilityTest* test, gconstpointer) > g_assert_true(ATSPI_IS_ACCESSIBLE(selectedChild.get())); > auto option1 = adoptGRef(atspi_accessible_get_child_at_index(listBox.get(), 0, nullptr)); > g_assert_true(selectedChild.get() == option1.get()); >+ g_assert_true(AccessibilityTest::isSelected(option1.get())); > test->startEventMonitor(listBox.get(), { "object:selection-changed" }); > g_assert_true(atspi_selection_select_child(ATSPI_SELECTION(listBox.get()), 2, nullptr)); > events = test->stopEventMonitor(1); >@@ -2116,12 +2185,16 @@ static void testSelectionListBox(AccessibilityTest* test, gconstpointer) > g_assert_true(ATSPI_IS_ACCESSIBLE(selectedChild.get())); > auto option3 = adoptGRef(atspi_accessible_get_child_at_index(listBox.get(), 2, nullptr)); > g_assert_true(selectedChild.get() == option3.get()); >+ g_assert_true(AccessibilityTest::isSelected(option3.get())); >+ g_assert_false(AccessibilityTest::isSelected(option1.get())); > g_assert_false(atspi_selection_deselect_selected_child(ATSPI_SELECTION(listBox.get()), 1, nullptr)); > g_assert_cmpint(atspi_selection_get_n_selected_children(ATSPI_SELECTION(listBox.get()), nullptr), ==, 1); > g_assert_true(atspi_selection_deselect_selected_child(ATSPI_SELECTION(listBox.get()), 0, nullptr)); > g_assert_cmpint(atspi_selection_get_n_selected_children(ATSPI_SELECTION(listBox.get()), nullptr), ==, 0); > g_assert_false(atspi_selection_is_child_selected(ATSPI_SELECTION(listBox.get()), 2, nullptr)); > g_assert_false(atspi_selection_select_all(ATSPI_SELECTION(listBox.get()), nullptr)); >+ g_assert_false(AccessibilityTest::isSelected(option1.get())); >+ g_assert_false(AccessibilityTest::isSelected(option3.get())); > g_assert_true(atspi_selection_select_child(ATSPI_SELECTION(listBox.get()), 0, nullptr)); > g_assert_cmpint(atspi_selection_get_n_selected_children(ATSPI_SELECTION(listBox.get()), nullptr), ==, 1); > g_assert_true(atspi_selection_is_child_selected(ATSPI_SELECTION(listBox.get()), 0, nullptr)); >@@ -2148,6 +2221,7 @@ static void testSelectionListBox(AccessibilityTest* test, gconstpointer) > g_assert_true(ATSPI_IS_ACCESSIBLE(selectedChild.get())); > auto option2 = adoptGRef(atspi_accessible_get_child_at_index(listBox.get(), 1, nullptr)); > g_assert_true(selectedChild.get() == option2.get()); >+ g_assert_true(AccessibilityTest::isSelected(option2.get())); > g_assert_true(atspi_selection_select_child(ATSPI_SELECTION(listBox.get()), 0, nullptr)); > g_assert_cmpint(atspi_selection_get_n_selected_children(ATSPI_SELECTION(listBox.get()), nullptr), ==, 2); > g_assert_true(atspi_selection_is_child_selected(ATSPI_SELECTION(listBox.get()), 0, nullptr)); >@@ -2155,6 +2229,8 @@ static void testSelectionListBox(AccessibilityTest* test, gconstpointer) > selectedChild = adoptGRef(atspi_selection_get_selected_child(ATSPI_SELECTION(listBox.get()), 0, nullptr)); > option1 = adoptGRef(atspi_accessible_get_child_at_index(listBox.get(), 0, nullptr)); > g_assert_true(selectedChild.get() == option1.get()); >+ g_assert_true(AccessibilityTest::isSelected(option1.get())); >+ g_assert_true(AccessibilityTest::isSelected(option2.get())); > selectedChild = adoptGRef(atspi_selection_get_selected_child(ATSPI_SELECTION(listBox.get()), 1, nullptr)); > g_assert_true(selectedChild.get() == option2.get()); > g_assert_true(atspi_selection_deselect_child(ATSPI_SELECTION(listBox.get()), 1, nullptr)); >@@ -2211,6 +2287,8 @@ static void testSelectionMenuList(AccessibilityTest* test, gconstpointer) > g_assert_cmpint(atspi_accessible_get_role(panel.get(), nullptr), ==, ATSPI_ROLE_PANEL); > g_assert_cmpint(atspi_accessible_get_child_count(panel.get(), nullptr), ==, 1); > >+ test->runJavaScriptAndWaitUntilFinished("document.getElementById('combo').focus();", nullptr); >+ > auto combo = adoptGRef(atspi_accessible_get_child_at_index(panel.get(), 0, nullptr)); > g_assert_true(ATSPI_IS_ACCESSIBLE(combo.get())); > g_assert_cmpint(atspi_accessible_get_role(combo.get(), nullptr), ==, ATSPI_ROLE_COMBO_BOX); >@@ -2231,6 +2309,9 @@ static void testSelectionMenuList(AccessibilityTest* test, gconstpointer) > g_assert_true(ATSPI_IS_ACCESSIBLE(selectedChild.get())); > auto option2 = adoptGRef(atspi_accessible_get_child_at_index(menuList.get(), 1, nullptr)); > g_assert_true(selectedChild.get() == option2.get()); >+ g_assert_true(AccessibilityTest::isSelected(option2.get())); >+ auto option1 = adoptGRef(atspi_accessible_get_child_at_index(menuList.get(), 0, nullptr)); >+ g_assert_false(AccessibilityTest::isSelected(option1.get())); > g_assert_false(atspi_selection_select_child(ATSPI_SELECTION(menuList.get()), 3, nullptr)); > test->startEventMonitor(menuList.get(), { "object:selection-changed" }); > g_assert_true(atspi_selection_select_child(ATSPI_SELECTION(menuList.get()), 0, nullptr)); >@@ -2239,6 +2320,11 @@ static void testSelectionMenuList(AccessibilityTest* test, gconstpointer) > g_assert_cmpstr(events[0]->type, ==, "object:selection-changed"); > events = { }; > g_assert_true(atspi_selection_is_child_selected(ATSPI_SELECTION(menuList.get()), 0, nullptr)); >+ selectedChild = adoptGRef(atspi_selection_get_selected_child(ATSPI_SELECTION(menuList.get()), 0, nullptr)); >+ g_assert_true(ATSPI_IS_ACCESSIBLE(selectedChild.get())); >+ g_assert_true(selectedChild.get() == option1.get()); >+ g_assert_true(AccessibilityTest::isSelected(option1.get())); >+ g_assert_false(AccessibilityTest::isSelected(option2.get())); > g_assert_false(atspi_selection_deselect_selected_child(ATSPI_SELECTION(menuList.get()), 0, nullptr)); > g_assert_false(atspi_selection_deselect_child(ATSPI_SELECTION(menuList.get()), 0, nullptr)); > g_assert_false(atspi_selection_select_all(ATSPI_SELECTION(menuList.get()), nullptr));
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
Flags:
aperez
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 233521
: 445193