25 G_DEFINE_TYPE(FlViewAccessible, fl_view_accessible, ATK_TYPE_PLUG)
28 FlutterSemanticsNode2* semantics) {
29 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
30 if (engine ==
nullptr) {
34 if (semantics->flags & kFlutterSemanticsFlagIsTextField) {
41 static FlAccessibleNode*
lookup_node(FlViewAccessible*
self, int32_t
id) {
42 return FL_ACCESSIBLE_NODE(
43 g_hash_table_lookup(self->semantics_nodes_by_id, GINT_TO_POINTER(
id)));
48 static FlAccessibleNode*
get_node(FlViewAccessible*
self,
49 FlutterSemanticsNode2* semantics) {
50 FlAccessibleNode* node =
lookup_node(
self, semantics->id);
51 if (node !=
nullptr) {
59 g_hash_table_insert(self->semantics_nodes_by_id,
60 GINT_TO_POINTER(semantics->id),
61 reinterpret_cast<gpointer
>(node));
65 g_signal_emit_by_name(
self,
"children-changed::add", 0, node,
nullptr);
66 self->root_node_created =
true;
74 FlViewAccessible*
self = FL_VIEW_ACCESSIBLE(accessible);
77 if (node ==
nullptr) {
86 FlViewAccessible*
self = FL_VIEW_ACCESSIBLE(accessible);
89 if (
i != 0 || node ==
nullptr) {
93 return ATK_OBJECT(g_object_ref(node));
98 return ATK_ROLE_PANEL;
103 FlViewAccessible*
self = FL_VIEW_ACCESSIBLE(accessible);
105 return node !=
nullptr ? atk_object_ref_state_set(ATK_OBJECT(node)) :
nullptr;
109 FlViewAccessible*
self = FL_VIEW_ACCESSIBLE(
object);
111 g_clear_pointer(&self->semantics_nodes_by_id, g_hash_table_unref);
113 g_weak_ref_clear(&self->engine);
115 G_OBJECT_CLASS(fl_view_accessible_parent_class)->dispose(
object);
128 self->semantics_nodes_by_id = g_hash_table_new_full(
129 g_direct_hash, g_direct_equal,
nullptr, g_object_unref);
133 FlViewAccessible*
self =
134 FL_VIEW_ACCESSIBLE(g_object_new(fl_view_accessible_get_type(),
nullptr));
135 g_weak_ref_init(&self->engine, engine);
140 FlViewAccessible*
self,
141 const FlutterSemanticsUpdate2* update) {
142 g_autoptr(GHashTable) pending_children =
143 g_hash_table_new_full(g_direct_hash, g_direct_equal,
nullptr,
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);
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);
158 node->text_selection_extent);
162 node->children_in_traversal_order, node->child_count);
163 g_hash_table_insert(pending_children, atk_node, children);
166 g_hash_table_foreach_remove(
168 [](gpointer key, gpointer
value, gpointer
user_data) -> gboolean {
169 FlViewAccessible*
self = FL_VIEW_ACCESSIBLE(
user_data);
171 FlAccessibleNode* parent = FL_ACCESSIBLE_NODE(key);
174 const int32_t* children_in_traversal_order =
177 g_autoptr(GPtrArray) children = g_ptr_array_new();
178 for (
size_t i = 0;
i < child_count;
i++) {
179 FlAccessibleNode* child =
181 g_assert(child !=
nullptr);
183 g_ptr_array_add(children, child);