mirror of
https://github.com/flutter/flutter
synced 2024-08-27 20:10:11 +00:00
RenderEditable should dispose created layers. (#135942)
This commit is contained in:
parent
8796955e98
commit
f0970365ca
|
@ -391,6 +391,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
|
|||
|
||||
@override
|
||||
void dispose() {
|
||||
_leaderLayerHandler.layer = null;
|
||||
_foregroundRenderObject?.dispose();
|
||||
_foregroundRenderObject = null;
|
||||
_backgroundRenderObject?.dispose();
|
||||
|
@ -2471,14 +2472,17 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
|
|||
}
|
||||
}
|
||||
|
||||
final LayerHandle<LeaderLayer> _leaderLayerHandler = LayerHandle<LeaderLayer>();
|
||||
|
||||
void _paintHandleLayers(PaintingContext context, List<TextSelectionPoint> endpoints, Offset offset) {
|
||||
Offset startPoint = endpoints[0].point;
|
||||
startPoint = Offset(
|
||||
clampDouble(startPoint.dx, 0.0, size.width),
|
||||
clampDouble(startPoint.dy, 0.0, size.height),
|
||||
);
|
||||
_leaderLayerHandler.layer = LeaderLayer(link: startHandleLayerLink, offset: startPoint + offset);
|
||||
context.pushLayer(
|
||||
LeaderLayer(link: startHandleLayerLink, offset: startPoint + offset),
|
||||
_leaderLayerHandler.layer!,
|
||||
super.paint,
|
||||
Offset.zero,
|
||||
);
|
||||
|
|
|
@ -287,12 +287,7 @@ void main() {
|
|||
await tester.pump(const Duration(milliseconds: 500));
|
||||
expect(renderEditable.cursorColor!.alpha, 0);
|
||||
expect(renderEditable, paintsExactlyCountTimes(#drawRect, 0));
|
||||
},
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(
|
||||
// TODO(ksokolovskyi): remove after fixing
|
||||
// https://github.com/flutter/flutter/issues/134386
|
||||
notDisposedAllowList: <String, int?> {'LeaderLayer': 5},
|
||||
));
|
||||
});
|
||||
|
||||
testWidgetsWithLeakTracking('Cursor does not animates when debugDeterministicCursor is set', (WidgetTester tester) async {
|
||||
EditableText.debugDeterministicCursor = true;
|
||||
|
@ -332,11 +327,7 @@ void main() {
|
|||
EditableText.debugDeterministicCursor = false;
|
||||
},
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(
|
||||
// TODO(ksokolovskyi): remove after fixing
|
||||
// https://github.com/flutter/flutter/issues/134386
|
||||
notDisposedAllowList: <String, int?> {'LeaderLayer': 6},
|
||||
));
|
||||
);
|
||||
|
||||
testWidgetsWithLeakTracking('Cursor does not animate on Android when debugDeterministicCursor is set', (WidgetTester tester) async {
|
||||
final Color defaultCursorColor = Color(ThemeData.fallback().colorScheme.primary.value);
|
||||
|
@ -375,12 +366,7 @@ void main() {
|
|||
expect(renderEditable, paints..rect(color: defaultCursorColor));
|
||||
|
||||
EditableText.debugDeterministicCursor = false;
|
||||
},
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(
|
||||
// TODO(ksokolovskyi): remove after fixing
|
||||
// https://github.com/flutter/flutter/issues/134386
|
||||
notDisposedAllowList: <String, int?> {'LeaderLayer': 4},
|
||||
));
|
||||
});
|
||||
|
||||
testWidgetsWithLeakTracking('Cursor animation restarts when it is moved using keys on desktop', (WidgetTester tester) async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.macOS;
|
||||
|
@ -460,11 +446,7 @@ void main() {
|
|||
debugDefaultTargetPlatformOverride = null;
|
||||
},
|
||||
variant: KeySimulatorTransitModeVariant.all(),
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(
|
||||
// TODO(ksokolovskyi): remove after fixing
|
||||
// https://github.com/flutter/flutter/issues/134386
|
||||
notDisposedAllowList: <String, int?> {'LeaderLayer': 18},
|
||||
));
|
||||
);
|
||||
|
||||
testWidgetsWithLeakTracking('Cursor does not show when showCursor set to false', (WidgetTester tester) async {
|
||||
const Widget widget = MaterialApp(
|
||||
|
@ -492,12 +474,7 @@ void main() {
|
|||
|
||||
await tester.pump(const Duration(milliseconds: 200));
|
||||
expect(renderEditable, paintsExactlyCountTimes(#drawRect, 0));
|
||||
},
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(
|
||||
// TODO(ksokolovskyi): remove after fixing
|
||||
// https://github.com/flutter/flutter/issues/134386
|
||||
notDisposedAllowList: <String, int?> {'LeaderLayer': 3},
|
||||
));
|
||||
});
|
||||
|
||||
testWidgetsWithLeakTracking('Cursor does not show when not focused', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/106512 .
|
||||
|
@ -527,12 +504,7 @@ void main() {
|
|||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
expect(renderEditable, isNot(paintsExactlyCountTimes(#drawRect, 0)));
|
||||
},
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(
|
||||
// TODO(ksokolovskyi): remove after fixing
|
||||
// https://github.com/flutter/flutter/issues/134386
|
||||
notDisposedAllowList: <String, int?> {'LeaderLayer': 2},
|
||||
));
|
||||
});
|
||||
|
||||
testWidgetsWithLeakTracking('Cursor radius is 2.0', (WidgetTester tester) async {
|
||||
const Widget widget = MaterialApp(
|
||||
|
@ -1031,11 +1003,7 @@ void main() {
|
|||
debugDefaultTargetPlatformOverride = null;
|
||||
},
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(
|
||||
// TODO(ksokolovskyi): remove after fixing
|
||||
// https://github.com/flutter/flutter/issues/134386
|
||||
notDisposedAllowList: <String, int?> {'LeaderLayer': 4},
|
||||
));
|
||||
);
|
||||
|
||||
testWidgetsWithLeakTracking('cursor layout', (WidgetTester tester) async {
|
||||
EditableText.debugDeterministicCursor = true;
|
||||
|
@ -1287,11 +1255,7 @@ void main() {
|
|||
);
|
||||
},
|
||||
skip: isBrowser && !isCanvasKit, // https://github.com/flutter/flutter/issues/56308
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(
|
||||
// TODO(ksokolovskyi): remove after fixing
|
||||
// https://github.com/flutter/flutter/issues/134386
|
||||
notDisposedAllowList: <String, int?> {'LeaderLayer': 1},
|
||||
));
|
||||
);
|
||||
|
||||
testWidgetsWithLeakTracking('getLocalRectForCaret reports the real caret Rect', (WidgetTester tester) async {
|
||||
EditableText.debugDeterministicCursor = true;
|
||||
|
@ -1337,9 +1301,5 @@ void main() {
|
|||
}
|
||||
},
|
||||
variant: TargetPlatformVariant.all(),
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(
|
||||
// TODO(ksokolovskyi): remove after fixing
|
||||
// https://github.com/flutter/flutter/issues/134386
|
||||
notDisposedAllowList: <String, int?> {'LeaderLayer': 792},
|
||||
));
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3780,11 +3780,6 @@ void main() {
|
|||
|
||||
verifyAutocorrectionRectVisibility(expectVisible: false);
|
||||
},
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(
|
||||
// TODO(ksokolovskyi): remove after fixing
|
||||
// https://github.com/flutter/flutter/issues/134386
|
||||
notDisposedAllowList: <String, int?> {'LeaderLayer': 5},
|
||||
),
|
||||
);
|
||||
|
||||
testWidgetsWithLeakTracking('Changing controller updates EditableText', (WidgetTester tester) async {
|
||||
|
@ -12699,12 +12694,7 @@ void main() {
|
|||
));
|
||||
|
||||
EditableText.debugDeterministicCursor = false;
|
||||
},
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(
|
||||
// TODO(ksokolovskyi): remove after fixing
|
||||
// https://github.com/flutter/flutter/issues/134386
|
||||
notDisposedAllowList: <String, int?> {'LeaderLayer': 2},
|
||||
));
|
||||
});
|
||||
|
||||
testWidgetsWithLeakTracking('Floating cursor ending with selection', (WidgetTester tester) async {
|
||||
EditableText.debugDeterministicCursor = true;
|
||||
|
@ -12884,12 +12874,7 @@ void main() {
|
|||
lastSelectionChangedCause = null;
|
||||
|
||||
EditableText.debugDeterministicCursor = false;
|
||||
},
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(
|
||||
// TODO(ksokolovskyi): remove after fixing
|
||||
// https://github.com/flutter/flutter/issues/134386
|
||||
notDisposedAllowList: <String, int?> {'LeaderLayer': 8},
|
||||
));
|
||||
});
|
||||
|
||||
group('Selection changed scroll into view', () {
|
||||
final String text = List<int>.generate(64, (int index) => index).join('\n');
|
||||
|
|
Loading…
Reference in a new issue