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
19 changes: 2 additions & 17 deletions lib/ui/hooks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void _updateAccessibilityFeatures(int values) {
if (newFeatures == window._accessibilityFeatures)
return;
window._accessibilityFeatures = newFeatures;
_invoke(window.onAccessibilityFeaturesChanged, window._onAccessibilityFlagsChangedZone);
_invoke(window.onAccessibilityFeaturesChanged, window._onAccessibilityFeaturesChangedZone);
}

@pragma('vm:entry-point')
Expand Down Expand Up @@ -276,22 +276,7 @@ void _invoke1<A>(void callback(A a), Zone zone, A arg) {
}
}

/// Invokes [callback] inside the given [zone] passing it [arg1] and [arg2].
// ignore: unused_element
void _invoke2<A1, A2>(void callback(A1 a1, A2 a2), Zone zone, A1 arg1, A2 arg2) {
if (callback == null)
return;

assert(zone != null);

if (identical(zone, Zone.current)) {
callback(arg1, arg2);
} else {
zone.runBinaryGuarded<A1, A2>(callback, arg1, arg2);
}
}

/// Invokes [callback] inside the given [zone] passing it [arg1], [arg2] and [arg3].
/// Invokes [callback] inside the given [zone] passing it [arg1], [arg2], and [arg3].
void _invoke3<A1, A2, A3>(void callback(A1 a1, A2 a2, A3 a3), Zone zone, A1 arg1, A2 arg2, A3 arg3) {
if (callback == null)
return;
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1098,10 +1098,10 @@ class Window {
/// callback was set.
VoidCallback get onAccessibilityFeaturesChanged => _onAccessibilityFeaturesChanged;
VoidCallback _onAccessibilityFeaturesChanged;
Zone _onAccessibilityFlagsChangedZone;
Zone _onAccessibilityFeaturesChangedZone;
set onAccessibilityFeaturesChanged(VoidCallback callback) {
_onAccessibilityFeaturesChanged = callback;
_onAccessibilityFlagsChangedZone = Zone.current;
_onAccessibilityFeaturesChangedZone = Zone.current;
}

/// Change the retained semantics data about this window.
Expand Down
10 changes: 5 additions & 5 deletions lib/web_ui/lib/src/engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,17 @@ void webOnlyInitializeEngine() {
// microsecond precision, and only then convert to `int`.
final int highResTimeMicroseconds = (1000 * highResTime).toInt();

if (ui.window.onBeginFrame != null) {
ui.window
.onBeginFrame(Duration(microseconds: highResTimeMicroseconds));
if (window._onBeginFrame != null) {
window
.invokeOnBeginFrame(Duration(microseconds: highResTimeMicroseconds));
}

if (ui.window.onDrawFrame != null) {
if (window._onDrawFrame != null) {
// TODO(yjbanov): technically Flutter flushes microtasks between
// onBeginFrame and onDrawFrame. We don't, which hasn't
// been an issue yet, but eventually we'll have to
// implement it properly.
ui.window.onDrawFrame();
window.invokeOnDrawFrame();
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions lib/web_ui/lib/src/engine/dom_renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,8 @@ flt-glass-pane * {
/// Called immediately after browser window metrics change.
void _metricsDidChange(html.Event event) {
window._computePhysicalSize();
if (ui.window.onMetricsChanged != null) {
ui.window.onMetricsChanged();
if (window._onMetricsChanged != null) {
window.invokeOnMetricsChanged();
}
}

Expand Down
8 changes: 4 additions & 4 deletions lib/web_ui/lib/src/engine/history.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ class BrowserHistory {
_setupFlutterEntry(_locationStrategy);

// 2. Send a 'popRoute' platform message so the app can handle it accordingly.
if (ui.window.onPlatformMessage != null) {
ui.window.onPlatformMessage(
if (window._onPlatformMessage != null) {
window.invokeOnPlatformMessage(
'flutter/navigation',
const JSONMethodCodec().encodeMethodCall(_popRouteMethodCall),
(_) {},
Expand All @@ -113,8 +113,8 @@ class BrowserHistory {
_userProvidedRouteName = null;

// Send a 'pushRoute' platform message so the app handles it accordingly.
if (ui.window.onPlatformMessage != null) {
ui.window.onPlatformMessage(
if (window._onPlatformMessage != null) {
window.invokeOnPlatformMessage(
'flutter/navigation',
const JSONMethodCodec().encodeMethodCall(
MethodCall('pushRoute', newRouteName),
Expand Down
4 changes: 2 additions & 2 deletions lib/web_ui/lib/src/engine/keyboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Keyboard {
static const JSONMessageCodec _messageCodec = JSONMessageCodec();

void _handleHtmlEvent(html.KeyboardEvent event) {
if (ui.window.onPlatformMessage == null) {
if (window._onPlatformMessage == null) {
return;
}

Expand All @@ -88,7 +88,7 @@ class Keyboard {
'metaState': _getMetaState(event),
};

ui.window.onPlatformMessage('flutter/keyevent',
window.invokeOnPlatformMessage('flutter/keyevent',
_messageCodec.encodeMessage(eventData), _noopCallback);
}

Expand Down
5 changes: 2 additions & 3 deletions lib/web_ui/lib/src/engine/pointer_binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@ class PointerBinding {

void _onPointerData(Iterable<ui.PointerData> data) {
final ui.PointerDataPacket packet = ui.PointerDataPacket(data: data.toList());
final ui.PointerDataPacketCallback callback = ui.window.onPointerDataPacket;
if (callback != null) {
callback(packet);
if (window._onPointerDataPacket != null) {
window.invokeOnPointerDataPacket(packet);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/web_ui/lib/src/engine/semantics/incrementable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ class Incrementable extends RoleManager {
final int newInputValue = int.parse(_element.value);
if (newInputValue > _currentSurrogateValue) {
_currentSurrogateValue += 1;
ui.window.onSemanticsAction(
window.invokeOnSemanticsAction(
semanticsObject.id, ui.SemanticsAction.increase, null);
} else if (newInputValue < _currentSurrogateValue) {
_currentSurrogateValue -= 1;
ui.window.onSemanticsAction(
window.invokeOnSemanticsAction(
semanticsObject.id, ui.SemanticsAction.decrease, null);
}
});
Expand Down
8 changes: 4 additions & 4 deletions lib/web_ui/lib/src/engine/semantics/scrollable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ class Scrollable extends RoleManager {
final int semanticsId = semanticsObject.id;
if (doScrollForward) {
if (semanticsObject.isVerticalScrollContainer) {
ui.window.onSemanticsAction(
window.invokeOnSemanticsAction(
semanticsId, ui.SemanticsAction.scrollUp, null);
} else {
assert(semanticsObject.isHorizontalScrollContainer);
ui.window.onSemanticsAction(
window.invokeOnSemanticsAction(
semanticsId, ui.SemanticsAction.scrollLeft, null);
}
} else {
if (semanticsObject.isVerticalScrollContainer) {
ui.window.onSemanticsAction(
window.invokeOnSemanticsAction(
semanticsId, ui.SemanticsAction.scrollDown, null);
} else {
assert(semanticsObject.isHorizontalScrollContainer);
ui.window.onSemanticsAction(
window.invokeOnSemanticsAction(
semanticsId, ui.SemanticsAction.scrollRight, null);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/web_ui/lib/src/engine/semantics/semantics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1236,8 +1236,8 @@ class EngineSemanticsOwner {
_gestureModeClock?.datetime = null;
}

if (ui.window.onSemanticsEnabledChanged != null) {
ui.window.onSemanticsEnabledChanged();
if (window._onSemanticsEnabledChanged != null) {
window.invokeOnSemanticsEnabledChanged();
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/engine/semantics/tappable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Tappable extends RoleManager {
GestureMode.browserGestures) {
return;
}
ui.window.onSemanticsAction(
window.invokeOnSemanticsAction(
semanticsObject.id, ui.SemanticsAction.tap, null);
};
element.addEventListener('click', _clickListener);
Expand Down
6 changes: 3 additions & 3 deletions lib/web_ui/lib/src/engine/semantics/text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ class TextField extends RoleManager {
}

textEditing.useCustomEditableElement(textEditingElement);
ui.window
.onSemanticsAction(semanticsObject.id, ui.SemanticsAction.tap, null);
window
.invokeOnSemanticsAction(semanticsObject.id, ui.SemanticsAction.tap, null);
});
}

Expand Down Expand Up @@ -187,7 +187,7 @@ class TextField extends RoleManager {

if (offsetX * offsetX + offsetY * offsetY < kTouchSlop) {
// Recognize it as a tap that requires a keyboard.
ui.window.onSemanticsAction(
window.invokeOnSemanticsAction(
semanticsObject.id, ui.SemanticsAction.tap, null);
}
} else {
Expand Down
12 changes: 6 additions & 6 deletions lib/web_ui/lib/src/engine/text_editing/text_editing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -823,8 +823,8 @@ class TextEditingChannel {

/// Sends the 'TextInputClient.updateEditingState' message to the framework.
void updateEditingState(int clientId, EditingState editingState) {
if (ui.window.onPlatformMessage != null) {
ui.window.onPlatformMessage(
if (window._onPlatformMessage != null) {
window.invokeOnPlatformMessage(
'flutter/textinput',
const JSONMethodCodec().encodeMethodCall(
MethodCall('TextInputClient.updateEditingState', <dynamic>[
Expand All @@ -839,8 +839,8 @@ class TextEditingChannel {

/// Sends the 'TextInputClient.performAction' message to the framework.
void performAction(int clientId, String inputAction) {
if (ui.window.onPlatformMessage != null) {
ui.window.onPlatformMessage(
if (window._onPlatformMessage != null) {
window.invokeOnPlatformMessage(
'flutter/textinput',
const JSONMethodCodec().encodeMethodCall(
MethodCall(
Expand All @@ -855,8 +855,8 @@ class TextEditingChannel {

/// Sends the 'TextInputClient.onConnectionClosed' message to the framework.
void onConnectionClosed(int clientId) {
if (ui.window.onPlatformMessage != null) {
ui.window.onPlatformMessage(
if (window._onPlatformMessage != null) {
window.invokeOnPlatformMessage(
'flutter/textinput',
const JSONMethodCodec().encodeMethodCall(
MethodCall(
Expand Down
11 changes: 11 additions & 0 deletions lib/web_ui/lib/src/engine/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -444,3 +444,14 @@ void applyWebkitClipFix(html.Element containerElement) {
containerElement.style.zIndex = '0';
}
}

final ByteData _fontChangeMessage = JSONMessageCodec().encodeMessage(<String, dynamic>{'type': 'fontsChange'});

FutureOr<void> sendFontChangeMessage() async {
if (window._onPlatformMessage != null)
window.invokeOnPlatformMessage(
'flutter/system',
_fontChangeMessage,
(_) {},
);
}
Loading