From ba990078f89c0276a7776ccb5dcbba0d3f864edc Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 9 Nov 2023 11:39:20 -0800 Subject: [PATCH] Reland "Remove physical geometry" (flutter/engine#47872) Relands #47825 with a doc fix (see second commit). --- engine/src/flutter/lib/ui/hooks.dart | 2 +- .../flutter/lib/ui/platform_dispatcher.dart | 9 +++---- engine/src/flutter/lib/ui/window.dart | 25 +------------------ .../lib/src/engine/platform_dispatcher.dart | 6 +---- .../lib/web_ui/lib/src/engine/window.dart | 3 --- engine/src/flutter/lib/web_ui/lib/window.dart | 1 - .../shell/common/fixtures/shell_test.dart | 2 +- 7 files changed, 8 insertions(+), 40 deletions(-) diff --git a/engine/src/flutter/lib/ui/hooks.dart b/engine/src/flutter/lib/ui/hooks.dart index 2d228e1bf6..1888e1d575 100644 --- a/engine/src/flutter/lib/ui/hooks.dart +++ b/engine/src/flutter/lib/ui/hooks.dart @@ -135,7 +135,7 @@ _ViewConfiguration _buildViewConfiguration( ) { return _ViewConfiguration( devicePixelRatio: devicePixelRatio, - geometry: Rect.fromLTWH(0.0, 0.0, width, height), + size: Size(width, height), viewPadding: ViewPadding._( top: viewPaddingTop, right: viewPaddingRight, diff --git a/engine/src/flutter/lib/ui/platform_dispatcher.dart b/engine/src/flutter/lib/ui/platform_dispatcher.dart index 60f6783f6a..cd1231c0b8 100644 --- a/engine/src/flutter/lib/ui/platform_dispatcher.dart +++ b/engine/src/flutter/lib/ui/platform_dispatcher.dart @@ -1462,7 +1462,7 @@ class _PlatformConfiguration { class _ViewConfiguration { const _ViewConfiguration({ this.devicePixelRatio = 1.0, - this.geometry = Rect.zero, + this.size = Size.zero, this.viewInsets = ViewPadding.zero, this.viewPadding = ViewPadding.zero, this.systemGestureInsets = ViewPadding.zero, @@ -1479,9 +1479,8 @@ class _ViewConfiguration { /// The pixel density of the output surface. final double devicePixelRatio; - /// The geometry requested for the view on the screen or within its parent - /// window, in logical pixels. - final Rect geometry; + /// The size requested for the view in logical pixels. + final Size size; /// The number of physical pixels on each side of the display rectangle into /// which the view can render, but over which the operating system will likely @@ -1551,7 +1550,7 @@ class _ViewConfiguration { @override String toString() { - return '$runtimeType[geometry: $geometry]'; + return '$runtimeType[size: $size]'; } } diff --git a/engine/src/flutter/lib/ui/window.dart b/engine/src/flutter/lib/ui/window.dart index 71b9ea56a4..1f25f1a049 100644 --- a/engine/src/flutter/lib/ui/window.dart +++ b/engine/src/flutter/lib/ui/window.dart @@ -138,25 +138,6 @@ class FlutterView { /// The value here is equal to the value exposed on [display]. double get devicePixelRatio => _viewConfiguration.devicePixelRatio; - /// The dimensions and location of the rectangle into which the scene rendered - /// in this view will be drawn on the screen, in physical pixels. - /// - /// When this changes, [PlatformDispatcher.onMetricsChanged] is called. - /// - /// At startup, the size and location of the view may not be known before Dart - /// code runs. If this value is observed early in the application lifecycle, - /// it may report [Rect.zero]. - /// - /// This value does not take into account any on-screen keyboards or other - /// system UI. The [padding] and [viewInsets] properties provide a view into - /// how much of each side of the view may be obscured by system UI. - /// - /// See also: - /// - /// * [WidgetsBindingObserver], for a mechanism at the widgets layer to - /// observe when this value changes. - Rect get physicalGeometry => _viewConfiguration.geometry; - /// The dimensions of the rectangle into which the scene rendered in this view /// will be drawn on the screen, in physical pixels. /// @@ -175,15 +156,11 @@ class FlutterView { /// system UI. The [padding] and [viewInsets] properties provide information /// about how much of each side of the view may be obscured by system UI. /// - /// This value is the same as the `size` member of [physicalGeometry]. - /// /// See also: /// - /// * [physicalGeometry], which reports the location of the view as well as - /// its size. /// * [WidgetsBindingObserver], for a mechanism at the widgets layer to /// observe when this value changes. - Size get physicalSize => _viewConfiguration.geometry.size; + Size get physicalSize => _viewConfiguration.size; /// The number of physical pixels on each side of the display rectangle into /// which the view can render, but over which the operating system will likely diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/platform_dispatcher.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/platform_dispatcher.dart index d5ce7fd284..0e1aae41ef 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/platform_dispatcher.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/platform_dispatcher.dart @@ -1342,7 +1342,6 @@ class ViewConfiguration { const ViewConfiguration({ this.view, this.devicePixelRatio = 1.0, - this.geometry = ui.Rect.zero, this.visible = false, this.viewInsets = ui.ViewPadding.zero as ViewPadding, this.viewPadding = ui.ViewPadding.zero as ViewPadding, @@ -1355,7 +1354,6 @@ class ViewConfiguration { ViewConfiguration copyWith({ EngineFlutterView? view, double? devicePixelRatio, - ui.Rect? geometry, bool? visible, ViewPadding? viewInsets, ViewPadding? viewPadding, @@ -1367,7 +1365,6 @@ class ViewConfiguration { return ViewConfiguration( view: view ?? this.view, devicePixelRatio: devicePixelRatio ?? this.devicePixelRatio, - geometry: geometry ?? this.geometry, visible: visible ?? this.visible, viewInsets: viewInsets ?? this.viewInsets, viewPadding: viewPadding ?? this.viewPadding, @@ -1380,7 +1377,6 @@ class ViewConfiguration { final EngineFlutterView? view; final double devicePixelRatio; - final ui.Rect geometry; final bool visible; final ViewPadding viewInsets; final ViewPadding viewPadding; @@ -1391,7 +1387,7 @@ class ViewConfiguration { @override String toString() { - return '$runtimeType[view: $view, geometry: $geometry]'; + return '$runtimeType[view: $view]'; } } diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/window.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/window.dart index 48e12ec5d1..abc24c7ae4 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/window.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/window.dart @@ -79,9 +79,6 @@ base class EngineFlutterView implements ui.FlutterView { late final PlatformViewMessageHandler platformViewMessageHandler = PlatformViewMessageHandler(platformViewsContainer: dom.platformViewsHost); - @override - ui.Rect get physicalGeometry => _viewConfiguration.geometry; - @override ui.Size get physicalSize { if (_physicalSize == null) { diff --git a/engine/src/flutter/lib/web_ui/lib/window.dart b/engine/src/flutter/lib/web_ui/lib/window.dart index 4f5cf61bec..5e009e3f31 100644 --- a/engine/src/flutter/lib/web_ui/lib/window.dart +++ b/engine/src/flutter/lib/web_ui/lib/window.dart @@ -15,7 +15,6 @@ abstract class FlutterView { PlatformDispatcher get platformDispatcher; int get viewId; double get devicePixelRatio; - Rect get physicalGeometry; Size get physicalSize; ViewPadding get viewInsets; ViewPadding get viewPadding; diff --git a/engine/src/flutter/shell/common/fixtures/shell_test.dart b/engine/src/flutter/shell/common/fixtures/shell_test.dart index cc6e32731d..591d2e7d68 100644 --- a/engine/src/flutter/shell/common/fixtures/shell_test.dart +++ b/engine/src/flutter/shell/common/fixtures/shell_test.dart @@ -530,7 +530,7 @@ List getCurrentViewWidths() { final List result = []; for (final FlutterView view in PlatformDispatcher.instance.views) { result.add(view.viewId); - result.add(view.physicalGeometry.width.round()); + result.add(view.physicalSize.width.round()); } return result; }