[gtk/ebassi/for-master: 1/4] a11y: Defer to the GtkAccessible's implementation



commit 292576f3129a1bd73d3b5b4ad0e41d70df1c805e
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Wed Nov 11 19:37:26 2020 +0000

    a11y: Defer to the GtkAccessible's implementation
    
    Since GtkATContexts are now lazily realized, we need to go through the
    GtkAccessible's implementation to access the :accessible-role property,
    in case there are fallbacks.

 gtk/gtkaccessible.c    | 10 +++++++---
 gtk/gtktestatcontext.c |  8 +-------
 2 files changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c
index e9f8d7d663..991bc02756 100644
--- a/gtk/gtkaccessible.c
+++ b/gtk/gtkaccessible.c
@@ -104,13 +104,17 @@ gtk_accessible_get_at_context (GtkAccessible *self)
 GtkAccessibleRole
 gtk_accessible_get_accessible_role (GtkAccessible *self)
 {
+  GtkAccessibleRole role;
+
   g_return_val_if_fail (GTK_IS_ACCESSIBLE (self), GTK_ACCESSIBLE_ROLE_NONE);
 
   GtkATContext *context = gtk_accessible_get_at_context (self);
-  if (context == NULL)
-    return GTK_ACCESSIBLE_ROLE_NONE;
+  if (context != NULL && gtk_at_context_is_realized (context))
+    return gtk_at_context_get_accessible_role (context);
+
+  g_object_get (G_OBJECT (self), "accessible-role", &role, NULL);
 
-  return gtk_at_context_get_accessible_role (context);
+  return role;
 }
 
 /**
diff --git a/gtk/gtktestatcontext.c b/gtk/gtktestatcontext.c
index c8bd222d1a..27ad90da67 100644
--- a/gtk/gtktestatcontext.c
+++ b/gtk/gtktestatcontext.c
@@ -118,15 +118,9 @@ gboolean
 gtk_test_accessible_has_role (GtkAccessible     *accessible,
                               GtkAccessibleRole  role)
 {
-  GtkATContext *context;
-
   g_return_val_if_fail (GTK_IS_ACCESSIBLE (accessible), FALSE);
 
-  context = gtk_accessible_get_at_context (accessible);
-  if (context == NULL)
-    return FALSE;
-
-  return gtk_at_context_get_accessible_role (context) == role;
+  return gtk_accessible_get_accessible_role (accessible) == role;
 }
 
 gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]