Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
fl_accessible_node.cc File Reference

Go to the source code of this file.

Classes

struct  ActionData
 
struct  FlAccessibleNodePrivate
 

Macros

#define FL_ACCESSIBLE_NODE_GET_PRIVATE(node)
 

Enumerations

enum  {
  PROP_0 ,
  PROP_ENGINE ,
  PROP_VIEW_ID ,
  PROP_ID ,
  PROP_LAST
}
 

Functions

static void fl_accessible_node_component_interface_init (AtkComponentIface *iface)
 
static void fl_accessible_node_action_interface_init (AtkActionIface *iface)
 
 G_DEFINE_TYPE_WITH_CODE (FlAccessibleNode, fl_accessible_node, ATK_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT, fl_accessible_node_component_interface_init) G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION, fl_accessible_node_action_interface_init)) static gboolean is_checkable(FlutterSemanticsFlags flags)
 
static gboolean is_checked (FlutterSemanticsFlags flags)
 
static gboolean is_focusable (FlutterSemanticsFlags flags)
 
static gboolean is_focused (FlutterSemanticsFlags flags)
 
static gboolean is_selected (FlutterSemanticsFlags flags)
 
static gboolean is_sensitive (FlutterSemanticsFlags flags)
 
static gboolean is_enabled (FlutterSemanticsFlags flags)
 
static gboolean has_action (FlutterSemanticsAction actions, FlutterSemanticsAction action)
 
static ActionDataget_action (FlAccessibleNodePrivate *priv, gint index)
 
static gboolean has_child (GPtrArray *children, AtkObject *object)
 
static void fl_accessible_node_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 
static void fl_accessible_node_dispose (GObject *object)
 
static const gchar * fl_accessible_node_get_name (AtkObject *accessible)
 
static AtkObject * fl_accessible_node_get_parent (AtkObject *accessible)
 
static gint fl_accessible_node_get_index_in_parent (AtkObject *accessible)
 
static gint fl_accessible_node_get_n_children (AtkObject *accessible)
 
static AtkObject * fl_accessible_node_ref_child (AtkObject *accessible, gint i)
 
static AtkRole fl_accessible_node_get_role (AtkObject *accessible)
 
static AtkStateSet * fl_accessible_node_ref_state_set (AtkObject *accessible)
 
static void fl_accessible_node_get_extents (AtkComponent *component, gint *x, gint *y, gint *width, gint *height, AtkCoordType coord_type)
 
static AtkLayer fl_accessible_node_get_layer (AtkComponent *component)
 
static gboolean fl_accessible_node_do_action (AtkAction *action, gint i)
 
static gint fl_accessible_node_get_n_actions (AtkAction *action)
 
static const gchar * fl_accessible_node_get_name (AtkAction *action, gint i)
 
static void fl_accessible_node_set_name_impl (FlAccessibleNode *self, const gchar *name)
 
static void fl_accessible_node_set_extents_impl (FlAccessibleNode *self, gint x, gint y, gint width, gint height)
 
static bool flag_changed (bool old_flag, bool new_flag)
 
static void fl_accessible_node_set_flags_impl (FlAccessibleNode *self, FlutterSemanticsFlags *flags)
 
static void fl_accessible_node_set_actions_impl (FlAccessibleNode *self, FlutterSemanticsAction actions)
 
static void fl_accessible_node_set_value_impl (FlAccessibleNode *self, const gchar *value)
 
static void fl_accessible_node_set_text_selection_impl (FlAccessibleNode *self, gint base, gint extent)
 
static void fl_accessible_node_set_text_direction_impl (FlAccessibleNode *self, FlutterTextDirection direction)
 
static void fl_accessible_node_perform_action_impl (FlAccessibleNode *self, FlutterSemanticsAction action, GBytes *data)
 
static void fl_accessible_node_class_init (FlAccessibleNodeClass *klass)
 
static void fl_accessible_node_init (FlAccessibleNode *self)
 
FlAccessibleNode * fl_accessible_node_new (FlEngine *engine, FlutterViewId view_id, int32_t node_id)
 
void fl_accessible_node_set_parent (FlAccessibleNode *self, AtkObject *parent, gint index)
 
void fl_accessible_node_set_children (FlAccessibleNode *self, GPtrArray *children)
 
void fl_accessible_node_set_name (FlAccessibleNode *self, const gchar *name)
 
void fl_accessible_node_set_extents (FlAccessibleNode *self, gint x, gint y, gint width, gint height)
 
void fl_accessible_node_set_flags (FlAccessibleNode *self, FlutterSemanticsFlags *flags)
 
void fl_accessible_node_set_actions (FlAccessibleNode *self, FlutterSemanticsAction actions)
 
void fl_accessible_node_set_value (FlAccessibleNode *self, const gchar *value)
 
void fl_accessible_node_set_text_selection (FlAccessibleNode *self, gint base, gint extent)
 
void fl_accessible_node_set_text_direction (FlAccessibleNode *self, FlutterTextDirection direction)
 
void fl_accessible_node_perform_action (FlAccessibleNode *self, FlutterSemanticsAction action, GBytes *data)
 

Variables

static ActionData action_mapping []
 

Macro Definition Documentation

◆ FL_ACCESSIBLE_NODE_GET_PRIVATE

#define FL_ACCESSIBLE_NODE_GET_PRIVATE (   node)
Value:
((FlAccessibleNodePrivate*)fl_accessible_node_get_instance_private( \
FL_ACCESSIBLE_NODE(node)))

Definition at line 68 of file fl_accessible_node.cc.

86 {
87 return flags.is_checked != kFlutterCheckStateNone ||
88 flags.is_toggled != kFlutterTristateNone;
89}
90
91// Returns TRUE if [flags] indicate this element is checked.
92static gboolean is_checked(FlutterSemanticsFlags flags) {
93 return flags.is_checked == kFlutterCheckStateTrue ||
95}
96
97// Returns TRUE if [flags] indicate this element is focusable.
98static gboolean is_focusable(FlutterSemanticsFlags flags) {
99 return flags.is_focused != kFlutterTristateNone;
100}
101
102// Returns TRUE if [flags] indicate this element is focused.
103static gboolean is_focused(FlutterSemanticsFlags flags) {
104 return flags.is_focused == kFlutterTristateTrue;
105}
106
107// Returns TRUE if [flags] indicate this element is selected.
108static gboolean is_selected(FlutterSemanticsFlags flags) {
109 return flags.is_selected == kFlutterTristateTrue;
110}
111
112// Returns TRUE if [flags] indicate this element is sensitive.
113static gboolean is_sensitive(FlutterSemanticsFlags flags) {
114 return flags.is_enabled != kFlutterTristateNone;
115}
116
117// Returns TRUE if [flags] indicate this element is enabled.
118static gboolean is_enabled(FlutterSemanticsFlags flags) {
119 return flags.is_enabled == kFlutterTristateTrue;
120}
121
122// Returns TRUE if [action] is set in [actions].
123static gboolean has_action(FlutterSemanticsAction actions,
125 return (actions & action) != 0;
126}
127
128// Gets the nth action.
130 if (index < 0 || static_cast<guint>(index) >= priv->actions->len) {
131 return nullptr;
132 }
133 return static_cast<ActionData*>(g_ptr_array_index(priv->actions, index));
134}
135
136// Checks if [object] is in [children].
137static gboolean has_child(GPtrArray* children, AtkObject* object) {
138 for (guint i = 0; i < children->len; i++) {
139 if (g_ptr_array_index(children, i) == object) {
140 return TRUE;
141 }
142 }
143
144 return FALSE;
145}
146
147static void fl_accessible_node_set_property(GObject* object,
148 guint prop_id,
149 const GValue* value,
150 GParamSpec* pspec) {
152 switch (prop_id) {
153 case PROP_ENGINE:
154 g_weak_ref_set(&priv->engine, g_value_get_object(value));
155 break;
156 case PROP_VIEW_ID:
157 priv->view_id = g_value_get_int64(value);
158 break;
159 case PROP_ID:
160 priv->node_id = g_value_get_int(value);
161 break;
162 default:
163 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
164 break;
165 }
166}
167
168static void fl_accessible_node_dispose(GObject* object) {
170
171 g_weak_ref_clear(&priv->engine);
172 g_weak_ref_clear(&priv->parent);
173 g_clear_pointer(&priv->name, g_free);
174 g_clear_pointer(&priv->actions, g_ptr_array_unref);
175 g_clear_pointer(&priv->children, g_ptr_array_unref);
176
177 G_OBJECT_CLASS(fl_accessible_node_parent_class)->dispose(object);
178}
179
180// Implements AtkObject::get_name.
181static const gchar* fl_accessible_node_get_name(AtkObject* accessible) {
183 return priv->name;
184}
185
186// Implements AtkObject::get_parent.
187static AtkObject* fl_accessible_node_get_parent(AtkObject* accessible) {
189 g_autoptr(AtkObject) parent = ATK_OBJECT(g_weak_ref_get(&priv->parent));
190 return parent;
191}
192
193// Implements AtkObject::get_index_in_parent.
196 return priv->index;
197}
198
199// Implements AtkObject::get_n_children.
200static gint fl_accessible_node_get_n_children(AtkObject* accessible) {
202 return priv->children->len;
203}
204
205// Implements AtkObject::ref_child.
206static AtkObject* fl_accessible_node_ref_child(AtkObject* accessible, gint i) {
208
209 if (i < 0 || static_cast<guint>(i) >= priv->children->len) {
210 return nullptr;
211 }
212
213 return ATK_OBJECT(g_object_ref(g_ptr_array_index(priv->children, i)));
214}
215
216// Implements AtkObject::get_role.
217static AtkRole fl_accessible_node_get_role(AtkObject* accessible) {
219 if (priv->flags.is_button) {
220 return ATK_ROLE_PUSH_BUTTON;
221 }
222 if (priv->flags.is_in_mutually_exclusive_group &&
223 priv->flags.is_checked != kFlutterCheckStateNone) {
224 return ATK_ROLE_RADIO_BUTTON;
225 }
226 if (priv->flags.is_checked != kFlutterCheckStateNone) {
227 return ATK_ROLE_CHECK_BOX;
228 }
229 if (priv->flags.is_toggled != kFlutterTristateNone) {
230 return ATK_ROLE_TOGGLE_BUTTON;
231 }
232 if (priv->flags.is_slider) {
233 return ATK_ROLE_SLIDER;
234 }
235 if (priv->flags.is_text_field && priv->flags.is_obscured) {
236 return ATK_ROLE_PASSWORD_TEXT;
237 }
238 if (priv->flags.is_text_field) {
239 return ATK_ROLE_TEXT;
240 }
241 if (priv->flags.is_header) {
242 return ATK_ROLE_HEADER;
243 }
244 if (priv->flags.is_link) {
245 return ATK_ROLE_LINK;
246 }
247 if (priv->flags.is_image) {
248 return ATK_ROLE_IMAGE;
249 }
250
251 return ATK_ROLE_PANEL;
252}
253
254// Implements AtkObject::ref_state_set.
255static AtkStateSet* fl_accessible_node_ref_state_set(AtkObject* accessible) {
257
258 AtkStateSet* state_set = atk_state_set_new();
259
260 if (!priv->flags.is_obscured) {
261 atk_state_set_add_state(state_set, ATK_STATE_SHOWING);
262 }
263 if (!priv->flags.is_hidden) {
264 atk_state_set_add_state(state_set, ATK_STATE_VISIBLE);
265 }
266 if (is_checkable(priv->flags)) {
267 atk_state_set_add_state(state_set, ATK_STATE_CHECKABLE);
268 }
269 if (is_checked(priv->flags)) {
270 atk_state_set_add_state(state_set, ATK_STATE_CHECKED);
271 }
272 if (is_focusable(priv->flags)) {
273 atk_state_set_add_state(state_set, ATK_STATE_FOCUSABLE);
274 }
275 if (is_focused(priv->flags)) {
276 atk_state_set_add_state(state_set, ATK_STATE_FOCUSED);
277 }
278 if (is_selected(priv->flags)) {
279 atk_state_set_add_state(state_set, ATK_STATE_SELECTED);
280 }
281 if (is_enabled(priv->flags)) {
282 atk_state_set_add_state(state_set, ATK_STATE_ENABLED);
283 }
284 if (is_sensitive(priv->flags)) {
285 atk_state_set_add_state(state_set, ATK_STATE_SENSITIVE);
286 }
287 if (priv->flags.is_read_only) {
288 atk_state_set_add_state(state_set, ATK_STATE_READ_ONLY);
289 }
290 if (priv->flags.is_text_field) {
291 atk_state_set_add_state(state_set, ATK_STATE_EDITABLE);
292 }
293
294 return state_set;
295}
296
297// Implements AtkComponent::get_extents.
298static void fl_accessible_node_get_extents(AtkComponent* component,
299 gint* x,
300 gint* y,
301 gint* width,
302 gint* height,
303 AtkCoordType coord_type) {
305
306 *x = 0;
307 *y = 0;
308 g_autoptr(AtkObject) parent = ATK_OBJECT(g_weak_ref_get(&priv->parent));
309 if (parent != nullptr) {
310 atk_component_get_extents(ATK_COMPONENT(parent), x, y, nullptr, nullptr,
311 coord_type);
312 }
313
314 *x += priv->x;
315 *y += priv->y;
316 *width = priv->width;
317 *height = priv->height;
318}
319
320// Implements AtkComponent::get_layer.
321static AtkLayer fl_accessible_node_get_layer(AtkComponent* component) {
322 return ATK_LAYER_WIDGET;
323}
324
325// Implements AtkAction::do_action.
326static gboolean fl_accessible_node_do_action(AtkAction* action, gint i) {
328
329 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&priv->engine));
330 if (engine == nullptr) {
331 return FALSE;
332 }
333
335 if (data == nullptr) {
336 return FALSE;
337 }
338
339 fl_accessible_node_perform_action(FL_ACCESSIBLE_NODE(action), data->action,
340 nullptr);
341 return TRUE;
342}
343
344// Implements AtkAction::get_n_actions.
345static gint fl_accessible_node_get_n_actions(AtkAction* action) {
347 return priv->actions->len;
348}
349
350// Implements AtkAction::get_name.
351static const gchar* fl_accessible_node_get_name(AtkAction* action, gint i) {
353
355 if (data == nullptr) {
356 return nullptr;
357 }
358
359 return data->name;
360}
361
362// Implements FlAccessibleNode::set_name.
363static void fl_accessible_node_set_name_impl(FlAccessibleNode* self,
364 const gchar* name) {
366 g_free(priv->name);
367 priv->name = g_strdup(name);
368}
369
370// Implements FlAccessibleNode::set_extents.
371static void fl_accessible_node_set_extents_impl(FlAccessibleNode* self,
372 gint x,
373 gint y,
374 gint width,
375 gint height) {
377 priv->x = x;
378 priv->y = y;
379 priv->width = width;
380 priv->height = height;
381}
382
383// Check two boolean flags are different, in a way that handles true values
384// being different (e.g. 1 and 2).
385static bool flag_changed(bool old_flag, bool new_flag) {
386 return !old_flag != !new_flag;
387}
388
389// Implements FlAccessibleNode::set_flags.
390static void fl_accessible_node_set_flags_impl(FlAccessibleNode* self,
391 FlutterSemanticsFlags* flags) {
393
394 FlutterSemanticsFlags old_flags = priv->flags;
395 priv->flags = *flags;
396
397 if (flag_changed(old_flags.is_obscured, flags->is_obscured)) {
398 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_SHOWING,
399 !flags->is_obscured);
400 }
401 if (flag_changed(old_flags.is_hidden, flags->is_hidden)) {
402 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_VISIBLE,
403 !flags->is_hidden);
404 }
405 if (flag_changed(is_checkable(old_flags), is_checkable(priv->flags))) {
406 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_CHECKABLE,
407 is_checkable(priv->flags));
408 }
409 if (flag_changed(is_checked(old_flags), is_checked(priv->flags))) {
410 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_CHECKED,
411 is_checked(priv->flags));
412 }
413 if (flag_changed(is_focusable(old_flags), is_focusable(priv->flags))) {
414 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_FOCUSABLE,
415 is_focusable(priv->flags));
416 }
417 if (flag_changed(is_focused(old_flags), is_focused(priv->flags))) {
418 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_FOCUSED,
419 is_focused(priv->flags));
420 }
421 if (flag_changed(is_selected(old_flags), is_selected(priv->flags))) {
422 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_SELECTED,
423 is_selected(priv->flags));
424 }
425 if (flag_changed(is_sensitive(old_flags), is_sensitive(priv->flags))) {
426 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_SENSITIVE,
427 is_sensitive(priv->flags));
428 }
429 if (flag_changed(is_enabled(old_flags), is_enabled(priv->flags))) {
430 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_ENABLED,
431 is_enabled(priv->flags));
432 }
433 if (flag_changed(old_flags.is_read_only, flags->is_read_only)) {
434 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_READ_ONLY,
435 flags->is_read_only);
436 }
437 if (flag_changed(old_flags.is_text_field, flags->is_text_field)) {
438 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_EDITABLE,
439 flags->is_text_field);
440 }
441}
442
443// Implements FlAccessibleNode::set_actions.
445 FlAccessibleNode* self,
446 FlutterSemanticsAction actions) {
448
449 // NOTE(robert-ancell): It appears that AtkAction doesn't have a method of
450 // notifying that actions have changed, and even if it did an ATK client
451 // might access the old IDs before checking for new ones. Keep an eye
452 // out for a case where Flutter changes the actions on an item and see
453 // if we can resolve this in another way.
454 g_ptr_array_remove_range(priv->actions, 0, priv->actions->len);
455 for (int i = 0; action_mapping[i].name != nullptr; i++) {
456 if (has_action(actions, action_mapping[i].action)) {
457 g_ptr_array_add(priv->actions, &action_mapping[i]);
458 }
459 }
460}
461
462// Implements FlAccessibleNode::set_value.
463static void fl_accessible_node_set_value_impl(FlAccessibleNode* self,
464 const gchar* value) {}
465
466// Implements FlAccessibleNode::set_text_selection.
467static void fl_accessible_node_set_text_selection_impl(FlAccessibleNode* self,
468 gint base,
469 gint extent) {}
470
471// Implements FlAccessibleNode::set_text_direction.
473 FlAccessibleNode* self,
474 FlutterTextDirection direction) {}
475
476// Implements FlAccessibleNode::perform_action.
478 FlAccessibleNode* self,
480 GBytes* data) {
482 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&priv->engine));
483 if (engine == nullptr) {
484 return;
485 }
487 action, data);
488}
489
490static void fl_accessible_node_class_init(FlAccessibleNodeClass* klass) {
491 G_OBJECT_CLASS(klass)->set_property = fl_accessible_node_set_property;
492 G_OBJECT_CLASS(klass)->dispose = fl_accessible_node_dispose;
493 ATK_OBJECT_CLASS(klass)->get_name = fl_accessible_node_get_name;
494 ATK_OBJECT_CLASS(klass)->get_parent = fl_accessible_node_get_parent;
495 ATK_OBJECT_CLASS(klass)->get_index_in_parent =
497 ATK_OBJECT_CLASS(klass)->get_n_children = fl_accessible_node_get_n_children;
498 ATK_OBJECT_CLASS(klass)->ref_child = fl_accessible_node_ref_child;
499 ATK_OBJECT_CLASS(klass)->get_role = fl_accessible_node_get_role;
500 ATK_OBJECT_CLASS(klass)->ref_state_set = fl_accessible_node_ref_state_set;
501 FL_ACCESSIBLE_NODE_CLASS(klass)->set_name = fl_accessible_node_set_name_impl;
502 FL_ACCESSIBLE_NODE_CLASS(klass)->set_extents =
504 FL_ACCESSIBLE_NODE_CLASS(klass)->set_flags =
506 FL_ACCESSIBLE_NODE_CLASS(klass)->set_actions =
508 FL_ACCESSIBLE_NODE_CLASS(klass)->set_value =
510 FL_ACCESSIBLE_NODE_CLASS(klass)->set_text_selection =
512 FL_ACCESSIBLE_NODE_CLASS(klass)->set_text_direction =
514 FL_ACCESSIBLE_NODE_CLASS(klass)->perform_action =
516
517 g_object_class_install_property(
518 G_OBJECT_CLASS(klass), PROP_ENGINE,
519 g_param_spec_object(
520 "engine", "engine", "Flutter engine", fl_engine_get_type(),
521 static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
522 G_PARAM_STATIC_STRINGS)));
523 g_object_class_install_property(
524 G_OBJECT_CLASS(klass), PROP_VIEW_ID,
525 g_param_spec_int64(
526 "view-id", "view-id", "View ID that this node belongs to", 0,
527 G_MAXINT64, 0,
528 static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)));
529 g_object_class_install_property(
530 G_OBJECT_CLASS(klass), PROP_ID,
531 g_param_spec_int(
532 "node-id", "node-id", "Accessibility node ID", 0, G_MAXINT, 0,
533 static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
534 G_PARAM_STATIC_STRINGS)));
535}
536
538 AtkComponentIface* iface) {
539 iface->get_extents = fl_accessible_node_get_extents;
540 iface->get_layer = fl_accessible_node_get_layer;
541}
542
543static void fl_accessible_node_action_interface_init(AtkActionIface* iface) {
544 iface->do_action = fl_accessible_node_do_action;
545 iface->get_n_actions = fl_accessible_node_get_n_actions;
546 iface->get_name = fl_accessible_node_get_name;
547}
548
549static void fl_accessible_node_init(FlAccessibleNode* self) {
551 g_weak_ref_init(&priv->engine, nullptr);
552 g_weak_ref_init(&priv->parent, nullptr);
553 priv->actions = g_ptr_array_new();
554 priv->children = g_ptr_array_new_with_free_func(g_object_unref);
555}
556
557FlAccessibleNode* fl_accessible_node_new(FlEngine* engine,
559 int32_t node_id) {
560 FlAccessibleNode* self = FL_ACCESSIBLE_NODE(
561 g_object_new(fl_accessible_node_get_type(), "engine", engine, "view-id",
562 view_id, "node-id", node_id, nullptr));
563 return self;
564}
565
566void fl_accessible_node_set_parent(FlAccessibleNode* self,
567 AtkObject* parent,
568 gint index) {
569 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
571 g_weak_ref_set(&priv->parent, parent);
572 priv->index = index;
573}
574
575void fl_accessible_node_set_children(FlAccessibleNode* self,
576 GPtrArray* children) {
577 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
579
580 // Remove nodes that are no longer required.
581 for (guint i = 0; i < priv->children->len;) {
582 AtkObject* object = ATK_OBJECT(g_ptr_array_index(priv->children, i));
583 if (has_child(children, object)) {
584 i++;
585 } else {
586 g_signal_emit_by_name(self, "children-changed::remove", i, object,
587 nullptr);
588 g_ptr_array_remove_index(priv->children, i);
589 }
590 }
591
592 // Add new nodes.
593 for (guint i = 0; i < children->len; i++) {
594 AtkObject* object = ATK_OBJECT(g_ptr_array_index(children, i));
595 if (!has_child(priv->children, object)) {
596 g_ptr_array_add(priv->children, g_object_ref(object));
597 g_signal_emit_by_name(self, "children-changed::add", i, object, nullptr);
598 }
599 }
600}
601
602void fl_accessible_node_set_name(FlAccessibleNode* self, const gchar* name) {
603 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
604
605 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_name(self, name);
606}
607
608void fl_accessible_node_set_extents(FlAccessibleNode* self,
609 gint x,
610 gint y,
611 gint width,
612 gint height) {
613 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
614
615 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_extents(self, x, y, width,
616 height);
617}
618
619void fl_accessible_node_set_flags(FlAccessibleNode* self,
620 FlutterSemanticsFlags* flags) {
621 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
622
623 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_flags(self, flags);
624}
625
626void fl_accessible_node_set_actions(FlAccessibleNode* self,
627 FlutterSemanticsAction actions) {
628 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
629
630 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_actions(self, actions);
631}
632
633void fl_accessible_node_set_value(FlAccessibleNode* self, const gchar* value) {
634 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
635
636 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_value(self, value);
637}
638
639void fl_accessible_node_set_text_selection(FlAccessibleNode* self,
640 gint base,
641 gint extent) {
642 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
643
644 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_text_selection(self, base,
645 extent);
646}
647
648void fl_accessible_node_set_text_direction(FlAccessibleNode* self,
649 FlutterTextDirection direction) {
650 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
651
652 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_text_direction(self,
653 direction);
654}
655
656void fl_accessible_node_perform_action(FlAccessibleNode* self,
658 GBytes* data) {
659 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
660
661 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->perform_action(self, action, data);
662}
int32_t x
@ kFlutterCheckStateNone
The semantics node does not have check state.
Definition embedder.h:289
@ kFlutterCheckStateTrue
The semantics node is checked.
Definition embedder.h:291
FlutterSemanticsAction
Definition embedder.h:122
int64_t FlutterViewId
Definition embedder.h:393
@ kFlutterTristateTrue
The property is applicable and its state is "true" or "on".
Definition embedder.h:282
@ kFlutterTristateNone
The property is not applicable to this semantics node.
Definition embedder.h:280
FlutterTextDirection
Definition embedder.h:366
FlutterEngine engine
Definition main.cc:84
FlViewAccessible * accessible
g_autoptr(FlEngine) engine
FlAccessibilityHandlerPrivate * priv
static gboolean has_child(GPtrArray *children, AtkObject *object)
static void fl_accessible_node_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
void fl_accessible_node_set_name(FlAccessibleNode *self, const gchar *name)
static gboolean fl_accessible_node_do_action(AtkAction *action, gint i)
static void fl_accessible_node_action_interface_init(AtkActionIface *iface)
static void fl_accessible_node_set_text_direction_impl(FlAccessibleNode *self, FlutterTextDirection direction)
void fl_accessible_node_set_text_direction(FlAccessibleNode *self, FlutterTextDirection direction)
void fl_accessible_node_perform_action(FlAccessibleNode *self, FlutterSemanticsAction action, GBytes *data)
@ PROP_ENGINE
@ PROP_VIEW_ID
static AtkStateSet * fl_accessible_node_ref_state_set(AtkObject *accessible)
static gboolean is_sensitive(FlutterSemanticsFlags flags)
static AtkRole fl_accessible_node_get_role(AtkObject *accessible)
static bool flag_changed(bool old_flag, bool new_flag)
static void fl_accessible_node_set_value_impl(FlAccessibleNode *self, const gchar *value)
void fl_accessible_node_set_text_selection(FlAccessibleNode *self, gint base, gint extent)
static AtkObject * fl_accessible_node_get_parent(AtkObject *accessible)
static void fl_accessible_node_class_init(FlAccessibleNodeClass *klass)
static void fl_accessible_node_set_actions_impl(FlAccessibleNode *self, FlutterSemanticsAction actions)
static void fl_accessible_node_component_interface_init(AtkComponentIface *iface)
void fl_accessible_node_set_actions(FlAccessibleNode *self, FlutterSemanticsAction actions)
static void fl_accessible_node_dispose(GObject *object)
void fl_accessible_node_set_children(FlAccessibleNode *self, GPtrArray *children)
void fl_accessible_node_set_extents(FlAccessibleNode *self, gint x, gint y, gint width, gint height)
static AtkLayer fl_accessible_node_get_layer(AtkComponent *component)
void fl_accessible_node_set_value(FlAccessibleNode *self, const gchar *value)
static gboolean is_enabled(FlutterSemanticsFlags flags)
static void fl_accessible_node_get_extents(AtkComponent *component, gint *x, gint *y, gint *width, gint *height, AtkCoordType coord_type)
static gint fl_accessible_node_get_n_actions(AtkAction *action)
static ActionData * get_action(FlAccessibleNodePrivate *priv, gint index)
static const gchar * fl_accessible_node_get_name(AtkObject *accessible)
static gboolean is_selected(FlutterSemanticsFlags flags)
static gboolean has_action(FlutterSemanticsAction actions, FlutterSemanticsAction action)
static gint fl_accessible_node_get_index_in_parent(AtkObject *accessible)
static gboolean is_focusable(FlutterSemanticsFlags flags)
static void fl_accessible_node_init(FlAccessibleNode *self)
void fl_accessible_node_set_parent(FlAccessibleNode *self, AtkObject *parent, gint index)
static void fl_accessible_node_perform_action_impl(FlAccessibleNode *self, FlutterSemanticsAction action, GBytes *data)
static ActionData action_mapping[]
static void fl_accessible_node_set_text_selection_impl(FlAccessibleNode *self, gint base, gint extent)
void fl_accessible_node_set_flags(FlAccessibleNode *self, FlutterSemanticsFlags *flags)
static gint fl_accessible_node_get_n_children(AtkObject *accessible)
static gboolean is_checked(FlutterSemanticsFlags flags)
static void fl_accessible_node_set_extents_impl(FlAccessibleNode *self, gint x, gint y, gint width, gint height)
FlAccessibleNode * fl_accessible_node_new(FlEngine *engine, FlutterViewId view_id, int32_t node_id)
#define FL_ACCESSIBLE_NODE_GET_PRIVATE(node)
static void fl_accessible_node_set_name_impl(FlAccessibleNode *self, const gchar *name)
static AtkObject * fl_accessible_node_ref_child(AtkObject *accessible, gint i)
static gboolean is_focused(FlutterSemanticsFlags flags)
static void fl_accessible_node_set_flags_impl(FlAccessibleNode *self, FlutterSemanticsFlags *flags)
return TRUE
void fl_engine_dispatch_semantics_action(FlEngine *self, FlutterViewId view_id, uint64_t node_id, FlutterSemanticsAction action, GBytes *data)
guint const GValue GParamSpec * pspec
G_BEGIN_DECLS FlutterViewId view_id
const char * name
Definition fuchsia.cc:50
void atk_object_notify_state_change(AtkObject *accessible, AtkState state, gboolean value)
Definition mock_gtk.cc:391
double y
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switch_defs.h:36
int32_t height
int32_t width
const gchar * name
FlutterTristate is_enabled
Whether a semantic node is currently enabled.
Definition embedder.h:306
bool is_obscured
Whether the value of the semantics node is obscured.
Definition embedder.h:326
FlutterTristate is_selected
Whether a semantics node is selected.
Definition embedder.h:304
FlutterTristate is_toggled
Definition embedder.h:309
FlutterTristate is_focused
Whether the semantic node currently holds the user's focus.
Definition embedder.h:316
bool is_hidden
Whether the semantics node is considered hidden.
Definition embedder.h:333
bool is_text_field
Whether the semantic node represents a text field.
Definition embedder.h:320
FlutterCheckState is_checked
Whether a semantics node is checked.
Definition embedder.h:302

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PROP_0 
PROP_ENGINE 
PROP_VIEW_ID 
PROP_ID 
PROP_LAST 

Definition at line 66 of file fl_accessible_node.cc.

Function Documentation

◆ fl_accessible_node_action_interface_init()

static void fl_accessible_node_action_interface_init ( AtkActionIface *  iface)
static

Definition at line 544 of file fl_accessible_node.cc.

544 {
545 iface->do_action = fl_accessible_node_do_action;
546 iface->get_n_actions = fl_accessible_node_get_n_actions;
547 iface->get_name = fl_accessible_node_get_name;
548}

References fl_accessible_node_do_action(), fl_accessible_node_get_n_actions(), and fl_accessible_node_get_name().

◆ fl_accessible_node_class_init()

static void fl_accessible_node_class_init ( FlAccessibleNodeClass *  klass)
static

Definition at line 491 of file fl_accessible_node.cc.

491 {
492 G_OBJECT_CLASS(klass)->set_property = fl_accessible_node_set_property;
493 G_OBJECT_CLASS(klass)->dispose = fl_accessible_node_dispose;
494 ATK_OBJECT_CLASS(klass)->get_name = fl_accessible_node_get_name;
495 ATK_OBJECT_CLASS(klass)->get_parent = fl_accessible_node_get_parent;
496 ATK_OBJECT_CLASS(klass)->get_index_in_parent =
498 ATK_OBJECT_CLASS(klass)->get_n_children = fl_accessible_node_get_n_children;
499 ATK_OBJECT_CLASS(klass)->ref_child = fl_accessible_node_ref_child;
500 ATK_OBJECT_CLASS(klass)->get_role = fl_accessible_node_get_role;
501 ATK_OBJECT_CLASS(klass)->ref_state_set = fl_accessible_node_ref_state_set;
502 FL_ACCESSIBLE_NODE_CLASS(klass)->set_name = fl_accessible_node_set_name_impl;
503 FL_ACCESSIBLE_NODE_CLASS(klass)->set_extents =
505 FL_ACCESSIBLE_NODE_CLASS(klass)->set_flags =
507 FL_ACCESSIBLE_NODE_CLASS(klass)->set_actions =
509 FL_ACCESSIBLE_NODE_CLASS(klass)->set_value =
511 FL_ACCESSIBLE_NODE_CLASS(klass)->set_text_selection =
513 FL_ACCESSIBLE_NODE_CLASS(klass)->set_text_direction =
515 FL_ACCESSIBLE_NODE_CLASS(klass)->perform_action =
517
518 g_object_class_install_property(
519 G_OBJECT_CLASS(klass), PROP_ENGINE,
520 g_param_spec_object(
521 "engine", "engine", "Flutter engine", fl_engine_get_type(),
522 static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
523 G_PARAM_STATIC_STRINGS)));
524 g_object_class_install_property(
525 G_OBJECT_CLASS(klass), PROP_VIEW_ID,
526 g_param_spec_int64(
527 "view-id", "view-id", "View ID that this node belongs to", 0,
528 G_MAXINT64, 0,
529 static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)));
530 g_object_class_install_property(
531 G_OBJECT_CLASS(klass), PROP_ID,
532 g_param_spec_int(
533 "node-id", "node-id", "Accessibility node ID", 0, G_MAXINT, 0,
534 static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
535 G_PARAM_STATIC_STRINGS)));
536}

References fl_accessible_node_dispose(), fl_accessible_node_get_index_in_parent(), fl_accessible_node_get_n_children(), fl_accessible_node_get_name(), fl_accessible_node_get_parent(), fl_accessible_node_get_role(), fl_accessible_node_perform_action_impl(), fl_accessible_node_ref_child(), fl_accessible_node_ref_state_set(), fl_accessible_node_set_actions_impl(), fl_accessible_node_set_extents_impl(), fl_accessible_node_set_flags_impl(), fl_accessible_node_set_name_impl(), fl_accessible_node_set_property(), fl_accessible_node_set_text_direction_impl(), fl_accessible_node_set_text_selection_impl(), fl_accessible_node_set_value_impl(), PROP_ENGINE, PROP_ID, and PROP_VIEW_ID.

◆ fl_accessible_node_component_interface_init()

static void fl_accessible_node_component_interface_init ( AtkComponentIface *  iface)
static

Definition at line 538 of file fl_accessible_node.cc.

539 {
540 iface->get_extents = fl_accessible_node_get_extents;
541 iface->get_layer = fl_accessible_node_get_layer;
542}

References fl_accessible_node_get_extents(), and fl_accessible_node_get_layer().

◆ fl_accessible_node_dispose()

static void fl_accessible_node_dispose ( GObject *  object)
static

Definition at line 169 of file fl_accessible_node.cc.

169 {
171
172 g_weak_ref_clear(&priv->engine);
173 g_weak_ref_clear(&priv->parent);
174 g_clear_pointer(&priv->name, g_free);
175 g_clear_pointer(&priv->actions, g_ptr_array_unref);
176 g_clear_pointer(&priv->children, g_ptr_array_unref);
177
178 G_OBJECT_CLASS(fl_accessible_node_parent_class)->dispose(object);
179}

References FlAccessibilityHandlerPrivate::engine, FL_ACCESSIBLE_NODE_GET_PRIVATE, and priv.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_do_action()

static gboolean fl_accessible_node_do_action ( AtkAction *  action,
gint  i 
)
static

Definition at line 327 of file fl_accessible_node.cc.

327 {
329
330 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&priv->engine));
331 if (engine == nullptr) {
332 return FALSE;
333 }
334
336 if (data == nullptr) {
337 return FALSE;
338 }
339
340 fl_accessible_node_perform_action(FL_ACCESSIBLE_NODE(action), data->action,
341 nullptr);
342 return TRUE;
343}

References action, engine, FlAccessibilityHandlerPrivate::engine, FL_ACCESSIBLE_NODE_GET_PRIVATE, fl_accessible_node_perform_action(), g_autoptr(), get_action(), i, priv, and TRUE.

Referenced by fl_accessible_node_action_interface_init().

◆ fl_accessible_node_get_extents()

static void fl_accessible_node_get_extents ( AtkComponent *  component,
gint *  x,
gint *  y,
gint *  width,
gint *  height,
AtkCoordType  coord_type 
)
static

Definition at line 299 of file fl_accessible_node.cc.

304 {
306
307 *x = 0;
308 *y = 0;
309 g_autoptr(AtkObject) parent = ATK_OBJECT(g_weak_ref_get(&priv->parent));
310 if (parent != nullptr) {
311 atk_component_get_extents(ATK_COMPONENT(parent), x, y, nullptr, nullptr,
312 coord_type);
313 }
314
315 *x += priv->x;
316 *y += priv->y;
317 *width = priv->width;
318 *height = priv->height;
319}

References FL_ACCESSIBLE_NODE_GET_PRIVATE, g_autoptr(), height, priv, width, x, and y.

Referenced by fl_accessible_node_component_interface_init().

◆ fl_accessible_node_get_index_in_parent()

static gint fl_accessible_node_get_index_in_parent ( AtkObject *  accessible)
static

◆ fl_accessible_node_get_layer()

static AtkLayer fl_accessible_node_get_layer ( AtkComponent *  component)
static

Definition at line 322 of file fl_accessible_node.cc.

322 {
323 return ATK_LAYER_WIDGET;
324}

Referenced by fl_accessible_node_component_interface_init().

◆ fl_accessible_node_get_n_actions()

static gint fl_accessible_node_get_n_actions ( AtkAction *  action)
static

Definition at line 346 of file fl_accessible_node.cc.

346 {
348 return priv->actions->len;
349}

References action, FL_ACCESSIBLE_NODE_GET_PRIVATE, and priv.

Referenced by fl_accessible_node_action_interface_init().

◆ fl_accessible_node_get_n_children()

static gint fl_accessible_node_get_n_children ( AtkObject *  accessible)
static

Definition at line 201 of file fl_accessible_node.cc.

201 {
203 return priv->children->len;
204}

References accessible, FL_ACCESSIBLE_NODE_GET_PRIVATE, and priv.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_get_name() [1/2]

static const gchar * fl_accessible_node_get_name ( AtkAction *  action,
gint  i 
)
static

Definition at line 352 of file fl_accessible_node.cc.

352 {
354
356 if (data == nullptr) {
357 return nullptr;
358 }
359
360 return data->name;
361}

References action, FL_ACCESSIBLE_NODE_GET_PRIVATE, get_action(), i, and priv.

◆ fl_accessible_node_get_name() [2/2]

static const gchar * fl_accessible_node_get_name ( AtkObject *  accessible)
static

◆ fl_accessible_node_get_parent()

static AtkObject * fl_accessible_node_get_parent ( AtkObject *  accessible)
static

Definition at line 188 of file fl_accessible_node.cc.

188 {
190 g_autoptr(AtkObject) parent = ATK_OBJECT(g_weak_ref_get(&priv->parent));
191 return parent;
192}

References accessible, FL_ACCESSIBLE_NODE_GET_PRIVATE, g_autoptr(), and priv.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_get_role()

static AtkRole fl_accessible_node_get_role ( AtkObject *  accessible)
static

Definition at line 218 of file fl_accessible_node.cc.

218 {
220 if (priv->flags.is_button) {
221 return ATK_ROLE_PUSH_BUTTON;
222 }
223 if (priv->flags.is_in_mutually_exclusive_group &&
224 priv->flags.is_checked != kFlutterCheckStateNone) {
225 return ATK_ROLE_RADIO_BUTTON;
226 }
227 if (priv->flags.is_checked != kFlutterCheckStateNone) {
228 return ATK_ROLE_CHECK_BOX;
229 }
230 if (priv->flags.is_toggled != kFlutterTristateNone) {
231 return ATK_ROLE_TOGGLE_BUTTON;
232 }
233 if (priv->flags.is_slider) {
234 return ATK_ROLE_SLIDER;
235 }
236 if (priv->flags.is_text_field && priv->flags.is_obscured) {
237 return ATK_ROLE_PASSWORD_TEXT;
238 }
239 if (priv->flags.is_text_field) {
240 return ATK_ROLE_TEXT;
241 }
242 if (priv->flags.is_header) {
243 return ATK_ROLE_HEADER;
244 }
245 if (priv->flags.is_link) {
246 return ATK_ROLE_LINK;
247 }
248 if (priv->flags.is_image) {
249 return ATK_ROLE_IMAGE;
250 }
251
252 return ATK_ROLE_PANEL;
253}

References accessible, FL_ACCESSIBLE_NODE_GET_PRIVATE, kFlutterCheckStateNone, kFlutterTristateNone, and priv.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_init()

static void fl_accessible_node_init ( FlAccessibleNode *  self)
static

Definition at line 550 of file fl_accessible_node.cc.

550 {
552 g_weak_ref_init(&priv->engine, nullptr);
553 g_weak_ref_init(&priv->parent, nullptr);
554 priv->actions = g_ptr_array_new();
555 priv->children = g_ptr_array_new_with_free_func(g_object_unref);
556}

References FlAccessibilityHandlerPrivate::engine, FL_ACCESSIBLE_NODE_GET_PRIVATE, priv, and self.

◆ fl_accessible_node_new()

FlAccessibleNode * fl_accessible_node_new ( FlEngine *  engine,
FlutterViewId  view_id,
int32_t  node_id 
)

fl_accessible_node_new: @engine: the #FlEngine this node came from. @view_id: the view ID this object represents. @node_id: the semantics node ID this object represents.

Creates a new accessibility object that exposes Flutter accessibility information to ATK.

Returns: a new #FlAccessibleNode.

Definition at line 558 of file fl_accessible_node.cc.

560 {
561 FlAccessibleNode* self = FL_ACCESSIBLE_NODE(
562 g_object_new(fl_accessible_node_get_type(), "engine", engine, "view-id",
563 view_id, "node-id", node_id, nullptr));
564 return self;
565}

References engine, self, and view_id.

Referenced by create_node(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ fl_accessible_node_perform_action()

void fl_accessible_node_perform_action ( FlAccessibleNode *  node,
FlutterSemanticsAction  action,
GBytes *  data 
)

fl_accessible_node_perform_action: @node: an #FlAccessibleNode. @action: the action being dispatched. @data: (allow-none): data associated with the action.

Performs a semantic action for this node.

Definition at line 657 of file fl_accessible_node.cc.

659 {
660 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
661
662 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->perform_action(self, action, data);
663}

References action, and self.

Referenced by fl_accessible_node_do_action(), fl_accessible_text_field_copy_text(), fl_accessible_text_field_cut_text(), fl_accessible_text_field_paste_text(), perform_set_selection_action(), and perform_set_text_action().

◆ fl_accessible_node_perform_action_impl()

static void fl_accessible_node_perform_action_impl ( FlAccessibleNode *  self,
FlutterSemanticsAction  action,
GBytes *  data 
)
static

Definition at line 478 of file fl_accessible_node.cc.

481 {
483 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&priv->engine));
484 if (engine == nullptr) {
485 return;
486 }
488 action, data);
489}

References action, engine, FlAccessibilityHandlerPrivate::engine, FL_ACCESSIBLE_NODE_GET_PRIVATE, fl_engine_dispatch_semantics_action(), g_autoptr(), priv, and self.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_ref_child()

static AtkObject * fl_accessible_node_ref_child ( AtkObject *  accessible,
gint  i 
)
static

Definition at line 207 of file fl_accessible_node.cc.

207 {
209
210 if (i < 0 || static_cast<guint>(i) >= priv->children->len) {
211 return nullptr;
212 }
213
214 return ATK_OBJECT(g_object_ref(g_ptr_array_index(priv->children, i)));
215}

References accessible, FL_ACCESSIBLE_NODE_GET_PRIVATE, i, and priv.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_ref_state_set()

static AtkStateSet * fl_accessible_node_ref_state_set ( AtkObject *  accessible)
static

Definition at line 256 of file fl_accessible_node.cc.

256 {
258
259 AtkStateSet* state_set = atk_state_set_new();
260
261 if (!priv->flags.is_obscured) {
262 atk_state_set_add_state(state_set, ATK_STATE_SHOWING);
263 }
264 if (!priv->flags.is_hidden) {
265 atk_state_set_add_state(state_set, ATK_STATE_VISIBLE);
266 }
267 if (is_checkable(priv->flags)) {
268 atk_state_set_add_state(state_set, ATK_STATE_CHECKABLE);
269 }
270 if (is_checked(priv->flags)) {
271 atk_state_set_add_state(state_set, ATK_STATE_CHECKED);
272 }
273 if (is_focusable(priv->flags)) {
274 atk_state_set_add_state(state_set, ATK_STATE_FOCUSABLE);
275 }
276 if (is_focused(priv->flags)) {
277 atk_state_set_add_state(state_set, ATK_STATE_FOCUSED);
278 }
279 if (is_selected(priv->flags)) {
280 atk_state_set_add_state(state_set, ATK_STATE_SELECTED);
281 }
282 if (is_enabled(priv->flags)) {
283 atk_state_set_add_state(state_set, ATK_STATE_ENABLED);
284 }
285 if (is_sensitive(priv->flags)) {
286 atk_state_set_add_state(state_set, ATK_STATE_SENSITIVE);
287 }
288 if (priv->flags.is_read_only) {
289 atk_state_set_add_state(state_set, ATK_STATE_READ_ONLY);
290 }
291 if (priv->flags.is_text_field) {
292 atk_state_set_add_state(state_set, ATK_STATE_EDITABLE);
293 }
294
295 return state_set;
296}

References accessible, FL_ACCESSIBLE_NODE_GET_PRIVATE, is_checked(), is_enabled(), is_focusable(), is_focused(), is_selected(), is_sensitive(), and priv.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_set_actions()

void fl_accessible_node_set_actions ( FlAccessibleNode *  node,
FlutterSemanticsAction  actions 
)

fl_accessible_node_set_actions: @node: an #FlAccessibleNode. @actions: the actions this node can perform.

Sets the actions that this node can perform.

Definition at line 627 of file fl_accessible_node.cc.

628 {
629 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
630
631 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_actions(self, actions);
632}

References self.

Referenced by fl_view_accessible_handle_update_semantics(), TEST_F(), TEST_F(), and TEST_F().

◆ fl_accessible_node_set_actions_impl()

static void fl_accessible_node_set_actions_impl ( FlAccessibleNode *  self,
FlutterSemanticsAction  actions 
)
static

Definition at line 445 of file fl_accessible_node.cc.

447 {
449
450 // NOTE(robert-ancell): It appears that AtkAction doesn't have a method of
451 // notifying that actions have changed, and even if it did an ATK client
452 // might access the old IDs before checking for new ones. Keep an eye
453 // out for a case where Flutter changes the actions on an item and see
454 // if we can resolve this in another way.
455 g_ptr_array_remove_range(priv->actions, 0, priv->actions->len);
456 for (int i = 0; action_mapping[i].name != nullptr; i++) {
457 if (has_action(actions, action_mapping[i].action)) {
458 g_ptr_array_add(priv->actions, &action_mapping[i]);
459 }
460 }
461}

References action, action_mapping, FL_ACCESSIBLE_NODE_GET_PRIVATE, has_action(), i, ActionData::name, priv, and self.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_set_children()

void fl_accessible_node_set_children ( FlAccessibleNode *  node,
GPtrArray *  children 
)

fl_accessible_node_set_children: @node: an #FlAccessibleNode. @children: (transfer none) (element-type AtkObject): a list of #AtkObject.

Sets the children of this node. The children can be changed at any time.

Definition at line 576 of file fl_accessible_node.cc.

577 {
578 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
580
581 // Remove nodes that are no longer required.
582 for (guint i = 0; i < priv->children->len;) {
583 AtkObject* object = ATK_OBJECT(g_ptr_array_index(priv->children, i));
584 if (has_child(children, object)) {
585 i++;
586 } else {
587 g_signal_emit_by_name(self, "children-changed::remove", i, object,
588 nullptr);
589 g_ptr_array_remove_index(priv->children, i);
590 }
591 }
592
593 // Add new nodes.
594 for (guint i = 0; i < children->len; i++) {
595 AtkObject* object = ATK_OBJECT(g_ptr_array_index(children, i));
596 if (!has_child(priv->children, object)) {
597 g_ptr_array_add(priv->children, g_object_ref(object));
598 g_signal_emit_by_name(self, "children-changed::add", i, object, nullptr);
599 }
600 }
601}

References FL_ACCESSIBLE_NODE_GET_PRIVATE, has_child(), i, priv, and self.

Referenced by fl_view_accessible_handle_update_semantics(), and TEST_F().

◆ fl_accessible_node_set_extents()

void fl_accessible_node_set_extents ( FlAccessibleNode *  node,
gint  x,
gint  y,
gint  width,
gint  height 
)

fl_accessible_node_set_extents: @node: an #FlAccessibleNode. @x: x co-ordinate of this node relative to its parent. @y: y co-ordinate of this node relative to its parent. @width: width of this node in pixels. @height: height of this node in pixels.

Sets the position and size of this node.

Definition at line 609 of file fl_accessible_node.cc.

613 {
614 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
615
616 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_extents(self, x, y, width,
617 height);
618}

References height, self, width, x, and y.

Referenced by fl_view_accessible_handle_update_semantics(), and TEST_F().

◆ fl_accessible_node_set_extents_impl()

static void fl_accessible_node_set_extents_impl ( FlAccessibleNode *  self,
gint  x,
gint  y,
gint  width,
gint  height 
)
static

Definition at line 372 of file fl_accessible_node.cc.

376 {
378 priv->x = x;
379 priv->y = y;
380 priv->width = width;
381 priv->height = height;
382}

References FL_ACCESSIBLE_NODE_GET_PRIVATE, height, priv, self, width, x, and y.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_set_flags()

void fl_accessible_node_set_flags ( FlAccessibleNode *  node,
FlutterSemanticsFlags flags 
)

fl_accessible_node_set_flags: @node: an #FlAccessibleNode. @flags: the flags for this node.

Sets the flags for this node.

Definition at line 620 of file fl_accessible_node.cc.

621 {
622 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
623
624 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_flags(self, flags);
625}

References self.

Referenced by fl_view_accessible_handle_update_semantics(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ fl_accessible_node_set_flags_impl()

static void fl_accessible_node_set_flags_impl ( FlAccessibleNode *  self,
FlutterSemanticsFlags flags 
)
static

Definition at line 391 of file fl_accessible_node.cc.

392 {
394
395 FlutterSemanticsFlags old_flags = priv->flags;
396 priv->flags = *flags;
397
398 if (flag_changed(old_flags.is_obscured, flags->is_obscured)) {
399 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_SHOWING,
400 !flags->is_obscured);
401 }
402 if (flag_changed(old_flags.is_hidden, flags->is_hidden)) {
403 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_VISIBLE,
404 !flags->is_hidden);
405 }
406 if (flag_changed(is_checkable(old_flags), is_checkable(priv->flags))) {
407 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_CHECKABLE,
408 is_checkable(priv->flags));
409 }
410 if (flag_changed(is_checked(old_flags), is_checked(priv->flags))) {
411 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_CHECKED,
412 is_checked(priv->flags));
413 }
414 if (flag_changed(is_focusable(old_flags), is_focusable(priv->flags))) {
415 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_FOCUSABLE,
416 is_focusable(priv->flags));
417 }
418 if (flag_changed(is_focused(old_flags), is_focused(priv->flags))) {
419 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_FOCUSED,
420 is_focused(priv->flags));
421 }
422 if (flag_changed(is_selected(old_flags), is_selected(priv->flags))) {
423 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_SELECTED,
424 is_selected(priv->flags));
425 }
426 if (flag_changed(is_sensitive(old_flags), is_sensitive(priv->flags))) {
427 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_SENSITIVE,
428 is_sensitive(priv->flags));
429 }
430 if (flag_changed(is_enabled(old_flags), is_enabled(priv->flags))) {
431 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_ENABLED,
432 is_enabled(priv->flags));
433 }
434 if (flag_changed(old_flags.is_read_only, flags->is_read_only)) {
435 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_READ_ONLY,
436 flags->is_read_only);
437 }
438 if (flag_changed(old_flags.is_text_field, flags->is_text_field)) {
439 atk_object_notify_state_change(ATK_OBJECT(self), ATK_STATE_EDITABLE,
440 flags->is_text_field);
441 }
442}

References atk_object_notify_state_change(), FL_ACCESSIBLE_NODE_GET_PRIVATE, flag_changed(), is_checked(), is_enabled(), is_focusable(), is_focused(), FlutterSemanticsFlags::is_hidden, FlutterSemanticsFlags::is_obscured, FlutterSemanticsFlags::is_read_only, is_selected(), is_sensitive(), FlutterSemanticsFlags::is_text_field, priv, and self.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_set_name()

void fl_accessible_node_set_name ( FlAccessibleNode *  self,
const gchar *  name 
)

Definition at line 603 of file fl_accessible_node.cc.

603 {
604 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
605
606 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_name(self, name);
607}

References name, and self.

Referenced by fl_view_accessible_handle_update_semantics(), and TEST_F().

◆ fl_accessible_node_set_name_impl()

static void fl_accessible_node_set_name_impl ( FlAccessibleNode *  self,
const gchar *  name 
)
static

Definition at line 364 of file fl_accessible_node.cc.

365 {
367 g_free(priv->name);
368 priv->name = g_strdup(name);
369}

References FL_ACCESSIBLE_NODE_GET_PRIVATE, name, priv, and self.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_set_parent()

void fl_accessible_node_set_parent ( FlAccessibleNode *  node,
AtkObject *  parent,
gint  index 
)

fl_accessible_node_set_parent: @node: an #FlAccessibleNode. @parent: an #AtkObject. @index: the index of this node in the parent.

Sets the parent of this node. The parent can be changed at any time.

Definition at line 567 of file fl_accessible_node.cc.

569 {
570 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
572 g_weak_ref_set(&priv->parent, parent);
573 priv->index = index;
574}

References FL_ACCESSIBLE_NODE_GET_PRIVATE, priv, and self.

Referenced by fl_view_accessible_handle_update_semantics(), get_node(), TEST_F(), and TEST_F().

◆ fl_accessible_node_set_property()

static void fl_accessible_node_set_property ( GObject *  object,
guint  prop_id,
const GValue *  value,
GParamSpec *  pspec 
)
static

Definition at line 148 of file fl_accessible_node.cc.

151 {
153 switch (prop_id) {
154 case PROP_ENGINE:
155 g_weak_ref_set(&priv->engine, g_value_get_object(value));
156 break;
157 case PROP_VIEW_ID:
158 priv->view_id = g_value_get_int64(value);
159 break;
160 case PROP_ID:
161 priv->node_id = g_value_get_int(value);
162 break;
163 default:
164 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
165 break;
166 }
167}

References FlAccessibilityHandlerPrivate::engine, FL_ACCESSIBLE_NODE_GET_PRIVATE, priv, PROP_ENGINE, PROP_ID, prop_id, PROP_VIEW_ID, pspec, and value.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_set_text_direction()

void fl_accessible_node_set_text_direction ( FlAccessibleNode *  node,
FlutterTextDirection  direction 
)

fl_accessible_node_set_text_direction: @node: an #FlAccessibleNode. @direction: the direction of the text.

Sets the text direction of this node.

Definition at line 649 of file fl_accessible_node.cc.

650 {
651 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
652
653 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_text_direction(self,
654 direction);
655}

References self.

Referenced by fl_view_accessible_handle_update_semantics().

◆ fl_accessible_node_set_text_direction_impl()

static void fl_accessible_node_set_text_direction_impl ( FlAccessibleNode *  self,
FlutterTextDirection  direction 
)
static

Definition at line 473 of file fl_accessible_node.cc.

475 {}

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_set_text_selection()

void fl_accessible_node_set_text_selection ( FlAccessibleNode *  node,
gint  base,
gint  extent 
)

fl_accessible_node_set_text_selection: @node: an #FlAccessibleNode. @base: the position at which the text selection originates. @extent: the position at which the text selection terminates.

Sets the text selection of this node.

Definition at line 640 of file fl_accessible_node.cc.

642 {
643 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
644
645 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_text_selection(self, base,
646 extent);
647}

References self.

Referenced by fl_view_accessible_handle_update_semantics(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ fl_accessible_node_set_text_selection_impl()

static void fl_accessible_node_set_text_selection_impl ( FlAccessibleNode *  self,
gint  base,
gint  extent 
)
static

Definition at line 468 of file fl_accessible_node.cc.

470 {}

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_set_value()

void fl_accessible_node_set_value ( FlAccessibleNode *  node,
const gchar *  value 
)

fl_accessible_node_set_value: @node: an #FlAccessibleNode. @value: a node value.

Sets the value of this node.

Definition at line 634 of file fl_accessible_node.cc.

634 {
635 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
636
637 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_value(self, value);
638}

References self, and value.

Referenced by fl_view_accessible_handle_update_semantics(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ fl_accessible_node_set_value_impl()

static void fl_accessible_node_set_value_impl ( FlAccessibleNode *  self,
const gchar *  value 
)
static

Definition at line 464 of file fl_accessible_node.cc.

465 {}

Referenced by fl_accessible_node_class_init().

◆ flag_changed()

static bool flag_changed ( bool  old_flag,
bool  new_flag 
)
static

Definition at line 386 of file fl_accessible_node.cc.

386 {
387 return !old_flag != !new_flag;
388}

Referenced by fl_accessible_node_set_flags_impl().

◆ G_DEFINE_TYPE_WITH_CODE()

G_DEFINE_TYPE_WITH_CODE ( FlAccessibleNode  ,
fl_accessible_node  ,
ATK_TYPE_OBJECT  ,
G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT, fl_accessible_node_component_interface_init) G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION, fl_accessible_node_action_interface_init  
)

Definition at line 76 of file fl_accessible_node.cc.

87 {
88 return flags.is_checked != kFlutterCheckStateNone ||
89 flags.is_toggled != kFlutterTristateNone;
90}

References FlutterSemanticsFlags::is_checked, FlutterSemanticsFlags::is_toggled, kFlutterCheckStateNone, and kFlutterTristateNone.

◆ get_action()

static ActionData * get_action ( FlAccessibleNodePrivate priv,
gint  index 
)
static

Definition at line 130 of file fl_accessible_node.cc.

130 {
131 if (index < 0 || static_cast<guint>(index) >= priv->actions->len) {
132 return nullptr;
133 }
134 return static_cast<ActionData*>(g_ptr_array_index(priv->actions, index));
135}

References priv.

Referenced by fl_accessible_node_do_action(), and fl_accessible_node_get_name().

◆ has_action()

static gboolean has_action ( FlutterSemanticsAction  actions,
FlutterSemanticsAction  action 
)
static

Definition at line 124 of file fl_accessible_node.cc.

125 {
126 return (actions & action) != 0;
127}

References action.

Referenced by fl_accessible_node_set_actions_impl().

◆ has_child()

static gboolean has_child ( GPtrArray *  children,
AtkObject *  object 
)
static

Definition at line 138 of file fl_accessible_node.cc.

138 {
139 for (guint i = 0; i < children->len; i++) {
140 if (g_ptr_array_index(children, i) == object) {
141 return TRUE;
142 }
143 }
144
145 return FALSE;
146}

References i, and TRUE.

Referenced by fl_accessible_node_set_children().

◆ is_checked()

◆ is_enabled()

◆ is_focusable()

static gboolean is_focusable ( FlutterSemanticsFlags  flags)
static

◆ is_focused()

static gboolean is_focused ( FlutterSemanticsFlags  flags)
static

◆ is_selected()

static gboolean is_selected ( FlutterSemanticsFlags  flags)
static

◆ is_sensitive()

static gboolean is_sensitive ( FlutterSemanticsFlags  flags)
static

Variable Documentation

◆ action_mapping

ActionData action_mapping[]
static
Initial value:
= {
"MoveCursorForwardByCharacter"},
"MoveCursorBackwardByCharacter"},
"DidGainAccessibilityFocus"},
"DidLoseAccessibilityFocus"},
{kFlutterSemanticsActionMoveCursorForwardByWord, "MoveCursorForwardByWord"},
"MoveCursorBackwardByWord"},
{static_cast<FlutterSemanticsAction>(0), nullptr}}
@ kFlutterSemanticsActionMoveCursorForwardByCharacter
Move the cursor forward by one character.
Definition embedder.h:149
@ kFlutterSemanticsActionDidLoseAccessibilityFocus
Indicate that the node has lost accessibility focus.
Definition embedder.h:163
@ kFlutterSemanticsActionExpand
A request that the node should be expanded.
Definition embedder.h:180
@ kFlutterSemanticsActionDecrease
Decrease the value represented by the semantics node.
Definition embedder.h:145
@ kFlutterSemanticsActionCollapse
A request that the node should be collapsed.
Definition embedder.h:182
@ kFlutterSemanticsActionScrollDown
Definition embedder.h:141
@ kFlutterSemanticsActionMoveCursorBackwardByCharacter
Move the cursor backward by one character.
Definition embedder.h:151
@ kFlutterSemanticsActionMoveCursorForwardByWord
Move the cursor forward by one word.
Definition embedder.h:169
@ kFlutterSemanticsActionLongPress
Definition embedder.h:128
@ kFlutterSemanticsActionScrollRight
Definition embedder.h:135
@ kFlutterSemanticsActionShowOnScreen
A request to fully show the semantics node on screen.
Definition embedder.h:147
@ kFlutterSemanticsActionDismiss
A request that the node should be dismissed.
Definition embedder.h:167
@ kFlutterSemanticsActionFocus
Request that the respective focusable widget gain input focus.
Definition embedder.h:175
@ kFlutterSemanticsActionPaste
Paste the current content of the clipboard.
Definition embedder.h:159
@ kFlutterSemanticsActionScrollUp
Definition embedder.h:138
@ kFlutterSemanticsActionCut
Cut the current selection and place it in the clipboard.
Definition embedder.h:157
@ kFlutterSemanticsActionCustomAction
Indicate that the user has invoked a custom accessibility action.
Definition embedder.h:165
@ kFlutterSemanticsActionCopy
Copy the current selection to the clipboard.
Definition embedder.h:155
@ kFlutterSemanticsActionMoveCursorBackwardByWord
Move the cursor backward by one word.
Definition embedder.h:171
@ kFlutterSemanticsActionIncrease
Increase the value represented by the semantics node.
Definition embedder.h:143
@ kFlutterSemanticsActionScrollLeft
Definition embedder.h:131
@ kFlutterSemanticsActionDidGainAccessibilityFocus
Indicate that the node has gained accessibility focus.
Definition embedder.h:161
@ kFlutterSemanticsActionTap
Definition embedder.h:125

Definition at line 13 of file fl_accessible_node.cc.

13 {
24 "MoveCursorForwardByCharacter"},
26 "MoveCursorBackwardByCharacter"},
31 "DidGainAccessibilityFocus"},
33 "DidLoseAccessibilityFocus"},
36 {kFlutterSemanticsActionMoveCursorForwardByWord, "MoveCursorForwardByWord"},
38 "MoveCursorBackwardByWord"},
42 {static_cast<FlutterSemanticsAction>(0), nullptr}};

Referenced by fl_accessible_node_set_actions_impl().