a11y: Don't present HIDDEN accessibles

The ARIA spec is clear on this: when an element has the
HIDDEN state, it should not be presented in the accessible
tree.

This change is incomplete, we also need to emit child-added/
removed signals when the state changes, but that needs to
wait for the child added infrastructure to land.
This commit is contained in:
Matthias Clasen 2020-10-24 10:32:24 -04:00
parent 1e13acb206
commit 374a451eeb

View File

@ -742,6 +742,8 @@ gtk_accessible_bounds_changed (GtkAccessible *self)
gboolean
gtk_accessible_should_present (GtkAccessible *self)
{
GtkATContext *context;
if (GTK_IS_WIDGET (self) &&
!gtk_widget_get_visible (GTK_WIDGET (self)))
return FALSE;
@ -749,6 +751,16 @@ gtk_accessible_should_present (GtkAccessible *self)
if (gtk_accessible_get_accessible_role (self) == GTK_ACCESSIBLE_ROLE_NONE)
return FALSE;
context = gtk_accessible_get_at_context (self);
if (gtk_at_context_has_accessible_state (context, GTK_ACCESSIBLE_STATE_HIDDEN))
{
GtkAccessibleValue *value;
value = gtk_at_context_get_accessible_state (context, GTK_ACCESSIBLE_STATE_HIDDEN);
if (gtk_boolean_accessible_value_get (value))
return FALSE;
}
return TRUE;
}