Skip to content

Commit

Permalink
Revert "Deprecate single semantics tree assumption from platform disp…
Browse files Browse the repository at this point in the history
…atcher (#36675)"

This reverts commit 7e03ebc.
  • Loading branch information
zanderso committed Oct 10, 2022
1 parent e3f1d89 commit 8b0186b
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 56 deletions.
8 changes: 0 additions & 8 deletions lib/ui/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -758,14 +758,6 @@ class PlatformDispatcher {
///
/// In either case, this function disposes the given update, which means the
/// semantics update cannot be used further.
@Deprecated('''
In a multi-view world, the platform dispatcher can no longer provide apis
to update semantics since each view will host its own semantics tree.
Semantics updates must be passed to an individual [FlutterView]. To update
semantics, use PlatformDispatcher.instance.views to get a [FlutterView] and
call `updateSemantics`.
''')
void updateSemantics(SemanticsUpdate update) => _updateSemantics(update);

@FfiNative<Void Function(Pointer<Void>)>('PlatformConfigurationNativeApi::UpdateSemantics')
Expand Down
24 changes: 11 additions & 13 deletions lib/ui/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -266,19 +266,6 @@ abstract class FlutterView {

@FfiNative<Void Function(Pointer<Void>)>('PlatformConfigurationNativeApi::Render')
external static void _render(Scene scene);

/// Change the retained semantics data about this [FlutterView].
///
/// If [PlatformDispatcher.semanticsEnabled] is true, the user has requested that this function
/// be called whenever the semantic content of this [FlutterView]
/// changes.
///
/// This function disposes the given update, which means the semantics update
/// cannot be used further.
void updateSemantics(SemanticsUpdate update) => _updateSemantics(update);

@FfiNative<Void Function(Pointer<Void>)>('PlatformConfigurationNativeApi::UpdateSemantics')
external static void _updateSemantics(SemanticsUpdate update);
}

/// A top-level platform window displaying a Flutter layer tree drawn from a
Expand Down Expand Up @@ -734,6 +721,17 @@ class SingletonFlutterWindow extends FlutterWindow {
platformDispatcher.onAccessibilityFeaturesChanged = callback;
}

/// Change the retained semantics data about this window.
///
/// {@macro dart.ui.window.functionForwardWarning}
///
/// If [semanticsEnabled] is true, the user has requested that this function
/// be called whenever the semantic content of this window changes.
///
/// In either case, this function disposes the given update, which means the
/// semantics update cannot be used further.
void updateSemantics(SemanticsUpdate update) => platformDispatcher.updateSemantics(update);

/// Sends a message to a platform-specific plugin.
///
/// {@macro dart.ui.window.functionForwardWarning}
Expand Down
8 changes: 0 additions & 8 deletions lib/web_ui/lib/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ abstract class PlatformDispatcher {
VoidCallback? get onAccessibilityFeaturesChanged;
set onAccessibilityFeaturesChanged(VoidCallback? callback);

@Deprecated('''
In a multi-view world, the platform dispatcher can no longer provide apis
to update semantics since each view will host its own semantics tree.
Semantics updates must be passed to an individual [FlutterView]. To update
semantics, use PlatformDispatcher.instance.views to get a [FlutterView] and
call `updateSemantics`.
''')
void updateSemantics(SemanticsUpdate update);

Locale get locale;
Expand Down
8 changes: 0 additions & 8 deletions lib/web_ui/lib/src/engine/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -698,14 +698,6 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
/// In either case, this function disposes the given update, which means the
/// semantics update cannot be used further.
@override
@Deprecated('''
In a multi-view world, the platform dispatcher can no longer provide apis
to update semantics since each view will host its own semantics tree.
Semantics updates must be passed to an individual [FlutterView]. To update
semantics, use PlatformDispatcher.instance.views to get a [FlutterView] and
call `updateSemantics`.
''')
void updateSemantics(ui.SemanticsUpdate update) {
EngineSemanticsOwner.instance.updateSemantics(update);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/web_ui/lib/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ abstract class FlutterView {
WindowPadding get padding => viewConfiguration.padding;
List<DisplayFeature> get displayFeatures => viewConfiguration.displayFeatures;
void render(Scene scene) => platformDispatcher.render(scene, this);
void updateSemantics(SemanticsUpdate update) => platformDispatcher.updateSemantics(update);
}

abstract class FlutterWindow extends FlutterView {
Expand Down Expand Up @@ -131,6 +130,8 @@ abstract class SingletonFlutterWindow extends FlutterWindow {
platformDispatcher.onAccessibilityFeaturesChanged = callback;
}

void updateSemantics(SemanticsUpdate update) => platformDispatcher.updateSemantics(update);

void sendPlatformMessage(
String name,
ByteData? data,
Expand Down
4 changes: 1 addition & 3 deletions shell/platform/embedder/fixtures/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,7 @@ void a11y_main() async {
label: 'Archive',
hint: 'archive message',
);

PlatformDispatcher.instance.views.first.updateSemantics(builder.build());

PlatformDispatcher.instance.updateSemantics(builder.build());
signalNativeTest();

// Await semantics action from embedder.
Expand Down
23 changes: 8 additions & 15 deletions testing/scenario_app/lib/src/locale_initialization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class LocaleInitialization extends Scenario {
// On the first frame, pretend that it drew a text field. Send the
// corresponding semantics tree comprised of 1 node with the locale data
// as the label.
final SemanticsUpdateBuilder semanticsUpdateBuilder =
SemanticsUpdateBuilder()..updateNode(
window.updateSemantics((SemanticsUpdateBuilder()
..updateNode(
id: 0,
// SemanticsFlag.isTextField.
flags: 16,
Expand Down Expand Up @@ -79,11 +79,8 @@ class LocaleInitialization extends Scenario {
childrenInTraversalOrder: Int32List(0),
childrenInHitTestOrder: Int32List(0),
additionalActions: Int32List(0),
);

final SemanticsUpdate semanticsUpdate = semanticsUpdateBuilder.build();

dispatcher.views.first.updateSemantics(semanticsUpdate);
)).build()
);
}

/// Handle taps.
Expand All @@ -101,8 +98,8 @@ class LocaleInitialization extends Scenario {
// Expand for other test cases.
}

final SemanticsUpdateBuilder semanticsUpdateBuilder =
SemanticsUpdateBuilder()..updateNode(
window.updateSemantics((SemanticsUpdateBuilder()
..updateNode(
id: 0,
// SemanticsFlag.isTextField.
flags: 16,
Expand Down Expand Up @@ -137,12 +134,8 @@ class LocaleInitialization extends Scenario {
childrenInTraversalOrder: Int32List(0),
childrenInHitTestOrder: Int32List(0),
additionalActions: Int32List(0),
);

final SemanticsUpdate semanticsUpdate = semanticsUpdateBuilder.build();

dispatcher.views.first.updateSemantics(semanticsUpdate);

)).build()
);
_tapCount++;
}
}

0 comments on commit 8b0186b

Please sign in to comment.