Unverified Commit fb33b7a1 authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Use placeholder dimensions that reflect the final text layout (#42558)

The _computeChildren[Width/Height]With[Min/Max]Intrinsics methods in
RenderParagraph overwrite the text painter's placeholder dimensions
in order to compute potential widths and heights for the paragraph.

The placeholder dimensions should be restored to the values computed by
_layoutChildren before painting the text.
parent 0821b759
fa13c1b039e693123888e434e4ee1f9ff79d3b6e
65bd07204149c4f7612bbf179cf088a2d69ca549
......@@ -488,7 +488,15 @@ class RenderParagraph extends RenderBox
_textPainter.markNeedsLayout();
}
// Placeholder dimensions representing the sizes of child inline widgets.
//
// These need to be cached because the text painter's placeholder dimensions
// will be overwritten during intrinsic width/height calculations and must be
// restored to the original values before final layout and painting.
List<PlaceholderDimensions> _placeholderDimensions;
void _layoutTextWithConstraints(BoxConstraints constraints) {
_textPainter.setPlaceholderDimensions(_placeholderDimensions);
_layoutText(minWidth: constraints.minWidth, maxWidth: constraints.maxWidth);
}
......@@ -501,7 +509,7 @@ class RenderParagraph extends RenderBox
return;
}
RenderBox child = firstChild;
final List<PlaceholderDimensions> placeholderDimensions = List<PlaceholderDimensions>(childCount);
_placeholderDimensions = List<PlaceholderDimensions>(childCount);
int childIndex = 0;
while (child != null) {
// Only constrain the width to the maximum width of the paragraph.
......@@ -525,7 +533,7 @@ class RenderParagraph extends RenderBox
break;
}
}
placeholderDimensions[childIndex] = PlaceholderDimensions(
_placeholderDimensions[childIndex] = PlaceholderDimensions(
size: child.size,
alignment: _placeholderSpans[childIndex].alignment,
baseline: _placeholderSpans[childIndex].baseline,
......@@ -534,7 +542,6 @@ class RenderParagraph extends RenderBox
child = childAfter(child);
childIndex += 1;
}
_textPainter.setPlaceholderDimensions(placeholderDimensions);
}
// Iterate through the laid-out children and set the parentData offsets based
......
......@@ -831,7 +831,7 @@ void main() {
find.byType(Container),
matchesGoldenFile(
'text_golden.TextInlineWidgetNest.1.png',
version: 2,
version: 3,
),
);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment