re-enable pointer events inside platform views (#22874)

This commit is contained in:
Yegor 2020-12-04 13:25:22 -08:00 committed by GitHub
parent c55027e8dc
commit 47add1dc32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 68 additions and 0 deletions

View File

@ -168,6 +168,10 @@ class HtmlViewEmbedder {
platformView.style.height = '${params.size.height}px';
platformView.style.position = 'absolute';
// <flt-scene-host> disables pointer events. Reenable them here because the
// underlying platform view would want to handle the pointer events.
platformView.style.pointerEvents = 'auto';
final int currentClippingCount = _countClips(params.mutators);
final int? previousClippingCount = _clipCount[viewId];
if (currentClippingCount != previousClippingCount) {

View File

@ -0,0 +1,64 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.12
import 'dart:async';
import 'dart:html' as html;
import 'package:ui/src/engine.dart';
import 'package:ui/ui.dart' as ui;
import 'package:test/bootstrap/browser.dart';
import 'package:test/test.dart';
import 'common.dart';
const MethodCodec codec = StandardMethodCodec();
final EngineSingletonFlutterWindow window = EngineSingletonFlutterWindow(0, EnginePlatformDispatcher.instance);
void main() {
internalBootstrapBrowserTest(() => testMain);
}
void testMain() {
group('HtmlViewEmbedder', () {
setUpCanvasKitTest();
test('embeds interactive platform views', () async {
ui.platformViewRegistry.registerViewFactory(
'test-platform-view',
(viewId) => html.DivElement()..id = 'view-0',
);
await _createPlatformView(0, 'test-platform-view');
final EnginePlatformDispatcher dispatcher = ui.window.platformDispatcher as EnginePlatformDispatcher;
final LayerSceneBuilder sb = LayerSceneBuilder();
sb.pushOffset(0, 0);
sb.addPlatformView(0, width: 10, height: 10);
dispatcher.rasterizer!.draw(sb.build().layerTree);
expect(
domRenderer.sceneElement!.querySelectorAll('#view-0').single.style.pointerEvents,
'auto',
);
});
// TODO: https://github.com/flutter/flutter/issues/60040
}, skip: isIosSafari);
}
// Sends a platform message to create a Platform View with the given id and viewType.
Future<void> _createPlatformView(int id, String viewType) {
final completer = Completer<void>();
window.sendPlatformMessage(
'flutter/platform_views',
codec.encodeMethodCall(MethodCall(
'create',
<String, dynamic>{
'id': id,
'viewType': viewType,
},
)),
(dynamic _) => completer.complete(),
);
return completer.future;
}