Skip to content
Permalink
Browse files
[GTK][a11y] Set active state when element is the selected option acti…
…ve or aria-current isn't false with ATSPI

https://bugs.webkit.org/show_bug.cgi?id=235029

Reviewed by Adrian Perez de Castro.

Source/WebCore:

* accessibility/atspi/AXObjectCacheAtspi.cpp:
(WebCore::AXObjectCache::postPlatformNotification):
* accessibility/atspi/AccessibilityObjectAtspi.cpp:
(WebCore::AccessibilityObjectAtspi::state const):

Tools:

Add a unit test to check acive state and implement AccessibilityUIElement::currentStateValue().

* TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp:
(testAccessibleState):
* WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
(WTR::AccessibilityUIElement::domIdentifier const):
(WTR::AccessibilityUIElement::currentStateValue const): Deleted.
* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
(WTR::AccessibilityUIElement::currentStateValue const):
* WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp:
(WTR::AccessibilityUIElement::currentStateValue const):
* WebKitTestRunner/InjectedBundle/win/AccessibilityUIElementWin.cpp:
(WTR::AccessibilityUIElement::currentStateValue const):


Canonical link: https://commits.webkit.org/245915@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287871 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
carlosgcampos committed Jan 11, 2022
1 parent 2c671cc commit 89152cfe9b989b50b5572dd3d82565da3841729e
@@ -1,3 +1,15 @@
2022-01-11 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK][a11y] Set active state when element is the selected option active or aria-current isn't false with ATSPI
https://bugs.webkit.org/show_bug.cgi?id=235029

Reviewed by Adrian Perez de Castro.

* accessibility/atspi/AXObjectCacheAtspi.cpp:
(WebCore::AXObjectCache::postPlatformNotification):
* accessibility/atspi/AccessibilityObjectAtspi.cpp:
(WebCore::AccessibilityObjectAtspi::state const):

2022-01-10 Yusuke Suzuki <ysuzuki@apple.com>

Fix Windows build after r287829
@@ -126,6 +126,7 @@ void AXObjectCache::postPlatformNotification(AXCoreObject* coreObject, AXNotific
wrapper->stateChanged("busy", coreObject->isBusy());
break;
case AXCurrentStateChanged:
wrapper->stateChanged("active", coreObject->currentState() != AccessibilityCurrentState::False);
break;
case AXRowExpanded:
wrapper->stateChanged("expanded", true);
@@ -789,6 +789,9 @@ uint64_t AccessibilityObjectAtspi::state() const
addState(Atspi::State::Showing);
}

if (m_coreObject->isSelectedOptionActive() || m_coreObject->currentState() != AccessibilityCurrentState::False)
addState(Atspi::State::Active);

if (m_coreObject->canSetFocusAttribute())
addState(Atspi::State::Focusable);

@@ -1,3 +1,24 @@
2022-01-11 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK][a11y] Set active state when element is the selected option active or aria-current isn't false with ATSPI
https://bugs.webkit.org/show_bug.cgi?id=235029

Reviewed by Adrian Perez de Castro.

Add a unit test to check acive state and implement AccessibilityUIElement::currentStateValue().

* TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp:
(testAccessibleState):
* WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
(WTR::AccessibilityUIElement::domIdentifier const):
(WTR::AccessibilityUIElement::currentStateValue const): Deleted.
* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
(WTR::AccessibilityUIElement::currentStateValue const):
* WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp:
(WTR::AccessibilityUIElement::currentStateValue const):
* WebKitTestRunner/InjectedBundle/win/AccessibilityUIElementWin.cpp:
(WTR::AccessibilityUIElement::currentStateValue const):

2022-01-10 Dewei Zhu <dewei_zhu@apple.com>

Revert r287861.
@@ -492,6 +492,7 @@ static void testAccessibleState(AccessibilityTest* test, gconstpointer)
" <input value='Disabled' disabled>"
" <input value='Read only' readonly>"
" <textarea rows=5 autofocus></textarea>"
" <ul><li aria-current='step'>Current</li></ul>"
" </body>"
"</html>",
nullptr);
@@ -502,7 +503,7 @@ static void testAccessibleState(AccessibilityTest* test, gconstpointer)

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), ==, 2);
g_assert_cmpint(atspi_accessible_get_child_count(documentWeb.get(), nullptr), ==, 3);

auto h1 = adoptGRef(atspi_accessible_get_child_at_index(documentWeb.get(), 0, nullptr));
g_assert_true(ATSPI_IS_ACCESSIBLE(h1.get()));
@@ -686,6 +687,17 @@ static void testAccessibleState(AccessibilityTest* test, gconstpointer)
// FIXME: ATK doesn't implement selectable text, but includes oprientation.
g_assert_true(atspi_state_set_contains(stateSet.get(), ATSPI_STATE_HORIZONTAL));
#endif

auto ul = adoptGRef(atspi_accessible_get_child_at_index(documentWeb.get(), 2, nullptr));
g_assert_true(ATSPI_IS_ACCESSIBLE(textArea.get()));
auto li = adoptGRef(atspi_accessible_get_child_at_index(ul.get(), 0, nullptr));
stateSet = adoptGRef(atspi_accessible_get_state_set(li.get()));
g_assert_cmpuint(AccessibilityTest::stateSetSize(stateSet.get()), ==, 5);
g_assert_true(atspi_state_set_contains(stateSet.get(), ATSPI_STATE_ACTIVE));
g_assert_true(atspi_state_set_contains(stateSet.get(), ATSPI_STATE_ENABLED));
g_assert_true(atspi_state_set_contains(stateSet.get(), ATSPI_STATE_SENSITIVE));
g_assert_true(atspi_state_set_contains(stateSet.get(), ATSPI_STATE_VISIBLE));
g_assert_true(atspi_state_set_contains(stateSet.get(), ATSPI_STATE_SHOWING));
}

static void testAccessibleStateChanged(AccessibilityTest* test, gconstpointer)
@@ -121,7 +121,6 @@ bool AccessibilityUIElement::isInDescriptionListTerm() const { return false; }
bool AccessibilityUIElement::isInCell() const { return false; }

JSRetainPtr<JSStringRef> AccessibilityUIElement::domIdentifier() const { return nullptr; }
JSRetainPtr<JSStringRef> AccessibilityUIElement::currentStateValue() const { return nullptr; }
JSRetainPtr<JSStringRef> AccessibilityUIElement::sortDirection() const { return nullptr; }
JSRetainPtr<JSStringRef> AccessibilityUIElement::lineRectsAndText() const { return { }; }
RefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker(AccessibilityTextMarker*) { return nullptr; }
@@ -1117,6 +1117,11 @@ double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute)
return 0;
}

JSRetainPtr<JSStringRef> AccessibilityUIElement::currentStateValue() const
{
return nullptr;
}

JSValueRef AccessibilityUIElement::uiElementArrayAttributeValue(JSStringRef attribute) const
{
// FIXME: implement
@@ -410,6 +410,12 @@ double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute)
return 0;
}

JSRetainPtr<JSStringRef> AccessibilityUIElement::currentStateValue() const
{
auto value = m_element->attributes().get("current");
return OpaqueJSString::tryCreate(!value.isNull() ? value : "false").leakRef();
}

JSValueRef AccessibilityUIElement::uiElementArrayAttributeValue(JSStringRef attribute) const
{
return nullptr;
@@ -190,6 +190,12 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::stringAttributeValue(JSStringRe
return nullptr;
}

JSRetainPtr<JSStringRef> AccessibilityUIElement::currentStateValue() const
{
notImplemented();
return nullptr;
}

JSRetainPtr<JSStringRef> AccessibilityUIElement::stringDescriptionOfAttributeValue(JSStringRef)
{
notImplemented();

0 comments on commit 89152cf

Please sign in to comment.