-
Notifications
You must be signed in to change notification settings - Fork 6k
[web] Defer injection of platform views until needed. #48960
Changes from 13 commits
0ecf2ff
5b00e5a
cc9c3a3
60549bf
e8af2c0
a07a5d9
526e186
62c0023
73952d0
6a7fea9
fed4781
df73550
76e4b9d
deba54d
e210595
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import 'package:ui/ui.dart' as ui; | |
|
|
||
| import '../configuration.dart'; | ||
| import '../dom.dart'; | ||
| import '../platform_views/content_manager.dart'; | ||
| import '../safe_browser_api.dart'; | ||
| import '../semantics/semantics.dart'; | ||
| import 'style_manager.dart'; | ||
|
|
@@ -204,6 +205,33 @@ class DomManager { | |
| sceneHost.append(sceneElement); | ||
| } | ||
| } | ||
|
|
||
| /// Injects a platform view with [platformViewId] into [platformViewsHost]. | ||
| /// | ||
| /// If the platform view is already injected, this method does *nothing*. | ||
| /// | ||
| /// The `platformViewsHost` can only be different if `platformViewId` is moving | ||
| /// from one [FlutterView] to another. In that case, the browser will move the | ||
| /// slot contents from the old `platformViewsHost` to the new one, but that | ||
| /// will cause the platformView to reset its state (an iframe will re-render, | ||
| /// text selections will be lost, video playback interrupted, etc...) | ||
| /// | ||
| /// Try not to move platform views across views! | ||
| void injectPlatformView(int platformViewId) { | ||
| // For now, we don't need anything fancier. If needed, this can be converted | ||
| // to a PlatformViewStrategy class for each web-renderer backend? | ||
| try { | ||
| final DomElement pv = PlatformViewManager.instance.getSlottedContent(platformViewId); | ||
| // If pv is already a descendant of platformViewsHost -> noop | ||
| if (pv.parent == platformViewsHost) { | ||
| return; | ||
| } | ||
| platformViewsHost.append(pv); | ||
| } catch (e) { | ||
| // Do not fail, many tests expect this to not crash! | ||
| domWindow.console.warn(e); | ||
| } | ||
|
||
| } | ||
| } | ||
|
|
||
| DomShadowRoot _attachShadowRoot(DomElement element) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.