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

Commit 4217b9c

Browse files
committed
Stop using PlatformViewManager from ck HtmlViewEmbedder.
The HtmlViewEmbedder has enough information to dispose all the views it knows of (the keys of _viewClipChains), so there's no need to call the PlatformViewManager to ask for ALL the views in the app.
1 parent d0b226c commit 4217b9c

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,7 @@ class HtmlViewEmbedder {
410410
// are going to be added back. Moving rather than removing and re-adding
411411
// the view helps it maintain state.
412412
disposeViews(diffResult.viewsToRemove
413-
.where((int view) => !diffResult.viewsToAdd.contains(view))
414-
.toSet());
413+
.where((int view) => !diffResult.viewsToAdd.contains(view)));
415414
_activeCompositionOrder.addAll(_compositionOrder);
416415
unusedViews.removeAll(_compositionOrder);
417416

@@ -510,7 +509,7 @@ class HtmlViewEmbedder {
510509
);
511510
}
512511

513-
void disposeViews(Set<int> viewsToDispose) {
512+
void disposeViews(Iterable<int> viewsToDispose) {
514513
for (final int viewId in viewsToDispose) {
515514
// Remove viewId from the _viewClipChains Map, and then from the DOM.
516515
final ViewClipChain? clipChain = _viewClipChains.remove(viewId);
@@ -659,7 +658,7 @@ class HtmlViewEmbedder {
659658

660659
/// Disposes the state of this view embedder.
661660
void dispose() {
662-
final Set<int> allViews = PlatformViewManager.instance.getKnownPlatformViewIds();
661+
final Iterable<int> allViews = _viewClipChains.keys;
663662
disposeViews(allViews);
664663
_context = EmbedderFrameContext();
665664
_currentCompositionParams.clear();

lib/web_ui/lib/src/engine/platform_views/content_manager.dart

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,18 +212,13 @@ class PlatformViewManager {
212212
/// component.
213213
bool isVisible(int viewId) => !isInvisible(viewId);
214214

215-
/// Returns the set of know view ids, so they can be cleaned up.
216-
Set<int> getKnownPlatformViewIds() => _contents.keys.toSet();
217-
218215
/// Clears the state. Used in tests.
219-
Set<int> debugClear() {
220-
final Set<int> result = _contents.keys.toSet();
221-
result.forEach(clearPlatformView);
216+
void debugClear() {
217+
_contents.keys.toList().forEach(clearPlatformView);
222218
_factories.clear();
223219
_contents.clear();
224220
_invisibleViews.clear();
225221
_viewIdToType.clear();
226-
return result;
227222
}
228223
}
229224

0 commit comments

Comments
 (0)