Tab labels incorrectly fade out (#4391)

Assigning to `size` called our intrinsic sizing functions re-entrantly, which
is a destructive operation on TextPainter. Ideally we'd made that a
non-destructive operation, but in the meantime we can fix the tab fading issue
by grabbing the text size before assigning to `size`.

Fixes #4365
This commit is contained in:
Adam Barth 2016-06-06 14:00:57 -07:00
parent 8f03ebe56b
commit b96d1dfc24
2 changed files with 8 additions and 4 deletions

View File

@ -38,7 +38,7 @@ class TextPainter {
}
ui.Paragraph _paragraph;
bool _needsLayout = false;
bool _needsLayout = true;
/// The (potentially styled) text to paint.
TextSpan get text => _text;

View File

@ -148,15 +148,19 @@ class RenderParagraph extends RenderBox {
@override
void performLayout() {
_layoutText(minWidth: constraints.minWidth, maxWidth: constraints.maxWidth);
size = constraints.constrain(_textPainter.size);
// We grab _textPainter.size here because assigning to `size` will trigger
// us to validate our intrinsic sizes, which will change _textPainter's
// layout because the intrinsic size calculations are destructive.
final Size textSize = _textPainter.size;
size = constraints.constrain(textSize);
final bool didOverflowWidth = size.width < _textPainter.width;
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
// a problem if we start having horizontal overflow and introduce a clip
// that affects the actual (but undetected) vertical overflow.
_hasVisualOverflow = didOverflowWidth || size.height < _textPainter.height;
_hasVisualOverflow = didOverflowWidth || size.height < textSize.height;
if (didOverflowWidth) {
switch (_overflow) {
case TextOverflow.clip: