| Flutter Linux Embedder |

Classes | Enumerations | 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

## Enumerations
enum | { kProp0, kPropEngine, kPropLast }

## Functions
| G_DEFINE_TYPE (FlViewAccessible, fl_view_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE) static void init_engine(FlViewAccessible *self
| g_object_add_weak_pointer (G_OBJECT(self), reinterpret_cast< gpointer * >(&self->engine))
static FlEngine * | get_engine (FlViewAccessible *self)
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 void | fl_view_accessible_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
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)
void | fl_view_accessible_handle_update_semantics (FlViewAccessible *self, const FlutterSemanticsUpdate2 *update)

## Variables
FlEngine * | engine

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
kProp0 |
kPropEngine |
kPropLast |

Definition at line 20 of file fl_view_accessible.cc.

20 { kProp0, kPropEngine, kPropLast };

## Function Documentation

## ◆ create_node()

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

Definition at line 41 of file fl_view_accessible.cc.

42 {
43 FlEngine* engine = get_engine(self);
44
45 if (semantics->flags & kFlutterSemanticsFlagIsTextField) {
46 return fl_accessible_text_field_new(engine, semantics->id);
47 }
48
49 return fl_accessible_node_new(engine, semantics->id);
50 }

References engine, fl_accessible_node_new(), fl_accessible_text_field_new(), and get_engine().

Referenced by get_node().

## ◆ fl_view_accessible_class_init()

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

Definition at line 137 of file fl_view_accessible.cc.

137 {
138 ATK_OBJECT_CLASS(klass)->get_n_children = fl_view_accessible_get_n_children;
139 ATK_OBJECT_CLASS(klass)->ref_child = fl_view_accessible_ref_child;
140 ATK_OBJECT_CLASS(klass)->get_role = fl_view_accessible_get_role;
141
142 G_OBJECT_CLASS(klass)->dispose = fl_view_accessible_dispose;
143 G_OBJECT_CLASS(klass)->set_property = fl_view_accessible_set_property;
144
145 g_object_class_install_property(
146 G_OBJECT_CLASS(klass), kPropEngine,
147 g_param_spec_object(
148 "engine", "engine", "Flutter engine", fl_engine_get_type(),
149 static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
150 G_PARAM_STATIC_STRINGS)));
151 }

References fl_view_accessible_dispose(), fl_view_accessible_get_n_children(), fl_view_accessible_get_role(), fl_view_accessible_ref_child(), fl_view_accessible_set_property(), and kPropEngine.

## ◆ fl_view_accessible_dispose()

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

Definition at line 123 of file fl_view_accessible.cc.

123 {
124 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(object);
125
126 g_clear_pointer(&self->semantics_nodes_by_id, g_hash_table_unref);
127
128 if (self->engine != nullptr) {
129 g_object_remove_weak_pointer(object,
130 reinterpret_cast<gpointer*>(&self->engine));
131 self->engine = nullptr;
132 }
133
134 G_OBJECT_CLASS(fl_view_accessible_parent_class)->dispose(object);
135 }

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 79 of file fl_view_accessible.cc.

79 {
80 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(accessible);
81 FlAccessibleNode* node = lookup_node(self, 0);
82
83 if (node == nullptr) {
84 return 0;
85 }
86
87 return 1;
88 }

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 103 of file fl_view_accessible.cc.

103 {
104 return ATK_ROLE_PANEL;
105 }

Referenced by fl_view_accessible_class_init().

## ◆ fl_view_accessible_handle_update_semantics()

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

Definition at line 158 of file fl_view_accessible.cc.

160 {
161 g_autoptr(GHashTable) pending_children =
162 g_hash_table_new_full(g_direct_hash, g_direct_equal, nullptr,
163 reinterpret_cast<GDestroyNotify>(fl_value_unref));
164
165 for (size_t i = 0; i < update->node_count; i++) {
166 FlutterSemanticsNode2* node = update->nodes[i];
167 FlAccessibleNode* atk_node = get_node(self, node);
168
169 fl_accessible_node_set_flags(atk_node, node->flags);
170 fl_accessible_node_set_actions(atk_node, node->actions);
171 fl_accessible_node_set_name(atk_node, node->label);
172 fl_accessible_node_set_extents(
173 atk_node, node->rect.left + node->transform.transX,
174 node->rect.top + node->transform.transY,
175 node->rect.right - node->rect.left, node->rect.bottom - node->rect.top);
176 fl_accessible_node_set_value(atk_node, node->value);
177 fl_accessible_node_set_text_selection(atk_node, node->text_selection_base,
178 node->text_selection_extent);
179 fl_accessible_node_set_text_direction(atk_node, node->text_direction);
180
181 FlValue* children = fl_value_new_int32_list(
182 node->children_in_traversal_order, node->child_count);
183 g_hash_table_insert(pending_children, atk_node, children);
184 }
185
186 g_hash_table_foreach_remove(
187 pending_children,
188 [](gpointer key, gpointer value, gpointer user_data) -> gboolean {
189 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(user_data);
190
191 FlAccessibleNode* parent = FL_ACCESSIBLE_NODE(key);
192
193 size_t child_count = fl_value_get_length(static_cast<FlValue*>(value));
194 const int32_t* children_in_traversal_order =
195 fl_value_get_int32_list(static_cast<FlValue*>(value));
196
197 g_autoptr(GPtrArray) children = g_ptr_array_new();
198 for (size_t i = 0; i < child_count; i++) {
199 FlAccessibleNode* child =
200 lookup_node(self, children_in_traversal_order[i]);
201 g_assert(child != nullptr);
202 fl_accessible_node_set_parent(child, ATK_OBJECT(parent), i);
203 g_ptr_array_add(children, child);
204 }
205 fl_accessible_node_set_children(parent, children);
206
207 return true;
208 },
209 self);
210 }

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(), lookup_node(), update, 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 153 of file fl_view_accessible.cc.

153 {
154 self->semantics_nodes_by_id = g_hash_table_new_full(
155 g_direct_hash, g_direct_equal, nullptr, g_object_unref);
156 }

## ◆ fl_view_accessible_ref_child()

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

Definition at line 91 of file fl_view_accessible.cc.

91 {
92 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(accessible);
93 FlAccessibleNode* node = lookup_node(self, 0);
94
95 if (i != 0 || node == nullptr) {
96 return nullptr;
97 }
98
99 return ATK_OBJECT(g_object_ref(node));
100 }

References lookup_node().

Referenced by fl_view_accessible_class_init().

## ◆ fl_view_accessible_set_property()

static void fl_view_accessible_set_property | ( | GObject * | object,
|  | guint | prop_id,
|  | const GValue * | value,
|  | GParamSpec * | pspec
| ) |  |
| static

Definition at line 108 of file fl_view_accessible.cc.

111 {
112 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(object);
113 switch (prop_id) {
114 case kPropEngine:
115 init_engine(self, FL_ENGINE(g_value_get_object(value)));
116 break;
117 default:
118 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
119 break;
120 }
121 }

References kPropEngine, prop_id, pspec, and value.

Referenced by fl_view_accessible_class_init().

## ◆ G_DEFINE_TYPE()

G_DEFINE_TYPE | ( | FlViewAccessible | ,
|  | fl_view_accessible | ,
|  | GTK_TYPE_CONTAINER_ACCESSIBLE |
| ) |  |

## ◆ g_object_add_weak_pointer()

g_object_add_weak_pointer | ( | G_OBJECT(self) | ,
|  | reinterpret_cast< gpointer * > &-> | engine
| ) |  |

Referenced by fl_accessible_node_set_parent(), fl_accessible_node_set_property(), fl_key_channel_user_data_new(), fl_keyboard_manager_new(), fl_keyboard_manager_user_data_new(), fl_mouse_cursor_plugin_new(), fl_plugin_registrar_new(), fl_scrolling_manager_new(), fl_settings_plugin_new(), and fl_text_input_plugin_new().

## ◆ get_engine()

static FlEngine* get_engine | ( | FlViewAccessible * | self | ) |
| static

Definition at line 33 of file fl_view_accessible.cc.

33 {
34 if (self->engine == nullptr) {
35 FlView* view = FL_VIEW(gtk_accessible_get_widget(GTK_ACCESSIBLE(self)));
36 init_engine(self, fl_view_get_engine(view));
37 }
38 return self->engine;
39 }

References fl_view_get_engine().

Referenced by create_node().

## ◆ get_node()

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

Definition at line 59 of file fl_view_accessible.cc.

60 {
61 FlAccessibleNode* node = lookup_node(self, semantics->id);
62 if (node != nullptr) {
63 return node;
64 }
65
66 node = create_node(self, semantics);
67 if (semantics->id == 0) {
68 fl_accessible_node_set_parent(node, ATK_OBJECT(self), 0);
69 g_signal_emit_by_name(self, "children-changed::add", 0, node, nullptr);
70 }
71 g_hash_table_insert(self->semantics_nodes_by_id,
72 GINT_TO_POINTER(semantics->id),
73 reinterpret_cast<gpointer>(node));
74
75 return node;
76 }

References create_node(), fl_accessible_node_set_parent(), 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 52 of file fl_view_accessible.cc.

52 {
53 return FL_ACCESSIBLE_NODE(
54 g_hash_table_lookup(self->semantics_nodes_by_id, GINT_TO_POINTER(id)));
55 }

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

## Variable Documentation

## ◆ engine

self engine

Initial value:
{
g_assert(self->engine == nullptr)

Definition at line 26 of file fl_view_accessible.cc.

Referenced by create_node(), fl_accessible_node_new(), fl_accessible_text_field_new(), fl_binary_messenger_impl_dispose(), fl_binary_messenger_new(), fl_binary_messenger_response_handle_impl_dispose(), fl_settings_plugin_new(), fl_task_runner_new(), fl_texture_registrar_new(), G_DECLARE_FINAL_TYPE(), make_mock_engine(), send_on_channel(), send_on_channel_finish(), send_response(), set_message_handler_on_channel(), TEST(), and test_lock_event().

prop_id
guint prop_id
Definition: fl_standard_method_codec.cc:31
fl_value_get_int32_list
const G_MODULE_EXPORT int32_t * fl_value_get_int32_list(FlValue *self)
Definition: fl_value.cc:696
get_node
static FlAccessibleNode * get_node(FlViewAccessible *self, FlutterSemanticsNode2 *semantics)
Definition: fl_view_accessible.cc:59
kPropLast
@ kPropLast
Definition: fl_view_accessible.cc:20
fl_accessible_node_set_text_selection
void fl_accessible_node_set_text_selection(FlAccessibleNode *self, gint base, gint extent)
Definition: fl_accessible_node.cc:562
fl_view_accessible_ref_child
static AtkObject * fl_view_accessible_ref_child(AtkObject *accessible, gint i)
Definition: fl_view_accessible.cc:91
fl_accessible_node_set_flags
void fl_accessible_node_set_flags(FlAccessibleNode *self, FlutterSemanticsFlag flags)
Definition: fl_accessible_node.cc:542
fl_accessible_node_set_parent
void fl_accessible_node_set_parent(FlAccessibleNode *self, AtkObject *parent, gint index)
Definition: fl_accessible_node.cc:487
fl_accessible_text_field_new
FlAccessibleNode * fl_accessible_text_field_new(FlEngine *engine, int32_t id)
Definition: fl_accessible_text_field.cc:618
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42
user_data
FlKeyEvent uint64_t FlKeyResponderAsyncCallback gpointer user_data
Definition: fl_key_channel_responder.cc:121
pspec
guint const GValue GParamSpec * pspec
Definition: fl_standard_method_codec.cc:33
fl_accessible_node_set_children
void fl_accessible_node_set_children(FlAccessibleNode *self, GPtrArray *children)
Definition: fl_accessible_node.cc:498
update
G_BEGIN_DECLS const FlutterSemanticsUpdate2 * update
Definition: fl_view_accessible.h:40
kProp0
@ kProp0
Definition: fl_view_accessible.cc:20
fl_value_unref
G_MODULE_EXPORT void fl_value_unref(FlValue *self)
Definition: fl_value.cc:400
create_node
static FlAccessibleNode * create_node(FlViewAccessible *self, FlutterSemanticsNode2 *semantics)
Definition: fl_view_accessible.cc:41
fl_view_accessible_dispose
static void fl_view_accessible_dispose(GObject *object)
Definition: fl_view_accessible.cc:123
fl_view_accessible_set_property
static void fl_view_accessible_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
Definition: fl_view_accessible.cc:108
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:531
fl_accessible_node_set_text_direction
void fl_accessible_node_set_text_direction(FlAccessibleNode *self, FlutterTextDirection direction)
Definition: fl_accessible_node.cc:571
kPropEngine
@ kPropEngine
Definition: fl_view_accessible.cc:20
fl_view_get_engine
G_MODULE_EXPORT FlEngine * fl_view_get_engine(FlView *self)
Definition: fl_view.cc:800
fl_accessible_node_set_value
void fl_accessible_node_set_value(FlAccessibleNode *self, const gchar *value)
Definition: fl_accessible_node.cc:556
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_get_length
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
Definition: fl_value.cc:724
fl_accessible_node_new
FlAccessibleNode * fl_accessible_node_new(FlEngine *engine, int32_t id)
Definition: fl_accessible_node.cc:481
get_engine
static FlEngine * get_engine(FlViewAccessible *self)
Definition: fl_view_accessible.cc:33
fl_view_accessible_get_n_children
static gint fl_view_accessible_get_n_children(AtkObject *accessible)
Definition: fl_view_accessible.cc:79
engine
FlEngine * engine
Definition: fl_view_accessible.cc:26
fl_accessible_node_set_name
void fl_accessible_node_set_name(FlAccessibleNode *self, const gchar *name)
Definition: fl_accessible_node.cc:525
fl_accessible_node_set_actions
void fl_accessible_node_set_actions(FlAccessibleNode *self, FlutterSemanticsAction actions)
Definition: fl_accessible_node.cc:549
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
lookup_node
static FlAccessibleNode * lookup_node(FlViewAccessible *self, int32_t id)
Definition: fl_view_accessible.cc:52
fl_view_accessible_get_role
static AtkRole fl_view_accessible_get_role(AtkObject *accessible)
Definition: fl_view_accessible.cc:103