14 {kFlutterSemanticsActionTap,
"Tap"},
15 {kFlutterSemanticsActionLongPress,
"LongPress"},
16 {kFlutterSemanticsActionScrollLeft,
"ScrollLeft"},
17 {kFlutterSemanticsActionScrollRight,
"ScrollRight"},
18 {kFlutterSemanticsActionScrollUp,
"ScrollUp"},
19 {kFlutterSemanticsActionScrollDown,
"ScrollDown"},
20 {kFlutterSemanticsActionIncrease,
"Increase"},
21 {kFlutterSemanticsActionDecrease,
"Decrease"},
22 {kFlutterSemanticsActionShowOnScreen,
"ShowOnScreen"},
23 {kFlutterSemanticsActionMoveCursorForwardByCharacter,
24 "MoveCursorForwardByCharacter"},
25 {kFlutterSemanticsActionMoveCursorBackwardByCharacter,
26 "MoveCursorBackwardByCharacter"},
27 {kFlutterSemanticsActionCopy,
"Copy"},
28 {kFlutterSemanticsActionCut,
"Cut"},
29 {kFlutterSemanticsActionPaste,
"Paste"},
30 {kFlutterSemanticsActionDidGainAccessibilityFocus,
31 "DidGainAccessibilityFocus"},
32 {kFlutterSemanticsActionDidLoseAccessibilityFocus,
33 "DidLoseAccessibilityFocus"},
34 {kFlutterSemanticsActionCustomAction,
"CustomAction"},
35 {kFlutterSemanticsActionDismiss,
"Dismiss"},
36 {kFlutterSemanticsActionMoveCursorForwardByWord,
"MoveCursorForwardByWord"},
37 {kFlutterSemanticsActionMoveCursorBackwardByWord,
38 "MoveCursorBackwardByWord"},
39 {kFlutterSemanticsActionFocus,
"Focus"},
40 {
static_cast<FlutterSemanticsAction
>(0),
nullptr}};
66 #define FL_ACCESSIBLE_NODE_GET_PRIVATE(node) \
67 ((FlAccessibleNodePrivate*)fl_accessible_node_get_instance_private( \
68 FL_ACCESSIBLE_NODE(node)))
71 AtkComponentIface* iface);
78 G_ADD_PRIVATE(FlAccessibleNode)
79 G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT,
81 G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION,
85 static gboolean has_action(FlutterSemanticsAction actions,
87 return (actions &
action) != 0;
92 if (index < 0 ||
static_cast<guint
>(index) >=
priv->actions->len) {
95 return static_cast<ActionData*
>(g_ptr_array_index(
priv->actions, index));
99 static gboolean
has_child(GPtrArray* children, AtkObject*
object) {
100 for (guint
i = 0;
i < children->len;
i++) {
101 if (g_ptr_array_index(children,
i) ==
object) {
116 g_assert(
priv->engine ==
nullptr);
117 priv->engine = FL_ENGINE(g_value_get_object(
value));
118 g_object_add_weak_pointer(
object,
119 reinterpret_cast<gpointer*
>(&
priv->engine));
122 priv->view_id = g_value_get_int64(
value);
128 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object,
prop_id,
pspec);
136 if (
priv->engine !=
nullptr) {
137 g_object_remove_weak_pointer(
object,
138 reinterpret_cast<gpointer*
>(&(
priv->engine)));
139 priv->engine =
nullptr;
141 if (
priv->parent !=
nullptr) {
142 g_object_remove_weak_pointer(
object,
143 reinterpret_cast<gpointer*
>(&(
priv->parent)));
144 priv->parent =
nullptr;
146 g_clear_pointer(&
priv->name, g_free);
147 g_clear_pointer(&
priv->actions, g_ptr_array_unref);
148 g_clear_pointer(&
priv->children, g_ptr_array_unref);
150 G_OBJECT_CLASS(fl_accessible_node_parent_class)->dispose(
object);
174 return priv->children->len;
181 if (
i < 0 ||
static_cast<guint
>(
i) >=
priv->children->len) {
185 return ATK_OBJECT(g_object_ref(g_ptr_array_index(
priv->children,
i)));
191 if (
priv->flags.is_button) {
192 return ATK_ROLE_PUSH_BUTTON;
194 if (
priv->flags.is_in_mutually_exclusive_group &&
195 priv->flags.is_checked != kFlutterCheckStateNone) {
196 return ATK_ROLE_RADIO_BUTTON;
198 if (
priv->flags.is_checked != kFlutterCheckStateNone) {
199 return ATK_ROLE_CHECK_BOX;
201 if (
priv->flags.is_toggled != kFlutterTristateNone) {
202 return ATK_ROLE_TOGGLE_BUTTON;
204 if (
priv->flags.is_slider) {
205 return ATK_ROLE_SLIDER;
207 if (
priv->flags.is_text_field &&
priv->flags.is_obscured) {
208 return ATK_ROLE_PASSWORD_TEXT;
210 if (
priv->flags.is_text_field) {
211 return ATK_ROLE_TEXT;
213 if (
priv->flags.is_header) {
214 return ATK_ROLE_HEADER;
216 if (
priv->flags.is_link) {
217 return ATK_ROLE_LINK;
219 if (
priv->flags.is_image) {
220 return ATK_ROLE_IMAGE;
223 return ATK_ROLE_PANEL;
230 AtkStateSet* state_set = atk_state_set_new();
232 if (!
priv->flags.is_obscured) {
233 atk_state_set_add_state(state_set, ATK_STATE_SHOWING);
235 if (!
priv->flags.is_hidden) {
236 atk_state_set_add_state(state_set, ATK_STATE_VISIBLE);
238 if (
priv->flags.is_checked != kFlutterCheckStateNone) {
239 atk_state_set_add_state(state_set, ATK_STATE_CHECKABLE);
241 if (
priv->flags.is_focused != kFlutterTristateNone) {
242 atk_state_set_add_state(state_set, ATK_STATE_FOCUSABLE);
244 if (
priv->flags.is_focused == kFlutterTristateTrue) {
245 atk_state_set_add_state(state_set, ATK_STATE_FOCUSED);
247 if (
priv->flags.is_checked ||
priv->flags.is_toggled) {
248 atk_state_set_add_state(state_set, ATK_STATE_CHECKED);
250 if (
priv->flags.is_selected) {
251 atk_state_set_add_state(state_set, ATK_STATE_SELECTED);
253 if (
priv->flags.is_enabled == kFlutterTristateTrue) {
254 atk_state_set_add_state(state_set, ATK_STATE_ENABLED);
255 atk_state_set_add_state(state_set, ATK_STATE_SENSITIVE);
257 if (
priv->flags.is_read_only) {
258 atk_state_set_add_state(state_set, ATK_STATE_READ_ONLY);
260 if (
priv->flags.is_text_field) {
261 atk_state_set_add_state(state_set, ATK_STATE_EDITABLE);
273 AtkCoordType coord_type) {
278 if (
priv->parent !=
nullptr) {
279 atk_component_get_extents(ATK_COMPONENT(
priv->parent), x, y,
nullptr,
280 nullptr, coord_type);
291 return ATK_LAYER_WIDGET;
298 if (
priv->engine ==
nullptr) {
303 if (data ==
nullptr) {
315 return priv->actions->len;
323 if (data ==
nullptr) {
335 priv->name = g_strdup(name);
354 return !old_flag != !new_flag;
359 FlutterSemanticsFlags* flags) {
362 FlutterSemanticsFlags old_flags =
priv->flags;
363 priv->flags = *flags;
365 if (
flag_changed(old_flags.is_obscured, flags->is_obscured)) {
366 atk_object_notify_state_change(ATK_OBJECT(
self), ATK_STATE_SHOWING,
367 !flags->is_obscured);
369 if (
flag_changed(old_flags.is_hidden, flags->is_hidden)) {
370 atk_object_notify_state_change(ATK_OBJECT(
self), ATK_STATE_VISIBLE,
373 bool was_checkable = old_flags.is_checked != kFlutterCheckStateNone;
374 bool is_checkable = flags->is_checked != kFlutterCheckStateNone;
376 atk_object_notify_state_change(ATK_OBJECT(
self), ATK_STATE_CHECKABLE,
379 if (
flag_changed(old_flags.is_focused, flags->is_focused)) {
380 atk_object_notify_state_change(ATK_OBJECT(
self), ATK_STATE_FOCUSABLE,
381 flags->is_focused != kFlutterTristateNone);
383 if (
flag_changed(old_flags.is_focused, flags->is_focused)) {
384 atk_object_notify_state_change(ATK_OBJECT(
self), ATK_STATE_FOCUSED,
385 flags->is_focused == kFlutterTristateTrue);
387 bool old_is_checked = old_flags.is_checked || old_flags.is_toggled;
388 bool is_checked = flags->is_checked || flags->is_toggled;
390 atk_object_notify_state_change(ATK_OBJECT(
self), ATK_STATE_CHECKED,
393 if (
flag_changed(old_flags.is_selected, flags->is_selected)) {
394 atk_object_notify_state_change(ATK_OBJECT(
self), ATK_STATE_SELECTED,
397 if (
flag_changed(old_flags.is_enabled, flags->is_enabled)) {
398 atk_object_notify_state_change(ATK_OBJECT(
self), ATK_STATE_ENABLED,
400 atk_object_notify_state_change(ATK_OBJECT(
self), ATK_STATE_SENSITIVE,
403 if (
flag_changed(old_flags.is_enabled, flags->is_enabled)) {
404 atk_object_notify_state_change(ATK_OBJECT(
self), ATK_STATE_ENABLED,
407 if (
flag_changed(old_flags.is_enabled, flags->is_enabled)) {
408 atk_object_notify_state_change(ATK_OBJECT(
self), ATK_STATE_ENABLED,
411 if (
flag_changed(old_flags.is_read_only, flags->is_read_only)) {
412 atk_object_notify_state_change(ATK_OBJECT(
self), ATK_STATE_READ_ONLY,
413 flags->is_read_only);
415 if (
flag_changed(old_flags.is_text_field, flags->is_text_field)) {
416 atk_object_notify_state_change(ATK_OBJECT(
self), ATK_STATE_EDITABLE,
417 flags->is_text_field);
423 FlAccessibleNode*
self,
424 FlutterSemanticsAction actions) {
432 g_ptr_array_remove_range(
priv->actions, 0,
priv->actions->len);
442 const gchar*
value) {}
451 FlAccessibleNode*
self,
452 FlutterTextDirection direction) {}
456 FlAccessibleNode*
self,
457 FlutterSemanticsAction
action,
469 ATK_OBJECT_CLASS(klass)->get_index_in_parent =
476 FL_ACCESSIBLE_NODE_CLASS(klass)->set_extents =
478 FL_ACCESSIBLE_NODE_CLASS(klass)->set_flags =
480 FL_ACCESSIBLE_NODE_CLASS(klass)->set_actions =
482 FL_ACCESSIBLE_NODE_CLASS(klass)->set_value =
484 FL_ACCESSIBLE_NODE_CLASS(klass)->set_text_selection =
486 FL_ACCESSIBLE_NODE_CLASS(klass)->set_text_direction =
488 FL_ACCESSIBLE_NODE_CLASS(klass)->perform_action =
491 g_object_class_install_property(
494 "engine",
"engine",
"Flutter engine", fl_engine_get_type(),
495 static_cast<GParamFlags
>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
496 G_PARAM_STATIC_STRINGS)));
497 g_object_class_install_property(
500 "view-id",
"view-id",
"View ID that this node belongs to", 0,
502 static_cast<GParamFlags
>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)));
503 g_object_class_install_property(
504 G_OBJECT_CLASS(klass),
PROP_ID,
506 "node-id",
"node-id",
"Accessibility node ID", 0, G_MAXINT, 0,
507 static_cast<GParamFlags
>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
508 G_PARAM_STATIC_STRINGS)));
512 AtkComponentIface* iface) {
525 priv->actions = g_ptr_array_new();
526 priv->children = g_ptr_array_new_with_free_func(g_object_unref);
532 FlAccessibleNode*
self = FL_ACCESSIBLE_NODE(
533 g_object_new(fl_accessible_node_get_type(),
"engine", engine,
"view-id",
534 view_id,
"node-id", node_id,
nullptr));
541 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
543 priv->parent = parent;
545 g_object_add_weak_pointer(G_OBJECT(
self),
546 reinterpret_cast<gpointer*
>(&(
priv->parent)));
550 GPtrArray* children) {
551 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
555 for (guint
i = 0;
i <
priv->children->len;) {
556 AtkObject*
object = ATK_OBJECT(g_ptr_array_index(
priv->children,
i));
560 g_signal_emit_by_name(
self,
"children-changed::remove",
i,
object,
562 g_ptr_array_remove_index(
priv->children,
i);
567 for (guint
i = 0;
i < children->len;
i++) {
568 AtkObject*
object = ATK_OBJECT(g_ptr_array_index(children,
i));
570 g_ptr_array_add(
priv->children, g_object_ref(
object));
571 g_signal_emit_by_name(
self,
"children-changed::add",
i,
object,
nullptr);
577 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
579 return FL_ACCESSIBLE_NODE_GET_CLASS(
self)->set_name(
self, name);
587 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
589 return FL_ACCESSIBLE_NODE_GET_CLASS(
self)->set_extents(
self, x, y,
width,
594 FlutterSemanticsFlags* flags) {
595 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
597 return FL_ACCESSIBLE_NODE_GET_CLASS(
self)->set_flags(
self, flags);
601 FlutterSemanticsAction actions) {
602 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
604 return FL_ACCESSIBLE_NODE_GET_CLASS(
self)->set_actions(
self, actions);
608 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
610 return FL_ACCESSIBLE_NODE_GET_CLASS(
self)->set_value(
self,
value);
616 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
618 return FL_ACCESSIBLE_NODE_GET_CLASS(
self)->set_text_selection(
self, base,
623 FlutterTextDirection direction) {
624 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
626 return FL_ACCESSIBLE_NODE_GET_CLASS(
self)->set_text_direction(
self,
631 FlutterSemanticsAction
action,
633 g_return_if_fail(FL_IS_ACCESSIBLE_NODE(
self));
635 return FL_ACCESSIBLE_NODE_GET_CLASS(
self)->perform_action(
self,
action, data);
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)
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 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)
static const gchar * fl_accessible_node_get_name(AtkObject *accessible)
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 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)
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 has_action(FlutterSemanticsAction actions
static AtkObject * fl_accessible_node_ref_child(AtkObject *accessible, gint i)
FlutterSemanticsAction action
static gint fl_accessible_node_get_index_in_parent(AtkObject *accessible)
static AtkObject * fl_accessible_node_get_parent(AtkObject *accessible)
static void fl_accessible_node_init(FlAccessibleNode *self)
void fl_accessible_node_set_parent(FlAccessibleNode *self, AtkObject *parent, gint index)
static AtkStateSet * fl_accessible_node_ref_state_set(AtkObject *accessible)
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 void fl_accessible_node_set_extents_impl(FlAccessibleNode *self, gint x, gint y, gint width, gint height)
static ActionData * get_action(FlAccessibleNodePrivate *priv, gint index)
#define FL_ACCESSIBLE_NODE_GET_PRIVATE(node)
FlAccessibleNode * fl_accessible_node_new(FlEngine *engine, FlutterViewId view_id, int32_t node_id)
static void fl_accessible_node_set_name_impl(FlAccessibleNode *self, const gchar *name)
static void fl_accessible_node_set_flags_impl(FlAccessibleNode *self, FlutterSemanticsFlags *flags)
void fl_engine_dispatch_semantics_action(FlEngine *self, FlutterViewId view_id, uint64_t node_id, FlutterSemanticsAction action, GBytes *data)
FlPixelBufferTexturePrivate * priv
const uint8_t uint32_t uint32_t * height
const uint8_t uint32_t * width
guint const GValue GParamSpec * pspec
G_BEGIN_DECLS FlutterViewId view_id
FlutterSemanticsAction action
FlutterSemanticsFlags flags
FlutterViewId view_id
The unique identifier of the view to which this node belongs.
AtkObject parent_instance