From 374a451eeb6e8791fd131862082e742143579b63 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 24 Oct 2020 10:32:24 -0400 Subject: [PATCH] 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. --- gtk/gtkaccessible.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c index 49fea56fb6..12be6332a3 100644 --- a/gtk/gtkaccessible.c +++ b/gtk/gtkaccessible.c @@ -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; }