Deprecate single semantics tree assumption from platform dispatcher (flutter/engine#36675)

This commit is contained in:
Alex Wallen
2022-10-10 11:41:16 -07:00
committed by GitHub
parent 3a8721cfa1
commit 3cd8b9eaa4
7 changed files with 56 additions and 22 deletions

View File

@@ -758,6 +758,14 @@ 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')

View File

@@ -266,6 +266,19 @@ 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
@@ -721,17 +734,6 @@ 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}

View File

@@ -83,6 +83,14 @@ 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;

View File

@@ -698,6 +698,14 @@ 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);
}

View File

@@ -16,6 +16,7 @@ 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 {
@@ -130,8 +131,6 @@ abstract class SingletonFlutterWindow extends FlutterWindow {
platformDispatcher.onAccessibilityFeaturesChanged = callback;
}
void updateSemantics(SemanticsUpdate update) => platformDispatcher.updateSemantics(update);
void sendPlatformMessage(
String name,
ByteData? data,

View File

@@ -264,7 +264,9 @@ void a11y_main() async {
label: 'Archive',
hint: 'archive message',
);
PlatformDispatcher.instance.updateSemantics(builder.build());
PlatformDispatcher.instance.views.first.updateSemantics(builder.build());
signalNativeTest();
// Await semantics action from embedder.

View File

@@ -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.
window.updateSemantics((SemanticsUpdateBuilder()
..updateNode(
final SemanticsUpdateBuilder semanticsUpdateBuilder =
SemanticsUpdateBuilder()..updateNode(
id: 0,
// SemanticsFlag.isTextField.
flags: 16,
@@ -79,8 +79,11 @@ class LocaleInitialization extends Scenario {
childrenInTraversalOrder: Int32List(0),
childrenInHitTestOrder: Int32List(0),
additionalActions: Int32List(0),
)).build()
);
);
final SemanticsUpdate semanticsUpdate = semanticsUpdateBuilder.build();
dispatcher.views.first.updateSemantics(semanticsUpdate);
}
/// Handle taps.
@@ -98,8 +101,8 @@ class LocaleInitialization extends Scenario {
// Expand for other test cases.
}
window.updateSemantics((SemanticsUpdateBuilder()
..updateNode(
final SemanticsUpdateBuilder semanticsUpdateBuilder =
SemanticsUpdateBuilder()..updateNode(
id: 0,
// SemanticsFlag.isTextField.
flags: 16,
@@ -134,8 +137,12 @@ class LocaleInitialization extends Scenario {
childrenInTraversalOrder: Int32List(0),
childrenInHitTestOrder: Int32List(0),
additionalActions: Int32List(0),
)).build()
);
);
final SemanticsUpdate semanticsUpdate = semanticsUpdateBuilder.build();
dispatcher.views.first.updateSemantics(semanticsUpdate);
_tapCount++;
}
}