| Flutter Linux Embedder |

Classes | Enumerations | Functions | Variables
fl_view_accessible.cc File Reference
`#include <atk/atk.h>`
`#include "flutter/shell/platform/linux/fl_accessible_node.h"`
`#include "flutter/shell/platform/linux/fl_accessible_text_field.h"`
`#include "flutter/shell/platform/linux/fl_view_accessible.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_value.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_view.h"`

Go to the source code of this file.

## Classes
struct | _FlViewAccessible

## Enumerations
enum | FlAtkLive { FL_ATK_LIVE_NONE , FL_ATK_LIVE_POLITE , FL_ATK_LIVE_ASSERTIVE , FL_ATK_LIVE_NONE , FL_ATK_LIVE_POLITE , FL_ATK_LIVE_ASSERTIVE }

## Functions
static FlAccessibleNode * | create_node (FlViewAccessible *self, FlutterSemanticsNode2 *semantics)
static FlAccessibleNode * | lookup_node (FlViewAccessible *self, int32_t id)
static FlAccessibleNode * | get_node (FlViewAccessible *self, FlutterSemanticsNode2 *semantics)
static gint | fl_view_accessible_get_n_children (AtkObject *accessible)
static AtkObject * | fl_view_accessible_ref_child (AtkObject *accessible, gint i)
static AtkRole | fl_view_accessible_get_role (AtkObject *accessible)
static AtkStateSet * | fl_view_accessible_ref_state_set (AtkObject *accessible)
static void | fl_view_accessible_dispose (GObject *object)
static void | fl_view_accessible_class_init (FlViewAccessibleClass *klass)
static void | fl_view_accessible_init (FlViewAccessible *self)
FlViewAccessible * | fl_view_accessible_new (FlEngine *engine, FlutterViewId view_id)
void | fl_view_accessible_handle_update_semantics (FlViewAccessible *self, const FlutterSemanticsUpdate2 *update)
void | fl_view_accessible_send_announcement (FlViewAccessible *self, const char *message, gboolean assertive)

## Variables
static constexpr int32_t | kRootSemanticsNodeId = 0

## Enumeration Type Documentation

## ◆ FlAtkLive

enum FlAtkLive

Enumerator
FL_ATK_LIVE_NONE |
FL_ATK_LIVE_POLITE |
FL_ATK_LIVE_ASSERTIVE |
FL_ATK_LIVE_NONE |
FL_ATK_LIVE_POLITE |
FL_ATK_LIVE_ASSERTIVE |

Definition at line 37 of file fl_view_accessible.cc.

37 {
38 FL_ATK_LIVE_NONE,
39 FL_ATK_LIVE_POLITE,
40 FL_ATK_LIVE_ASSERTIVE
41 } FlAtkLive;
FlAtkLive
FlAtkLive
Definition: fl_view_accessible.cc:37
FL_ATK_LIVE_ASSERTIVE
@ FL_ATK_LIVE_ASSERTIVE
Definition: fl_view_accessible.cc:40
FL_ATK_LIVE_NONE
@ FL_ATK_LIVE_NONE
Definition: fl_view_accessible.cc:38
FL_ATK_LIVE_POLITE
@ FL_ATK_LIVE_POLITE
Definition: fl_view_accessible.cc:39

## Function Documentation

## ◆ create_node()

static FlAccessibleNode* create_node | ( | FlViewAccessible * | self,
|  | FlutterSemanticsNode2 * | semantics
| ) |  |
| static

Definition at line 43 of file fl_view_accessible.cc.

44 {
45 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
46 if (engine == nullptr) {
47 return nullptr;
48 }
49
50 if (semantics->flags2->is_text_field) {
51 return fl_accessible_text_field_new(engine, self->view_id, semantics->id);
52 }
53
54 return fl_accessible_node_new(engine, self->view_id, semantics->id);
55 }
g_autoptr
g_autoptr(FlEngine) engine
fl_accessible_node_new
FlAccessibleNode * fl_accessible_node_new(FlEngine *engine, FlutterViewId view_id, int32_t node_id)
Definition: fl_accessible_node.cc:560
fl_accessible_text_field_new
FlAccessibleNode * fl_accessible_text_field_new(FlEngine *engine, FlutterViewId view_id, int32_t id)
Definition: fl_accessible_text_field.cc:618

References fl_accessible_node_new(), fl_accessible_text_field_new(), and g_autoptr().

Referenced by get_node().

## ◆ fl_view_accessible_class_init()

static void fl_view_accessible_class_init | ( | FlViewAccessibleClass * | klass | ) |
| static

Definition at line 134 of file fl_view_accessible.cc.

134 {
135 ATK_OBJECT_CLASS(klass)->get_n_children = fl_view_accessible_get_n_children;
136 ATK_OBJECT_CLASS(klass)->ref_child = fl_view_accessible_ref_child;
137 ATK_OBJECT_CLASS(klass)->get_role = fl_view_accessible_get_role;
138 ATK_OBJECT_CLASS(klass)->ref_state_set = fl_view_accessible_ref_state_set;
139
140 G_OBJECT_CLASS(klass)->dispose = fl_view_accessible_dispose;
141 }
fl_view_accessible_dispose
static void fl_view_accessible_dispose(GObject *object)
Definition: fl_view_accessible.cc:124
fl_view_accessible_ref_child
static AtkObject * fl_view_accessible_ref_child(AtkObject *accessible, gint i)
Definition: fl_view_accessible.cc:101
fl_view_accessible_get_role
static AtkRole fl_view_accessible_get_role(AtkObject *accessible)
Definition: fl_view_accessible.cc:113
fl_view_accessible_get_n_children
static gint fl_view_accessible_get_n_children(AtkObject *accessible)
Definition: fl_view_accessible.cc:89
fl_view_accessible_ref_state_set
static AtkStateSet * fl_view_accessible_ref_state_set(AtkObject *accessible)
Definition: fl_view_accessible.cc:118

References fl_view_accessible_dispose(), fl_view_accessible_get_n_children(), fl_view_accessible_get_role(), fl_view_accessible_ref_child(), and fl_view_accessible_ref_state_set().

## ◆ fl_view_accessible_dispose()

static void fl_view_accessible_dispose | ( | GObject * | object | ) |
| static

Definition at line 124 of file fl_view_accessible.cc.

124 {
125 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(object);
126
127 g_clear_pointer(&self->semantics_nodes_by_id, g_hash_table_unref);
128
129 g_weak_ref_clear(&self->engine);
130
131 G_OBJECT_CLASS(fl_view_accessible_parent_class)->dispose(object);
132 }

Referenced by fl_view_accessible_class_init().

## ◆ fl_view_accessible_get_n_children()

static gint fl_view_accessible_get_n_children | ( | AtkObject * | accessible | ) |
| static

Definition at line 89 of file fl_view_accessible.cc.

89 {
90 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(accessible);
91 FlAccessibleNode* node = lookup_node(self, 0);
92
93 if (node == nullptr) {
94 return 0;
95 }
96
97 return 1;
98 }
accessible
FlViewAccessible * accessible
Definition: fl_accessibility_handler.cc:41
lookup_node
static FlAccessibleNode * lookup_node(FlViewAccessible *self, int32_t id)
Definition: fl_view_accessible.cc:57

References accessible, and lookup_node().

Referenced by fl_view_accessible_class_init().

## ◆ fl_view_accessible_get_role()

static AtkRole fl_view_accessible_get_role | ( | AtkObject * | accessible | ) |
| static

Definition at line 113 of file fl_view_accessible.cc.

113 {
114 return ATK_ROLE_PANEL;
115 }

Referenced by fl_view_accessible_class_init().

## ◆ fl_view_accessible_handle_update_semantics()

void fl_view_accessible_handle_update_semantics | ( | FlViewAccessible * | accessible,
|  | const FlutterSemanticsUpdate2 * | update
| ) |  |

fl_view_accessible_handle_update_semantics: @accessible: an #FlViewAccessible. @update: semantic update information.

Handle a semantics update from Flutter.

Definition at line 157 of file fl_view_accessible.cc.

159 {
160 g_return_if_fail(FL_IS_VIEW_ACCESSIBLE(self));
161
162 g_autoptr(GHashTable) pending_children =
163 g_hash_table_new_full(g_direct_hash, g_direct_equal, nullptr,
164 reinterpret_cast<GDestroyNotify>(fl_value_unref));
165 for (size_t i = 0; i < update->node_count; i++) {
166 FlutterSemanticsNode2* node = update->nodes[i];
167 FlAccessibleNode* atk_node = get_node(self, node);
168
169 fl_accessible_node_set_flags(atk_node, node->flags2);
170 fl_accessible_node_set_actions(atk_node, node->actions);
171 fl_accessible_node_set_name(atk_node, node->label);
172 fl_accessible_node_set_extents(
173 atk_node, node->rect.left + node->transform.transX,
174 node->rect.top + node->transform.transY,
175 node->rect.right - node->rect.left, node->rect.bottom - node->rect.top);
176 fl_accessible_node_set_value(atk_node, node->value);
177 fl_accessible_node_set_text_selection(atk_node, node->text_selection_base,
178 node->text_selection_extent);
179 fl_accessible_node_set_text_direction(atk_node, node->text_direction);
180
181 FlValue* children = fl_value_new_int32_list(
182 node->children_in_traversal_order, node->child_count);
183 g_hash_table_insert(pending_children, atk_node, children);
184 }
185
186 g_hash_table_foreach_remove(
187 pending_children,
188 [](gpointer key, gpointer value, gpointer user_data) -> gboolean {
189 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(user_data);
190
191 FlAccessibleNode* parent = FL_ACCESSIBLE_NODE(key);
192
193 size_t child_count = fl_value_get_length(static_cast<FlValue*>(value));
194 const int32_t* children_in_traversal_order =
195 fl_value_get_int32_list(static_cast<FlValue*>(value));
196
197 g_autoptr(GPtrArray) children = g_ptr_array_new();
198 for (size_t i = 0; i < child_count; i++) {
199 FlAccessibleNode* child =
200 lookup_node(self, children_in_traversal_order[i]);
201 if (child == nullptr) {
202 continue;
203 }
204 fl_accessible_node_set_parent(child, ATK_OBJECT(parent), i);
205 g_ptr_array_add(children, child);
206 }
207 fl_accessible_node_set_children(parent, children);
208
209 return TRUE;
210 },
211 self);
212 }
user_data
const char FlTextDirection FlAssertiveness gpointer user_data
Definition: fl_accessibility_handler.cc:24
fl_accessible_node_set_name
void fl_accessible_node_set_name(FlAccessibleNode *self, const gchar *name)
Definition: fl_accessible_node.cc:607
fl_accessible_node_set_text_direction
void fl_accessible_node_set_text_direction(FlAccessibleNode *self, FlutterTextDirection direction)
Definition: fl_accessible_node.cc:653
fl_accessible_node_set_text_selection
void fl_accessible_node_set_text_selection(FlAccessibleNode *self, gint base, gint extent)
Definition: fl_accessible_node.cc:644
fl_accessible_node_set_actions
void fl_accessible_node_set_actions(FlAccessibleNode *self, FlutterSemanticsAction actions)
Definition: fl_accessible_node.cc:631
fl_accessible_node_set_children
void fl_accessible_node_set_children(FlAccessibleNode *self, GPtrArray *children)
Definition: fl_accessible_node.cc:580
fl_accessible_node_set_extents
void fl_accessible_node_set_extents(FlAccessibleNode *self, gint x, gint y, gint width, gint height)
Definition: fl_accessible_node.cc:613
fl_accessible_node_set_value
void fl_accessible_node_set_value(FlAccessibleNode *self, const gchar *value)
Definition: fl_accessible_node.cc:638
fl_accessible_node_set_parent
void fl_accessible_node_set_parent(FlAccessibleNode *self, AtkObject *parent, gint index)
Definition: fl_accessible_node.cc:569
fl_accessible_node_set_flags
void fl_accessible_node_set_flags(FlAccessibleNode *self, FlutterSemanticsFlags *flags)
Definition: fl_accessible_node.cc:624
TRUE
return TRUE
Definition: fl_compositor_software.cc:68
i
int i
Definition: fl_socket_accessible.cc:18
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
fl_value_new_int32_list
G_MODULE_EXPORT FlValue * fl_value_new_int32_list(const int32_t *data, size_t data_length)
Definition: fl_value.cc:309
fl_value_unref
G_MODULE_EXPORT void fl_value_unref(FlValue *self)
Definition: fl_value.cc:400
fl_value_get_int32_list
G_MODULE_EXPORT const int32_t * fl_value_get_int32_list(FlValue *self)
Definition: fl_value.cc:696
fl_value_get_length
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
Definition: fl_value.cc:724
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42
get_node
static FlAccessibleNode * get_node(FlViewAccessible *self, FlutterSemanticsNode2 *semantics)
Definition: fl_view_accessible.cc:64

References fl_accessible_node_set_actions(), fl_accessible_node_set_children(), fl_accessible_node_set_extents(), fl_accessible_node_set_flags(), fl_accessible_node_set_name(), fl_accessible_node_set_parent(), fl_accessible_node_set_text_direction(), fl_accessible_node_set_text_selection(), fl_accessible_node_set_value(), fl_value_get_int32_list(), fl_value_get_length(), fl_value_new_int32_list(), fl_value_unref(), g_autoptr(), get_node(), i, lookup_node(), TRUE, user_data, and value.

Referenced by TEST(), and update_semantics_cb().

## ◆ fl_view_accessible_init()

static void fl_view_accessible_init | ( | FlViewAccessible * | self | ) |
| static

Definition at line 143 of file fl_view_accessible.cc.

143 {
144 self->semantics_nodes_by_id = g_hash_table_new_full(
145 g_direct_hash, g_direct_equal, nullptr, g_object_unref);
146 }

## ◆ fl_view_accessible_new()

FlViewAccessible* fl_view_accessible_new | ( | FlEngine * | engine,
|  | FlutterViewId | view_id
| ) |  |

Definition at line 148 of file fl_view_accessible.cc.

149 {
150 FlViewAccessible* self =
151 FL_VIEW_ACCESSIBLE(g_object_new(fl_view_accessible_get_type(), nullptr));
152 g_weak_ref_init(&self->engine, engine);
153 self->view_id = view_id;
154 return self;
155 }
view_id
G_BEGIN_DECLS FlutterViewId view_id
Definition: fl_view_accessible.h:49

References view_id.

Referenced by setup_engine(), and TEST().

## ◆ fl_view_accessible_ref_child()

static AtkObject* fl_view_accessible_ref_child | ( | AtkObject * | accessible,
|  | gint | i
| ) |  |
| static

Definition at line 101 of file fl_view_accessible.cc.

101 {
102 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(accessible);
103 FlAccessibleNode* node = lookup_node(self, 0);
104
105 if (i != 0 || node == nullptr) {
106 return nullptr;
107 }
108
109 return ATK_OBJECT(g_object_ref(node));
110 }

References accessible, i, and lookup_node().

Referenced by fl_view_accessible_class_init().

## ◆ fl_view_accessible_ref_state_set()

static AtkStateSet* fl_view_accessible_ref_state_set | ( | AtkObject * | accessible | ) |
| static

Definition at line 118 of file fl_view_accessible.cc.

118 {
119 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(accessible);
120 FlAccessibleNode* node = lookup_node(self, 0);
121 return node != nullptr ? atk_object_ref_state_set(ATK_OBJECT(node)) : nullptr;
122 }

References accessible, and lookup_node().

Referenced by fl_view_accessible_class_init().

## ◆ fl_view_accessible_send_announcement()

void fl_view_accessible_send_announcement | ( | FlViewAccessible * | accessible,
|  | const char * | message,
|  | gboolean | assertive
| ) |  |

fl_view_accessible_send_announcement: @accessible: an #FlViewAccessible. @message: text to be announced. @assertive: TRUE if the message should be in an assertive voice.

Sends an annoucement to a screen reader.

Definition at line 214 of file fl_view_accessible.cc.

216 {
217 g_return_if_fail(FL_IS_VIEW_ACCESSIBLE(self));
218 if (atk_get_major_version() == 2 && atk_get_minor_version() >= 50) {
219 g_signal_emit_by_name(
220 self, "notification", message,
221 assertive ? FL_ATK_LIVE_ASSERTIVE : FL_ATK_LIVE_POLITE);
222 } else if (atk_get_major_version() == 2 && atk_get_minor_version() >= 46) {
223 g_signal_emit_by_name(self, "announcement", message);
224 }
225 }
message
const char * message
Definition: fl_accessibility_handler.cc:21

References FL_ATK_LIVE_ASSERTIVE, FL_ATK_LIVE_POLITE, and message.

## ◆ get_node()

static FlAccessibleNode* get_node | ( | FlViewAccessible * | self,
|  | FlutterSemanticsNode2 * | semantics
| ) |  |
| static

Definition at line 64 of file fl_view_accessible.cc.

65 {
66 FlAccessibleNode* node = lookup_node(self, semantics->id);
67 if (node != nullptr) {
68 return node;
69 }
70
71 node = create_node(self, semantics);
72 if (semantics->id == kRootSemanticsNodeId) {
73 fl_accessible_node_set_parent(node, ATK_OBJECT(self), 0);
74 }
75 g_hash_table_insert(self->semantics_nodes_by_id,
76 GINT_TO_POINTER(semantics->id),
77 reinterpret_cast<gpointer>(node));
78
79 // Update when root node is created.
80 if (!self->root_node_created && semantics->id == kRootSemanticsNodeId) {
81 g_signal_emit_by_name(self, "children-changed::add", 0, node, nullptr);
82 self->root_node_created = true;
83 }
84
85 return node;
86 }
create_node
static FlAccessibleNode * create_node(FlViewAccessible *self, FlutterSemanticsNode2 *semantics)
Definition: fl_view_accessible.cc:43
kRootSemanticsNodeId
static constexpr int32_t kRootSemanticsNodeId
Definition: fl_view_accessible.cc:17

References create_node(), fl_accessible_node_set_parent(), kRootSemanticsNodeId, and lookup_node().

Referenced by fl_view_accessible_handle_update_semantics().

## ◆ lookup_node()

static FlAccessibleNode* lookup_node | ( | FlViewAccessible * | self,
|  | int32_t | id
| ) |  |
| static

Definition at line 57 of file fl_view_accessible.cc.

57 {
58 return FL_ACCESSIBLE_NODE(
59 g_hash_table_lookup(self->semantics_nodes_by_id, GINT_TO_POINTER(id)));
60 }

Referenced by fl_view_accessible_get_n_children(), fl_view_accessible_handle_update_semantics(), fl_view_accessible_ref_child(), fl_view_accessible_ref_state_set(), and get_node().

## Variable Documentation

## ◆ kRootSemanticsNodeId

constexpr int32_t kRootSemanticsNodeId = 0
| static constexpr

Definition at line 17 of file fl_view_accessible.cc.

Referenced by get_node().