Unverified Commit 8fff6f5d authored by LongCatIsLooong's avatar LongCatIsLooong Committed by GitHub

Remove more rounding hacks from TextPainter (#127826)

Add the conditional rounding that I forgot to add in https://github.com/flutter/flutter/pull/127099
parent ca495da9
......@@ -362,8 +362,10 @@ class _TextPainterLayoutCacheWithOffset {
static double _contentWidthFor(double minWidth, double maxWidth, TextWidthBasis widthBasis, _TextLayout layout) {
// TODO(LongCatIsLooong): remove the rounding when _applyFloatingPointHack
// is removed.
minWidth = minWidth.floorToDouble();
maxWidth = maxWidth.floorToDouble();
if (_TextLayout._shouldApplyFloatingPointHack) {
minWidth = minWidth.floorToDouble();
maxWidth = maxWidth.floorToDouble();
}
return switch (widthBasis) {
TextWidthBasis.longestLine => clampDouble(layout.longestLine, minWidth, maxWidth),
TextWidthBasis.parent => clampDouble(layout.maxIntrinsicLineExtent, minWidth, maxWidth),
......
......@@ -5041,14 +5041,8 @@ class _ScribbleFocusableState extends State<_ScribbleFocusable> implements Scrib
class _ScribblePlaceholder extends WidgetSpan {
const _ScribblePlaceholder({
required super.child,
super.alignment,
super.baseline,
required this.size,
}) : assert(baseline != null || !(
identical(alignment, ui.PlaceholderAlignment.aboveBaseline) ||
identical(alignment, ui.PlaceholderAlignment.belowBaseline) ||
identical(alignment, ui.PlaceholderAlignment.baseline)
));
});
/// The size of the span, used in place of adding a placeholder size to the [TextPainter].
final Size size;
......
......@@ -132,7 +132,10 @@ void main() {
final Offset entryButtonBottomLeft = tester.getBottomLeft(
find.widgetWithIcon(IconButton, Icons.edit_outlined),
);
expect(saveButtonBottomLeft.dx, 800 - 89.0);
expect(
saveButtonBottomLeft.dx,
const bool.hasEnvironment('SKPARAGRAPH_REMOVE_ROUNDING_HACK') ? moreOrLessEquals(711.6, epsilon: 1e-5) : (800 - 89.0),
);
expect(saveButtonBottomLeft.dy, helpTextTopLeft.dy);
expect(entryButtonBottomLeft.dx, saveButtonBottomLeft.dx - 48.0);
expect(entryButtonBottomLeft.dy, helpTextTopLeft.dy);
......
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