Skip to content

Commit

Permalink
Revert "Reland "Clipping if only one character text overflows (flutte…
Browse files Browse the repository at this point in the history
…r#99146)" (flutter#102130)"

This reverts commit 3f43d9f.
  • Loading branch information
XilaiZhang committed Jul 1, 2022
1 parent 1e14993 commit 031d597
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 34 deletions.
9 changes: 0 additions & 9 deletions packages/flutter/lib/src/painting/text_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -599,15 +599,6 @@ class TextPainter {
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? _lastMaxWidth;

Expand Down
8 changes: 1 addition & 7 deletions packages/flutter/lib/src/rendering/paragraph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -630,12 +630,6 @@ class RenderParagraph extends RenderBox
@visibleForTesting
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 }) {
final bool widthMatters = softWrap || overflow == TextOverflow.ellipsis;
_textPainter.layout(
Expand Down Expand Up @@ -787,7 +781,7 @@ class RenderParagraph extends RenderBox
size = constraints.constrain(textSize);

final bool didOverflowHeight = size.height < textSize.height || textDidExceedMaxLines;
final bool didOverflowWidth = size.width < textSize.width || size.width < _textPainter.longestLine;
final bool didOverflowWidth = size.width < textSize.width;
// 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
// visual overflow when there actually is visual overflow. This can become
Expand Down
18 changes: 0 additions & 18 deletions packages/flutter/test/rendering/paragraph_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -326,24 +326,6 @@ void main() {
expect(paragraph.debugHasOverflowShader, isFalse);
}, 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', () {
final RenderParagraph paragraph = RenderParagraph(
const TextSpan(
Expand Down

0 comments on commit 031d597

Please sign in to comment.