Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
fl_accessibility_channel.cc File Reference

Go to the source code of this file.

Classes

struct  _FlAccessibilityChannel
 

Functions

static FlTextDirection parse_text_direction (int64_t value)
 
static FlAssertiveness parse_assertiveness (int64_t value)
 
static void process_announce (FlAccessibilityChannel *self, FlValue *data)
 
static void process_message (FlAccessibilityChannel *self, FlValue *message)
 
static void message_cb (FlBasicMessageChannel *channel, FlValue *message, FlBasicMessageChannelResponseHandle *response_handle, gpointer user_data)
 
static void fl_accessibility_channel_dispose (GObject *object)
 
static void fl_accessibility_channel_class_init (FlAccessibilityChannelClass *klass)
 
static void fl_accessibility_channel_init (FlAccessibilityChannel *self)
 
FlAccessibilityChannel * fl_accessibility_channel_new (FlBinaryMessenger *messenger, FlAccessibilityChannelVTable *vtable, gpointer user_data)
 

Variables

static constexpr char kChannelName [] = "flutter/accessibility"
 
static constexpr char kTypeKey [] = "type"
 
static constexpr char kDataKey [] = "data"
 
static constexpr char kAnnounceType [] = "announce"
 
static constexpr char kTooltipType [] = "tooltip"
 
static constexpr char kLongPressType [] = "longPress"
 
static constexpr char kTapType [] = "tap"
 
static constexpr char kFocusType [] = "focus"
 
static constexpr char kViewIdKey [] = "viewId"
 
static constexpr char kMessageKey [] = "message"
 
static constexpr char kTextDirectionKey [] = "textDirection"
 
static constexpr char kAssertivenessKey [] = "assertiveness"
 

Function Documentation

◆ fl_accessibility_channel_class_init()

static void fl_accessibility_channel_class_init ( FlAccessibilityChannelClass *  klass)
static

Definition at line 170 of file fl_accessibility_channel.cc.

171 {
172 G_OBJECT_CLASS(klass)->dispose = fl_accessibility_channel_dispose;
173}
static void fl_accessibility_channel_dispose(GObject *object)

References fl_accessibility_channel_dispose().

◆ fl_accessibility_channel_dispose()

static void fl_accessibility_channel_dispose ( GObject *  object)
static

Definition at line 162 of file fl_accessibility_channel.cc.

162 {
163 FlAccessibilityChannel* self = FL_ACCESSIBILITY_CHANNEL(object);
164
165 g_clear_object(&self->channel);
166
167 G_OBJECT_CLASS(fl_accessibility_channel_parent_class)->dispose(object);
168}

References self.

Referenced by fl_accessibility_channel_class_init().

◆ fl_accessibility_channel_init()

static void fl_accessibility_channel_init ( FlAccessibilityChannel *  self)
static

Definition at line 175 of file fl_accessibility_channel.cc.

175{}

◆ fl_accessibility_channel_new()

FlAccessibilityChannel * fl_accessibility_channel_new ( FlBinaryMessenger *  messenger,
FlAccessibilityChannelVTable vtable,
gpointer  user_data 
)

fl_accessibility_channel_new: @messenger: an #FlBinaryMessenger @vtable: callbacks for incoming method calls. @user_data: data to pass in callbacks.

Creates a new channel that handles accessibility requests from Dart.

Returns: a new #FlAccessibilityChannel

Definition at line 177 of file fl_accessibility_channel.cc.

180 {
181 FlAccessibilityChannel* self = FL_ACCESSIBILITY_CHANNEL(
182 g_object_new(fl_accessibility_channel_get_type(), nullptr));
183
184 self->vtable = vtable;
185 self->user_data = user_data;
186
187 g_autoptr(FlStandardMessageCodec) codec = fl_standard_message_codec_new();
188 self->channel = fl_basic_message_channel_new(messenger, kChannelName,
189 FL_MESSAGE_CODEC(codec));
191 nullptr);
192
193 return self;
194}
static void message_cb(FlBasicMessageChannel *channel, FlValue *message, FlBasicMessageChannelResponseHandle *response_handle, gpointer user_data)
static constexpr char kChannelName[]
g_autoptr(FlEngine) engine
G_MODULE_EXPORT FlBasicMessageChannel * fl_basic_message_channel_new(FlBinaryMessenger *messenger, const gchar *name, FlMessageCodec *codec)
G_MODULE_EXPORT void fl_basic_message_channel_set_message_handler(FlBasicMessageChannel *self, FlBasicMessageChannelMessageHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
G_MODULE_EXPORT FlStandardMessageCodec * fl_standard_message_codec_new()

References fl_basic_message_channel_new(), fl_basic_message_channel_set_message_handler(), fl_standard_message_codec_new(), g_autoptr(), kChannelName, message_cb(), self, and user_data.

Referenced by fl_accessibility_handler_new().

◆ message_cb()

static void message_cb ( FlBasicMessageChannel *  channel,
FlValue message,
FlBasicMessageChannelResponseHandle *  response_handle,
gpointer  user_data 
)
static

Definition at line 147 of file fl_accessibility_channel.cc.

150 {
151 FlAccessibilityChannel* self = FL_ACCESSIBILITY_CHANNEL(user_data);
152
154
155 g_autoptr(GError) error = nullptr;
156 if (!fl_basic_message_channel_respond(channel, response_handle, nullptr,
157 &error)) {
158 g_warning("Failed to send message response: %s", error->message);
159 }
160}
static void process_message(FlAccessibilityChannel *self, FlValue *message)
const char * message
G_MODULE_EXPORT gboolean fl_basic_message_channel_respond(FlBasicMessageChannel *self, FlBasicMessageChannelResponseHandle *response_handle, FlValue *message, GError **error)
const gchar * channel
const uint8_t uint32_t uint32_t GError ** error

References channel, error, fl_basic_message_channel_respond(), g_autoptr(), message, process_message(), self, and user_data.

Referenced by fl_accessibility_channel_new().

◆ parse_assertiveness()

static FlAssertiveness parse_assertiveness ( int64_t  value)
static

Definition at line 51 of file fl_accessibility_channel.cc.

51 {
52 switch (value) {
53 case 0:
55 case 1:
57 default:
58 g_warning("Unknown assertiveness value %" G_GINT64_FORMAT, value);
60 }
61}
@ FL_ASSERTIVENESS_POLITE
@ FL_ASSERTIVENESS_ASSERTIVE

References FL_ASSERTIVENESS_ASSERTIVE, FL_ASSERTIVENESS_POLITE, and value.

Referenced by process_announce().

◆ parse_text_direction()

static FlTextDirection parse_text_direction ( int64_t  value)
static

Definition at line 39 of file fl_accessibility_channel.cc.

39 {
40 switch (value) {
41 case 0:
43 case 1:
45 default:
46 g_warning("Unknown text direction value %" G_GINT64_FORMAT, value);
48 }
49}
@ FL_TEXT_DIRECTION_LTR
@ FL_TEXT_DIRECTION_RTL

References FL_TEXT_DIRECTION_LTR, FL_TEXT_DIRECTION_RTL, and value.

Referenced by process_announce().

◆ process_announce()

static void process_announce ( FlAccessibilityChannel *  self,
FlValue data 
)
static

Definition at line 63 of file fl_accessibility_channel.cc.

63 {
65 if (view_id_value == nullptr ||
66 fl_value_get_type(view_id_value) != FL_VALUE_TYPE_INT) {
67 g_warning("Missing/invalid view ID in accessibility announce event");
68 return;
69 }
70 int64_t view_id = fl_value_get_int(view_id_value);
71
73 if (message_value == nullptr ||
74 fl_value_get_type(message_value) != FL_VALUE_TYPE_STRING) {
75 g_warning("Missing/invalid message in accessibility announce event");
76 return;
77 }
78 const char* message = fl_value_get_string(message_value);
79
80 FlValue* text_direction_value =
82 if (text_direction_value == nullptr ||
83 fl_value_get_type(text_direction_value) != FL_VALUE_TYPE_INT) {
84 g_warning("Missing/invalid text direction in accessibility announce event");
85 return;
86 }
88 parse_text_direction(fl_value_get_int(text_direction_value));
89
90 FlValue* assertiveness_value =
93 if (assertiveness_value != nullptr) {
94 if (fl_value_get_type(assertiveness_value) != FL_VALUE_TYPE_INT) {
95 g_warning("Invalid assertiveness in accessibility announce event");
96 return;
97 }
99 }
100
101 self->vtable->send_announcement(view_id, message, text_direction,
102 assertiveness, self->user_data);
103}
static constexpr char kAssertivenessKey[]
static constexpr char kViewIdKey[]
static FlTextDirection parse_text_direction(int64_t value)
static FlAssertiveness parse_assertiveness(int64_t value)
static constexpr char kTextDirectionKey[]
static constexpr char kMessageKey[]
const char FlTextDirection text_direction
const char FlTextDirection FlAssertiveness assertiveness
G_MODULE_EXPORT FlValue * fl_value_lookup_string(FlValue *self, const gchar *key)
Definition fl_value.cc:811
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
Definition fl_value.cc:668
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition fl_value.cc:466
G_MODULE_EXPORT const gchar * fl_value_get_string(FlValue *self)
Definition fl_value.cc:682
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition fl_value.h:42
@ FL_VALUE_TYPE_STRING
Definition fl_value.h:68
@ FL_VALUE_TYPE_INT
Definition fl_value.h:66
G_BEGIN_DECLS FlutterViewId view_id
std::shared_ptr< const fml::Mapping > data

References assertiveness, data, FL_ASSERTIVENESS_POLITE, fl_value_get_int(), fl_value_get_string(), fl_value_get_type(), fl_value_lookup_string(), FL_VALUE_TYPE_INT, FL_VALUE_TYPE_STRING, kAssertivenessKey, kMessageKey, kTextDirectionKey, kViewIdKey, message, parse_assertiveness(), parse_text_direction(), self, text_direction, and view_id.

Referenced by process_message().

◆ process_message()

static void process_message ( FlAccessibilityChannel *  self,
FlValue message 
)
static

Definition at line 106 of file fl_accessibility_channel.cc.

106 {
108 g_warning("Got invalid accessibility event message type");
109 return;
110 }
111
113 if (type_value == nullptr) {
114 g_warning("Accessibility event missing type");
115 return;
116 }
117 if (fl_value_get_type(type_value) != FL_VALUE_TYPE_STRING) {
118 g_warning("Got invalid accessibility event type");
119 return;
120 }
121 const char* type = fl_value_get_string(type_value);
122
124 if (data == nullptr) {
125 g_warning("Accessibility event missing data");
126 return;
127 }
129 g_warning("Got invalid accessibility data type");
130 return;
131 }
132
133 if (strcmp(type, kAnnounceType) == 0) {
135 } else if (strcmp(type, kTooltipType) == 0) {
136 } else if (strcmp(type, kLongPressType) == 0) {
137 } else if (strcmp(type, kTapType) == 0) {
138 // Only used by Android
139 } else if (strcmp(type, kFocusType) == 0) {
140 // Only used by Android and iOS.
141 } else {
142 // Silently ignore unknown types.
143 }
144}
GLenum type
static constexpr char kFocusType[]
static constexpr char kTapType[]
static constexpr char kTooltipType[]
static constexpr char kTypeKey[]
static void process_announce(FlAccessibilityChannel *self, FlValue *data)
static constexpr char kDataKey[]
static constexpr char kLongPressType[]
static constexpr char kAnnounceType[]
@ FL_VALUE_TYPE_MAP
Definition fl_value.h:74

References data, fl_value_get_string(), fl_value_get_type(), fl_value_lookup_string(), FL_VALUE_TYPE_MAP, FL_VALUE_TYPE_STRING, kAnnounceType, kDataKey, kFocusType, kLongPressType, kTapType, kTooltipType, kTypeKey, message, process_announce(), self, and type.

Referenced by message_cb().

Variable Documentation

◆ kAnnounceType

constexpr char kAnnounceType[] = "announce"
staticconstexpr

Definition at line 14 of file fl_accessibility_channel.cc.

Referenced by process_message().

◆ kAssertivenessKey

constexpr char kAssertivenessKey[] = "assertiveness"
staticconstexpr

Definition at line 23 of file fl_accessibility_channel.cc.

Referenced by process_announce().

◆ kChannelName

constexpr char kChannelName[] = "flutter/accessibility"
staticconstexpr

Definition at line 9 of file fl_accessibility_channel.cc.

Referenced by fl_accessibility_channel_new().

◆ kDataKey

constexpr char kDataKey[] = "data"
staticconstexpr

◆ kFocusType

constexpr char kFocusType[] = "focus"
staticconstexpr

Definition at line 18 of file fl_accessibility_channel.cc.

Referenced by process_message().

◆ kLongPressType

constexpr char kLongPressType[] = "longPress"
staticconstexpr

Definition at line 16 of file fl_accessibility_channel.cc.

Referenced by process_message().

◆ kMessageKey

constexpr char kMessageKey[] = "message"
staticconstexpr

Definition at line 21 of file fl_accessibility_channel.cc.

Referenced by process_announce().

◆ kTapType

constexpr char kTapType[] = "tap"
staticconstexpr

Definition at line 17 of file fl_accessibility_channel.cc.

Referenced by process_message().

◆ kTextDirectionKey

constexpr char kTextDirectionKey[] = "textDirection"
staticconstexpr

Definition at line 22 of file fl_accessibility_channel.cc.

Referenced by process_announce().

◆ kTooltipType

constexpr char kTooltipType[] = "tooltip"
staticconstexpr

Definition at line 15 of file fl_accessibility_channel.cc.

Referenced by process_message().

◆ kTypeKey

constexpr char kTypeKey[] = "type"
staticconstexpr

Definition at line 11 of file fl_accessibility_channel.cc.

Referenced by process_message().

◆ kViewIdKey

constexpr char kViewIdKey[] = "viewId"
staticconstexpr

Definition at line 20 of file fl_accessibility_channel.cc.

Referenced by process_announce().