Fix stale physicalSize on resize event (#16822)

This commit is contained in:
Ferhat 2020-02-26 15:54:10 -08:00 committed by GitHub
parent 060a7733a6
commit c0e29b6000
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -472,6 +472,7 @@ 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();
}

View File

@ -48,12 +48,11 @@ class EngineWindow extends ui.Window {
@override
ui.Size get physicalSize {
if (_physicalSize?.value == null) {
if (_physicalSize == null) {
_computePhysicalSize();
}
assert(_physicalSize != null);
assert(_physicalSize.value != null);
return _physicalSize.value;
return _physicalSize;
}
/// Computes the physical size of the screen from [html.window].
@ -65,7 +64,7 @@ class EngineWindow extends ui.Window {
assert(() {
if (webOnlyDebugPhysicalSizeOverride != null) {
_physicalSize = FrameReference<ui.Size>(webOnlyDebugPhysicalSizeOverride);
_physicalSize = webOnlyDebugPhysicalSizeOverride;
override = true;
}
return true;
@ -82,15 +81,15 @@ class EngineWindow extends ui.Window {
windowInnerWidth = html.window.innerWidth * devicePixelRatio;
windowInnerHeight = html.window.innerHeight * devicePixelRatio;
}
_physicalSize = FrameReference<ui.Size>(ui.Size(
_physicalSize = ui.Size(
windowInnerWidth,
windowInnerHeight,
));
);
}
}
/// Lazily populated and cleared at the end of the frame.
FrameReference<ui.Size> _physicalSize;
ui.Size _physicalSize;
/// Overrides the value of [physicalSize] in tests.
ui.Size webOnlyDebugPhysicalSizeOverride;