Remove unneeded local variables and comments in Editable and RenderParagraph (#146843)
This PR removes unnecessary local variables and related comments in `Editable` and `RenderParagraph` as both now use another `TextPainter` instance for intrinsics cache. Test-exempt: minor refactor and comments.
This commit is contained in:
@@ -2312,18 +2312,10 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
|
||||
..layout(minWidth: minWidth, maxWidth: maxWidth);
|
||||
positionInlineChildren(_textPainter.inlinePlaceholderBoxes!);
|
||||
_computeCaretPrototype();
|
||||
// We grab _textPainter.size here because assigning to `size` on the next
|
||||
// line will trigger us to validate our intrinsic sizes, which will change
|
||||
// _textPainter's layout because the intrinsic size calculations are
|
||||
// destructive, which would mean we would get different results if we later
|
||||
// used properties on _textPainter in this method.
|
||||
// Other _textPainter state like didExceedMaxLines will also be affected,
|
||||
// though we currently don't use those here.
|
||||
// See also RenderParagraph which has a similar issue.
|
||||
final Size textPainterSize = _textPainter.size;
|
||||
|
||||
final double width = forceLine
|
||||
? constraints.maxWidth
|
||||
: constraints.constrainWidth(_textPainter.size.width + _caretMargin);
|
||||
: constraints.constrainWidth(_textPainter.width + _caretMargin);
|
||||
assert(maxLines != 1 || _textPainter.maxLines == 1);
|
||||
final double preferredHeight = switch (maxLines) {
|
||||
null => math.max(_textPainter.height, preferredLineHeight * (minLines ?? 0)),
|
||||
@@ -2336,7 +2328,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
|
||||
};
|
||||
|
||||
size = Size(width, constraints.constrainHeight(preferredHeight));
|
||||
final Size contentSize = Size(textPainterSize.width + _caretMargin, textPainterSize.height);
|
||||
final Size contentSize = Size(_textPainter.width + _caretMargin, _textPainter.height);
|
||||
|
||||
final BoxConstraints painterConstraints = BoxConstraints.tight(contentSize);
|
||||
|
||||
|
||||
@@ -809,16 +809,10 @@ class RenderParagraph extends RenderBox with ContainerRenderObjectMixin<RenderBo
|
||||
_layoutTextWithConstraints(constraints);
|
||||
positionInlineChildren(_textPainter.inlinePlaceholderBoxes!);
|
||||
|
||||
// We grab _textPainter.size and _textPainter.didExceedMaxLines 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. Other _textPainter state will also be
|
||||
// affected. See also RenderEditable which has a similar issue.
|
||||
final Size textSize = _textPainter.size;
|
||||
final bool textDidExceedMaxLines = _textPainter.didExceedMaxLines;
|
||||
size = constraints.constrain(textSize);
|
||||
|
||||
final bool didOverflowHeight = size.height < textSize.height || textDidExceedMaxLines;
|
||||
final bool didOverflowHeight = size.height < textSize.height || _textPainter.didExceedMaxLines;
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user