diff --git a/analysis_options.yaml b/analysis_options.yaml index a92f9fb784c8f9e35be22667b12c8915c979655c..4bd9407504965e6e30de938ee8694cd3be1dfbfe 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -7,7 +7,7 @@ # - "sort_constructors_first" disabled (because we have private fake # constructors), # - "prefer_final_fields" disabled (because we do weird things with -# private fields, especially on the Window object): +# private fields, especially on the PlatformDispatcher object): analyzer: enable-experiment: diff --git a/common/settings.h b/common/settings.h index c956423ca89147c3fd9ef0e69b6d74866ac39e4e..e408454f5248fb5d0e93a810de3ee127b6b57f33 100644 --- a/common/settings.h +++ b/common/settings.h @@ -221,11 +221,11 @@ struct Settings { FrameRasterizedCallback frame_rasterized_callback; // This data will be available to the isolate immediately on launch via the - // Window.getPersistentIsolateData callback. This is meant for information - // that the isolate cannot request asynchronously (platform messages can be - // used for that purpose). This data is held for the lifetime of the shell and - // is available on isolate restarts in the shell instance. Due to this, - // the buffer must be as small as possible. + // PlatformDispatcher.getPersistentIsolateData callback. This is meant for + // information that the isolate cannot request asynchronously (platform + // messages can be used for that purpose). This data is held for the lifetime + // of the shell and is available on isolate restarts in the shell instance. + // Due to this, the buffer must be as small as possible. std::shared_ptr persistent_isolate_data; /// Max size of old gen heap size in MB, or 0 for unlimited, -1 for default diff --git a/lib/ui/window.dart b/lib/ui/window.dart index 7c8e514e0066e03931a847e7ccaa6a5d61dff6d2..f4795b057cf597b6af8138854ca7989d55e3ba42 100644 --- a/lib/ui/window.dart +++ b/lib/ui/window.dart @@ -795,220 +795,6 @@ class AccessibilityFeatures { int get hashCode => _index.hashCode; } -/// A soon-to-be deprecated class that is wholly replaced by -/// [SingletonFlutterWindow]. -/// -/// This class will be removed once the framework no longer refers to it. -// In order for the documentation build to succeed, this interface duplicates -// all of the methods with documentation, overrides them, and calls the super -// implementation. Once this merges into the framework and the framework -// references to it can be updated, this class will be removed entirely. -class Window extends SingletonFlutterWindow { - Window._(Object windowId, PlatformDispatcher platformDispatcher) - : super._(windowId, platformDispatcher); - - @override - // ignore: unnecessary_overrides - double get devicePixelRatio => super.devicePixelRatio; - - @override - // ignore: unnecessary_overrides - Rect get physicalGeometry => super.physicalGeometry; - - @override - // ignore: unnecessary_overrides - Size get physicalSize => super.physicalSize; - - @override - // ignore: unnecessary_overrides - WindowPadding get viewInsets => super.viewInsets; - - @override - // ignore: unnecessary_overrides - WindowPadding get viewPadding => super.viewPadding; - - @override - // ignore: unnecessary_overrides - WindowPadding get systemGestureInsets => super.systemGestureInsets; - - @override - // ignore: unnecessary_overrides - WindowPadding get padding => super.padding; - - @override - // ignore: unnecessary_overrides - void render(Scene scene) => super.render(scene); - - @override - // ignore: unnecessary_overrides - VoidCallback? get onMetricsChanged => super.onMetricsChanged; - @override - // ignore: unnecessary_overrides - set onMetricsChanged(VoidCallback? callback) { - super.onMetricsChanged = callback; - } - - @override - // ignore: unnecessary_overrides - Locale get locale => super.locale; - - @override - // ignore: unnecessary_overrides - List get locales => super.locales; - - @override - // ignore: unnecessary_overrides - Locale? computePlatformResolvedLocale(List supportedLocales) { - return super.computePlatformResolvedLocale(supportedLocales); - } - - @override - // ignore: unnecessary_overrides - VoidCallback? get onLocaleChanged => super.onLocaleChanged; - @override - // ignore: unnecessary_overrides - set onLocaleChanged(VoidCallback? callback) { - super.onLocaleChanged = callback; - } - - @override - // ignore: unnecessary_overrides - String get initialLifecycleState => super.initialLifecycleState; - - @override - // ignore: unnecessary_overrides - double get textScaleFactor => super.textScaleFactor; - - @override - // ignore: unnecessary_overrides - bool get alwaysUse24HourFormat => super.alwaysUse24HourFormat; - - @override - // ignore: unnecessary_overrides - VoidCallback? get onTextScaleFactorChanged => super.onTextScaleFactorChanged; - @override - // ignore: unnecessary_overrides - set onTextScaleFactorChanged(VoidCallback? callback) { - super.onTextScaleFactorChanged = callback; - } - - @override - // ignore: unnecessary_overrides - Brightness get platformBrightness => super.platformBrightness; - - @override - // ignore: unnecessary_overrides - VoidCallback? get onPlatformBrightnessChanged => super.onPlatformBrightnessChanged; - @override - // ignore: unnecessary_overrides - set onPlatformBrightnessChanged(VoidCallback? callback) { - super.onPlatformBrightnessChanged = callback; - } - - @override - // ignore: unnecessary_overrides - FrameCallback? get onBeginFrame => super.onBeginFrame; - @override - // ignore: unnecessary_overrides - set onBeginFrame(FrameCallback? callback) { - super.onBeginFrame = callback; - } - - @override - // ignore: unnecessary_overrides - VoidCallback? get onDrawFrame => super.onDrawFrame; - @override - // ignore: unnecessary_overrides - set onDrawFrame(VoidCallback? callback) { - super.onDrawFrame = callback; - } - - @override - // ignore: unnecessary_overrides - TimingsCallback? get onReportTimings => super.onReportTimings; - @override - // ignore: unnecessary_overrides - set onReportTimings(TimingsCallback? callback) { - super.onReportTimings = callback; - } - - @override - // ignore: unnecessary_overrides - PointerDataPacketCallback? get onPointerDataPacket => super.onPointerDataPacket; - @override - // ignore: unnecessary_overrides - set onPointerDataPacket(PointerDataPacketCallback? callback) { - super.onPointerDataPacket = callback; - } - - @override - // ignore: unnecessary_overrides - String get defaultRouteName => super.defaultRouteName; - - @override - // ignore: unnecessary_overrides - void scheduleFrame() => super.scheduleFrame(); - - @override - // ignore: unnecessary_overrides - bool get semanticsEnabled => super.semanticsEnabled; - - @override - // ignore: unnecessary_overrides - VoidCallback? get onSemanticsEnabledChanged => super.onSemanticsEnabledChanged; - @override - // ignore: unnecessary_overrides - set onSemanticsEnabledChanged(VoidCallback? callback) { - super.onSemanticsEnabledChanged = callback; - } - - @override - // ignore: unnecessary_overrides - SemanticsActionCallback? get onSemanticsAction => super.onSemanticsAction; - @override - // ignore: unnecessary_overrides - set onSemanticsAction(SemanticsActionCallback? callback) { - super.onSemanticsAction = callback; - } - - @override - // ignore: unnecessary_overrides - AccessibilityFeatures get accessibilityFeatures => super.accessibilityFeatures; - - @override - // ignore: unnecessary_overrides - VoidCallback? get onAccessibilityFeaturesChanged => - super.onAccessibilityFeaturesChanged; - @override - // ignore: unnecessary_overrides - set onAccessibilityFeaturesChanged(VoidCallback? callback) { - super.onAccessibilityFeaturesChanged = callback; - } - - @override - // ignore: unnecessary_overrides - void updateSemantics(SemanticsUpdate update) => super.updateSemantics(update); - - @override - // ignore: unnecessary_overrides - void sendPlatformMessage(String name, ByteData? data, PlatformMessageResponseCallback? callback) { - super.sendPlatformMessage(name, data, callback); - } - - @override - // ignore: unnecessary_overrides - PlatformMessageCallback? get onPlatformMessage => super.onPlatformMessage; - @override - // ignore: unnecessary_overrides - set onPlatformMessage(PlatformMessageCallback? callback) { - super.onPlatformMessage = callback; - } - - @override - // ignore: unnecessary_overrides - void setIsolateDebugName(String name) => super.setIsolateDebugName(name); -} - /// Describes the contrast of a theme or color palette. enum Brightness { /// The color is dark and will require a light text color to achieve readable @@ -1053,4 +839,4 @@ enum Brightness { /// * [PlatformDispatcher.views], contains the current list of Flutter windows /// belonging to the application, including top level application windows like /// this one. -final Window window = Window._(0, PlatformDispatcher.instance); +final SingletonFlutterWindow window = SingletonFlutterWindow._(0, PlatformDispatcher.instance); diff --git a/lib/web_ui/lib/src/engine/dom_renderer.dart b/lib/web_ui/lib/src/engine/dom_renderer.dart index d650614f24448656e00dee8d4da21a2aaaa61c78..af01cbc74c483a9b9188d7c8261cb3bb72ba9527 100644 --- a/lib/web_ui/lib/src/engine/dom_renderer.dart +++ b/lib/web_ui/lib/src/engine/dom_renderer.dart @@ -478,8 +478,8 @@ flt-glass-pane * { /// /// When there is a text editing going on in mobile devices, do not change /// the physicalSize, change the [window.viewInsets]. See: - /// https://api.flutter.dev/flutter/dart-ui/Window/viewInsets.html - /// https://api.flutter.dev/flutter/dart-ui/Window/physicalSize.html + /// https://api.flutter.dev/flutter/dart-ui/FlutterView/viewInsets.html + /// https://api.flutter.dev/flutter/dart-ui/FlutterView/physicalSize.html /// /// Note: always check for rotations for a mobile device. Update the physical /// size if the change is caused by a rotation. diff --git a/lib/web_ui/lib/src/engine/html/scene_builder.dart b/lib/web_ui/lib/src/engine/html/scene_builder.dart index 80cf5ed1c966049ded9fb645217ee9790d53f919..03d470173d243a103562dda2915c551ca1e48a7e 100644 --- a/lib/web_ui/lib/src/engine/html/scene_builder.dart +++ b/lib/web_ui/lib/src/engine/html/scene_builder.dart @@ -307,13 +307,12 @@ class SurfaceSceneBuilder implements ui.SceneBuilder { /// - 0x08: visualizeEngineStatistics - graph UI thread frame times /// Set enabledOptions to 0x0F to enable all the currently defined features. /// - /// The "UI thread" is the thread that includes all the execution of - /// the main Dart isolate (the isolate that can call - /// [Window.render]). The UI thread frame time is the total time - /// spent executing the [Window.onBeginFrame] callback. The "raster - /// thread" is the thread (running on the CPU) that subsequently - /// processes the [Scene] provided by the Dart code to turn it into - /// GPU commands and send it to the GPU. + /// The "UI thread" is the thread that includes all the execution of the main + /// Dart isolate (the isolate that can call [FlutterView.render]). The UI + /// thread frame time is the total time spent executing the + /// [FlutterView.onBeginFrame] callback. The "raster thread" is the thread + /// (running on the CPU) that subsequently processes the [Scene] provided by + /// the Dart code to turn it into GPU commands and send it to the GPU. /// /// See also the [PerformanceOverlayOption] enum in the rendering library. /// for more details. @@ -522,7 +521,7 @@ class SurfaceSceneBuilder implements ui.SceneBuilder { /// /// Returns a [Scene] containing the objects that have been added to /// this scene builder. The [Scene] can then be displayed on the - /// screen with [Window.render]. + /// screen with [FlutterView.render]. /// /// After calling this function, the scene builder object is invalid and /// cannot be used further. diff --git a/lib/web_ui/lib/src/engine/platform_dispatcher.dart b/lib/web_ui/lib/src/engine/platform_dispatcher.dart index d196ef5c9ff9324c4f4e1ee9d6c4694fa87f6105..78e9124361b526d61e46b2b71dcdae038a9e9f7c 100644 --- a/lib/web_ui/lib/src/engine/platform_dispatcher.dart +++ b/lib/web_ui/lib/src/engine/platform_dispatcher.dart @@ -174,7 +174,7 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher { /// rasterized frames. /// /// It's preferred to use [SchedulerBinding.addTimingsCallback] than to use - /// [Window.onReportTimings] directly because + /// [PlatformDispatcher.onReportTimings] directly because /// [SchedulerBinding.addTimingsCallback] allows multiple callbacks. /// /// This can be used to see if the application has missed frames (through diff --git a/lib/web_ui/lib/src/engine/semantics/semantics.dart b/lib/web_ui/lib/src/engine/semantics/semantics.dart index 226d9a478acb560ae5881e22242895180b605bba..1d511e5198cf34b55d9daa5c1bc0219b09126656 100644 --- a/lib/web_ui/lib/src/engine/semantics/semantics.dart +++ b/lib/web_ui/lib/src/engine/semantics/semantics.dart @@ -1265,11 +1265,11 @@ class EngineSemanticsOwner { final SemanticsHelper semanticsHelper = SemanticsHelper(); - /// Whether the user has requested that [updateSemantics] be called when - /// the semantic contents of window changes. + /// Whether the user has requested that [updateSemantics] be called when the + /// semantic contents of window changes. /// - /// The [ui.Window.onSemanticsEnabledChanged] callback is called whenever this - /// value changes. + /// The [ui.PlatformDispatcher.onSemanticsEnabledChanged] callback is called + /// whenever this value changes. /// /// This is separate from accessibility [mode], which controls how gestures /// are interpreted when this value is true. diff --git a/lib/web_ui/lib/src/engine/window.dart b/lib/web_ui/lib/src/engine/window.dart index 78defa3bd3ca94119bb9bd38373662022df48a2e..0557acd9c129dbacb16404399386bbb2d793e88c 100644 --- a/lib/web_ui/lib/src/engine/window.dart +++ b/lib/web_ui/lib/src/engine/window.dart @@ -22,10 +22,8 @@ set customUrlStrategy(UrlStrategy? strategy) { _customUrlStrategy = strategy; } -/// The Web implementation of [ui.Window]. -// TODO(gspencergoog): Once the framework no longer uses ui.Window, make this extend -// ui.SingletonFlutterWindow instead. -class EngineFlutterWindow extends ui.Window { +/// The Web implementation of [ui.SingletonFlutterWindow]. +class EngineFlutterWindow extends ui.SingletonFlutterWindow { EngineFlutterWindow(this._windowId, this.platformDispatcher) { final EnginePlatformDispatcher engineDispatcher = platformDispatcher as EnginePlatformDispatcher; engineDispatcher._windows[_windowId] = this; @@ -245,7 +243,7 @@ UrlStrategy? _createDefaultUrlStrategy() { : const HashUrlStrategy(); } -/// The Web implementation of [ui.Window]. +/// The Web implementation of [ui.SingletonFlutterWindow]. class EngineSingletonFlutterWindow extends EngineFlutterWindow { EngineSingletonFlutterWindow(Object windowId, ui.PlatformDispatcher platformDispatcher) : super(windowId, platformDispatcher); diff --git a/lib/web_ui/lib/src/ui/window.dart b/lib/web_ui/lib/src/ui/window.dart index 9966ef3617b4ecefe26f33cce68152ce0f551b42..6fc8b901cd742d9e8e5da1e777d0efd0b39b4547 100644 --- a/lib/web_ui/lib/src/ui/window.dart +++ b/lib/web_ui/lib/src/ui/window.dart @@ -124,138 +124,6 @@ abstract class SingletonFlutterWindow extends FlutterWindow { void setIsolateDebugName(String name) => PlatformDispatcher.instance.setIsolateDebugName(name); } -// This class will go away entirely once references to it are removed from the -// framework. The many explicit overrides are an artifact of needing to add the -// same overrides to the one in dart:ui in order to get dartdoc to find the docs -// for them. -abstract class Window extends SingletonFlutterWindow { - @override - double get devicePixelRatio; - - @override - Rect get physicalGeometry; - - @override - Size get physicalSize; - - @override - WindowPadding get viewInsets; - - @override - WindowPadding get viewPadding; - - @override - WindowPadding get systemGestureInsets; - - @override - WindowPadding get padding; - - @override - void render(Scene scene); - - @override - VoidCallback? get onMetricsChanged; - @override - set onMetricsChanged(VoidCallback? callback); - - @override - Locale? get locale => super.locale; - - @override - List? get locales => super.locales; - - @override - Locale? computePlatformResolvedLocale(List supportedLocales); - - @override - VoidCallback? get onLocaleChanged; - @override - set onLocaleChanged(VoidCallback? callback); - - @override - String get initialLifecycleState; - - @override - double get textScaleFactor; - - @override - bool get alwaysUse24HourFormat; - - @override - VoidCallback? get onTextScaleFactorChanged; - @override - set onTextScaleFactorChanged(VoidCallback? callback); - - @override - Brightness get platformBrightness; - - @override - VoidCallback? get onPlatformBrightnessChanged; - @override - set onPlatformBrightnessChanged(VoidCallback? callback); - - @override - FrameCallback? get onBeginFrame; - @override - set onBeginFrame(FrameCallback? callback); - - @override - VoidCallback? get onDrawFrame; - @override - set onDrawFrame(VoidCallback? callback); - - @override - TimingsCallback? get onReportTimings; - @override - set onReportTimings(TimingsCallback? callback); - - @override - PointerDataPacketCallback? get onPointerDataPacket; - @override - set onPointerDataPacket(PointerDataPacketCallback? callback); - - @override - String get defaultRouteName; - - @override - void scheduleFrame(); - - @override - bool get semanticsEnabled; - - @override - VoidCallback? get onSemanticsEnabledChanged; - @override - set onSemanticsEnabledChanged(VoidCallback? callback); - - @override - SemanticsActionCallback? get onSemanticsAction; - @override - set onSemanticsAction(SemanticsActionCallback? callback); - - @override - AccessibilityFeatures get accessibilityFeatures; - - @override - VoidCallback? get onAccessibilityFeaturesChanged; - @override - set onAccessibilityFeaturesChanged(VoidCallback? callback); - - @override - void updateSemantics(SemanticsUpdate update); - - @override - void sendPlatformMessage(String name, ByteData? data, PlatformMessageResponseCallback? callback); - - @override - PlatformMessageCallback? get onPlatformMessage; - @override - set onPlatformMessage(PlatformMessageCallback? callback); - - @override - void setIsolateDebugName(String name); -} - class AccessibilityFeatures { const AccessibilityFeatures._(this._index); @@ -368,4 +236,4 @@ class IsolateNameServer { } } -Window get window => engine.window; +SingletonFlutterWindow get window => engine.window; diff --git a/lib/web_ui/test/engine/window_test.dart b/lib/web_ui/test/engine/window_test.dart index e61c9f1e422896a7708d2206ba6818683ab15784..04ae42243e4025bf94fd0f987515d362f7443bca 100644 --- a/lib/web_ui/test/engine/window_test.dart +++ b/lib/web_ui/test/engine/window_test.dart @@ -271,7 +271,7 @@ void testMain() { expect(responded, true); }); - test('Window implements locale, locales, and locale change notifications', () async { + test('SingletonFlutterWindow implements locale, locales, and locale change notifications', () async { // This will count how many times we notified about locale changes. int localeChangedCount = 0; window.onLocaleChanged = () {