-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Dynamic view sizing #138648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic view sizing #138648
Conversation
9dcfe19 to
84c5798
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI @jacob314 @kenzieschmoll Is this change going to have any impact on DevTools or other widget inspector use cases?
Background: Prior to this change, the root RenderView would claim that its constraints are null. With this change, we are actually giving the RenderView proper constraints. This enables the use case to size the RenderView based on its actual content, which is something people are asking for on the web: When Flutter is embedded into an existing web page, the Flutter HTML element should only take up as much space as the Flutter-rendered content needs. The embedder can communicate legal sizes for the element by providing constraints, which the framework then uses as the input to its layout algorithm (instead of just using a fixes size as before).
Since there's a specific test in here to ensure that the constraints of the RenderView are null I wanted to check with you whether you anticipate this breaking anything on your end when that is no longer true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked out your branch and connected to gallery with the Flutter inspector. I didn't see any issues with this change. @jacob314 feel free to add anything if something stands out to you as problematic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No concerns at all. Potentially that test could be documented to make it clearer that it is more of a golden test than enforcing invariants required by the widget inspector.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks for confirming!
69143d4 to
74c3404
Compare
ditman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(RS)LGTM!
(There's some areas that I've never touched, like rendering/box or the binding, but everything seems to make sense, and this works on my apps, so...)
gspencergoog
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like ViewConstraints.tight could be const, allowing this to be const.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly, Dart currently doesn't allow ViewConstraints.tight to be const, see https://github.com/flutter/engine/pull/48090/files#r1406511737.
Towards #134501. Required to roll flutter/engine#48090 into the framework. **DO NOT SUBMIT until #138648 and flutter/engine#48090 are ready.**
Towards flutter/flutter#134501. This PR makes the following changes to the public dart:ui API: * It adds the `FlutterView.pysicalConstraints` property that describes max and min width and height for a view. The framework is allowed to size the `FlutterView` to any `Size` that meets these constraints. * It adds an optional `size` argument to `FlutterView.render`. The framework provides the chosen `Size` that meets the aforementioned constraints to the `render` method. If the `FlutterView.pysicalConstraints` are tight (minHeight == maxHeight and minWidth == maxWidth) the argument is optional to remain backwards compatible. In all other cases, a `Size` must be provided. * It adds a `ViewConstraints` class, which is basically the `dart:ui` version of `BoxConstraints` (This is similar to how we have `ViewPadding` in dart:ui to mirror `EdgeInsets` from the framework). It describes the constraints of a `FlutterView`, i.e. it powers the `FlutterView.pysicalConstraints` property. This change does not wire anything up to the embedders. For now, `FlutterView.pysicalConstraints` just returns tight constraints for the embedder-provided size of the view (`FlutterView.physicalSize`) and the size provided to `FlutterView.render` is ignored (after it is checked that it meets the constrains). This PR enables the framework to implement the new dynamic view sizing and embedders to separately expose the new functionality to their clients. Presubmits will fail until flutter/flutter#138565 is submitted to the framework. **DO NOT SUBMIT until flutter/flutter#138648 is ready.**
63fbd5d to
4ab8bd6
Compare
This enables support for dynamic view resizing in non-web embedders. While this patch enables support for dynamic view resizing in non-web embedders, it does not *implement* support in any embedder. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support for dynamic view resizing in non-web embedders, it does not *implement* support in any embedder. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support for dynamic view resizing in non-web embedders, it does not *implement* support in any embedder. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
Part of #169147 (iOS) and #149033 (Android). Implementation PRs coming up! This enables support for dynamic view resizing in non-web embedders. While this PR enables support, it does not _implement_ support. Specifically, this creates the pipes (in viewport metrics) for min/max width/height constraints that tell the engine and framework that when rendering the frame it should adjust the width/height as needed for the content. The engine should also discard layer trees that do not fit the constraints. Since the engine now relies on BoxConstraints, geometry.h has now been moved out of embedder specific codepath so that both embedder and engine can depend on it. Related PRs: `dart:ui`: flutter/engine#48090 `framework`: #138648 `framework reland`: #140918 `Web`: flutter/engine#50271 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. --------- Co-authored-by: Matt Boetger <[email protected]> Co-authored-by: Matt Boetger <[email protected]>
Part of flutter#169147 (iOS) and flutter#149033 (Android). Implementation PRs coming up! This enables support for dynamic view resizing in non-web embedders. While this PR enables support, it does not _implement_ support. Specifically, this creates the pipes (in viewport metrics) for min/max width/height constraints that tell the engine and framework that when rendering the frame it should adjust the width/height as needed for the content. The engine should also discard layer trees that do not fit the constraints. Since the engine now relies on BoxConstraints, geometry.h has now been moved out of embedder specific codepath so that both embedder and engine can depend on it. Related PRs: `dart:ui`: flutter/engine#48090 `framework`: flutter#138648 `framework reland`: flutter#140918 `Web`: flutter/engine#50271 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. --------- Co-authored-by: Matt Boetger <[email protected]> Co-authored-by: Matt Boetger <[email protected]>
Part of flutter#169147 (iOS) and flutter#149033 (Android). Implementation PRs coming up! This enables support for dynamic view resizing in non-web embedders. While this PR enables support, it does not _implement_ support. Specifically, this creates the pipes (in viewport metrics) for min/max width/height constraints that tell the engine and framework that when rendering the frame it should adjust the width/height as needed for the content. The engine should also discard layer trees that do not fit the constraints. Since the engine now relies on BoxConstraints, geometry.h has now been moved out of embedder specific codepath so that both embedder and engine can depend on it. Related PRs: `dart:ui`: flutter/engine#48090 `framework`: flutter#138648 `framework reland`: flutter#140918 `Web`: flutter/engine#50271 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. --------- Co-authored-by: Matt Boetger <[email protected]> Co-authored-by: Matt Boetger <[email protected]>
Part of flutter#169147 (iOS) and flutter#149033 (Android). Implementation PRs coming up! This enables support for dynamic view resizing in non-web embedders. While this PR enables support, it does not _implement_ support. Specifically, this creates the pipes (in viewport metrics) for min/max width/height constraints that tell the engine and framework that when rendering the frame it should adjust the width/height as needed for the content. The engine should also discard layer trees that do not fit the constraints. Since the engine now relies on BoxConstraints, geometry.h has now been moved out of embedder specific codepath so that both embedder and engine can depend on it. Related PRs: `dart:ui`: flutter/engine#48090 `framework`: flutter#138648 `framework reland`: flutter#140918 `Web`: flutter/engine#50271 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. --------- Co-authored-by: Matt Boetger <[email protected]> Co-authored-by: Matt Boetger <[email protected]>

Towards #134501.
This change is based on flutter/engine#48090. It changes the
RenderViewto be dynamically sized based on its content if theFlutterViewit is configured with allows it (i.e. theFlutterViewhas looseFlutterView.physicalConstraints). For that, it uses thosephysicalConstraintsas input to the layout algorithm by passing them on to its child (after translating them to logical constraints via the device pixel ratio). The resultingSizethat theRenderViewwould like to be is then communicated back to the engine by passing it to theFlutterView.rendercall.Tests will fail until flutter/engine#48090 has rolled into the framework.