Skip to content

Commit 621ad98

Browse files
Remove TextPainter migration flag from the framework (#134274)
The migration flag in `ParagraphBuilder` will be removed next.
1 parent 97cdc0e commit 621ad98

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

packages/flutter/lib/src/painting/text_painter.dart

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,6 @@ class _TextLayout {
279279
// object when it's no logner needed.
280280
ui.Paragraph _paragraph;
281281

282-
// TODO(LongCatIsLooong): https://github.com/flutter/flutter/issues/31707
283-
// remove this hack as well as the flooring in `layout`.
284-
@pragma('vm:prefer-inline')
285-
// ignore: deprecated_member_use
286-
static double _applyFloatingPointHack(double layoutValue) => ui.ParagraphBuilder.shouldDisableRoundingHack ? layoutValue : layoutValue.ceilToDouble();
287-
288282
/// Whether this layout has been invalidated and disposed.
289283
///
290284
/// Only for use when asserts are enabled.
@@ -294,23 +288,23 @@ class _TextLayout {
294288
///
295289
/// If a line ends with trailing spaces, the trailing spaces may extend
296290
/// outside of the horizontal paint bounds defined by [width].
297-
double get width => _applyFloatingPointHack(_paragraph.width);
291+
double get width => _paragraph.width;
298292

299293
/// The vertical space required to paint this text.
300-
double get height => _applyFloatingPointHack(_paragraph.height);
294+
double get height => _paragraph.height;
301295

302296
/// The width at which decreasing the width of the text would prevent it from
303297
/// painting itself completely within its bounds.
304-
double get minIntrinsicLineExtent => _applyFloatingPointHack(_paragraph.minIntrinsicWidth);
298+
double get minIntrinsicLineExtent => _paragraph.minIntrinsicWidth;
305299

306300
/// The width at which increasing the width of the text no longer decreases the height.
307301
///
308302
/// Includes trailing spaces if any.
309-
double get maxIntrinsicLineExtent => _applyFloatingPointHack(_paragraph.maxIntrinsicWidth);
303+
double get maxIntrinsicLineExtent => _paragraph.maxIntrinsicWidth;
310304

311305
/// The distance from the left edge of the leftmost glyph to the right edge of
312306
/// the rightmost glyph in the paragraph.
313-
double get longestLine => _applyFloatingPointHack(_paragraph.longestLine);
307+
double get longestLine => _paragraph.longestLine;
314308

315309
/// Returns the distance from the top of the text to the first baseline of the
316310
/// given type.
@@ -359,13 +353,6 @@ class _TextPainterLayoutCacheWithOffset {
359353
ui.Paragraph get paragraph => layout._paragraph;
360354

361355
static double _contentWidthFor(double minWidth, double maxWidth, TextWidthBasis widthBasis, _TextLayout layout) {
362-
// TODO(LongCatIsLooong): remove the rounding when _applyFloatingPointHack
363-
// is removed.
364-
// ignore: deprecated_member_use
365-
if (!ui.ParagraphBuilder.shouldDisableRoundingHack) {
366-
minWidth = minWidth.floorToDouble();
367-
maxWidth = maxWidth.floorToDouble();
368-
}
369356
return switch (widthBasis) {
370357
TextWidthBasis.longestLine => clampDouble(layout.longestLine, minWidth, maxWidth),
371358
TextWidthBasis.parent => clampDouble(layout.maxIntrinsicLineExtent, minWidth, maxWidth),

packages/flutter/lib/src/rendering/binding.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'dart:ui' as ui show ParagraphBuilder, SemanticsUpdate;
5+
import 'dart:ui' as ui show SemanticsUpdate;
66

77
import 'package:flutter/foundation.dart';
88
import 'package:flutter/gestures.dart';
@@ -49,11 +49,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
4949
addPostFrameCallback(_handleWebFirstFrame);
5050
}
5151
rootPipelineOwner.attach(_manifold);
52-
// TODO(LongCatIsLooong): clean up after
53-
// https://github.com/flutter/flutter/issues/31707 is fully migrated.
54-
if (!const bool.fromEnvironment('SKPARAGRAPH_REMOVE_ROUNDING_HACK', defaultValue: true)) {
55-
ui.ParagraphBuilder.setDisableRoundingHack(false);
56-
}
5752
}
5853

5954
/// The current [RendererBinding], if one has been created.

0 commit comments

Comments
 (0)