| 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, const FlutterSemanticsNode *semantics)
static FlAccessibleNode * | lookup_node (FlViewAccessible *self, int32_t id)
static FlAccessibleNode * | get_node (FlViewAccessible *self, const FlutterSemanticsNode *semantics)
static void | commit_updates (FlViewAccessible *self)
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_node (FlViewAccessible *self, const FlutterSemanticsNode *node)

## Variables
FlEngine * | engine

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
kProp0 |
kPropEngine |
kPropLast |

Definition at line 23 of file fl_view_accessible.cc.

23 { kProp0, kPropEngine, kPropLast };

## Function Documentation

## ◆ commit_updates()

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

Definition at line 81 of file fl_view_accessible.cc.

81 {
82 g_hash_table_foreach_remove(
83 self->pending_children,
84 [](gpointer key, gpointer value, gpointer user_data) -> gboolean {
85 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(user_data);
86
87 FlAccessibleNode* parent = FL_ACCESSIBLE_NODE(key);
88
89 size_t child_count = fl_value_get_length(static_cast<FlValue*>(value));
90 const int32_t* children_in_traversal_order =
91 fl_value_get_int32_list(static_cast<FlValue*>(value));
92
93 g_autoptr(GPtrArray) children = g_ptr_array_new();
94 for (size_t i = 0; i < child_count; i++) {
95 FlAccessibleNode* child =
96 lookup_node(self, children_in_traversal_order[i]);
97 g_assert(child != nullptr);
98 fl_accessible_node_set_parent(child, ATK_OBJECT(parent), i);
99 g_ptr_array_add(children, child);
100 }
101 fl_accessible_node_set_children(parent, children);
102
103 return true;
104 },
105 self);
106 }

References fl_accessible_node_set_children(), self, user_data, and value.

Referenced by fl_view_accessible_handle_update_semantics_node().

## ◆ create_node()

static FlAccessibleNode* create_node | ( | FlViewAccessible * | self,
|  | const FlutterSemanticsNode * | semantics
| ) |  |
| static

Definition at line 44 of file fl_view_accessible.cc.

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

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

168 {
169 ATK_OBJECT_CLASS(klass)->get_n_children = fl_view_accessible_get_n_children;
170 ATK_OBJECT_CLASS(klass)->ref_child = fl_view_accessible_ref_child;
171 ATK_OBJECT_CLASS(klass)->get_role = fl_view_accessible_get_role;
172
173 G_OBJECT_CLASS(klass)->dispose = fl_view_accessible_dispose;
174 G_OBJECT_CLASS(klass)->set_property = fl_view_accessible_set_property;
175
176 g_object_class_install_property(
177 G_OBJECT_CLASS(klass), kPropEngine,
178 g_param_spec_object(
179 "engine", "engine", "Flutter engine", fl_engine_get_type(),
180 static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
181 G_PARAM_STATIC_STRINGS)));
182 }

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

153 {
154 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(object);
155
156 g_clear_pointer(&self->semantics_nodes_by_id, g_hash_table_unref);
157 g_clear_pointer(&self->pending_children, g_hash_table_unref);
158
159 if (self->engine != nullptr) {
160 g_object_remove_weak_pointer(object,
161 reinterpret_cast<gpointer*>(&self->engine));
162 self->engine = nullptr;
163 }
164
165 G_OBJECT_CLASS(fl_view_accessible_parent_class)->dispose(object);
166 }

References self.

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

109 {
110 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(accessible);
111 FlAccessibleNode* node = lookup_node(self, 0);
112
113 if (node == nullptr) {
114 return 0;
115 }
116
117 return 1;
118 }

References lookup_node(), and 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 133 of file fl_view_accessible.cc.

133 {
134 return ATK_ROLE_PANEL;
135 }

Referenced by fl_view_accessible_class_init().

## ◆ fl_view_accessible_handle_update_semantics_node()

void fl_view_accessible_handle_update_semantics_node | ( | FlViewAccessible * | self,
|  | const FlutterSemanticsNode * | node
| ) |  |

Definition at line 192 of file fl_view_accessible.cc.

194 {
195 if (node->id == kFlutterSemanticsNodeIdBatchEnd) {
196 commit_updates(self);
197 return;
198 }
199
200 FlAccessibleNode* atk_node = get_node(self, node);
201
202 fl_accessible_node_set_flags(atk_node, node->flags);
203 fl_accessible_node_set_actions(atk_node, node->actions);
204 fl_accessible_node_set_name(atk_node, node->label);
205 fl_accessible_node_set_extents(
206 atk_node, node->rect.left + node->transform.transX,
207 node->rect.top + node->transform.transY,
208 node->rect.right - node->rect.left, node->rect.bottom - node->rect.top);
209 fl_accessible_node_set_value(atk_node, node->value);
210 fl_accessible_node_set_text_selection(atk_node, node->text_selection_base,
211 node->text_selection_extent);
212 fl_accessible_node_set_text_direction(atk_node, node->text_direction);
213
214 FlValue* children = fl_value_new_int32_list(node->children_in_traversal_order,
215 node->child_count);
216 g_hash_table_insert(self->pending_children, atk_node, children);
217 }

References commit_updates(), fl_accessible_node_set_actions(), fl_accessible_node_set_extents(), fl_accessible_node_set_flags(), fl_accessible_node_set_name(), fl_accessible_node_set_text_direction(), fl_accessible_node_set_text_selection(), fl_accessible_node_set_value(), fl_value_new_int32_list(), get_node(), node, and self.

Referenced by fl_accessibility_plugin_handle_update_semantics_node(), and TEST().

## ◆ fl_view_accessible_init()

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

Definition at line 184 of file fl_view_accessible.cc.

184 {
185 self->semantics_nodes_by_id = g_hash_table_new_full(
186 g_direct_hash, g_direct_equal, nullptr, g_object_unref);
187 self->pending_children =
188 g_hash_table_new_full(g_direct_hash, g_direct_equal, nullptr,
189 reinterpret_cast<GDestroyNotify>(fl_value_unref));
190 }

References fl_value_unref().

## ◆ fl_view_accessible_ref_child()

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

Definition at line 121 of file fl_view_accessible.cc.

121 {
122 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(accessible);
123 FlAccessibleNode* node = lookup_node(self, 0);
124
125 if (i != 0 || node == nullptr) {
126 return nullptr;
127 }
128
129 return ATK_OBJECT(g_object_ref(node));
130 }

References lookup_node(), and 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 138 of file fl_view_accessible.cc.

141 {
142 FlViewAccessible* self = FL_VIEW_ACCESSIBLE(object);
143 switch (prop_id) {
144 case kPropEngine:
145 init_engine(self, FL_ENGINE(g_value_get_object(value)));
146 break;
147 default:
148 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
149 break;
150 }
151 }

References kPropEngine, 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_accessibility_plugin_new(), 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 36 of file fl_view_accessible.cc.

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

References fl_view_get_engine(), and self.

Referenced by create_node().

## ◆ get_node()

static FlAccessibleNode* get_node | ( | FlViewAccessible * | self,
|  | const FlutterSemanticsNode * | semantics
| ) |  |
| static

Definition at line 62 of file fl_view_accessible.cc.

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

References create_node(), fl_accessible_node_set_parent(), lookup_node(), node, and self.

Referenced by fl_view_accessible_handle_update_semantics_node().

## ◆ lookup_node()

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

Definition at line 55 of file fl_view_accessible.cc.

55 {
56 return FL_ACCESSIBLE_NODE(
57 g_hash_table_lookup(self->semantics_nodes_by_id, GINT_TO_POINTER(id)));
58 }

References self.

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

## Variable Documentation

## ◆ engine

self engine

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

Definition at line 29 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(), test_lock_event(), and window_state_event_cb().

create_node
static FlAccessibleNode * create_node(FlViewAccessible *self, const FlutterSemanticsNode *semantics)
Definition: fl_view_accessible.cc:44
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:121
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:40
user_data
FlKeyEvent uint64_t FlKeyResponderAsyncCallback gpointer user_data
Definition: fl_key_channel_responder.cc:121
fl_accessible_node_set_children
void fl_accessible_node_set_children(FlAccessibleNode *self, GPtrArray *children)
Definition: fl_accessible_node.cc:498
fl_value_unref
G_MODULE_EXPORT void fl_value_unref(FlValue *self)
Definition: fl_value.cc:369
fl_view_accessible_dispose
static void fl_view_accessible_dispose(GObject *object)
Definition: fl_view_accessible.cc:153
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:138
kProp0
@ kProp0
Definition: fl_view_accessible.cc:23
get_node
static FlAccessibleNode * get_node(FlViewAccessible *self, const FlutterSemanticsNode *semantics)
Definition: fl_view_accessible.cc:62
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
kPropEngine
@ kPropEngine
Definition: fl_view_accessible.cc:23
fl_accessible_node_set_text_direction
void fl_accessible_node_set_text_direction(FlAccessibleNode *self, FlutterTextDirection direction)
Definition: fl_accessible_node.cc:571
fl_view_get_engine
G_MODULE_EXPORT FlEngine * fl_view_get_engine(FlView *self)
Definition: fl_view.cc:770
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:298
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:36
self
GdkEvent FlView * self
Definition: fl_view.cc:100
kPropLast
@ kPropLast
Definition: fl_view_accessible.cc:23
commit_updates
static void commit_updates(FlViewAccessible *self)
Definition: fl_view_accessible.cc:81
fl_view_accessible_get_n_children
static gint fl_view_accessible_get_n_children(AtkObject *accessible)
Definition: fl_view_accessible.cc:109
engine
FlEngine * engine
Definition: fl_view_accessible.cc:29
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:41
lookup_node
static FlAccessibleNode * lookup_node(FlViewAccessible *self, int32_t id)
Definition: fl_view_accessible.cc:55
node
G_BEGIN_DECLS const FlutterSemanticsNode * node
Definition: fl_view_accessible.h:40
fl_view_accessible_get_role
static AtkRole fl_view_accessible_get_role(AtkObject *accessible)
Definition: fl_view_accessible.cc:133