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

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 548 of file fl_accessible_node.cc.

548 {
549 iface->do_action = fl_accessible_node_do_action;
550 iface->get_n_actions = fl_accessible_node_get_n_actions;
551 iface->get_name = fl_accessible_node_get_name;
552}

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 495 of file fl_accessible_node.cc.

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

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 542 of file fl_accessible_node.cc.

543 {
544 iface->get_extents = fl_accessible_node_get_extents;
545 iface->get_layer = fl_accessible_node_get_layer;
546}

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 172 of file fl_accessible_node.cc.

172 {
174
175 if (priv->engine != nullptr) {
176 g_object_remove_weak_pointer(object,
177 reinterpret_cast<gpointer*>(&(priv->engine)));
178 priv->engine = nullptr;
179 }
180 if (priv->parent != nullptr) {
181 g_object_remove_weak_pointer(object,
182 reinterpret_cast<gpointer*>(&(priv->parent)));
183 priv->parent = nullptr;
184 }
185 g_clear_pointer(&priv->name, g_free);
186 g_clear_pointer(&priv->actions, g_ptr_array_unref);
187 g_clear_pointer(&priv->children, g_ptr_array_unref);
188
189 G_OBJECT_CLASS(fl_accessible_node_parent_class)->dispose(object);
190}

References 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 336 of file fl_accessible_node.cc.

336 {
338
339 if (priv->engine == nullptr) {
340 return FALSE;
341 }
342
344 if (data == nullptr) {
345 return FALSE;
346 }
347
348 fl_accessible_node_perform_action(FL_ACCESSIBLE_NODE(action), data->action,
349 nullptr);
350 return TRUE;
351}

References action, data, FL_ACCESSIBLE_NODE_GET_PRIVATE, fl_accessible_node_perform_action(), 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 309 of file fl_accessible_node.cc.

314 {
316
317 *x = 0;
318 *y = 0;
319 if (priv->parent != nullptr) {
320 atk_component_get_extents(ATK_COMPONENT(priv->parent), x, y, nullptr,
321 nullptr, coord_type);
322 }
323
324 *x += priv->x;
325 *y += priv->y;
326 *width = priv->width;
327 *height = priv->height;
328}

References FL_ACCESSIBLE_NODE_GET_PRIVATE, 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

Definition at line 205 of file fl_accessible_node.cc.

205 {
207 return priv->index;
208}

References FL_ACCESSIBLE_NODE_GET_PRIVATE, and priv.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_get_layer()

static AtkLayer fl_accessible_node_get_layer ( AtkComponent *  component)
static

Definition at line 331 of file fl_accessible_node.cc.

331 {
332 return ATK_LAYER_WIDGET;
333}

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 354 of file fl_accessible_node.cc.

354 {
356 return priv->actions->len;
357}

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 211 of file fl_accessible_node.cc.

211 {
213 return priv->children->len;
214}

References 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 360 of file fl_accessible_node.cc.

360 {
362
364 if (data == nullptr) {
365 return nullptr;
366 }
367
368 return data->name;
369}

References action, data, 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 199 of file fl_accessible_node.cc.

199 {
201 return priv->parent;
202}

References FL_ACCESSIBLE_NODE_GET_PRIVATE, 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 228 of file fl_accessible_node.cc.

228 {
230 if (priv->flags.is_button) {
231 return ATK_ROLE_PUSH_BUTTON;
232 }
233 if (priv->flags.is_in_mutually_exclusive_group &&
234 priv->flags.is_checked != kFlutterCheckStateNone) {
235 return ATK_ROLE_RADIO_BUTTON;
236 }
237 if (priv->flags.is_checked != kFlutterCheckStateNone) {
238 return ATK_ROLE_CHECK_BOX;
239 }
240 if (priv->flags.is_toggled != kFlutterTristateNone) {
241 return ATK_ROLE_TOGGLE_BUTTON;
242 }
243 if (priv->flags.is_slider) {
244 return ATK_ROLE_SLIDER;
245 }
246 if (priv->flags.is_text_field && priv->flags.is_obscured) {
247 return ATK_ROLE_PASSWORD_TEXT;
248 }
249 if (priv->flags.is_text_field) {
250 return ATK_ROLE_TEXT;
251 }
252 if (priv->flags.is_header) {
253 return ATK_ROLE_HEADER;
254 }
255 if (priv->flags.is_link) {
256 return ATK_ROLE_LINK;
257 }
258 if (priv->flags.is_image) {
259 return ATK_ROLE_IMAGE;
260 }
261
262 return ATK_ROLE_PANEL;
263}

References 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 554 of file fl_accessible_node.cc.

554 {
556 priv->actions = g_ptr_array_new();
557 priv->children = g_ptr_array_new_with_free_func(g_object_unref);
558}

References 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 560 of file fl_accessible_node.cc.

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

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(), 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 661 of file fl_accessible_node.cc.

663 {
664 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
665
666 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->perform_action(self, action, data);
667}

References action, data, 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

◆ fl_accessible_node_ref_child()

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

Definition at line 217 of file fl_accessible_node.cc.

217 {
219
220 if (i < 0 || static_cast<guint>(i) >= priv->children->len) {
221 return nullptr;
222 }
223
224 return ATK_OBJECT(g_object_ref(g_ptr_array_index(priv->children, i)));
225}

References 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 266 of file fl_accessible_node.cc.

266 {
268
269 AtkStateSet* state_set = atk_state_set_new();
270
271 if (!priv->flags.is_obscured) {
272 atk_state_set_add_state(state_set, ATK_STATE_SHOWING);
273 }
274 if (!priv->flags.is_hidden) {
275 atk_state_set_add_state(state_set, ATK_STATE_VISIBLE);
276 }
277 if (is_checkable(priv->flags)) {
278 atk_state_set_add_state(state_set, ATK_STATE_CHECKABLE);
279 }
280 if (is_checked(priv->flags)) {
281 atk_state_set_add_state(state_set, ATK_STATE_CHECKED);
282 }
283 if (is_focusable(priv->flags)) {
284 atk_state_set_add_state(state_set, ATK_STATE_FOCUSABLE);
285 }
286 if (is_focused(priv->flags)) {
287 atk_state_set_add_state(state_set, ATK_STATE_FOCUSED);
288 }
289 if (is_selected(priv->flags)) {
290 atk_state_set_add_state(state_set, ATK_STATE_SELECTED);
291 }
292 if (is_enabled(priv->flags)) {
293 atk_state_set_add_state(state_set, ATK_STATE_ENABLED);
294 }
295 if (is_sensitive(priv->flags)) {
296 atk_state_set_add_state(state_set, ATK_STATE_SENSITIVE);
297 }
298 if (priv->flags.is_read_only) {
299 atk_state_set_add_state(state_set, ATK_STATE_READ_ONLY);
300 }
301 if (priv->flags.is_text_field) {
302 atk_state_set_add_state(state_set, ATK_STATE_EDITABLE);
303 }
304
305 return state_set;
306}

References 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 631 of file fl_accessible_node.cc.

632 {
633 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
634
635 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_actions(self, actions);
636}

References self.

Referenced by fl_view_accessible_handle_update_semantics(), TEST(), 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 453 of file fl_accessible_node.cc.

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

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 580 of file fl_accessible_node.cc.

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

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 613 of file fl_accessible_node.cc.

617 {
618 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
619
620 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_extents(self, x, y, width,
621 height);
622}

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 380 of file fl_accessible_node.cc.

384 {
386 priv->x = x;
387 priv->y = y;
388 priv->width = width;
389 priv->height = height;
390}

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 624 of file fl_accessible_node.cc.

625 {
626 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
627
628 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_flags(self, flags);
629}

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 399 of file fl_accessible_node.cc.

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

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 607 of file fl_accessible_node.cc.

607 {
608 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
609
610 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_name(self, name);
611}

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 372 of file fl_accessible_node.cc.

373 {
375 g_free(priv->name);
376 priv->name = g_strdup(name);
377}

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 569 of file fl_accessible_node.cc.

571 {
572 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
574 priv->parent = parent;
575 priv->index = index;
576 g_object_add_weak_pointer(G_OBJECT(self),
577 reinterpret_cast<gpointer*>(&(priv->parent)));
578}

References FL_ACCESSIBLE_NODE_GET_PRIVATE, priv, and self.

Referenced by fl_view_accessible_handle_update_semantics(), get_node(), 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_assert(priv->engine == nullptr);
156 priv->engine = FL_ENGINE(g_value_get_object(value));
157 g_object_add_weak_pointer(object,
158 reinterpret_cast<gpointer*>(&priv->engine));
159 break;
160 case PROP_VIEW_ID:
161 priv->view_id = g_value_get_int64(value);
162 break;
163 case PROP_ID:
164 priv->node_id = g_value_get_int(value);
165 break;
166 default:
167 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
168 break;
169 }
170}

References 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 653 of file fl_accessible_node.cc.

654 {
655 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
656
657 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_text_direction(self,
658 direction);
659}

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 481 of file fl_accessible_node.cc.

483 {}

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 644 of file fl_accessible_node.cc.

646 {
647 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
648
649 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_text_selection(self, base,
650 extent);
651}

References self.

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

◆ 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 476 of file fl_accessible_node.cc.

478 {}

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 638 of file fl_accessible_node.cc.

638 {
639 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
640
641 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_value(self, value);
642}

References self, and value.

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

◆ fl_accessible_node_set_value_impl()

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

Definition at line 472 of file fl_accessible_node.cc.

473 {}

Referenced by fl_accessible_node_class_init().

◆ flag_changed()

static bool flag_changed ( bool  old_flag,
bool  new_flag 
)
static

Definition at line 394 of file fl_accessible_node.cc.

394 {
395 return !old_flag != !new_flag;
396}

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:142
@ kFlutterSemanticsActionDidLoseAccessibilityFocus
Indicate that the node has lost accessibility focus.
Definition embedder.h:156
@ kFlutterSemanticsActionExpand
A request that the node should be expanded.
Definition embedder.h:173
@ kFlutterSemanticsActionDecrease
Decrease the value represented by the semantics node.
Definition embedder.h:138
@ kFlutterSemanticsActionCollapse
A request that the node should be collapsed.
Definition embedder.h:175
@ kFlutterSemanticsActionScrollDown
Definition embedder.h:134
@ kFlutterSemanticsActionMoveCursorBackwardByCharacter
Move the cursor backward by one character.
Definition embedder.h:144
@ kFlutterSemanticsActionMoveCursorForwardByWord
Move the cursor forward by one word.
Definition embedder.h:162
@ kFlutterSemanticsActionLongPress
Definition embedder.h:121
@ kFlutterSemanticsActionScrollRight
Definition embedder.h:128
@ kFlutterSemanticsActionShowOnScreen
A request to fully show the semantics node on screen.
Definition embedder.h:140
@ kFlutterSemanticsActionDismiss
A request that the node should be dismissed.
Definition embedder.h:160
@ kFlutterSemanticsActionFocus
Request that the respective focusable widget gain input focus.
Definition embedder.h:168
@ kFlutterSemanticsActionPaste
Paste the current content of the clipboard.
Definition embedder.h:152
@ kFlutterSemanticsActionScrollUp
Definition embedder.h:131
@ kFlutterSemanticsActionCut
Cut the current selection and place it in the clipboard.
Definition embedder.h:150
@ kFlutterSemanticsActionCustomAction
Indicate that the user has invoked a custom accessibility action.
Definition embedder.h:158
@ kFlutterSemanticsActionCopy
Copy the current selection to the clipboard.
Definition embedder.h:148
@ kFlutterSemanticsActionMoveCursorBackwardByWord
Move the cursor backward by one word.
Definition embedder.h:164
@ kFlutterSemanticsActionIncrease
Increase the value represented by the semantics node.
Definition embedder.h:136
@ kFlutterSemanticsActionScrollLeft
Definition embedder.h:124
@ kFlutterSemanticsActionDidGainAccessibilityFocus
Indicate that the node has gained accessibility focus.
Definition embedder.h:154
@ kFlutterSemanticsActionTap
Definition embedder.h:118

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().