Skip to content

Commit

Permalink
SemanticsUpdateBuilder migration: introduce identifier (#48882)
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
bartekpacia authored Dec 11, 2023
1 parent c660860 commit b864fdf
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
2 changes: 2 additions & 0 deletions lib/ui/fixtures/ui_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ external void _validateVertices(Vertices vertices);
@pragma('vm:entry-point')
void sendSemanticsUpdate() {
final SemanticsUpdateBuilder builder = SemanticsUpdateBuilder();
final String identifier = "identifier";
final String label = "label";
final List<StringAttribute> labelAttributes = <StringAttribute> [
SpellOutStringAttribute(range: TextRange(start: 1, end: 2)),
Expand Down Expand Up @@ -212,6 +213,7 @@ void sendSemanticsUpdate() {
rect: Rect.fromLTRB(0, 0, 10, 10),
elevation: 0,
thickness: 0,
identifier: identifier,
label: label,
labelAttributes: labelAttributes,
value: value,
Expand Down
9 changes: 3 additions & 6 deletions lib/ui/semantics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,7 @@ abstract class SemanticsUpdateBuilder {
required double elevation,
required double thickness,
required Rect rect,
// TODO(bartekpacia): Re-add once migration is complete
// String identifier,
required String identifier,
required String label,
required List<StringAttribute> labelAttributes,
required String value,
Expand Down Expand Up @@ -878,8 +877,7 @@ base class _NativeSemanticsUpdateBuilder extends NativeFieldWrapperClass1 implem
required double elevation,
required double thickness,
required Rect rect,
// TODO(bartekpacia): Re-add once migration is complete
// String identifier,
required String identifier,
required String label,
required List<StringAttribute> labelAttributes,
required String value,
Expand Down Expand Up @@ -918,8 +916,7 @@ base class _NativeSemanticsUpdateBuilder extends NativeFieldWrapperClass1 implem
rect.bottom,
elevation,
thickness,
// TODO(bartekpacia): Pass real identifier parameter once migration is complete
'',
identifier,
label,
labelAttributes,
value,
Expand Down
6 changes: 2 additions & 4 deletions lib/web_ui/lib/semantics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,7 @@ class SemanticsUpdateBuilder {
required double elevation,
required double thickness,
required Rect rect,
// TODO(bartekpacia): Re-add once migration is complete
// String identifier,
required String identifier,
required String label,
required List<StringAttribute> labelAttributes,
required String value,
Expand Down Expand Up @@ -396,8 +395,7 @@ class SemanticsUpdateBuilder {
scrollExtentMax: scrollExtentMax,
scrollExtentMin: scrollExtentMin,
rect: rect,
// TODO(bartekpacia): Pass real identifier parameter once migration is complete
identifier: '',
identifier: identifier,
label: label,
labelAttributes: labelAttributes,
value: value,
Expand Down
3 changes: 1 addition & 2 deletions lib/web_ui/test/engine/semantics/semantics_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3097,8 +3097,7 @@ void updateNode(
elevation: elevation,
thickness: thickness,
rect: rect,
// TODO(bartekpacia): Pass real identifier parameter once migration is complete
// identifier: '',
identifier: identifier,
label: label,
labelAttributes: labelAttributes,
hint: hint,
Expand Down
5 changes: 5 additions & 0 deletions shell/platform/embedder/fixtures/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Future<void> a11y_main() async {
final SemanticsUpdateBuilder builder = SemanticsUpdateBuilder()
..updateNode(
id: 42,
identifier: '',
label: 'A: root',
labelAttributes: <StringAttribute>[],
rect: Rect.fromLTRB(0.0, 0.0, 10.0, 10.0),
Expand Down Expand Up @@ -170,6 +171,7 @@ Future<void> a11y_main() async {
)
..updateNode(
id: 84,
identifier: '',
label: 'B: leaf',
labelAttributes: <StringAttribute>[],
rect: Rect.fromLTRB(40.0, 40.0, 80.0, 80.0),
Expand Down Expand Up @@ -203,6 +205,7 @@ Future<void> a11y_main() async {
)
..updateNode(
id: 96,
identifier: '',
label: 'C: branch',
labelAttributes: <StringAttribute>[],
rect: Rect.fromLTRB(40.0, 40.0, 80.0, 80.0),
Expand Down Expand Up @@ -236,6 +239,7 @@ Future<void> a11y_main() async {
)
..updateNode(
id: 128,
identifier: '',
label: 'D: leaf',
labelAttributes: <StringAttribute>[],
rect: Rect.fromLTRB(40.0, 40.0, 80.0, 80.0),
Expand Down Expand Up @@ -301,6 +305,7 @@ Future<void> a11y_string_attributes() async {
final SemanticsUpdateBuilder builder = SemanticsUpdateBuilder()
..updateNode(
id: 42,
identifier: 'identifier',
label: 'What is the meaning of life?',
labelAttributes: <StringAttribute>[
LocaleStringAttribute(
Expand Down
2 changes: 2 additions & 0 deletions testing/scenario_app/lib/src/locale_initialization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class LocaleInitialization extends Scenario {
// SemanticsAction.tap.
actions: 1,
rect: const Rect.fromLTRB(0.0, 0.0, 414.0, 48.0),
identifier: '',
label: view.platformDispatcher.locales.toString(),
labelAttributes: <StringAttribute>[],
textDirection: TextDirection.ltr,
Expand Down Expand Up @@ -107,6 +108,7 @@ class LocaleInitialization extends Scenario {
// SemanticsAction.tap.
actions: 1,
rect: const Rect.fromLTRB(0.0, 0.0, 414.0, 48.0),
identifier: '',
label: label,
labelAttributes: <StringAttribute>[],
textDirection: TextDirection.ltr,
Expand Down

0 comments on commit b864fdf

Please sign in to comment.