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},
20 static_cast<FlutterSemanticsFlag
>(kFlutterSemanticsFlagIsChecked |
21 kFlutterSemanticsFlagIsToggled),
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},
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}};
86 #define FL_ACCESSIBLE_NODE_GET_PRIVATE(node) \
87 ((FlAccessibleNodePrivate*)fl_accessible_node_get_instance_private( \
88 FL_ACCESSIBLE_NODE(node)))
91 AtkComponentIface* iface);
98 G_ADD_PRIVATE(FlAccessibleNode)
99 G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT,
101 G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION,
105 static gboolean flag_is_changed(FlutterSemanticsFlag old_flags,
107 FlutterSemanticsFlag
flag) {
113 FlutterSemanticsFlag
flag) {
119 FlutterSemanticsAction action) {
120 return (actions & action) != 0;
125 if (index < 0 ||
static_cast<guint
>(index) >=
priv->actions->len) {
128 return static_cast<ActionData*
>(g_ptr_array_index(
priv->actions, index));
132 static gboolean
has_child(GPtrArray* children, AtkObject*
object) {
133 for (guint
i = 0;
i < children->len;
i++) {
134 if (g_ptr_array_index(children,
i) ==
object) {
149 g_assert(
priv->engine ==
nullptr);
150 priv->engine = FL_ENGINE(g_value_get_object(
value));
151 g_object_add_weak_pointer(
object,
152 reinterpret_cast<gpointer*
>(&
priv->engine));
158 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object,
prop_id,
pspec);
166 if (
priv->engine !=
nullptr) {
167 g_object_remove_weak_pointer(
object,
168 reinterpret_cast<gpointer*
>(&(
priv->engine)));
169 priv->engine =
nullptr;
171 if (
priv->parent !=
nullptr) {
172 g_object_remove_weak_pointer(
object,
173 reinterpret_cast<gpointer*
>(&(
priv->parent)));
174 priv->parent =
nullptr;
176 g_clear_pointer(&
priv->name, g_free);
177 g_clear_pointer(&
priv->actions, g_ptr_array_unref);
178 g_clear_pointer(&
priv->children, g_ptr_array_unref);
180 G_OBJECT_CLASS(fl_accessible_node_parent_class)->dispose(
object);
204 return priv->children->len;
211 if (
i < 0 ||
static_cast<guint
>(
i) >=
priv->children->len) {
215 return ATK_OBJECT(g_object_ref(g_ptr_array_index(
priv->children,
i)));
221 if ((
priv->flags & kFlutterSemanticsFlagIsButton) != 0) {
222 return ATK_ROLE_PUSH_BUTTON;
224 if ((
priv->flags & kFlutterSemanticsFlagIsInMutuallyExclusiveGroup) != 0 &&
225 (
priv->flags & kFlutterSemanticsFlagHasCheckedState) != 0) {
226 return ATK_ROLE_RADIO_BUTTON;
228 if ((
priv->flags & kFlutterSemanticsFlagHasCheckedState) != 0) {
229 return ATK_ROLE_CHECK_BOX;
231 if ((
priv->flags & kFlutterSemanticsFlagHasToggledState) != 0) {
232 return ATK_ROLE_TOGGLE_BUTTON;
234 if ((
priv->flags & kFlutterSemanticsFlagIsSlider) != 0) {
235 return ATK_ROLE_SLIDER;
237 if ((
priv->flags & kFlutterSemanticsFlagIsTextField) != 0 &&
238 (
priv->flags & kFlutterSemanticsFlagIsObscured) != 0) {
239 return ATK_ROLE_PASSWORD_TEXT;
241 if ((
priv->flags & kFlutterSemanticsFlagIsTextField) != 0) {
242 return ATK_ROLE_TEXT;
244 if ((
priv->flags & kFlutterSemanticsFlagIsHeader) != 0) {
245 return ATK_ROLE_HEADER;
247 if ((
priv->flags & kFlutterSemanticsFlagIsLink) != 0) {
248 return ATK_ROLE_LINK;
250 if ((
priv->flags & kFlutterSemanticsFlagIsImage) != 0) {
251 return ATK_ROLE_IMAGE;
254 return ATK_ROLE_PANEL;
261 AtkStateSet* state_set = atk_state_set_new();
282 AtkCoordType coord_type) {
287 if (
priv->parent !=
nullptr) {
288 atk_component_get_extents(ATK_COMPONENT(
priv->parent), x, y,
nullptr,
289 nullptr, coord_type);
300 return ATK_LAYER_WIDGET;
307 if (
priv->engine ==
nullptr) {
312 if (data ==
nullptr) {
324 return priv->actions->len;
332 if (data ==
nullptr) {
344 priv->name = g_strdup(name);
362 FlutterSemanticsFlag
flags) {
365 FlutterSemanticsFlag old_flags =
priv->flags;
383 FlAccessibleNode*
self,
384 FlutterSemanticsAction actions) {
392 g_ptr_array_remove_range(
priv->actions, 0,
priv->actions->len);
402 const gchar*
value) {}
411 FlAccessibleNode*
self,
412 FlutterTextDirection direction) {}
416 FlAccessibleNode*
self,
417 FlutterSemanticsAction action,
428 ATK_OBJECT_CLASS(klass)->get_index_in_parent =
435 FL_ACCESSIBLE_NODE_CLASS(klass)->set_extents =
437 FL_ACCESSIBLE_NODE_CLASS(klass)->set_flags =
439 FL_ACCESSIBLE_NODE_CLASS(klass)->set_actions =
441 FL_ACCESSIBLE_NODE_CLASS(klass)->set_value =
443 FL_ACCESSIBLE_NODE_CLASS(klass)->set_text_selection =
445 FL_ACCESSIBLE_NODE_CLASS(klass)->set_text_direction =
447 FL_ACCESSIBLE_NODE_CLASS(klass)->perform_action =
450 g_object_class_install_property(
453 "engine",
"engine",
"Flutter engine", fl_engine_get_type(),
454 static_cast<GParamFlags
>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
455 G_PARAM_STATIC_STRINGS)));
456 g_object_class_install_property(
457 G_OBJECT_CLASS(klass),
kPropId,
459 "id",
"id",
"Accessibility node ID", 0, G_MAXINT, 0,
460 static_cast<GParamFlags
>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
461 G_PARAM_STATIC_STRINGS)));
465 AtkComponentIface* iface) {
478 priv->actions = g_ptr_array_new();
479 priv->children = g_ptr_array_new_with_free_func(g_object_unref);
483 FlAccessibleNode*
self = FL_ACCESSIBLE_NODE(g_object_new(
484 fl_accessible_node_get_type(),
"engine", engine,
"id",
id,
nullptr));
491 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
493 priv->parent = parent;
495 g_object_add_weak_pointer(G_OBJECT(
self),
496 reinterpret_cast<gpointer*
>(&(
priv->parent)));
500 GPtrArray* children) {
501 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
505 for (guint
i = 0;
i <
priv->children->len;) {
506 AtkObject*
object = ATK_OBJECT(g_ptr_array_index(
priv->children,
i));
510 g_signal_emit_by_name(
self,
"children-changed::remove",
i,
object,
512 g_ptr_array_remove_index(
priv->children,
i);
517 for (guint
i = 0;
i < children->len;
i++) {
518 AtkObject*
object = ATK_OBJECT(g_ptr_array_index(children,
i));
520 g_ptr_array_add(
priv->children, g_object_ref(
object));
521 g_signal_emit_by_name(
self,
"children-changed::add",
i,
object,
nullptr);
527 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
529 return FL_ACCESSIBLE_NODE_GET_CLASS(
self)->set_name(
self, name);
537 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
539 return FL_ACCESSIBLE_NODE_GET_CLASS(
self)->set_extents(
self, x, y,
width,
544 FlutterSemanticsFlag
flags) {
545 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
547 return FL_ACCESSIBLE_NODE_GET_CLASS(
self)->set_flags(
self,
flags);
551 FlutterSemanticsAction actions) {
552 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
554 return FL_ACCESSIBLE_NODE_GET_CLASS(
self)->set_actions(
self, actions);
558 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
560 return FL_ACCESSIBLE_NODE_GET_CLASS(
self)->set_value(
self,
value);
566 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
568 return FL_ACCESSIBLE_NODE_GET_CLASS(
self)->set_text_selection(
self, base,
573 FlutterTextDirection direction) {
574 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
576 return FL_ACCESSIBLE_NODE_GET_CLASS(
self)->set_text_direction(
self,
581 FlutterSemanticsAction action,
583 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
585 return FL_ACCESSIBLE_NODE_GET_CLASS(
self)->perform_action(
self, action, data);