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
86c79a83
Unverified
Commit
86c79a83
authored
Sep 11, 2021
by
LongCatIsLooong
Committed by
GitHub
Sep 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TextPainter] Don't invalidate layout cache for paint only changes (#89515)
parent
e0b56dbf
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
165 additions
and
68 deletions
+165
-68
text_painter.dart
packages/flutter/lib/src/painting/text_painter.dart
+118
-66
text_painter_test.dart
packages/flutter/test/painting/text_painter_test.dart
+10
-1
text_test.dart
packages/flutter/test/widgets/text_test.dart
+37
-1
No files found.
packages/flutter/lib/src/painting/text_painter.dart
View file @
86c79a83
This diff is collapsed.
Click to expand it.
packages/flutter/test/painting/text_painter_test.dart
View file @
86c79a83
...
...
@@ -152,7 +152,16 @@ void main() {
test
(
'TextPainter error test'
,
()
{
final
TextPainter
painter
=
TextPainter
(
textDirection:
TextDirection
.
ltr
);
expect
(()
{
painter
.
paint
(
MockCanvas
(),
Offset
.
zero
);
},
anyOf
(
throwsFlutterError
,
throwsAssertionError
));
Object
?
e
;
try
{
painter
.
paint
(
MockCanvas
(),
Offset
.
zero
);
}
catch
(
exception
)
{
e
=
exception
;
}
expect
(
e
.
toString
(),
contains
(
'TextPainter.paint called when text geometry was not yet calculated'
),
);
});
test
(
'TextPainter requires textDirection'
,
()
{
...
...
packages/flutter/test/widgets/text_test.dart
View file @
86c79a83
...
...
@@ -1261,7 +1261,7 @@ void main() {
testWidgets
(
'Text uses TextStyle.overflow'
,
(
WidgetTester
tester
)
async
{
const
TextOverflow
overflow
=
TextOverflow
.
fade
;
await
tester
.
pumpWidget
(
const
Text
(
await
tester
.
pumpWidget
(
const
Text
(
'Hello World'
,
textDirection:
TextDirection
.
ltr
,
style:
TextStyle
(
overflow:
overflow
),
...
...
@@ -1272,6 +1272,42 @@ void main() {
expect
(
richText
.
overflow
,
overflow
);
expect
(
richText
.
text
.
style
!.
overflow
,
overflow
);
});
testWidgets
(
'Text can be hit-tested without layout or paint being called in a frame'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/85108.
await
tester
.
pumpWidget
(
const
Opacity
(
opacity:
1.0
,
child:
Text
(
'Hello World'
,
textDirection:
TextDirection
.
ltr
,
style:
TextStyle
(
color:
Color
(
0xFF123456
)),
),
),
);
// The color changed and the opacity is set to 0:
// * 0 opacity will prevent RenderParagraph.paint from being called.
// * Only changing the color will prevent RenderParagraph.performLayout
// from being called.
// The underlying TextPainter should not evict its layout cache in this
// case, for hit-testing.
await
tester
.
pumpWidget
(
const
Opacity
(
opacity:
0.0
,
child:
Text
(
'Hello World'
,
textDirection:
TextDirection
.
ltr
,
style:
TextStyle
(
color:
Color
(
0x87654321
)),
),
),
);
await
tester
.
tap
(
find
.
text
(
'Hello World'
));
expect
(
tester
.
takeException
(),
isNull
);
});
}
Future
<
void
>
_pumpTextWidget
({
...
...
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