Flutter Linux Embedder
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.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PROP_0 
PROP_ENGINE 
PROP_VIEW_ID 
PROP_ID 
PROP_LAST 

Definition at line 66 of file fl_accessible_node.cc.

Function Documentation

◆ fl_accessible_node_action_interface_init()

static void fl_accessible_node_action_interface_init ( AtkActionIface *  iface)
static

Definition at line 544 of file fl_accessible_node.cc.

544  {
545  iface->do_action = fl_accessible_node_do_action;
546  iface->get_n_actions = fl_accessible_node_get_n_actions;
547  iface->get_name = fl_accessible_node_get_name;
548 }
static gboolean fl_accessible_node_do_action(AtkAction *action, gint i)
static const gchar * fl_accessible_node_get_name(AtkObject *accessible)
static gint fl_accessible_node_get_n_actions(AtkAction *action)

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

◆ fl_accessible_node_class_init()

static void fl_accessible_node_class_init ( FlAccessibleNodeClass *  klass)
static

Definition at line 491 of file fl_accessible_node.cc.

491  {
492  G_OBJECT_CLASS(klass)->set_property = fl_accessible_node_set_property;
493  G_OBJECT_CLASS(klass)->dispose = fl_accessible_node_dispose;
494  ATK_OBJECT_CLASS(klass)->get_name = fl_accessible_node_get_name;
495  ATK_OBJECT_CLASS(klass)->get_parent = fl_accessible_node_get_parent;
496  ATK_OBJECT_CLASS(klass)->get_index_in_parent =
498  ATK_OBJECT_CLASS(klass)->get_n_children = fl_accessible_node_get_n_children;
499  ATK_OBJECT_CLASS(klass)->ref_child = fl_accessible_node_ref_child;
500  ATK_OBJECT_CLASS(klass)->get_role = fl_accessible_node_get_role;
501  ATK_OBJECT_CLASS(klass)->ref_state_set = fl_accessible_node_ref_state_set;
502  FL_ACCESSIBLE_NODE_CLASS(klass)->set_name = fl_accessible_node_set_name_impl;
503  FL_ACCESSIBLE_NODE_CLASS(klass)->set_extents =
505  FL_ACCESSIBLE_NODE_CLASS(klass)->set_flags =
507  FL_ACCESSIBLE_NODE_CLASS(klass)->set_actions =
509  FL_ACCESSIBLE_NODE_CLASS(klass)->set_value =
511  FL_ACCESSIBLE_NODE_CLASS(klass)->set_text_selection =
513  FL_ACCESSIBLE_NODE_CLASS(klass)->set_text_direction =
515  FL_ACCESSIBLE_NODE_CLASS(klass)->perform_action =
517 
518  g_object_class_install_property(
519  G_OBJECT_CLASS(klass), PROP_ENGINE,
520  g_param_spec_object(
521  "engine", "engine", "Flutter engine", fl_engine_get_type(),
522  static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
523  G_PARAM_STATIC_STRINGS)));
524  g_object_class_install_property(
525  G_OBJECT_CLASS(klass), PROP_VIEW_ID,
526  g_param_spec_int64(
527  "view-id", "view-id", "View ID that this node belongs to", 0,
528  G_MAXINT64, 0,
529  static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)));
530  g_object_class_install_property(
531  G_OBJECT_CLASS(klass), PROP_ID,
532  g_param_spec_int(
533  "node-id", "node-id", "Accessibility node ID", 0, G_MAXINT, 0,
534  static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
535  G_PARAM_STATIC_STRINGS)));
536 }
static void fl_accessible_node_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
static void fl_accessible_node_set_text_direction_impl(FlAccessibleNode *self, FlutterTextDirection direction)
static AtkRole fl_accessible_node_get_role(AtkObject *accessible)
static void fl_accessible_node_set_value_impl(FlAccessibleNode *self, const gchar *value)
static void fl_accessible_node_set_actions_impl(FlAccessibleNode *self, FlutterSemanticsAction actions)
static void fl_accessible_node_dispose(GObject *object)
static AtkObject * fl_accessible_node_ref_child(AtkObject *accessible, gint i)
static gint fl_accessible_node_get_index_in_parent(AtkObject *accessible)
static AtkObject * fl_accessible_node_get_parent(AtkObject *accessible)
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 void fl_accessible_node_set_text_selection_impl(FlAccessibleNode *self, gint base, gint extent)
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 void fl_accessible_node_set_name_impl(FlAccessibleNode *self, const gchar *name)
static void fl_accessible_node_set_flags_impl(FlAccessibleNode *self, FlutterSemanticsFlags *flags)

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

◆ fl_accessible_node_component_interface_init()

static void fl_accessible_node_component_interface_init ( AtkComponentIface *  iface)
static

Definition at line 538 of file fl_accessible_node.cc.

539  {
540  iface->get_extents = fl_accessible_node_get_extents;
541  iface->get_layer = fl_accessible_node_get_layer;
542 }
static AtkLayer fl_accessible_node_get_layer(AtkComponent *component)
static void fl_accessible_node_get_extents(AtkComponent *component, gint *x, gint *y, gint *width, gint *height, AtkCoordType coord_type)

References fl_accessible_node_get_extents(), and fl_accessible_node_get_layer().

◆ fl_accessible_node_dispose()

static void fl_accessible_node_dispose ( GObject *  object)
static

Definition at line 169 of file fl_accessible_node.cc.

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

References FlAccessibilityHandlerPrivate::engine, FL_ACCESSIBLE_NODE_GET_PRIVATE, and priv.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_do_action()

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

Definition at line 327 of file fl_accessible_node.cc.

327  {
329 
330  g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&priv->engine));
331  if (engine == nullptr) {
332  return FALSE;
333  }
334 
335  ActionData* data = get_action(priv, i);
336  if (data == nullptr) {
337  return FALSE;
338  }
339 
340  fl_accessible_node_perform_action(FL_ACCESSIBLE_NODE(action), data->action,
341  nullptr);
342  return TRUE;
343 }
g_autoptr(FlEngine) engine
void fl_accessible_node_perform_action(FlAccessibleNode *self, FlutterSemanticsAction action, GBytes *data)
static ActionData * get_action(FlAccessibleNodePrivate *priv, gint index)
return TRUE
FlutterSemanticsAction action

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

Referenced by fl_accessible_node_action_interface_init().

◆ fl_accessible_node_get_extents()

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

Definition at line 299 of file fl_accessible_node.cc.

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

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

Referenced by fl_accessible_node_component_interface_init().

◆ fl_accessible_node_get_index_in_parent()

static gint fl_accessible_node_get_index_in_parent ( AtkObject *  accessible)
static

Definition at line 195 of file fl_accessible_node.cc.

195  {
197  return priv->index;
198 }
FlViewAccessible * accessible

References accessible, 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 322 of file fl_accessible_node.cc.

322  {
323  return ATK_LAYER_WIDGET;
324 }

Referenced by fl_accessible_node_component_interface_init().

◆ fl_accessible_node_get_n_actions()

static gint fl_accessible_node_get_n_actions ( AtkAction *  action)
static

Definition at line 346 of file fl_accessible_node.cc.

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

References FL_ACCESSIBLE_NODE_GET_PRIVATE, and priv.

Referenced by fl_accessible_node_action_interface_init().

◆ fl_accessible_node_get_n_children()

static gint fl_accessible_node_get_n_children ( AtkObject *  accessible)
static

Definition at line 201 of file fl_accessible_node.cc.

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

References accessible, FL_ACCESSIBLE_NODE_GET_PRIVATE, and priv.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_get_name() [1/2]

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

Definition at line 352 of file fl_accessible_node.cc.

352  {
354 
355  ActionData* data = get_action(priv, i);
356  if (data == nullptr) {
357  return nullptr;
358  }
359 
360  return data->name;
361 }
const gchar * name

References FL_ACCESSIBLE_NODE_GET_PRIVATE, get_action(), i, ActionData::name, and priv.

◆ fl_accessible_node_get_name() [2/2]

static const gchar* fl_accessible_node_get_name ( AtkObject *  accessible)
static

◆ fl_accessible_node_get_parent()

static AtkObject* fl_accessible_node_get_parent ( AtkObject *  accessible)
static

Definition at line 188 of file fl_accessible_node.cc.

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

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

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_get_role()

static AtkRole fl_accessible_node_get_role ( AtkObject *  accessible)
static

Definition at line 218 of file fl_accessible_node.cc.

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

References accessible, FL_ACCESSIBLE_NODE_GET_PRIVATE, and priv.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_init()

static void fl_accessible_node_init ( FlAccessibleNode *  self)
static

Definition at line 550 of file fl_accessible_node.cc.

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

References FlAccessibilityHandlerPrivate::engine, FL_ACCESSIBLE_NODE_GET_PRIVATE, and priv.

◆ fl_accessible_node_new()

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

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

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

Returns: a new #FlAccessibleNode.

Definition at line 558 of file fl_accessible_node.cc.

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

References view_id.

Referenced by create_node(), and TEST_F().

◆ fl_accessible_node_perform_action()

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

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

Performs a semantic action for this node.

Definition at line 657 of file fl_accessible_node.cc.

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

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

◆ fl_accessible_node_perform_action_impl()

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

Definition at line 478 of file fl_accessible_node.cc.

481  {
483  g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&priv->engine));
484  if (engine == nullptr) {
485  return;
486  }
487  fl_engine_dispatch_semantics_action(engine, priv->view_id, priv->node_id,
488  action, data);
489 }
void fl_engine_dispatch_semantics_action(FlEngine *self, FlutterViewId view_id, uint64_t node_id, FlutterSemanticsAction action, GBytes *data)
Definition: fl_engine.cc:1471

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

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_ref_child()

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

Definition at line 207 of file fl_accessible_node.cc.

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

References accessible, FL_ACCESSIBLE_NODE_GET_PRIVATE, i, and priv.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_ref_state_set()

static AtkStateSet* fl_accessible_node_ref_state_set ( AtkObject *  accessible)
static

Definition at line 256 of file fl_accessible_node.cc.

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

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

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_set_actions()

void fl_accessible_node_set_actions ( FlAccessibleNode *  node,
FlutterSemanticsAction  actions 
)

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

Sets the actions that this node can perform.

Definition at line 627 of file fl_accessible_node.cc.

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

Referenced by fl_view_accessible_handle_update_semantics(), and TEST_F().

◆ fl_accessible_node_set_actions_impl()

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

Definition at line 445 of file fl_accessible_node.cc.

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

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

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_set_children()

void fl_accessible_node_set_children ( FlAccessibleNode *  node,
GPtrArray *  children 
)

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

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

Definition at line 576 of file fl_accessible_node.cc.

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

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

Referenced by fl_view_accessible_handle_update_semantics(), and TEST_F().

◆ fl_accessible_node_set_extents()

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

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

Sets the position and size of this node.

Definition at line 609 of file fl_accessible_node.cc.

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

References height, width, x, and y.

Referenced by fl_view_accessible_handle_update_semantics(), and TEST_F().

◆ fl_accessible_node_set_extents_impl()

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

Definition at line 372 of file fl_accessible_node.cc.

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

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

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_set_flags()

void fl_accessible_node_set_flags ( FlAccessibleNode *  node,
FlutterSemanticsFlags *  flags 
)

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

Sets the flags for this node.

Definition at line 620 of file fl_accessible_node.cc.

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

Referenced by fl_view_accessible_handle_update_semantics(), and TEST_F().

◆ fl_accessible_node_set_flags_impl()

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

Definition at line 391 of file fl_accessible_node.cc.

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

References FL_ACCESSIBLE_NODE_GET_PRIVATE, flag_changed(), 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_name()

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

Definition at line 603 of file fl_accessible_node.cc.

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

Referenced by fl_view_accessible_handle_update_semantics(), and TEST_F().

◆ fl_accessible_node_set_name_impl()

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

Definition at line 364 of file fl_accessible_node.cc.

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

References FL_ACCESSIBLE_NODE_GET_PRIVATE, and priv.

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_set_parent()

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

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

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

Definition at line 567 of file fl_accessible_node.cc.

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

References FL_ACCESSIBLE_NODE_GET_PRIVATE, and priv.

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_weak_ref_set(&priv->engine, g_value_get_object(value));
156  break;
157  case PROP_VIEW_ID:
158  priv->view_id = g_value_get_int64(value);
159  break;
160  case PROP_ID:
161  priv->node_id = g_value_get_int(value);
162  break;
163  default:
164  G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
165  break;
166  }
167 }
uint8_t value
guint prop_id
guint const GValue GParamSpec * pspec

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

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_set_text_direction()

void fl_accessible_node_set_text_direction ( FlAccessibleNode *  node,
FlutterTextDirection  direction 
)

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

Sets the text direction of this node.

Definition at line 649 of file fl_accessible_node.cc.

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

Referenced by fl_view_accessible_handle_update_semantics().

◆ fl_accessible_node_set_text_direction_impl()

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

Definition at line 473 of file fl_accessible_node.cc.

475  {}

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_set_text_selection()

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

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

Sets the text selection of this node.

Definition at line 640 of file fl_accessible_node.cc.

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

Referenced by fl_view_accessible_handle_update_semantics(), and TEST_F().

◆ fl_accessible_node_set_text_selection_impl()

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

Definition at line 468 of file fl_accessible_node.cc.

470  {}

Referenced by fl_accessible_node_class_init().

◆ fl_accessible_node_set_value()

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

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

Sets the value of this node.

Definition at line 634 of file fl_accessible_node.cc.

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

References value.

Referenced by fl_view_accessible_handle_update_semantics(), and TEST_F().

◆ fl_accessible_node_set_value_impl()

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

Definition at line 464 of file fl_accessible_node.cc.

465  {}

Referenced by fl_accessible_node_class_init().

◆ flag_changed()

static bool flag_changed ( bool  old_flag,
bool  new_flag 
)
static

Definition at line 386 of file fl_accessible_node.cc.

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

Referenced by fl_accessible_node_set_flags_impl().

◆ G_DEFINE_TYPE_WITH_CODE()

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

Definition at line 76 of file fl_accessible_node.cc.

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

◆ 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 }

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

static gboolean is_checked ( FlutterSemanticsFlags  flags)
static

Definition at line 93 of file fl_accessible_node.cc.

93  {
94  return flags.is_checked == kFlutterCheckStateTrue ||
95  flags.is_toggled == kFlutterTristateTrue;
96 }

Referenced by fl_accessible_node_ref_state_set(), and fl_accessible_node_set_flags_impl().

◆ is_enabled()

static gboolean is_enabled ( FlutterSemanticsFlags  flags)
static

Definition at line 119 of file fl_accessible_node.cc.

119  {
120  return flags.is_enabled == kFlutterTristateTrue;
121 }

Referenced by find_stage_by_record(), fl_accessible_node_ref_state_set(), and fl_accessible_node_set_flags_impl().

◆ is_focusable()

static gboolean is_focusable ( FlutterSemanticsFlags  flags)
static

Definition at line 99 of file fl_accessible_node.cc.

99  {
100  return flags.is_focused != kFlutterTristateNone;
101 }

Referenced by fl_accessible_node_ref_state_set(), and fl_accessible_node_set_flags_impl().

◆ is_focused()

static gboolean is_focused ( FlutterSemanticsFlags  flags)
static

Definition at line 104 of file fl_accessible_node.cc.

104  {
105  return flags.is_focused == kFlutterTristateTrue;
106 }

Referenced by fl_accessible_node_ref_state_set(), fl_accessible_node_set_flags_impl(), and window_state_event_cb().

◆ is_selected()

static gboolean is_selected ( FlutterSemanticsFlags  flags)
static

Definition at line 109 of file fl_accessible_node.cc.

109  {
110  return flags.is_selected == kFlutterTristateTrue;
111 }

Referenced by fl_accessible_node_ref_state_set(), and fl_accessible_node_set_flags_impl().

◆ is_sensitive()

static gboolean is_sensitive ( FlutterSemanticsFlags  flags)
static

Definition at line 114 of file fl_accessible_node.cc.

114  {
115  return flags.is_enabled != kFlutterTristateNone;
116 }

Referenced by fl_accessible_node_ref_state_set(), and fl_accessible_node_set_flags_impl().

Variable Documentation

◆ action_mapping

ActionData action_mapping[]
static
Initial value:
= {
{kFlutterSemanticsActionTap, "Tap"},
{kFlutterSemanticsActionLongPress, "LongPress"},
{kFlutterSemanticsActionScrollLeft, "ScrollLeft"},
{kFlutterSemanticsActionScrollRight, "ScrollRight"},
{kFlutterSemanticsActionScrollUp, "ScrollUp"},
{kFlutterSemanticsActionScrollDown, "ScrollDown"},
{kFlutterSemanticsActionIncrease, "Increase"},
{kFlutterSemanticsActionDecrease, "Decrease"},
{kFlutterSemanticsActionShowOnScreen, "ShowOnScreen"},
{kFlutterSemanticsActionMoveCursorForwardByCharacter,
"MoveCursorForwardByCharacter"},
{kFlutterSemanticsActionMoveCursorBackwardByCharacter,
"MoveCursorBackwardByCharacter"},
{kFlutterSemanticsActionCopy, "Copy"},
{kFlutterSemanticsActionCut, "Cut"},
{kFlutterSemanticsActionPaste, "Paste"},
{kFlutterSemanticsActionDidGainAccessibilityFocus,
"DidGainAccessibilityFocus"},
{kFlutterSemanticsActionDidLoseAccessibilityFocus,
"DidLoseAccessibilityFocus"},
{kFlutterSemanticsActionCustomAction, "CustomAction"},
{kFlutterSemanticsActionDismiss, "Dismiss"},
{kFlutterSemanticsActionMoveCursorForwardByWord, "MoveCursorForwardByWord"},
{kFlutterSemanticsActionMoveCursorBackwardByWord,
"MoveCursorBackwardByWord"},
{kFlutterSemanticsActionFocus, "Focus"},
{kFlutterSemanticsActionExpand, "Expand"},
{kFlutterSemanticsActionCollapse, "Collapse"},
{static_cast<FlutterSemanticsAction>(0), nullptr}}

Definition at line 13 of file fl_accessible_node.cc.

Referenced by fl_accessible_node_set_actions_impl().