From 621ad9872c12f6e488a5e4ac4555f800e0a6034d Mon Sep 17 00:00:00 2001 From: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Fri, 8 Sep 2023 15:01:52 -0700 Subject: [PATCH] Remove TextPainter migration flag from the framework (#134274) The migration flag in `ParagraphBuilder` will be removed next. --- .../lib/src/painting/text_painter.dart | 23 ++++--------------- .../flutter/lib/src/rendering/binding.dart | 7 +----- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/packages/flutter/lib/src/painting/text_painter.dart b/packages/flutter/lib/src/painting/text_painter.dart index 6457e7cd37f4..0d1b24c7594b 100644 --- a/packages/flutter/lib/src/painting/text_painter.dart +++ b/packages/flutter/lib/src/painting/text_painter.dart @@ -279,12 +279,6 @@ class _TextLayout { // object when it's no logner needed. ui.Paragraph _paragraph; - // TODO(LongCatIsLooong): https://github.com/flutter/flutter/issues/31707 - // remove this hack as well as the flooring in `layout`. - @pragma('vm:prefer-inline') - // ignore: deprecated_member_use - static double _applyFloatingPointHack(double layoutValue) => ui.ParagraphBuilder.shouldDisableRoundingHack ? layoutValue : layoutValue.ceilToDouble(); - /// Whether this layout has been invalidated and disposed. /// /// Only for use when asserts are enabled. @@ -294,23 +288,23 @@ class _TextLayout { /// /// If a line ends with trailing spaces, the trailing spaces may extend /// outside of the horizontal paint bounds defined by [width]. - double get width => _applyFloatingPointHack(_paragraph.width); + double get width => _paragraph.width; /// The vertical space required to paint this text. - double get height => _applyFloatingPointHack(_paragraph.height); + double get height => _paragraph.height; /// The width at which decreasing the width of the text would prevent it from /// painting itself completely within its bounds. - double get minIntrinsicLineExtent => _applyFloatingPointHack(_paragraph.minIntrinsicWidth); + double get minIntrinsicLineExtent => _paragraph.minIntrinsicWidth; /// The width at which increasing the width of the text no longer decreases the height. /// /// Includes trailing spaces if any. - double get maxIntrinsicLineExtent => _applyFloatingPointHack(_paragraph.maxIntrinsicWidth); + double get maxIntrinsicLineExtent => _paragraph.maxIntrinsicWidth; /// The distance from the left edge of the leftmost glyph to the right edge of /// the rightmost glyph in the paragraph. - double get longestLine => _applyFloatingPointHack(_paragraph.longestLine); + double get longestLine => _paragraph.longestLine; /// Returns the distance from the top of the text to the first baseline of the /// given type. @@ -359,13 +353,6 @@ class _TextPainterLayoutCacheWithOffset { ui.Paragraph get paragraph => layout._paragraph; static double _contentWidthFor(double minWidth, double maxWidth, TextWidthBasis widthBasis, _TextLayout layout) { - // TODO(LongCatIsLooong): remove the rounding when _applyFloatingPointHack - // is removed. - // ignore: deprecated_member_use - if (!ui.ParagraphBuilder.shouldDisableRoundingHack) { - minWidth = minWidth.floorToDouble(); - maxWidth = maxWidth.floorToDouble(); - } return switch (widthBasis) { TextWidthBasis.longestLine => clampDouble(layout.longestLine, minWidth, maxWidth), TextWidthBasis.parent => clampDouble(layout.maxIntrinsicLineExtent, minWidth, maxWidth), diff --git a/packages/flutter/lib/src/rendering/binding.dart b/packages/flutter/lib/src/rendering/binding.dart index bb9bd4fe7761..5d1552ec3cb5 100644 --- a/packages/flutter/lib/src/rendering/binding.dart +++ b/packages/flutter/lib/src/rendering/binding.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:ui' as ui show ParagraphBuilder, SemanticsUpdate; +import 'dart:ui' as ui show SemanticsUpdate; import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; @@ -49,11 +49,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture addPostFrameCallback(_handleWebFirstFrame); } rootPipelineOwner.attach(_manifold); - // TODO(LongCatIsLooong): clean up after - // https://github.com/flutter/flutter/issues/31707 is fully migrated. - if (!const bool.fromEnvironment('SKPARAGRAPH_REMOVE_ROUNDING_HACK', defaultValue: true)) { - ui.ParagraphBuilder.setDisableRoundingHack(false); - } } /// The current [RendererBinding], if one has been created.