Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b864fdf

Browse files
authored
SemanticsUpdateBuilder migration: introduce identifier (#48882)
This PR adds `String? identifier` to `SemanticsUpdateBuilder` (currently it's only available in the temproary `SemanticsUpdateBuilderNew` API. This is mainly targeted at flutter/flutter#17988 Steps: part 1: [engine] add `SemanticsUpdateBuilderNew` #47961 part 2: [flutter] use `SemanticsUpdateBuilderNew` flutter/flutter#138331 **part 3: [engine] update `SemanticsUpdateBuilder` to be the same as `SemanticsUpdateBuilderNew`** <-- we are here part 4: [flutter] use (now updated) `SemanticsUpdateBuilder` again. part 5: [engine] remove `SemanticsBuilderNew`
1 parent c660860 commit b864fdf

6 files changed

Lines changed: 15 additions & 12 deletions

File tree

lib/ui/fixtures/ui_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ external void _validateVertices(Vertices vertices);
145145
@pragma('vm:entry-point')
146146
void sendSemanticsUpdate() {
147147
final SemanticsUpdateBuilder builder = SemanticsUpdateBuilder();
148+
final String identifier = "identifier";
148149
final String label = "label";
149150
final List<StringAttribute> labelAttributes = <StringAttribute> [
150151
SpellOutStringAttribute(range: TextRange(start: 1, end: 2)),
@@ -212,6 +213,7 @@ void sendSemanticsUpdate() {
212213
rect: Rect.fromLTRB(0, 0, 10, 10),
213214
elevation: 0,
214215
thickness: 0,
216+
identifier: identifier,
215217
label: label,
216218
labelAttributes: labelAttributes,
217219
value: value,

lib/ui/semantics.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -807,8 +807,7 @@ abstract class SemanticsUpdateBuilder {
807807
required double elevation,
808808
required double thickness,
809809
required Rect rect,
810-
// TODO(bartekpacia): Re-add once migration is complete
811-
// String identifier,
810+
required String identifier,
812811
required String label,
813812
required List<StringAttribute> labelAttributes,
814813
required String value,
@@ -878,8 +877,7 @@ base class _NativeSemanticsUpdateBuilder extends NativeFieldWrapperClass1 implem
878877
required double elevation,
879878
required double thickness,
880879
required Rect rect,
881-
// TODO(bartekpacia): Re-add once migration is complete
882-
// String identifier,
880+
required String identifier,
883881
required String label,
884882
required List<StringAttribute> labelAttributes,
885883
required String value,
@@ -918,8 +916,7 @@ base class _NativeSemanticsUpdateBuilder extends NativeFieldWrapperClass1 implem
918916
rect.bottom,
919917
elevation,
920918
thickness,
921-
// TODO(bartekpacia): Pass real identifier parameter once migration is complete
922-
'',
919+
identifier,
923920
label,
924921
labelAttributes,
925922
value,

lib/web_ui/lib/semantics.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,7 @@ class SemanticsUpdateBuilder {
360360
required double elevation,
361361
required double thickness,
362362
required Rect rect,
363-
// TODO(bartekpacia): Re-add once migration is complete
364-
// String identifier,
363+
required String identifier,
365364
required String label,
366365
required List<StringAttribute> labelAttributes,
367366
required String value,
@@ -396,8 +395,7 @@ class SemanticsUpdateBuilder {
396395
scrollExtentMax: scrollExtentMax,
397396
scrollExtentMin: scrollExtentMin,
398397
rect: rect,
399-
// TODO(bartekpacia): Pass real identifier parameter once migration is complete
400-
identifier: '',
398+
identifier: identifier,
401399
label: label,
402400
labelAttributes: labelAttributes,
403401
value: value,

lib/web_ui/test/engine/semantics/semantics_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3097,8 +3097,7 @@ void updateNode(
30973097
elevation: elevation,
30983098
thickness: thickness,
30993099
rect: rect,
3100-
// TODO(bartekpacia): Pass real identifier parameter once migration is complete
3101-
// identifier: '',
3100+
identifier: identifier,
31023101
label: label,
31033102
labelAttributes: labelAttributes,
31043103
hint: hint,

shell/platform/embedder/fixtures/main.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ Future<void> a11y_main() async {
137137
final SemanticsUpdateBuilder builder = SemanticsUpdateBuilder()
138138
..updateNode(
139139
id: 42,
140+
identifier: '',
140141
label: 'A: root',
141142
labelAttributes: <StringAttribute>[],
142143
rect: Rect.fromLTRB(0.0, 0.0, 10.0, 10.0),
@@ -170,6 +171,7 @@ Future<void> a11y_main() async {
170171
)
171172
..updateNode(
172173
id: 84,
174+
identifier: '',
173175
label: 'B: leaf',
174176
labelAttributes: <StringAttribute>[],
175177
rect: Rect.fromLTRB(40.0, 40.0, 80.0, 80.0),
@@ -203,6 +205,7 @@ Future<void> a11y_main() async {
203205
)
204206
..updateNode(
205207
id: 96,
208+
identifier: '',
206209
label: 'C: branch',
207210
labelAttributes: <StringAttribute>[],
208211
rect: Rect.fromLTRB(40.0, 40.0, 80.0, 80.0),
@@ -236,6 +239,7 @@ Future<void> a11y_main() async {
236239
)
237240
..updateNode(
238241
id: 128,
242+
identifier: '',
239243
label: 'D: leaf',
240244
labelAttributes: <StringAttribute>[],
241245
rect: Rect.fromLTRB(40.0, 40.0, 80.0, 80.0),
@@ -301,6 +305,7 @@ Future<void> a11y_string_attributes() async {
301305
final SemanticsUpdateBuilder builder = SemanticsUpdateBuilder()
302306
..updateNode(
303307
id: 42,
308+
identifier: 'identifier',
304309
label: 'What is the meaning of life?',
305310
labelAttributes: <StringAttribute>[
306311
LocaleStringAttribute(

testing/scenario_app/lib/src/locale_initialization.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class LocaleInitialization extends Scenario {
4949
// SemanticsAction.tap.
5050
actions: 1,
5151
rect: const Rect.fromLTRB(0.0, 0.0, 414.0, 48.0),
52+
identifier: '',
5253
label: view.platformDispatcher.locales.toString(),
5354
labelAttributes: <StringAttribute>[],
5455
textDirection: TextDirection.ltr,
@@ -107,6 +108,7 @@ class LocaleInitialization extends Scenario {
107108
// SemanticsAction.tap.
108109
actions: 1,
109110
rect: const Rect.fromLTRB(0.0, 0.0, 414.0, 48.0),
111+
identifier: '',
110112
label: label,
111113
labelAttributes: <StringAttribute>[],
112114
textDirection: TextDirection.ltr,

0 commit comments

Comments
 (0)