Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions lib/ui/fixtures/ui_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -826,27 +826,6 @@ void hooksTests() async {
expectEquals(enabled, newValue);
});

await test('onSemanticsAction preserves callback zone', () {
late Zone innerZone;
late Zone runZone;
late int id;
late int action;

runZoned(() {
innerZone = Zone.current;
window.onSemanticsAction = (int i, SemanticsAction a, ByteData? _) {
runZone = Zone.current;
action = a.index;
id = i;
};
});

_callHook('_dispatchSemanticsAction', 3, 1234, 4, null);
expectIdentical(runZone, innerZone);
expectEquals(id, 1234);
expectEquals(action, 4);
});

await test('onSemanticsActionEvent preserves callback zone', () {
late Zone innerZone;
late Zone runZone;
Expand Down
28 changes: 0 additions & 28 deletions lib/ui/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ typedef PointerDataPacketCallback = void Function(PointerDataPacket packet);
/// framework and should not be propagated further.
typedef KeyDataCallback = bool Function(KeyData data);

/// Signature for [PlatformDispatcher.onSemanticsAction].
// TODO(goderbauer): Deprecate/remove this when the framework has migrated to SemanticsActionEventCallback.
typedef SemanticsActionCallback = void Function(int nodeId, SemanticsAction action, ByteData? args);

/// Signature for [PlatformDispatcher.onSemanticsActionEvent].
typedef SemanticsActionEventCallback = void Function(SemanticsActionEvent action);

Expand Down Expand Up @@ -1151,23 +1147,6 @@ class PlatformDispatcher {
_invoke(onSemanticsEnabledChanged, _onSemanticsEnabledChangedZone);
}

/// A callback that is invoked whenever the user requests an action to be
/// performed on a semantics node.
///
/// This callback is used when the user expresses the action they wish to
/// perform based on the semantics node supplied by updateSemantics.
///
/// The framework invokes this callback in the same zone in which the
/// callback was set.
// TODO(goderbauer): Deprecate/remove this when the framework has migrated to onSemanticsActionEvent.
SemanticsActionCallback? get onSemanticsAction => _onSemanticsAction;
SemanticsActionCallback? _onSemanticsAction;
Zone _onSemanticsActionZone = Zone.root;
set onSemanticsAction(SemanticsActionCallback? callback) {
_onSemanticsAction = callback;
_onSemanticsActionZone = Zone.current;
}

/// A callback that is invoked whenever the user requests an action to be
/// performed on a semantics node.
///
Expand Down Expand Up @@ -1209,13 +1188,6 @@ class PlatformDispatcher {

// Called from the engine, via hooks.dart
void _dispatchSemanticsAction(int nodeId, int action, ByteData? args) {
_invoke3<int, SemanticsAction, ByteData?>(
onSemanticsAction,
_onSemanticsActionZone,
nodeId,
SemanticsAction.fromIndex(action)!,
args,
);
_invoke1<SemanticsActionEvent>(
onSemanticsActionEvent,
_onSemanticsActionEventZone,
Expand Down
9 changes: 5 additions & 4 deletions lib/ui/semantics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,11 @@ abstract class SemanticsUpdateBuilder {
///
/// The `actions` are a bit field of [SemanticsAction]s that can be undertaken
/// by this node. If the user wishes to undertake one of these actions on this
/// node, the [PlatformDispatcher.onSemanticsAction] will be called with `id`
/// and one of the possible [SemanticsAction]s. Because the semantics tree is
/// maintained asynchronously, the [PlatformDispatcher.onSemanticsAction]
/// callback might be called with an action that is no longer possible.
/// node, the [PlatformDispatcher.onSemanticsActionEvent] will be called with
/// a [SemanticsActionEvent] specifying the action to be performed. Because
/// the semantics tree is maintained asynchronously, the
/// [PlatformDispatcher.onSemanticsActionEvent] callback might be called with
/// an action that is no longer possible.
///
/// The `label` is a string that describes this node. The `value` property
/// describes the current value of the node as a string. The `increasedValue`
Expand Down
15 changes: 0 additions & 15 deletions lib/ui/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -756,21 +756,6 @@ class SingletonFlutterWindow extends FlutterView {
platformDispatcher.onFrameDataChanged = callback;
}

/// A callback that is invoked whenever the user requests an action to be
/// performed.
///
/// {@macro dart.ui.window.accessorForwardWarning}
///
/// This callback is used when the user expresses the action they wish to
/// perform based on the semantics supplied by [updateSemantics].
///
/// The framework invokes this callback in the same zone in which the
/// callback was set.
SemanticsActionCallback? get onSemanticsAction => platformDispatcher.onSemanticsAction;
set onSemanticsAction(SemanticsActionCallback? callback) {
platformDispatcher.onSemanticsAction = callback;
}

/// Additional accessibility features that may be enabled by the platform.
AccessibilityFeatures get accessibilityFeatures => platformDispatcher.accessibilityFeatures;

Expand Down
4 changes: 0 additions & 4 deletions lib/web_ui/lib/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ typedef FrameCallback = void Function(Duration duration);
typedef TimingsCallback = void Function(List<FrameTiming> timings);
typedef PointerDataPacketCallback = void Function(PointerDataPacket packet);
typedef KeyDataCallback = bool Function(KeyData data);
typedef SemanticsActionCallback = void Function(int nodeId, SemanticsAction action, ByteData? args);
typedef SemanticsActionEventCallback = void Function(SemanticsActionEvent action);
typedef PlatformMessageResponseCallback = void Function(ByteData? data);
typedef PlatformMessageCallback = void Function(
Expand Down Expand Up @@ -135,9 +134,6 @@ abstract class PlatformDispatcher {
VoidCallback? get onSemanticsEnabledChanged;
set onSemanticsEnabledChanged(VoidCallback? callback);

SemanticsActionCallback? get onSemanticsAction;
set onSemanticsAction(SemanticsActionCallback? callback);

SemanticsActionEventCallback? get onSemanticsActionEvent;
set onSemanticsActionEvent(SemanticsActionEventCallback? callback);

Expand Down
20 changes: 0 additions & 20 deletions lib/web_ui/lib/src/engine/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1193,24 +1193,6 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
invoke(_onSemanticsEnabledChanged, _onSemanticsEnabledChangedZone);
}

/// A callback that is invoked whenever the user requests an action to be
/// performed.
///
/// This callback is used when the user expresses the action they wish to
/// perform based on the semantics supplied by [updateSemantics].
///
/// The framework invokes this callback in the same zone in which the
/// callback was set.
@override
ui.SemanticsActionCallback? get onSemanticsAction => _onSemanticsAction;
ui.SemanticsActionCallback? _onSemanticsAction;
Zone? _onSemanticsActionZone;
@override
set onSemanticsAction(ui.SemanticsActionCallback? callback) {
_onSemanticsAction = callback;
_onSemanticsActionZone = Zone.current;
}

/// A callback that is invoked whenever the user requests an action to be
/// performed on a semantics node.
///
Expand All @@ -1233,8 +1215,6 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
/// Otherwise zones won't work properly.
void invokeOnSemanticsAction(
int nodeId, ui.SemanticsAction action, ByteData? args) {
invoke3<int, ui.SemanticsAction, ByteData?>(
_onSemanticsAction, _onSemanticsActionZone, nodeId, action, args);
invoke1<ui.SemanticsActionEvent>(
_onSemanticsActionEvent, _onSemanticsActionEventZone, ui.SemanticsActionEvent(
type: action,
Expand Down
5 changes: 0 additions & 5 deletions lib/web_ui/lib/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ abstract class SingletonFlutterWindow extends FlutterView {
platformDispatcher.onSemanticsEnabledChanged = callback;
}

SemanticsActionCallback? get onSemanticsAction => platformDispatcher.onSemanticsAction;
set onSemanticsAction(SemanticsActionCallback? callback) {
platformDispatcher.onSemanticsAction = callback;
}

FrameData get frameData => const FrameData._();

VoidCallback? get onFrameDataChanged => null;
Expand Down
28 changes: 14 additions & 14 deletions lib/web_ui/test/engine/semantics/semantics_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1102,12 +1102,12 @@ void _testVerticalScrolling() {
// fired.
final Zone testZone = Zone.current;

ui.window.onSemanticsAction =
(int id, ui.SemanticsAction action, ByteData? args) {
idLogController.add(id);
actionLogController.add(action);
ui.PlatformDispatcher.instance.onSemanticsActionEvent =
(ui.SemanticsActionEvent event) {
idLogController.add(event.nodeId);
actionLogController.add(event.type);
testZone.run(() {
expect(args, null);
expect(event.arguments, null);
});
};
semantics()
Expand Down Expand Up @@ -1459,8 +1459,8 @@ void _testIncrementables() {
}

final List<CapturedAction> capturedActions = <CapturedAction>[];
EnginePlatformDispatcher.instance.onSemanticsAction = (int nodeId, ui.SemanticsAction action, ByteData? args) {
capturedActions.add((nodeId, action, args));
EnginePlatformDispatcher.instance.onSemanticsActionEvent = (ui.SemanticsActionEvent event) {
capturedActions.add((event.nodeId, event.type, event.arguments));
};

pumpSemantics(isFocused: false);
Expand Down Expand Up @@ -1814,8 +1814,8 @@ void _testCheckables() {
}

final List<CapturedAction> capturedActions = <CapturedAction>[];
EnginePlatformDispatcher.instance.onSemanticsAction = (int nodeId, ui.SemanticsAction action, ByteData? args) {
capturedActions.add((nodeId, action, args));
EnginePlatformDispatcher.instance.onSemanticsActionEvent = (ui.SemanticsActionEvent event) {
capturedActions.add((event.nodeId, event.type, event.arguments));
};

pumpSemantics(isFocused: false);
Expand Down Expand Up @@ -1973,8 +1973,8 @@ void _testTappable() {
}

final List<CapturedAction> capturedActions = <CapturedAction>[];
EnginePlatformDispatcher.instance.onSemanticsAction = (int nodeId, ui.SemanticsAction action, ByteData? args) {
capturedActions.add((nodeId, action, args));
EnginePlatformDispatcher.instance.onSemanticsActionEvent = (ui.SemanticsActionEvent event) {
capturedActions.add((event.nodeId, event.type, event.arguments));
};

pumpSemantics(isFocused: false);
Expand Down Expand Up @@ -2634,7 +2634,7 @@ void _testDialog() {
});
}

typedef CapturedAction = (int nodeId, ui.SemanticsAction action, ByteData? args);
typedef CapturedAction = (int nodeId, ui.SemanticsAction action, Object? args);

void _testFocusable() {
test('AccessibilityFocusManager can manage element focus', () async {
Expand All @@ -2656,8 +2656,8 @@ void _testFocusable() {
}

final List<CapturedAction> capturedActions = <CapturedAction>[];
EnginePlatformDispatcher.instance.onSemanticsAction = (int nodeId, ui.SemanticsAction action, ByteData? args) {
capturedActions.add((nodeId, action, args));
EnginePlatformDispatcher.instance.onSemanticsActionEvent = (ui.SemanticsActionEvent event) {
capturedActions.add((event.nodeId, event.type, event.arguments));
};
expect(capturedActions, isEmpty);

Expand Down
10 changes: 5 additions & 5 deletions lib/web_ui/test/engine/semantics/semantics_tester.dart
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,12 @@ class SemanticsActionLogger {
// fired.
final Zone testZone = Zone.current;

ui.window.onSemanticsAction =
(int id, ui.SemanticsAction action, ByteData? args) {
_idLogController.add(id);
_actionLogController.add(action);
ui.PlatformDispatcher.instance.onSemanticsActionEvent =
(ui.SemanticsActionEvent event) {
_idLogController.add(event.nodeId);
_actionLogController.add(event.type);
testZone.run(() {
expect(args, null);
expect(event.arguments, null);
});
};
}
Expand Down
8 changes: 4 additions & 4 deletions lib/web_ui/test/engine/window_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,17 @@ Future<void> testMain() async {
EnginePlatformDispatcher.instance.invokeOnSemanticsEnabledChanged();
});

test('onSemanticsAction preserves the zone', () {
test('onSemanticsActionEvent preserves the zone', () {
final Zone innerZone = Zone.current.fork();

innerZone.runGuarded(() {
void callback(int _, ui.SemanticsAction __, ByteData? ___) {
void callback(ui.SemanticsActionEvent _) {
expect(Zone.current, innerZone);
}
window.onSemanticsAction = callback;
ui.PlatformDispatcher.instance.onSemanticsActionEvent = callback;

// Test that the getter returns the exact same callback, e.g. it doesn't wrap it.
expect(window.onSemanticsAction, same(callback));
expect(ui.PlatformDispatcher.instance.onSemanticsActionEvent, same(callback));
});

EnginePlatformDispatcher.instance.invokeOnSemanticsAction(0, ui.SemanticsAction.tap, null);
Expand Down