| Flutter Linux Embedder |

Classes | Functions | Variables
fl_view_accessible.cc File Reference
`#include "flutter/shell/platform/linux/fl_view_accessible.h"`
`#include "flutter/shell/platform/linux/fl_accessible_node.h"`
`#include "flutter/shell/platform/linux/fl_accessible_text_field.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_value.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_view.h"`

Go to the source code of this file.

## Classes
struct | _FlViewAccessible

## Functions
static FlAccessibleNode * | create_node (FlViewAccessible *self, FlutterSemanticsNode2 *semantics)
static FlAccessibleNode * | lookup_node (FlViewAccessible *self, int32_t id)
static FlAccessibleNode * | get_node (FlViewAccessible *self, FlutterSemanticsNode2 *semantics)
static gint | fl_view_accessible_get_n_children (AtkObject *accessible)
static AtkObject * | fl_view_accessible_ref_child (AtkObject *accessible, gint i)
static AtkRole | fl_view_accessible_get_role (AtkObject *accessible)
static AtkStateSet * | fl_view_accessible_ref_state_set (AtkObject *accessible)
static void | fl_view_accessible_dispose (GObject *object)
static void | fl_view_accessible_class_init (FlViewAccessibleClass *klass)
static void | fl_view_accessible_init (FlViewAccessible *self)
FlViewAccessible * | fl_view_accessible_new (FlEngine *engine)
void | fl_view_accessible_handle_update_semantics (FlViewAccessible *self, const FlutterSemanticsUpdate2 *update)

## Variables
static constexpr int32_t | kRootSemanticsNodeId = 0

## Function Documentation

## ◆ create_node()

static FlAccessibleNode* create_node | ( | FlViewAccessible * | self,
|  | FlutterSemanticsNode2 * | semantics
| ) |  |
| static

Definition at line 27 of file fl_view_accessible.cc.

28 {
29 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
30 if (engine == nullptr) {
31 return nullptr;
32 }
33
34 if (semantics->flags & kFlutterSemanticsFlagIsTextField) {
35 return fl_accessible_text_field_new(engine, semantics->id);
36 }
37
38 return fl_accessible_node_new(engine, semantics->id);
39 }
fl_accessible_node_new
FlAccessibleNode * fl_accessible_node_new(FlEngine *engine, int32_t id)
Definition: fl_accessible_node.cc:482
fl_accessible_text_field_new
FlAccessibleNode * fl_accessible_text_field_new(FlEngine *engine, int32_t id)
Definition: fl_accessible_text_field.cc:618

References fl_accessible_node_new(), and fl_accessible_text_field_new().

Referenced by get_node().

## ◆ fl_view_accessible_class_init()

static void fl_view_accessible_class_init | ( | FlViewAccessibleClass * | klass | ) |
| static

Definition at line 118 of file fl_view_accessible.cc.

118 {
119 ATK_OBJECT_CLASS(klass)->get_n_children = fl_view_accessible_get_n_children;
120 ATK_OBJECT_CLASS(klass)->ref_child = fl_view_accessible_ref_child;
121 ATK_OBJECT_CLASS(klass)->get_role = fl_view_accessible_get_role;
122 ATK_OBJECT_CLASS(klass)->ref_state_set = fl_view_accessible_ref_state_set;
123
124 G_OBJECT_CLASS(klass)->dispose = fl_view_accessible_dispose;
125 }
fl_view_accessible_dispose
static void fl_view_accessible_dispose(GObject *object)
Definition: fl_view_accessible.cc:108
fl_view_accessible_ref_child
static AtkObject * fl_view_accessible_ref_child(AtkObject *accessible, gint i)
Definition: fl_view_accessible.cc:85
fl_view_accessible_get_role
static AtkRole fl_view_accessible_get_role(AtkObject *accessible)
Definition: fl_view_accessible.cc:97
fl_view_accessible_get_n_children
static gint fl_view_accessible_get_n_children(AtkObject *accessible)
Definition: fl_view_accessible.cc:73
fl_view_accessible_ref_state_set
static AtkStateSet * fl_view_accessible_ref_state_set(AtkObject *accessible)
Definition: fl_view_accessible.cc:102

References fl_view_accessible_dispose(), fl_view_accessible_get_n_children(), fl_view_accessible_get_role(), fl_view_accessible_ref_child(), and fl_view_accessible_ref_state_set().

## ◆ fl_view_accessible_dispose()

static void fl_view_accessible_dispose | ( | GObject * | object | ) |
| static

Definition at line 108 of file fl_view_accessible.cc.

108 {
109 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(object);
110
111 g_clear_pointer(&self->semantics_nodes_by_id, g_hash_table_unref);
112
113 g_weak_ref_clear(&self->engine);
114
115 G_OBJECT_CLASS(fl_view_accessible_parent_class)->dispose(object);
116 }

Referenced by fl_view_accessible_class_init().

## ◆ fl_view_accessible_get_n_children()

static gint fl_view_accessible_get_n_children | ( | AtkObject * | accessible | ) |
| static

Definition at line 73 of file fl_view_accessible.cc.

73 {
74 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(accessible);
75 FlAccessibleNode* node = lookup_node(self, 0);
76
77 if (node == nullptr) {
78 return 0;
79 }
80
81 return 1;
82 }
lookup_node
static FlAccessibleNode * lookup_node(FlViewAccessible *self, int32_t id)
Definition: fl_view_accessible.cc:41

References lookup_node().

Referenced by fl_view_accessible_class_init().

## ◆ fl_view_accessible_get_role()

static AtkRole fl_view_accessible_get_role | ( | AtkObject * | accessible | ) |
| static

Definition at line 97 of file fl_view_accessible.cc.

97 {
98 return ATK_ROLE_PANEL;
99 }

Referenced by fl_view_accessible_class_init().

## ◆ fl_view_accessible_handle_update_semantics()

void fl_view_accessible_handle_update_semantics | ( | FlViewAccessible * | accessible,
|  | const FlutterSemanticsUpdate2 * | update
| ) |  |

fl_view_accessible_handle_update_semantics: @accessible: an #FlViewAccessible. @update: semantic update information.

Handle a semantics update from Flutter.

Definition at line 139 of file fl_view_accessible.cc.

141 {
142 g_autoptr(GHashTable) pending_children =
143 g_hash_table_new_full(g_direct_hash, g_direct_equal, nullptr,
144 reinterpret_cast<GDestroyNotify>(fl_value_unref));
145 for (size_t i = 0; i < update->node_count; i++) {
146 FlutterSemanticsNode2* node = update->nodes[i];
147 FlAccessibleNode* atk_node = get_node(self, node);
148
149 fl_accessible_node_set_flags(atk_node, node->flags);
150 fl_accessible_node_set_actions(atk_node, node->actions);
151 fl_accessible_node_set_name(atk_node, node->label);
152 fl_accessible_node_set_extents(
153 atk_node, node->rect.left + node->transform.transX,
154 node->rect.top + node->transform.transY,
155 node->rect.right - node->rect.left, node->rect.bottom - node->rect.top);
156 fl_accessible_node_set_value(atk_node, node->value);
157 fl_accessible_node_set_text_selection(atk_node, node->text_selection_base,
158 node->text_selection_extent);
159 fl_accessible_node_set_text_direction(atk_node, node->text_direction);
160
161 FlValue* children = fl_value_new_int32_list(
162 node->children_in_traversal_order, node->child_count);
163 g_hash_table_insert(pending_children, atk_node, children);
164 }
165
166 g_hash_table_foreach_remove(
167 pending_children,
168 [](gpointer key, gpointer value, gpointer user_data) -> gboolean {
169 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(user_data);
170
171 FlAccessibleNode* parent = FL_ACCESSIBLE_NODE(key);
172
173 size_t child_count = fl_value_get_length(static_cast<FlValue*>(value));
174 const int32_t* children_in_traversal_order =
175 fl_value_get_int32_list(static_cast<FlValue*>(value));
176
177 g_autoptr(GPtrArray) children = g_ptr_array_new();
178 for (size_t i = 0; i < child_count; i++) {
179 FlAccessibleNode* child =
180 lookup_node(self, children_in_traversal_order[i]);
181 g_assert(child != nullptr);
182 fl_accessible_node_set_parent(child, ATK_OBJECT(parent), i);
183 g_ptr_array_add(children, child);
184 }
185 fl_accessible_node_set_children(parent, children);
186
187 return TRUE;
188 },
189 self);
190 }
fl_accessible_node_set_name
void fl_accessible_node_set_name(FlAccessibleNode *self, const gchar *name)
Definition: fl_accessible_node.cc:526
fl_accessible_node_set_text_direction
void fl_accessible_node_set_text_direction(FlAccessibleNode *self, FlutterTextDirection direction)
Definition: fl_accessible_node.cc:572
fl_accessible_node_set_text_selection
void fl_accessible_node_set_text_selection(FlAccessibleNode *self, gint base, gint extent)
Definition: fl_accessible_node.cc:563
fl_accessible_node_set_actions
void fl_accessible_node_set_actions(FlAccessibleNode *self, FlutterSemanticsAction actions)
Definition: fl_accessible_node.cc:550
fl_accessible_node_set_children
void fl_accessible_node_set_children(FlAccessibleNode *self, GPtrArray *children)
Definition: fl_accessible_node.cc:499
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:532
fl_accessible_node_set_value
void fl_accessible_node_set_value(FlAccessibleNode *self, const gchar *value)
Definition: fl_accessible_node.cc:557
fl_accessible_node_set_flags
void fl_accessible_node_set_flags(FlAccessibleNode *self, FlutterSemanticsFlag flags)
Definition: fl_accessible_node.cc:543
fl_accessible_node_set_parent
void fl_accessible_node_set_parent(FlAccessibleNode *self, AtkObject *parent, gint index)
Definition: fl_accessible_node.cc:488
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90
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
fl_value_new_int32_list
G_MODULE_EXPORT FlValue * fl_value_new_int32_list(const int32_t *data, size_t data_length)
Definition: fl_value.cc:309
fl_value_unref
G_MODULE_EXPORT void fl_value_unref(FlValue *self)
Definition: fl_value.cc:400
fl_value_get_int32_list
G_MODULE_EXPORT const int32_t * fl_value_get_int32_list(FlValue *self)
Definition: fl_value.cc:696
fl_value_get_length
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
Definition: fl_value.cc:724
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42
get_node
static FlAccessibleNode * get_node(FlViewAccessible *self, FlutterSemanticsNode2 *semantics)
Definition: fl_view_accessible.cc:48

References fl_accessible_node_set_actions(), fl_accessible_node_set_children(), fl_accessible_node_set_extents(), fl_accessible_node_set_flags(), fl_accessible_node_set_name(), fl_accessible_node_set_parent(), fl_accessible_node_set_text_direction(), fl_accessible_node_set_text_selection(), fl_accessible_node_set_value(), fl_value_get_int32_list(), fl_value_get_length(), fl_value_new_int32_list(), fl_value_unref(), get_node(), i, lookup_node(), TRUE, user_data, and value.

Referenced by TEST(), and update_semantics_cb().

## ◆ fl_view_accessible_init()

static void fl_view_accessible_init | ( | FlViewAccessible * | self | ) |
| static

Definition at line 127 of file fl_view_accessible.cc.

127 {
128 self->semantics_nodes_by_id = g_hash_table_new_full(
129 g_direct_hash, g_direct_equal, nullptr, g_object_unref);
130 }

## ◆ fl_view_accessible_new()

FlViewAccessible* fl_view_accessible_new | ( | FlEngine * | engine | ) |

Definition at line 132 of file fl_view_accessible.cc.

132 {
133 FlViewAccessible* self =
134 FL_VIEW_ACCESSIBLE(g_object_new(fl_view_accessible_get_type(), nullptr));
135 g_weak_ref_init(&self->engine, engine);
136 return self;
137 }

Referenced by realize_cb(), and TEST().

## ◆ fl_view_accessible_ref_child()

static AtkObject* fl_view_accessible_ref_child | ( | AtkObject * | accessible,
|  | gint | i
| ) |  |
| static

Definition at line 85 of file fl_view_accessible.cc.

85 {
86 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(accessible);
87 FlAccessibleNode* node = lookup_node(self, 0);
88
89 if (i != 0 || node == nullptr) {
90 return nullptr;
91 }
92
93 return ATK_OBJECT(g_object_ref(node));
94 }

References i, and lookup_node().

Referenced by fl_view_accessible_class_init().

## ◆ fl_view_accessible_ref_state_set()

static AtkStateSet* fl_view_accessible_ref_state_set | ( | AtkObject * | accessible | ) |
| static

Definition at line 102 of file fl_view_accessible.cc.

102 {
103 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(accessible);
104 FlAccessibleNode* node = lookup_node(self, 0);
105 return node != nullptr ? atk_object_ref_state_set(ATK_OBJECT(node)) : nullptr;
106 }

References lookup_node().

Referenced by fl_view_accessible_class_init().

## ◆ get_node()

static FlAccessibleNode* get_node | ( | FlViewAccessible * | self,
|  | FlutterSemanticsNode2 * | semantics
| ) |  |
| static

Definition at line 48 of file fl_view_accessible.cc.

49 {
50 FlAccessibleNode* node = lookup_node(self, semantics->id);
51 if (node != nullptr) {
52 return node;
53 }
54
55 node = create_node(self, semantics);
56 if (semantics->id == kRootSemanticsNodeId) {
57 fl_accessible_node_set_parent(node, ATK_OBJECT(self), 0);
58 }
59 g_hash_table_insert(self->semantics_nodes_by_id,
60 GINT_TO_POINTER(semantics->id),
61 reinterpret_cast<gpointer>(node));
62
63 // Update when root node is created.
64 if (!self->root_node_created && semantics->id == kRootSemanticsNodeId) {
65 g_signal_emit_by_name(self, "children-changed::add", 0, node, nullptr);
66 self->root_node_created = true;
67 }
68
69 return node;
70 }
create_node
static FlAccessibleNode * create_node(FlViewAccessible *self, FlutterSemanticsNode2 *semantics)
Definition: fl_view_accessible.cc:27
kRootSemanticsNodeId
static constexpr int32_t kRootSemanticsNodeId
Definition: fl_view_accessible.cc:11

References create_node(), fl_accessible_node_set_parent(), kRootSemanticsNodeId, and lookup_node().

Referenced by fl_view_accessible_handle_update_semantics().

## ◆ lookup_node()

static FlAccessibleNode* lookup_node | ( | FlViewAccessible * | self,
|  | int32_t | id
| ) |  |
| static

Definition at line 41 of file fl_view_accessible.cc.

41 {
42 return FL_ACCESSIBLE_NODE(
43 g_hash_table_lookup(self->semantics_nodes_by_id, GINT_TO_POINTER(id)));
44 }

Referenced by fl_view_accessible_get_n_children(), fl_view_accessible_handle_update_semantics(), fl_view_accessible_ref_child(), fl_view_accessible_ref_state_set(), and get_node().

## Variable Documentation

## ◆ kRootSemanticsNodeId

constexpr int32_t kRootSemanticsNodeId = 0
| static constexpr

Definition at line 11 of file fl_view_accessible.cc.

Referenced by get_node().