Fix UiKitView which wrongly unconditionally repaints (#111790)
This commit is contained in:
parent
88707f7cdc
commit
4ead92cf9b
@ -320,10 +320,13 @@ class RenderUiKitView extends RenderBox {
|
|||||||
/// must have been created by calling [PlatformViewsService.initUiKitView].
|
/// must have been created by calling [PlatformViewsService.initUiKitView].
|
||||||
UiKitViewController get viewController => _viewController;
|
UiKitViewController get viewController => _viewController;
|
||||||
UiKitViewController _viewController;
|
UiKitViewController _viewController;
|
||||||
set viewController(UiKitViewController viewController) {
|
set viewController(UiKitViewController value) {
|
||||||
assert(viewController != null);
|
assert(value != null);
|
||||||
final bool needsSemanticsUpdate = _viewController.id != viewController.id;
|
if (_viewController == value) {
|
||||||
_viewController = viewController;
|
return;
|
||||||
|
}
|
||||||
|
final bool needsSemanticsUpdate = _viewController.id != value.id;
|
||||||
|
_viewController = value;
|
||||||
markNeedsPaint();
|
markNeedsPaint();
|
||||||
if (needsSemanticsUpdate) {
|
if (needsSemanticsUpdate) {
|
||||||
markNeedsSemanticsUpdate();
|
markNeedsSemanticsUpdate();
|
||||||
|
@ -260,6 +260,42 @@ void main() {
|
|||||||
expect(renderBox.debugLayer, isNull);
|
expect(renderBox.debugLayer, isNull);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('markNeedsPaint does not get called when setting the same viewController', () {
|
||||||
|
FakeAsync().run((FakeAsync async) {
|
||||||
|
final Completer<void> viewCreation = Completer<void>();
|
||||||
|
const MethodChannel channel = MethodChannel('flutter/platform_views');
|
||||||
|
binding.defaultBinaryMessenger.setMockMethodCallHandler(channel, (MethodCall methodCall) async {
|
||||||
|
assert(methodCall.method == 'create', 'Unexpected method call');
|
||||||
|
await viewCreation.future;
|
||||||
|
return /*textureId=*/ 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
bool futureCallbackRan = false;
|
||||||
|
|
||||||
|
PlatformViewsService.initUiKitView(id: 0, viewType: 'webview', layoutDirection: TextDirection.ltr).then((UiKitViewController viewController) {
|
||||||
|
final RenderUiKitView renderBox = RenderUiKitView(
|
||||||
|
viewController: viewController,
|
||||||
|
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
|
||||||
|
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{},
|
||||||
|
);
|
||||||
|
|
||||||
|
layout(renderBox);
|
||||||
|
pumpFrame(phase: EnginePhase.paint);
|
||||||
|
expect(renderBox.debugNeedsPaint, isFalse);
|
||||||
|
|
||||||
|
renderBox.viewController = viewController;
|
||||||
|
|
||||||
|
expect(renderBox.debugNeedsPaint, isFalse);
|
||||||
|
|
||||||
|
futureCallbackRan = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
viewCreation.complete();
|
||||||
|
async.flushMicrotasks();
|
||||||
|
expect(futureCallbackRan, true);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.PointerData _pointerData(
|
ui.PointerData _pointerData(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user