Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
f0970365
Unverified
Commit
f0970365
authored
Oct 06, 2023
by
Polina Cherkasova
Committed by
GitHub
Oct 06, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RenderEditable should dispose created layers. (#135942)
parent
8796955e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
67 deletions
+16
-67
editable.dart
packages/flutter/lib/src/rendering/editable.dart
+5
-1
editable_text_cursor_test.dart
packages/flutter/test/widgets/editable_text_cursor_test.dart
+9
-49
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+2
-17
No files found.
packages/flutter/lib/src/rendering/editable.dart
View file @
f0970365
...
...
@@ -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
,
);
...
...
packages/flutter/test/widgets/editable_text_cursor_test.dart
View file @
f0970365
...
...
@@ -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
},
));
);
}
packages/flutter/test/widgets/editable_text_test.dart
View file @
f0970365
...
...
@@ -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
'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment