Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6685202

Browse files
author
auto-submit[bot]
committed
Revert "Remove physical geometry (#47825)"
This reverts commit ff13610.
1 parent 87cebd9 commit 6685202

File tree

7 files changed

+38
-8
lines changed

7 files changed

+38
-8
lines changed

lib/ui/hooks.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ _ViewConfiguration _buildViewConfiguration(
135135
) {
136136
return _ViewConfiguration(
137137
devicePixelRatio: devicePixelRatio,
138-
size: Size(width, height),
138+
geometry: Rect.fromLTWH(0.0, 0.0, width, height),
139139
viewPadding: ViewPadding._(
140140
top: viewPaddingTop,
141141
right: viewPaddingRight,

lib/ui/platform_dispatcher.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ class _PlatformConfiguration {
14621462
class _ViewConfiguration {
14631463
const _ViewConfiguration({
14641464
this.devicePixelRatio = 1.0,
1465-
this.size = Size.zero,
1465+
this.geometry = Rect.zero,
14661466
this.viewInsets = ViewPadding.zero,
14671467
this.viewPadding = ViewPadding.zero,
14681468
this.systemGestureInsets = ViewPadding.zero,
@@ -1479,8 +1479,9 @@ class _ViewConfiguration {
14791479
/// The pixel density of the output surface.
14801480
final double devicePixelRatio;
14811481

1482-
/// The size requested for the view in logical pixels.
1483-
final Size size;
1482+
/// The geometry requested for the view on the screen or within its parent
1483+
/// window, in logical pixels.
1484+
final Rect geometry;
14841485

14851486
/// The number of physical pixels on each side of the display rectangle into
14861487
/// which the view can render, but over which the operating system will likely
@@ -1550,7 +1551,7 @@ class _ViewConfiguration {
15501551

15511552
@override
15521553
String toString() {
1553-
return '$runtimeType[size: $size]';
1554+
return '$runtimeType[geometry: $geometry]';
15541555
}
15551556
}
15561557

lib/ui/window.dart

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,25 @@ class FlutterView {
138138
/// The value here is equal to the value exposed on [display].
139139
double get devicePixelRatio => _viewConfiguration.devicePixelRatio;
140140

141+
/// The dimensions and location of the rectangle into which the scene rendered
142+
/// in this view will be drawn on the screen, in physical pixels.
143+
///
144+
/// When this changes, [PlatformDispatcher.onMetricsChanged] is called.
145+
///
146+
/// At startup, the size and location of the view may not be known before Dart
147+
/// code runs. If this value is observed early in the application lifecycle,
148+
/// it may report [Rect.zero].
149+
///
150+
/// This value does not take into account any on-screen keyboards or other
151+
/// system UI. The [padding] and [viewInsets] properties provide a view into
152+
/// how much of each side of the view may be obscured by system UI.
153+
///
154+
/// See also:
155+
///
156+
/// * [WidgetsBindingObserver], for a mechanism at the widgets layer to
157+
/// observe when this value changes.
158+
Rect get physicalGeometry => _viewConfiguration.geometry;
159+
141160
/// The dimensions of the rectangle into which the scene rendered in this view
142161
/// will be drawn on the screen, in physical pixels.
143162
///
@@ -160,9 +179,11 @@ class FlutterView {
160179
///
161180
/// See also:
162181
///
182+
/// * [physicalGeometry], which reports the location of the view as well as
183+
/// its size.
163184
/// * [WidgetsBindingObserver], for a mechanism at the widgets layer to
164185
/// observe when this value changes.
165-
Size get physicalSize => _viewConfiguration.size;
186+
Size get physicalSize => _viewConfiguration.geometry.size;
166187

167188
/// The number of physical pixels on each side of the display rectangle into
168189
/// which the view can render, but over which the operating system will likely

lib/web_ui/lib/src/engine/platform_dispatcher.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,7 @@ class ViewConfiguration {
13401340
const ViewConfiguration({
13411341
this.view,
13421342
this.devicePixelRatio = 1.0,
1343+
this.geometry = ui.Rect.zero,
13431344
this.visible = false,
13441345
this.viewInsets = ui.ViewPadding.zero as ViewPadding,
13451346
this.viewPadding = ui.ViewPadding.zero as ViewPadding,
@@ -1352,6 +1353,7 @@ class ViewConfiguration {
13521353
ViewConfiguration copyWith({
13531354
EngineFlutterView? view,
13541355
double? devicePixelRatio,
1356+
ui.Rect? geometry,
13551357
bool? visible,
13561358
ViewPadding? viewInsets,
13571359
ViewPadding? viewPadding,
@@ -1363,6 +1365,7 @@ class ViewConfiguration {
13631365
return ViewConfiguration(
13641366
view: view ?? this.view,
13651367
devicePixelRatio: devicePixelRatio ?? this.devicePixelRatio,
1368+
geometry: geometry ?? this.geometry,
13661369
visible: visible ?? this.visible,
13671370
viewInsets: viewInsets ?? this.viewInsets,
13681371
viewPadding: viewPadding ?? this.viewPadding,
@@ -1375,6 +1378,7 @@ class ViewConfiguration {
13751378

13761379
final EngineFlutterView? view;
13771380
final double devicePixelRatio;
1381+
final ui.Rect geometry;
13781382
final bool visible;
13791383
final ViewPadding viewInsets;
13801384
final ViewPadding viewPadding;
@@ -1385,7 +1389,7 @@ class ViewConfiguration {
13851389

13861390
@override
13871391
String toString() {
1388-
return '$runtimeType[view: $view]';
1392+
return '$runtimeType[view: $view, geometry: $geometry]';
13891393
}
13901394
}
13911395

lib/web_ui/lib/src/engine/window.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ base class EngineFlutterView implements ui.FlutterView {
7373
late final PlatformViewMessageHandler platformViewMessageHandler =
7474
PlatformViewMessageHandler(platformViewsContainer: dom.platformViewsHost);
7575

76+
@override
77+
ui.Rect get physicalGeometry => _viewConfiguration.geometry;
78+
7679
@override
7780
ui.Size get physicalSize {
7881
if (_physicalSize == null) {

lib/web_ui/lib/window.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ abstract class FlutterView {
1515
PlatformDispatcher get platformDispatcher;
1616
int get viewId;
1717
double get devicePixelRatio;
18+
Rect get physicalGeometry;
1819
Size get physicalSize;
1920
ViewPadding get viewInsets;
2021
ViewPadding get viewPadding;

shell/common/fixtures/shell_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ List<int> getCurrentViewWidths() {
530530
final List<int> result = <int>[];
531531
for (final FlutterView view in PlatformDispatcher.instance.views) {
532532
result.add(view.viewId);
533-
result.add(view.physicalSize.width.round());
533+
result.add(view.physicalGeometry.width.round());
534534
}
535535
return result;
536536
}

0 commit comments

Comments
 (0)