mirror of
https://github.com/flutter/flutter
synced 2024-10-30 05:39:14 +00:00
Remove more rounding hacks from TextPainter (#127826)
Add the conditional rounding that I forgot to add in https://github.com/flutter/flutter/pull/127099
This commit is contained in:
parent
ca495da92a
commit
8fff6f5d34
3 changed files with 9 additions and 10 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue