a11y: Improve name computation
authorMatthias Clasen <mclasen@redhat.com>
Tue, 20 Jun 2023 16:34:01 +0000 (12:34 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 20 Jun 2023 16:34:51 +0000 (12:34 -0400)
We only want to settle on subtree content
if it provides nonempty text. Otherwise,
the tooltip should still win.

This was clarified in the current Editor Draft
of the accessible name computation spec.

gtk/gtkatcontext.c

index efbc572665e7b0f5a47a047017da05ddb9e8b582..4d8618464451d534680ad30f882008e31cf4ba41 100644 (file)
@@ -1321,7 +1321,7 @@ gtk_at_context_get_text_accumulate (GtkATContext          *self,
     {
       if (GTK_IS_WIDGET (self->accessible))
         {
-          gboolean has_child = FALSE;
+          GString *s = g_string_new ("");
 
           for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (self->accessible));
                child != NULL;
@@ -1330,13 +1330,17 @@ gtk_at_context_get_text_accumulate (GtkATContext          *self,
               GtkAccessible *rel = GTK_ACCESSIBLE (child);
               GtkATContext *rel_context = gtk_accessible_get_at_context (rel);
 
-              gtk_at_context_get_text_accumulate (rel_context, nodes, res, property, relation, FALSE, TRUE);
-
-              has_child = TRUE;
+              gtk_at_context_get_text_accumulate (rel_context, nodes, s, property, relation, FALSE, TRUE);
             }
 
-           if (has_child)
-             return;
+           if (s->len > 0)
+             {
+               g_string_append (res, s->str);
+               g_string_free (s, TRUE);
+               return;
+             }
+
+           g_string_free (s, TRUE);
         }
     }