Don't present GTK class names to assistive technologies even as a fallback
authorLukáš Tyrychtr <lukastyrychtr@gmail.com>
Wed, 21 Dec 2022 10:04:07 +0000 (11:04 +0100)
committerLukáš Tyrychtr <lukastyrychtr@gmail.com>
Wed, 21 Dec 2022 10:35:46 +0000 (11:35 +0100)
A screen reader user is not interested in GTK internals, for example,
he does not care whether a button is an image button or not,
and a screen reader will report the fact that it is a button anyway.
Same applies for GtkEntry widgets, for example.

This actually is sufficient to fix gnome-control-center#2244.
And, according to the discussion in #5145, it should be fine.

gtk/gtkatcontext.c

index aa4b9f51f2c20078078166e132d2a52d18a07b67..07d330d59e07ba731c1d324c7a87f750886b51aa 100644 (file)
@@ -902,31 +902,6 @@ 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_LANDMARK:
-    case GTK_ACCESSIBLE_ROLE_LIST_ITEM:
-    case GTK_ACCESSIBLE_ROLE_REGION:
-    case GTK_ACCESSIBLE_ROLE_SEARCH:
-    case GTK_ACCESSIBLE_ROLE_SEPARATOR:
-      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,
@@ -998,13 +973,6 @@ gtk_at_context_get_name_accumulate (GtkATContext *self,
         return;
     }
 
-  /* This fallback is in place only for unlabelled elements */
-  if (names->len != 0)
-    return;
-
-  /* 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));
 }
 
 static void