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
a4de06ad
Unverified
Commit
a4de06ad
authored
Feb 15, 2019
by
Michael Goderbauer
Committed by
GitHub
Feb 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reapply "Fix overflow clipping/fading for text (#27892)" (#27980)
Fixes
https://github.com/flutter/flutter/issues/25025
parent
3b47b443
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
6 deletions
+77
-6
paragraph.dart
packages/flutter/lib/src/rendering/paragraph.dart
+7
-6
text_test.dart
packages/flutter/test/widgets/text_test.dart
+70
-0
No files found.
packages/flutter/lib/src/rendering/paragraph.dart
View file @
a4de06ad
...
@@ -281,15 +281,16 @@ class RenderParagraph extends RenderBox {
...
@@ -281,15 +281,16 @@ class RenderParagraph extends RenderBox {
@override
@override
void
performLayout
()
{
void
performLayout
()
{
_layoutTextWithConstraints
(
constraints
);
_layoutTextWithConstraints
(
constraints
);
// We grab _textPainter.size
here because assigning to `size` will trigger
// We grab _textPainter.size
and _textPainter.didExceedMaxLines here because
//
us to validate our intrinsic sizes, which will change _textPainter's
//
assigning to `size` will trigger us to validate our intrinsic sizes,
//
layout because the intrinsic size calculations are destructive.
//
which will change _textPainter's layout because the intrinsic size
//
Other _textPainter state like didExceedMaxLines will also be affected.
//
calculations are destructive. Other _textPainter state will also be
// See also RenderEditable which has a similar issue.
//
affected.
See also RenderEditable which has a similar issue.
final
Size
textSize
=
_textPainter
.
size
;
final
Size
textSize
=
_textPainter
.
size
;
final
bool
didOverflowHeight
=
_textPainter
.
didExceedMaxLines
;
final
bool
textDidExceedMaxLines
=
_textPainter
.
didExceedMaxLines
;
size
=
constraints
.
constrain
(
textSize
);
size
=
constraints
.
constrain
(
textSize
);
final
bool
didOverflowHeight
=
size
.
height
<
textSize
.
height
||
textDidExceedMaxLines
;
final
bool
didOverflowWidth
=
size
.
width
<
textSize
.
width
;
final
bool
didOverflowWidth
=
size
.
width
<
textSize
.
width
;
// TODO(abarth): We're only measuring the sizes of the line boxes here. If
// TODO(abarth): We're only measuring the sizes of the line boxes here. If
// the glyphs draw outside the line boxes, we might think that there isn't
// the glyphs draw outside the line boxes, we might think that there isn't
...
...
packages/flutter/test/widgets/text_test.dart
View file @
a4de06ad
...
@@ -7,6 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
...
@@ -7,6 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'../rendering/mock_canvas.dart'
;
import
'semantics_tester.dart'
;
import
'semantics_tester.dart'
;
void
main
(
)
{
void
main
(
)
{
...
@@ -246,4 +247,73 @@ void main() {
...
@@ -246,4 +247,73 @@ void main() {
expect
(
semantics
,
hasSemantics
(
expectedSemantics
,
ignoreTransform:
true
,
ignoreId:
true
));
expect
(
semantics
,
hasSemantics
(
expectedSemantics
,
ignoreTransform:
true
,
ignoreId:
true
));
semantics
.
dispose
();
semantics
.
dispose
();
},
skip:
true
);
// TODO(jonahwilliams): correct once https://github.com/flutter/flutter/issues/20891 is resolved.
},
skip:
true
);
// TODO(jonahwilliams): correct once https://github.com/flutter/flutter/issues/20891 is resolved.
testWidgets
(
'Overflow is clipping correctly - short text with overflow: clip'
,
(
WidgetTester
tester
)
async
{
await
_pumpTextWidget
(
tester:
tester
,
overflow:
TextOverflow
.
clip
,
text:
'Hi'
,
);
expect
(
find
.
byType
(
Text
),
isNot
(
paints
..
clipRect
()));
});
testWidgets
(
'Overflow is clipping correctly - long text with overflow: ellipsis'
,
(
WidgetTester
tester
)
async
{
await
_pumpTextWidget
(
tester:
tester
,
overflow:
TextOverflow
.
ellipsis
,
text:
'a long long long long text, should be clip'
,
);
expect
(
find
.
byType
(
Text
),
paints
..
clipRect
(
rect:
Rect
.
fromLTWH
(
0
,
0
,
50
,
50
)));
});
testWidgets
(
'Overflow is clipping correctly - short text with overflow: ellipsis'
,
(
WidgetTester
tester
)
async
{
await
_pumpTextWidget
(
tester:
tester
,
overflow:
TextOverflow
.
ellipsis
,
text:
'Hi'
,
);
expect
(
find
.
byType
(
Text
),
isNot
(
paints
..
clipRect
()));
});
testWidgets
(
'Overflow is clipping correctly - long text with overflow: fade'
,
(
WidgetTester
tester
)
async
{
await
_pumpTextWidget
(
tester:
tester
,
overflow:
TextOverflow
.
fade
,
text:
'a long long long long text, should be clip'
,
);
expect
(
find
.
byType
(
Text
),
paints
..
clipRect
(
rect:
Rect
.
fromLTWH
(
0
,
0
,
50
,
50
)));
});
testWidgets
(
'Overflow is clipping correctly - short text with overflow: fade'
,
(
WidgetTester
tester
)
async
{
await
_pumpTextWidget
(
tester:
tester
,
overflow:
TextOverflow
.
fade
,
text:
'Hi'
,
);
expect
(
find
.
byType
(
Text
),
isNot
(
paints
..
clipRect
()));
});
}
Future
<
void
>
_pumpTextWidget
({
WidgetTester
tester
,
String
text
,
TextOverflow
overflow
})
{
return
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
Container
(
width:
50.0
,
height:
50.0
,
child:
Text
(
text
,
overflow:
overflow
,
),
),
),
),
);
}
}
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