Fix needsCompositing propagation from child widgets. (#32717)

This fixes propagation of needsCompositing from child widgets.

When needsCompositing is turned on by a child widget, it necessarily sets the needsCompositing bit of its parent widget, but RenderPointerListener was ignoring that piece of information and only turning on compositing if it thought it needed it for itself.

This corrects that, and adds a test for the condition, and updates a test that was affected by the change.

Fixes #32525 (again)
This commit is contained in:
Greg Spencer 2019-05-14 17:09:29 -07:00 committed by GitHub
parent a967bc35f3
commit ed90d05596
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 1 deletions

View File

@ -2654,7 +2654,7 @@ class RenderPointerListener extends RenderProxyBoxWithHitTestBehavior {
bool get _hasActiveAnnotation => _hoverAnnotation != null && _mouseIsConnected; bool get _hasActiveAnnotation => _hoverAnnotation != null && _mouseIsConnected;
@override @override
bool get needsCompositing => _hasActiveAnnotation; bool get needsCompositing => super.needsCompositing || _hasActiveAnnotation;
@override @override
void paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {

View File

@ -234,12 +234,14 @@ void main() {
' │ repaints)\n' ' │ repaints)\n'
'\n' '\n'
' └─child: _RenderScrollSemantics#00000\n' ' └─child: _RenderScrollSemantics#00000\n'
' │ needs compositing\n'
' │ parentData: <none> (can use size)\n' ' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n' ' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ semantic boundary\n' ' │ semantic boundary\n'
' │ size: Size(800.0, 600.0)\n' ' │ size: Size(800.0, 600.0)\n'
'\n' '\n'
' └─child: RenderPointerListener#00000\n' ' └─child: RenderPointerListener#00000\n'
' │ needs compositing\n'
' │ parentData: <none> (can use size)\n' ' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n' ' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n' ' │ size: Size(800.0, 600.0)\n'
@ -247,6 +249,7 @@ void main() {
' │ listeners: signal\n' ' │ listeners: signal\n'
'\n' '\n'
' └─child: RenderSemanticsGestureHandler#00000\n' ' └─child: RenderSemanticsGestureHandler#00000\n'
' │ needs compositing\n'
' │ parentData: <none> (can use size)\n' ' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n' ' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n' ' │ size: Size(800.0, 600.0)\n'
@ -377,12 +380,14 @@ void main() {
' │ repaints)\n' ' │ repaints)\n'
'\n' '\n'
' └─child: _RenderScrollSemantics#00000\n' ' └─child: _RenderScrollSemantics#00000\n'
' │ needs compositing\n'
' │ parentData: <none> (can use size)\n' ' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n' ' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ semantic boundary\n' ' │ semantic boundary\n'
' │ size: Size(800.0, 600.0)\n' ' │ size: Size(800.0, 600.0)\n'
'\n' '\n'
' └─child: RenderPointerListener#00000\n' ' └─child: RenderPointerListener#00000\n'
' │ needs compositing\n'
' │ parentData: <none> (can use size)\n' ' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n' ' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n' ' │ size: Size(800.0, 600.0)\n'
@ -390,6 +395,7 @@ void main() {
' │ listeners: signal\n' ' │ listeners: signal\n'
'\n' '\n'
' └─child: RenderSemanticsGestureHandler#00000\n' ' └─child: RenderSemanticsGestureHandler#00000\n'
' │ needs compositing\n'
' │ parentData: <none> (can use size)\n' ' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n' ' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n' ' │ size: Size(800.0, 600.0)\n'

View File

@ -391,6 +391,28 @@ void main() {
await gesture.removePointer(); await gesture.removePointer();
}); });
testWidgets('needsCompositing set when parent class needsCompositing is set', (WidgetTester tester) async {
await tester.pumpWidget(
Listener(
onPointerEnter: (PointerEnterEvent _) {},
child: const Opacity(opacity: 0.5, child: Placeholder()),
),
);
RenderPointerListener listener = tester.renderObject(find.byType(Listener).first);
expect(listener.needsCompositing, isTrue);
await tester.pumpWidget(
Listener(
onPointerEnter: (PointerEnterEvent _) {},
child: const Placeholder(),
),
);
listener = tester.renderObject(find.byType(Listener).first);
expect(listener.needsCompositing, isFalse);
});
testWidgets('works with transform', (WidgetTester tester) async { testWidgets('works with transform', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/31986. // Regression test for https://github.com/flutter/flutter/issues/31986.
final Key key = UniqueKey(); final Key key = UniqueKey();