[gtk/ebassi/for-master: 6/14] a11y: Skip unlabelled structural roles
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/ebassi/for-master: 6/14] a11y: Skip unlabelled structural roles
- Date: Wed, 11 Nov 2020 18:33:35 +0000 (UTC)
commit 04c4d293a727ebc79a8baebe2463782ce1c6a69a
Author: Emmanuele Bassi <ebassi gnome org>
Date: Wed Nov 11 17:50:42 2020 +0000
a11y: Skip unlabelled structural roles
If a structural role is left unlabelled, just leave it unnamed.
gtk/gtkatcontext.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkatcontext.c b/gtk/gtkatcontext.c
index 661ac848b1..74f368d5e7 100644
--- a/gtk/gtkatcontext.c
+++ b/gtk/gtkatcontext.c
@@ -862,6 +862,27 @@ gtk_at_context_get_accessible_relation (GtkATContext *self,
return gtk_accessible_attribute_set_get_value (self->relations, relation);
}
+static gboolean
+is_structural_role (GtkAccessibleRole role)
+{
+ /* Keep the switch small while avoiding the compiler warning for
+ * unhandled enumeration values
+ */
+ switch ((int) role)
+ {
+ case GTK_ACCESSIBLE_ROLE_FORM:
+ case GTK_ACCESSIBLE_ROLE_GROUP:
+ case GTK_ACCESSIBLE_ROLE_GENERIC:
+ case GTK_ACCESSIBLE_ROLE_REGION:
+ return TRUE;
+
+ default:
+ break;
+ }
+
+ return FALSE;
+}
+
/* See the WAI-ARIA ยง 4.3, "Accessible Name and Description Computation" */
static void
gtk_at_context_get_name_accumulate (GtkATContext *self,
@@ -937,7 +958,8 @@ gtk_at_context_get_name_accumulate (GtkATContext *self,
if (names->len != 0)
return;
- if (self->accessible)
+ /* Ignore structural elements, namely: generic containers */
+ if (self->accessible != NULL && !is_structural_role (role))
g_ptr_array_add (names, (char *)G_OBJECT_TYPE_NAME (self->accessible));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]