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

Commit f94f282

Browse files
committed
re-enable pointer events inside platform views
1 parent 217d39e commit f94f282

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ class HtmlViewEmbedder {
168168
platformView.style.height = '${params.size.height}px';
169169
platformView.style.position = 'absolute';
170170

171+
// <flt-scene-host> disables pointer events. Reenable them here because the
172+
// underlying platform view would want to handle the pointer events.
173+
platformView.style.pointerEvents = 'auto';
174+
171175
final int currentClippingCount = _countClips(params.mutators);
172176
final int? previousClippingCount = _clipCount[viewId];
173177
if (currentClippingCount != previousClippingCount) {
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// @dart = 2.12
6+
import 'dart:async';
7+
import 'dart:html' as html;
8+
9+
import 'package:ui/src/engine.dart';
10+
import 'package:ui/ui.dart' as ui;
11+
12+
import 'package:test/bootstrap/browser.dart';
13+
import 'package:test/test.dart';
14+
15+
import 'common.dart';
16+
17+
const MethodCodec codec = StandardMethodCodec();
18+
final EngineSingletonFlutterWindow window = EngineSingletonFlutterWindow(0, EnginePlatformDispatcher.instance);
19+
20+
void main() {
21+
internalBootstrapBrowserTest(() => testMain);
22+
}
23+
24+
void testMain() {
25+
group('HtmlViewEmbedder', () {
26+
setUpCanvasKitTest();
27+
28+
test('embeds interactive platform views', () async {
29+
ui.platformViewRegistry.registerViewFactory(
30+
'test-platform-view',
31+
(viewId) => html.DivElement()..id = 'view-0',
32+
);
33+
await _createPlatformView(0, 'test-platform-view');
34+
35+
final EnginePlatformDispatcher dispatcher = ui.window.platformDispatcher as EnginePlatformDispatcher;
36+
final LayerSceneBuilder sb = LayerSceneBuilder();
37+
sb.pushOffset(0, 0);
38+
sb.addPlatformView(0, width: 10, height: 10);
39+
dispatcher.rasterizer!.draw(sb.build().layerTree);
40+
expect(
41+
domRenderer.sceneElement!.querySelectorAll('#view-0').single.style.pointerEvents,
42+
'auto',
43+
);
44+
});
45+
// TODO: https://github.com/flutter/flutter/issues/60040
46+
}, skip: isIosSafari);
47+
}
48+
49+
// Sends a platform message to create a Platform View with the given id and viewType.
50+
Future<void> _createPlatformView(int id, String viewType) {
51+
final completer = Completer<void>();
52+
window.sendPlatformMessage(
53+
'flutter/platform_views',
54+
codec.encodeMethodCall(MethodCall(
55+
'create',
56+
<String, dynamic>{
57+
'id': id,
58+
'viewType': viewType,
59+
},
60+
)),
61+
(dynamic _) => completer.complete(),
62+
);
63+
return completer.future;
64+
}

0 commit comments

Comments
 (0)