| Flutter Linux Embedder |

fl_accessible_node.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "flutter/shell/platform/linux/fl_accessible_node.h"
6 #include "flutter/shell/platform/linux/fl_engine_private.h"
7
8 // Maps Flutter semantics flags to ATK flags.
9 static struct {
10 AtkStateType state;
11 FlutterSemanticsFlag flag;
12 gboolean invert;
13 } flag_mapping[] = {
14 {ATK_STATE_SHOWING, kFlutterSemanticsFlagIsObscured, TRUE},
15 {ATK_STATE_VISIBLE, kFlutterSemanticsFlagIsHidden, TRUE},
16 {ATK_STATE_CHECKABLE, kFlutterSemanticsFlagHasCheckedState, FALSE},
17 {ATK_STATE_FOCUSABLE, kFlutterSemanticsFlagIsFocusable, FALSE},
18 {ATK_STATE_FOCUSED, kFlutterSemanticsFlagIsFocused, FALSE},
19 {ATK_STATE_CHECKED,
20 static_cast<FlutterSemanticsFlag>(kFlutterSemanticsFlagIsChecked |
21 kFlutterSemanticsFlagIsToggled),
22 FALSE},
23 {ATK_STATE_SELECTED, kFlutterSemanticsFlagIsSelected, FALSE},
24 {ATK_STATE_ENABLED, kFlutterSemanticsFlagIsEnabled, FALSE},
25 {ATK_STATE_SENSITIVE, kFlutterSemanticsFlagIsEnabled, FALSE},
26 {ATK_STATE_READ_ONLY, kFlutterSemanticsFlagIsReadOnly, FALSE},
27 {ATK_STATE_EDITABLE, kFlutterSemanticsFlagIsTextField, FALSE},
28 {ATK_STATE_INVALID, static_cast<FlutterSemanticsFlag>(0), FALSE},
29 };
30
31 // Maps Flutter semantics actions to ATK actions.
32 typedef struct {
33 FlutterSemanticsAction action;
34 const gchar* name;
35 } ActionData;
36 static ActionData action_mapping[] = {
37 {kFlutterSemanticsActionTap, "Tap"},
38 {kFlutterSemanticsActionLongPress, "LongPress"},
39 {kFlutterSemanticsActionScrollLeft, "ScrollLeft"},
40 {kFlutterSemanticsActionScrollRight, "ScrollRight"},
41 {kFlutterSemanticsActionScrollUp, "ScrollUp"},
42 {kFlutterSemanticsActionScrollDown, "ScrollDown"},
43 {kFlutterSemanticsActionIncrease, "Increase"},
44 {kFlutterSemanticsActionDecrease, "Decrease"},
45 {kFlutterSemanticsActionShowOnScreen, "ShowOnScreen"},
46 {kFlutterSemanticsActionMoveCursorForwardByCharacter,
47 "MoveCursorForwardByCharacter"},
48 {kFlutterSemanticsActionMoveCursorBackwardByCharacter,
49 "MoveCursorBackwardByCharacter"},
50 {kFlutterSemanticsActionCopy, "Copy"},
51 {kFlutterSemanticsActionCut, "Cut"},
52 {kFlutterSemanticsActionPaste, "Paste"},
53 {kFlutterSemanticsActionDidGainAccessibilityFocus,
54 "DidGainAccessibilityFocus"},
55 {kFlutterSemanticsActionDidLoseAccessibilityFocus,
56 "DidLoseAccessibilityFocus"},
57 {kFlutterSemanticsActionCustomAction, "CustomAction"},
58 {kFlutterSemanticsActionDismiss, "Dismiss"},
59 {kFlutterSemanticsActionMoveCursorForwardByWord, "MoveCursorForwardByWord"},
60 {kFlutterSemanticsActionMoveCursorBackwardByWord,
61 "MoveCursorBackwardByWord"},
62 {kFlutterSemanticsActionFocus, "Focus"},
63 {static_cast<FlutterSemanticsAction>(0), nullptr}};
64
65 struct FlAccessibleNodePrivate {
66 AtkObject parent_instance;
67
68 // Weak reference to the engine this node is created for.
69 FlEngine* engine;
70
71 /// The unique identifier of the view to which this node belongs.
72 FlutterViewId view_id;
73
74 // Weak reference to the parent node of this one or %NULL.
75 AtkObject* parent;
76
77 int32_t node_id;
78 gchar* name;
79 gint index;
80 gint x, y, width, height;
81 GPtrArray* actions;
82 gsize actions_length;
83 GPtrArray* children;
84 FlutterSemanticsFlag flags;
85 };
86
87 enum { PROP_0, PROP_ENGINE, PROP_VIEW_ID, PROP_ID, PROP_LAST };
88
89 #define FL_ACCESSIBLE_NODE_GET_PRIVATE(node) \
90 ((FlAccessibleNodePrivate*)fl_accessible_node_get_instance_private( \
91 FL_ACCESSIBLE_NODE(node)))
92
93 static void fl_accessible_node_component_interface_init(
94 AtkComponentIface* iface);
95 static void fl_accessible_node_action_interface_init(AtkActionIface* iface);
96
97 G_DEFINE_TYPE_WITH_CODE(
98 FlAccessibleNode,
99 fl_accessible_node,
100 ATK_TYPE_OBJECT,
101 G_ADD_PRIVATE(FlAccessibleNode)
102 G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT,
103 fl_accessible_node_component_interface_init)
104 G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION,
105 fl_accessible_node_action_interface_init))
106
107 // Returns TRUE if [flag] has changed between [old_flags] and [flags].
108 static gboolean flag_is_changed(FlutterSemanticsFlag old_flags,
109 FlutterSemanticsFlag flags,
110 FlutterSemanticsFlag flag) {
111 return (old_flags & flag) != (flags & flag);
112 }
113
114 // Returns TRUE if [flag] is set in [flags].
115 static gboolean has_flag(FlutterSemanticsFlag flags,
116 FlutterSemanticsFlag flag) {
117 return (flags & flag) != 0;
118 }
119
120 // Returns TRUE if [action] is set in [actions].
121 static gboolean has_action(FlutterSemanticsAction actions,
122 FlutterSemanticsAction action) {
123 return (actions & action) != 0;
124 }
125
126 // Gets the nth action.
127 static ActionData* get_action(FlAccessibleNodePrivate* priv, gint index) {
128 if (index < 0 || static_cast<guint>(index) >= priv->actions->len) {
129 return nullptr;
130 }
131 return static_cast<ActionData*>(g_ptr_array_index(priv->actions, index));
132 }
133
134 // Checks if [object] is in [children].
135 static gboolean has_child(GPtrArray* children, AtkObject* object) {
136 for (guint i = 0; i < children->len; i++) {
137 if (g_ptr_array_index(children, i) == object) {
138 return TRUE;
139 }
140 }
141
142 return FALSE;
143 }
144
145 static void fl_accessible_node_set_property(GObject* object,
146 guint prop_id,
147 const GValue* value,
148 GParamSpec* pspec) {
149 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(object);
150 switch (prop_id) {
151 case PROP_ENGINE:
152 g_assert(priv->engine == nullptr);
153 priv->engine = FL_ENGINE(g_value_get_object(value));
154 g_object_add_weak_pointer(object,
155 reinterpret_cast<gpointer*>(&priv->engine));
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 }
168
169 static void fl_accessible_node_dispose(GObject* object) {
170 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(object);
171
172 if (priv->engine != nullptr) {
173 g_object_remove_weak_pointer(object,
174 reinterpret_cast<gpointer*>(&(priv->engine)));
175 priv->engine = nullptr;
176 }
177 if (priv->parent != nullptr) {
178 g_object_remove_weak_pointer(object,
179 reinterpret_cast<gpointer*>(&(priv->parent)));
180 priv->parent = nullptr;
181 }
182 g_clear_pointer(&priv->name, g_free);
183 g_clear_pointer(&priv->actions, g_ptr_array_unref);
184 g_clear_pointer(&priv->children, g_ptr_array_unref);
185
186 G_OBJECT_CLASS(fl_accessible_node_parent_class)->dispose(object);
187 }
188
189 // Implements AtkObject::get_name.
190 static const gchar* fl_accessible_node_get_name(AtkObject* accessible) {
191 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(accessible);
192 return priv->name;
193 }
194
195 // Implements AtkObject::get_parent.
196 static AtkObject* fl_accessible_node_get_parent(AtkObject* accessible) {
197 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(accessible);
198 return priv->parent;
199 }
200
201 // Implements AtkObject::get_index_in_parent.
202 static gint fl_accessible_node_get_index_in_parent(AtkObject* accessible) {
203 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(accessible);
204 return priv->index;
205 }
206
207 // Implements AtkObject::get_n_children.
208 static gint fl_accessible_node_get_n_children(AtkObject* accessible) {
209 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(accessible);
210 return priv->children->len;
211 }
212
213 // Implements AtkObject::ref_child.
214 static AtkObject* fl_accessible_node_ref_child(AtkObject* accessible, gint i) {
215 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(accessible);
216
217 if (i < 0 || static_cast<guint>(i) >= priv->children->len) {
218 return nullptr;
219 }
220
221 return ATK_OBJECT(g_object_ref(g_ptr_array_index(priv->children, i)));
222 }
223
224 // Implements AtkObject::get_role.
225 static AtkRole fl_accessible_node_get_role(AtkObject* accessible) {
226 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(accessible);
227 if ((priv->flags & kFlutterSemanticsFlagIsButton) != 0) {
228 return ATK_ROLE_PUSH_BUTTON;
229 }
230 if ((priv->flags & kFlutterSemanticsFlagIsInMutuallyExclusiveGroup) != 0 &&
231 (priv->flags & kFlutterSemanticsFlagHasCheckedState) != 0) {
232 return ATK_ROLE_RADIO_BUTTON;
233 }
234 if ((priv->flags & kFlutterSemanticsFlagHasCheckedState) != 0) {
235 return ATK_ROLE_CHECK_BOX;
236 }
237 if ((priv->flags & kFlutterSemanticsFlagHasToggledState) != 0) {
238 return ATK_ROLE_TOGGLE_BUTTON;
239 }
240 if ((priv->flags & kFlutterSemanticsFlagIsSlider) != 0) {
241 return ATK_ROLE_SLIDER;
242 }
243 if ((priv->flags & kFlutterSemanticsFlagIsTextField) != 0 &&
244 (priv->flags & kFlutterSemanticsFlagIsObscured) != 0) {
245 return ATK_ROLE_PASSWORD_TEXT;
246 }
247 if ((priv->flags & kFlutterSemanticsFlagIsTextField) != 0) {
248 return ATK_ROLE_TEXT;
249 }
250 if ((priv->flags & kFlutterSemanticsFlagIsHeader) != 0) {
251 return ATK_ROLE_HEADER;
252 }
253 if ((priv->flags & kFlutterSemanticsFlagIsLink) != 0) {
254 return ATK_ROLE_LINK;
255 }
256 if ((priv->flags & kFlutterSemanticsFlagIsImage) != 0) {
257 return ATK_ROLE_IMAGE;
258 }
259
260 return ATK_ROLE_PANEL;
261 }
262
263 // Implements AtkObject::ref_state_set.
264 static AtkStateSet* fl_accessible_node_ref_state_set(AtkObject* accessible) {
265 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(accessible);
266
267 AtkStateSet* state_set = atk_state_set_new();
268
269 for (int i = 0; flag_mapping[i].state != ATK_STATE_INVALID; i++) {
270 gboolean enabled = has_flag(priv->flags, flag_mapping[i].flag);
271 if (flag_mapping[i].invert) {
272 enabled = !enabled;
273 }
274 if (enabled) {
275 atk_state_set_add_state(state_set, flag_mapping[i].state);
276 }
277 }
278
279 return state_set;
280 }
281
282 // Implements AtkComponent::get_extents.
283 static void fl_accessible_node_get_extents(AtkComponent* component,
284 gint* x,
285 gint* y,
286 gint* width,
287 gint* height,
288 AtkCoordType coord_type) {
289 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(component);
290
291 *x = 0;
292 *y = 0;
293 if (priv->parent != nullptr) {
294 atk_component_get_extents(ATK_COMPONENT(priv->parent), x, y, nullptr,
295 nullptr, coord_type);
296 }
297
298 *x += priv->x;
299 *y += priv->y;
300 *width = priv->width;
301 *height = priv->height;
302 }
303
304 // Implements AtkComponent::get_layer.
305 static AtkLayer fl_accessible_node_get_layer(AtkComponent* component) {
306 return ATK_LAYER_WIDGET;
307 }
308
309 // Implements AtkAction::do_action.
310 static gboolean fl_accessible_node_do_action(AtkAction* action, gint i) {
311 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(action);
312
313 if (priv->engine == nullptr) {
314 return FALSE;
315 }
316
317 ActionData* data = get_action(priv, i);
318 if (data == nullptr) {
319 return FALSE;
320 }
321
322 fl_accessible_node_perform_action(FL_ACCESSIBLE_NODE(action), data->action,
323 nullptr);
324 return TRUE;
325 }
326
327 // Implements AtkAction::get_n_actions.
328 static gint fl_accessible_node_get_n_actions(AtkAction* action) {
329 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(action);
330 return priv->actions->len;
331 }
332
333 // Implements AtkAction::get_name.
334 static const gchar* fl_accessible_node_get_name(AtkAction* action, gint i) {
335 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(action);
336
337 ActionData* data = get_action(priv, i);
338 if (data == nullptr) {
339 return nullptr;
340 }
341
342 return data->name;
343 }
344
345 // Implements FlAccessibleNode::set_name.
346 static void fl_accessible_node_set_name_impl(FlAccessibleNode* self,
347 const gchar* name) {
348 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(self);
349 g_free(priv->name);
350 priv->name = g_strdup(name);
351 }
352
353 // Implements FlAccessibleNode::set_extents.
354 static void fl_accessible_node_set_extents_impl(FlAccessibleNode* self,
355 gint x,
356 gint y,
357 gint width,
358 gint height) {
359 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(self);
360 priv->x = x;
361 priv->y = y;
362 priv->width = width;
363 priv->height = height;
364 }
365
366 // Implements FlAccessibleNode::set_flags.
367 static void fl_accessible_node_set_flags_impl(FlAccessibleNode* self,
368 FlutterSemanticsFlag flags) {
369 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(self);
370
371 FlutterSemanticsFlag old_flags = priv->flags;
372 priv->flags = flags;
373
374 for (int i = 0; flag_mapping[i].state != ATK_STATE_INVALID; i++) {
375 if (flag_is_changed(old_flags, flags, flag_mapping[i].flag)) {
376 gboolean enabled = has_flag(flags, flag_mapping[i].flag);
377 if (flag_mapping[i].invert) {
378 enabled = !enabled;
379 }
380
381 atk_object_notify_state_change(ATK_OBJECT(self), flag_mapping[i].state,
382 enabled);
383 }
384 }
385 }
386
387 // Implements FlAccessibleNode::set_actions.
388 static void fl_accessible_node_set_actions_impl(
389 FlAccessibleNode* self,
390 FlutterSemanticsAction actions) {
391 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(self);
392
393 // NOTE(robert-ancell): It appears that AtkAction doesn't have a method of
394 // notifying that actions have changed, and even if it did an ATK client
395 // might access the old IDs before checking for new ones. Keep an eye
396 // out for a case where Flutter changes the actions on an item and see
397 // if we can resolve this in another way.
398 g_ptr_array_remove_range(priv->actions, 0, priv->actions->len);
399 for (int i = 0; action_mapping[i].name != nullptr; i++) {
400 if (has_action(actions, action_mapping[i].action)) {
401 g_ptr_array_add(priv->actions, &action_mapping[i]);
402 }
403 }
404 }
405
406 // Implements FlAccessibleNode::set_value.
407 static void fl_accessible_node_set_value_impl(FlAccessibleNode* self,
408 const gchar* value) {}
409
410 // Implements FlAccessibleNode::set_text_selection.
411 static void fl_accessible_node_set_text_selection_impl(FlAccessibleNode* self,
412 gint base,
413 gint extent) {}
414
415 // Implements FlAccessibleNode::set_text_direction.
416 static void fl_accessible_node_set_text_direction_impl(
417 FlAccessibleNode* self,
418 FlutterTextDirection direction) {}
419
420 // Implements FlAccessibleNode::perform_action.
421 static void fl_accessible_node_perform_action_impl(
422 FlAccessibleNode* self,
423 FlutterSemanticsAction action,
424 GBytes* data) {
425 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(self);
426 fl_engine_dispatch_semantics_action(priv->engine, priv->view_id,
427 priv->node_id, action, data);
428 }
429
430 static void fl_accessible_node_class_init(FlAccessibleNodeClass* klass) {
431 G_OBJECT_CLASS(klass)->set_property = fl_accessible_node_set_property;
432 G_OBJECT_CLASS(klass)->dispose = fl_accessible_node_dispose;
433 ATK_OBJECT_CLASS(klass)->get_name = fl_accessible_node_get_name;
434 ATK_OBJECT_CLASS(klass)->get_parent = fl_accessible_node_get_parent;
435 ATK_OBJECT_CLASS(klass)->get_index_in_parent =
436 fl_accessible_node_get_index_in_parent;
437 ATK_OBJECT_CLASS(klass)->get_n_children = fl_accessible_node_get_n_children;
438 ATK_OBJECT_CLASS(klass)->ref_child = fl_accessible_node_ref_child;
439 ATK_OBJECT_CLASS(klass)->get_role = fl_accessible_node_get_role;
440 ATK_OBJECT_CLASS(klass)->ref_state_set = fl_accessible_node_ref_state_set;
441 FL_ACCESSIBLE_NODE_CLASS(klass)->set_name = fl_accessible_node_set_name_impl;
442 FL_ACCESSIBLE_NODE_CLASS(klass)->set_extents =
443 fl_accessible_node_set_extents_impl;
444 FL_ACCESSIBLE_NODE_CLASS(klass)->set_flags =
445 fl_accessible_node_set_flags_impl;
446 FL_ACCESSIBLE_NODE_CLASS(klass)->set_actions =
447 fl_accessible_node_set_actions_impl;
448 FL_ACCESSIBLE_NODE_CLASS(klass)->set_value =
449 fl_accessible_node_set_value_impl;
450 FL_ACCESSIBLE_NODE_CLASS(klass)->set_text_selection =
451 fl_accessible_node_set_text_selection_impl;
452 FL_ACCESSIBLE_NODE_CLASS(klass)->set_text_direction =
453 fl_accessible_node_set_text_direction_impl;
454 FL_ACCESSIBLE_NODE_CLASS(klass)->perform_action =
455 fl_accessible_node_perform_action_impl;
456
457 g_object_class_install_property(
458 G_OBJECT_CLASS(klass), PROP_ENGINE,
459 g_param_spec_object(
460 "engine", "engine", "Flutter engine", fl_engine_get_type(),
461 static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
462 G_PARAM_STATIC_STRINGS)));
463 g_object_class_install_property(
464 G_OBJECT_CLASS(klass), PROP_VIEW_ID,
465 g_param_spec_int64(
466 "view-id", "view-id", "View ID that this node belongs to", 0,
467 G_MAXINT64, 0,
468 static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)));
469 g_object_class_install_property(
470 G_OBJECT_CLASS(klass), PROP_ID,
471 g_param_spec_int(
472 "node-id", "node-id", "Accessibility node ID", 0, G_MAXINT, 0,
473 static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
474 G_PARAM_STATIC_STRINGS)));
475 }
476
477 static void fl_accessible_node_component_interface_init(
478 AtkComponentIface* iface) {
479 iface->get_extents = fl_accessible_node_get_extents;
480 iface->get_layer = fl_accessible_node_get_layer;
481 }
482
483 static void fl_accessible_node_action_interface_init(AtkActionIface* iface) {
484 iface->do_action = fl_accessible_node_do_action;
485 iface->get_n_actions = fl_accessible_node_get_n_actions;
486 iface->get_name = fl_accessible_node_get_name;
487 }
488
489 static void fl_accessible_node_init(FlAccessibleNode* self) {
490 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(self);
491 priv->actions = g_ptr_array_new();
492 priv->children = g_ptr_array_new_with_free_func(g_object_unref);
493 }
494
495 FlAccessibleNode* fl_accessible_node_new(FlEngine* engine,
496 FlutterViewId view_id,
497 int32_t node_id) {
498 FlAccessibleNode* self = FL_ACCESSIBLE_NODE(
499 g_object_new(fl_accessible_node_get_type(), "engine", engine, "view-id",
500 view_id, "node-id", node_id, nullptr));
501 return self;
502 }
503
504 void fl_accessible_node_set_parent(FlAccessibleNode* self,
505 AtkObject* parent,
506 gint index) {
507 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
508 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(self);
509 priv->parent = parent;
510 priv->index = index;
511 g_object_add_weak_pointer(G_OBJECT(self),
512 reinterpret_cast<gpointer*>(&(priv->parent)));
513 }
514
515 void fl_accessible_node_set_children(FlAccessibleNode* self,
516 GPtrArray* children) {
517 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
518 FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(self);
519
520 // Remove nodes that are no longer required.
521 for (guint i = 0; i < priv->children->len;) {
522 AtkObject* object = ATK_OBJECT(g_ptr_array_index(priv->children, i));
523 if (has_child(children, object)) {
524 i++;
525 } else {
526 g_signal_emit_by_name(self, "children-changed::remove", i, object,
527 nullptr);
528 g_ptr_array_remove_index(priv->children, i);
529 }
530 }
531
532 // Add new nodes.
533 for (guint i = 0; i < children->len; i++) {
534 AtkObject* object = ATK_OBJECT(g_ptr_array_index(children, i));
535 if (!has_child(priv->children, object)) {
536 g_ptr_array_add(priv->children, g_object_ref(object));
537 g_signal_emit_by_name(self, "children-changed::add", i, object, nullptr);
538 }
539 }
540 }
541
542 void fl_accessible_node_set_name(FlAccessibleNode* self, const gchar* name) {
543 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
544
545 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_name(self, name);
546 }
547
548 void fl_accessible_node_set_extents(FlAccessibleNode* self,
549 gint x,
550 gint y,
551 gint width,
552 gint height) {
553 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
554
555 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_extents(self, x, y, width,
556 height);
557 }
558
559 void fl_accessible_node_set_flags(FlAccessibleNode* self,
560 FlutterSemanticsFlag flags) {
561 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
562
563 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_flags(self, flags);
564 }
565
566 void fl_accessible_node_set_actions(FlAccessibleNode* self,
567 FlutterSemanticsAction actions) {
568 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
569
570 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_actions(self, actions);
571 }
572
573 void fl_accessible_node_set_value(FlAccessibleNode* self, const gchar* value) {
574 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
575
576 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_value(self, value);
577 }
578
579 void fl_accessible_node_set_text_selection(FlAccessibleNode* self,
580 gint base,
581 gint extent) {
582 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
583
584 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_text_selection(self, base,
585 extent);
586 }
587
588 void fl_accessible_node_set_text_direction(FlAccessibleNode* self,
589 FlutterTextDirection direction) {
590 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
591
592 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->set_text_direction(self,
593 direction);
594 }
595
596 void fl_accessible_node_perform_action(FlAccessibleNode* self,
597 FlutterSemanticsAction action,
598 GBytes* data) {
599 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));
600
601 return FL_ACCESSIBLE_NODE_GET_CLASS(self)->perform_action(self, action, data);
602 }
has_child
static gboolean has_child(GPtrArray *children, AtkObject *object)
Definition: fl_accessible_node.cc:135
fl_accessible_node_set_property
static void fl_accessible_node_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
Definition: fl_accessible_node.cc:145
fl_accessible_node_set_name
void fl_accessible_node_set_name(FlAccessibleNode *self, const gchar *name)
Definition: fl_accessible_node.cc:542
fl_accessible_node_do_action
static gboolean fl_accessible_node_do_action(AtkAction *action, gint i)
Definition: fl_accessible_node.cc:310
fl_accessible_node_action_interface_init
static void fl_accessible_node_action_interface_init(AtkActionIface *iface)
Definition: fl_accessible_node.cc:483
fl_accessible_node_set_text_direction_impl
static void fl_accessible_node_set_text_direction_impl(FlAccessibleNode *self, FlutterTextDirection direction)
Definition: fl_accessible_node.cc:416
flag
FlutterSemanticsFlag flag
Definition: fl_accessible_node.cc:11
fl_accessible_node_set_text_direction
void fl_accessible_node_set_text_direction(FlAccessibleNode *self, FlutterTextDirection direction)
Definition: fl_accessible_node.cc:588
fl_accessible_node_perform_action
void fl_accessible_node_perform_action(FlAccessibleNode *self, FlutterSemanticsAction action, GBytes *data)
Definition: fl_accessible_node.cc:596
fl_accessible_node_get_role
static AtkRole fl_accessible_node_get_role(AtkObject *accessible)
Definition: fl_accessible_node.cc:225
fl_accessible_node_set_value_impl
static void fl_accessible_node_set_value_impl(FlAccessibleNode *self, const gchar *value)
Definition: fl_accessible_node.cc:407
fl_accessible_node_set_text_selection
void fl_accessible_node_set_text_selection(FlAccessibleNode *self, gint base, gint extent)
Definition: fl_accessible_node.cc:579
fl_accessible_node_class_init
static void fl_accessible_node_class_init(FlAccessibleNodeClass *klass)
Definition: fl_accessible_node.cc:430
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)) static gboolean flag_is_changed(FlutterSemanticsFlag old_flags
fl_accessible_node_set_actions_impl
static void fl_accessible_node_set_actions_impl(FlAccessibleNode *self, FlutterSemanticsAction actions)
Definition: fl_accessible_node.cc:388
fl_accessible_node_component_interface_init
static void fl_accessible_node_component_interface_init(AtkComponentIface *iface)
Definition: fl_accessible_node.cc:477
fl_accessible_node_set_actions
void fl_accessible_node_set_actions(FlAccessibleNode *self, FlutterSemanticsAction actions)
Definition: fl_accessible_node.cc:566
fl_accessible_node_dispose
static void fl_accessible_node_dispose(GObject *object)
Definition: fl_accessible_node.cc:169
fl_accessible_node_set_children
void fl_accessible_node_set_children(FlAccessibleNode *self, GPtrArray *children)
Definition: fl_accessible_node.cc:515
fl_accessible_node_set_flags_impl
static void fl_accessible_node_set_flags_impl(FlAccessibleNode *self, FlutterSemanticsFlag flags)
Definition: fl_accessible_node.cc:367
fl_accessible_node_get_name
static const gchar * fl_accessible_node_get_name(AtkObject *accessible)
Definition: fl_accessible_node.cc:190
fl_accessible_node_set_extents
void fl_accessible_node_set_extents(FlAccessibleNode *self, gint x, gint y, gint width, gint height)
Definition: fl_accessible_node.cc:548
fl_accessible_node_get_layer
static AtkLayer fl_accessible_node_get_layer(AtkComponent *component)
Definition: fl_accessible_node.cc:305
fl_accessible_node_set_value
void fl_accessible_node_set_value(FlAccessibleNode *self, const gchar *value)
Definition: fl_accessible_node.cc:573
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)
Definition: fl_accessible_node.cc:283
fl_accessible_node_get_n_actions
static gint fl_accessible_node_get_n_actions(AtkAction *action)
Definition: fl_accessible_node.cc:328
state
AtkStateType state
Definition: fl_accessible_node.cc:10
flags
FlutterSemanticsFlag flags
Definition: fl_accessible_node.cc:109
fl_accessible_node_ref_child
static AtkObject * fl_accessible_node_ref_child(AtkObject *accessible, gint i)
Definition: fl_accessible_node.cc:214
fl_accessible_node_set_flags
void fl_accessible_node_set_flags(FlAccessibleNode *self, FlutterSemanticsFlag flags)
Definition: fl_accessible_node.cc:559
has_action
static gboolean has_action(FlutterSemanticsAction actions, FlutterSemanticsAction action)
Definition: fl_accessible_node.cc:121
fl_accessible_node_get_index_in_parent
static gint fl_accessible_node_get_index_in_parent(AtkObject *accessible)
Definition: fl_accessible_node.cc:202
fl_accessible_node_get_parent
static AtkObject * fl_accessible_node_get_parent(AtkObject *accessible)
Definition: fl_accessible_node.cc:196
fl_accessible_node_init
static void fl_accessible_node_init(FlAccessibleNode *self)
Definition: fl_accessible_node.cc:489
fl_accessible_node_set_parent
void fl_accessible_node_set_parent(FlAccessibleNode *self, AtkObject *parent, gint index)
Definition: fl_accessible_node.cc:504
fl_accessible_node_ref_state_set
static AtkStateSet * fl_accessible_node_ref_state_set(AtkObject *accessible)
Definition: fl_accessible_node.cc:264
fl_accessible_node_perform_action_impl
static void fl_accessible_node_perform_action_impl(FlAccessibleNode *self, FlutterSemanticsAction action, GBytes *data)
Definition: fl_accessible_node.cc:421
invert
gboolean invert
Definition: fl_accessible_node.cc:12
flag_mapping
static struct @0 flag_mapping[]
action_mapping
static ActionData action_mapping[]
Definition: fl_accessible_node.cc:36
fl_accessible_node_set_text_selection_impl
static void fl_accessible_node_set_text_selection_impl(FlAccessibleNode *self, gint base, gint extent)
Definition: fl_accessible_node.cc:411
fl_accessible_node_get_n_children
static gint fl_accessible_node_get_n_children(AtkObject *accessible)
Definition: fl_accessible_node.cc:208
PROP_ENGINE
@ PROP_ENGINE
Definition: fl_accessible_node.cc:87
PROP_VIEW_ID
@ PROP_VIEW_ID
Definition: fl_accessible_node.cc:87
PROP_LAST
@ PROP_LAST
Definition: fl_accessible_node.cc:87
PROP_0
@ PROP_0
Definition: fl_accessible_node.cc:87
PROP_ID
@ PROP_ID
Definition: fl_accessible_node.cc:87
fl_accessible_node_set_extents_impl
static void fl_accessible_node_set_extents_impl(FlAccessibleNode *self, gint x, gint y, gint width, gint height)
Definition: fl_accessible_node.cc:354
has_flag
static gboolean has_flag(FlutterSemanticsFlag flags, FlutterSemanticsFlag flag)
Definition: fl_accessible_node.cc:115
get_action
static ActionData * get_action(FlAccessibleNodePrivate *priv, gint index)
Definition: fl_accessible_node.cc:127
FL_ACCESSIBLE_NODE_GET_PRIVATE
#define FL_ACCESSIBLE_NODE_GET_PRIVATE(node)
Definition: fl_accessible_node.cc:89
fl_accessible_node_new
FlAccessibleNode * fl_accessible_node_new(FlEngine *engine, FlutterViewId view_id, int32_t node_id)
Definition: fl_accessible_node.cc:495
fl_accessible_node_set_name_impl
static void fl_accessible_node_set_name_impl(FlAccessibleNode *self, const gchar *name)
Definition: fl_accessible_node.cc:346
fl_accessible_node.h
fl_engine_dispatch_semantics_action
void fl_engine_dispatch_semantics_action(FlEngine *self, FlutterViewId view_id, uint64_t node_id, FlutterSemanticsAction action, GBytes *data)
Definition: fl_engine.cc:1232
fl_engine_private.h
priv
FlPixelBufferTexturePrivate * priv
Definition: fl_pixel_buffer_texture.cc:30
height
const uint8_t uint32_t uint32_t * height
Definition: fl_pixel_buffer_texture_test.cc:39
width
const uint8_t uint32_t * width
Definition: fl_pixel_buffer_texture_test.cc:38
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
i
int i
Definition: fl_socket_accessible.cc:18
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
prop_id
guint prop_id
Definition: fl_standard_method_codec.cc:31
pspec
guint const GValue GParamSpec * pspec
Definition: fl_standard_method_codec.cc:33
view_id
G_BEGIN_DECLS FlutterViewId view_id
Definition: fl_view_accessible.h:49
ActionData
Definition: fl_accessible_node.cc:32
ActionData::name
const gchar * name
Definition: fl_accessible_node.cc:34
ActionData::action
FlutterSemanticsAction action
Definition: fl_accessible_node.cc:33
FlAccessibleNodePrivate
Definition: fl_accessible_node.cc:65
FlAccessibleNodePrivate::actions_length
gsize actions_length
Definition: fl_accessible_node.cc:82
FlAccessibleNodePrivate::view_id
FlutterViewId view_id
The unique identifier of the view to which this node belongs.
Definition: fl_accessible_node.cc:72
FlAccessibleNodePrivate::name
gchar * name
Definition: fl_accessible_node.cc:78
FlAccessibleNodePrivate::flags
FlutterSemanticsFlag flags
Definition: fl_accessible_node.cc:84
FlAccessibleNodePrivate::y
gint y
Definition: fl_accessible_node.cc:80
FlAccessibleNodePrivate::parent_instance
AtkObject parent_instance
Definition: fl_accessible_node.cc:66
FlAccessibleNodePrivate::width
gint width
Definition: fl_accessible_node.cc:80
FlAccessibleNodePrivate::engine
FlEngine * engine
Definition: fl_accessible_node.cc:69
FlAccessibleNodePrivate::children
GPtrArray * children
Definition: fl_accessible_node.cc:83
FlAccessibleNodePrivate::x
gint x
Definition: fl_accessible_node.cc:80
FlAccessibleNodePrivate::index
gint index
Definition: fl_accessible_node.cc:79
FlAccessibleNodePrivate::height
gint height
Definition: fl_accessible_node.cc:80
FlAccessibleNodePrivate::node_id
int32_t node_id
Definition: fl_accessible_node.cc:77
FlAccessibleNodePrivate::actions
GPtrArray * actions
Definition: fl_accessible_node.cc:81
FlAccessibleNodePrivate::parent
AtkObject * parent
Definition: fl_accessible_node.cc:75