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
3f43d9f3
Unverified
Commit
3f43d9f3
authored
Jun 29, 2022
by
xubaolin
Committed by
GitHub
Jun 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reland "Clipping if only one character text overflows (#99146)" (#102130)
Fixes a text clipping edge case.
parent
e3f75609
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
1 deletion
+34
-1
text_painter.dart
packages/flutter/lib/src/painting/text_painter.dart
+9
-0
paragraph.dart
packages/flutter/lib/src/rendering/paragraph.dart
+7
-1
paragraph_test.dart
packages/flutter/test/rendering/paragraph_test.dart
+18
-0
No files found.
packages/flutter/lib/src/painting/text_painter.dart
View file @
3f43d9f3
...
@@ -599,6 +599,15 @@ class TextPainter {
...
@@ -599,6 +599,15 @@ class TextPainter {
return
_paragraph
!.
didExceedMaxLines
;
return
_paragraph
!.
didExceedMaxLines
;
}
}
/// The distance from the left edge of the leftmost glyph to the right edge of
/// the rightmost glyph in the paragraph.
///
/// Valid only after [layout] has been called.
double
get
longestLine
{
assert
(!
_debugNeedsLayout
);
return
_paragraph
!.
longestLine
;
}
double
?
_lastMinWidth
;
double
?
_lastMinWidth
;
double
?
_lastMaxWidth
;
double
?
_lastMaxWidth
;
...
...
packages/flutter/lib/src/rendering/paragraph.dart
View file @
3f43d9f3
...
@@ -630,6 +630,12 @@ class RenderParagraph extends RenderBox
...
@@ -630,6 +630,12 @@ class RenderParagraph extends RenderBox
@visibleForTesting
@visibleForTesting
bool
get
debugHasOverflowShader
=>
_overflowShader
!=
null
;
bool
get
debugHasOverflowShader
=>
_overflowShader
!=
null
;
/// Whether this paragraph currently has overflow and needs clipping.
///
/// Used to test this object. Not for use in production.
@visibleForTesting
bool
get
debugNeedsClipping
=>
_needsClipping
;
void
_layoutText
({
double
minWidth
=
0.0
,
double
maxWidth
=
double
.
infinity
})
{
void
_layoutText
({
double
minWidth
=
0.0
,
double
maxWidth
=
double
.
infinity
})
{
final
bool
widthMatters
=
softWrap
||
overflow
==
TextOverflow
.
ellipsis
;
final
bool
widthMatters
=
softWrap
||
overflow
==
TextOverflow
.
ellipsis
;
_textPainter
.
layout
(
_textPainter
.
layout
(
...
@@ -781,7 +787,7 @@ class RenderParagraph extends RenderBox
...
@@ -781,7 +787,7 @@ class RenderParagraph extends RenderBox
size
=
constraints
.
constrain
(
textSize
);
size
=
constraints
.
constrain
(
textSize
);
final
bool
didOverflowHeight
=
size
.
height
<
textSize
.
height
||
textDidExceedMaxLines
;
final
bool
didOverflowHeight
=
size
.
height
<
textSize
.
height
||
textDidExceedMaxLines
;
final
bool
didOverflowWidth
=
size
.
width
<
textSize
.
width
;
final
bool
didOverflowWidth
=
size
.
width
<
textSize
.
width
||
size
.
width
<
_textPainter
.
longestLine
;
// 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
// visual overflow when there actually is visual overflow. This can become
// visual overflow when there actually is visual overflow. This can become
...
...
packages/flutter/test/rendering/paragraph_test.dart
View file @
3f43d9f3
...
@@ -326,6 +326,24 @@ void main() {
...
@@ -326,6 +326,24 @@ void main() {
expect
(
paragraph
.
debugHasOverflowShader
,
isFalse
);
expect
(
paragraph
.
debugHasOverflowShader
,
isFalse
);
},
skip:
isBrowser
);
// https://github.com/flutter/flutter/issues/61018
},
skip:
isBrowser
);
// https://github.com/flutter/flutter/issues/61018
test
(
'one character clip test'
,
()
{
// Regressing test for https://github.com/flutter/flutter/issues/99140
final
RenderParagraph
paragraph
=
RenderParagraph
(
const
TextSpan
(
text:
'7'
,
style:
TextStyle
(
fontFamily:
'Ahem'
,
fontSize:
60.0
),
),
textDirection:
TextDirection
.
ltr
,
maxLines:
1
,
);
// Lay out in a narrow box to force clipping.
// The text width is 60 bigger than the constraints width.
layout
(
paragraph
,
constraints:
BoxConstraints
.
tight
(
const
Size
(
50.0
,
200.0
)));
expect
(
paragraph
.
debugNeedsClipping
,
true
);
},
skip:
isBrowser
);
// https://github.com/flutter/flutter/issues/61018
test
(
'maxLines'
,
()
{
test
(
'maxLines'
,
()
{
final
RenderParagraph
paragraph
=
RenderParagraph
(
final
RenderParagraph
paragraph
=
RenderParagraph
(
const
TextSpan
(
const
TextSpan
(
...
...
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