Unverified Commit 621ad987 authored by LongCatIsLooong's avatar LongCatIsLooong Committed by GitHub

Remove TextPainter migration flag from the framework (#134274)

The migration flag in `ParagraphBuilder` will be removed next.
parent 97cdc0ec
...@@ -279,12 +279,6 @@ class _TextLayout { ...@@ -279,12 +279,6 @@ class _TextLayout {
// object when it's no logner needed. // object when it's no logner needed.
ui.Paragraph _paragraph; 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. /// Whether this layout has been invalidated and disposed.
/// ///
/// Only for use when asserts are enabled. /// Only for use when asserts are enabled.
...@@ -294,23 +288,23 @@ class _TextLayout { ...@@ -294,23 +288,23 @@ class _TextLayout {
/// ///
/// If a line ends with trailing spaces, the trailing spaces may extend /// If a line ends with trailing spaces, the trailing spaces may extend
/// outside of the horizontal paint bounds defined by [width]. /// 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. /// 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 /// The width at which decreasing the width of the text would prevent it from
/// painting itself completely within its bounds. /// 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. /// The width at which increasing the width of the text no longer decreases the height.
/// ///
/// Includes trailing spaces if any. /// 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 distance from the left edge of the leftmost glyph to the right edge of
/// the rightmost glyph in the paragraph. /// 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 /// Returns the distance from the top of the text to the first baseline of the
/// given type. /// given type.
...@@ -359,13 +353,6 @@ class _TextPainterLayoutCacheWithOffset { ...@@ -359,13 +353,6 @@ class _TextPainterLayoutCacheWithOffset {
ui.Paragraph get paragraph => layout._paragraph; ui.Paragraph get paragraph => layout._paragraph;
static double _contentWidthFor(double minWidth, double maxWidth, TextWidthBasis widthBasis, _TextLayout layout) { 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) { return switch (widthBasis) {
TextWidthBasis.longestLine => clampDouble(layout.longestLine, minWidth, maxWidth), TextWidthBasis.longestLine => clampDouble(layout.longestLine, minWidth, maxWidth),
TextWidthBasis.parent => clampDouble(layout.maxIntrinsicLineExtent, minWidth, maxWidth), TextWidthBasis.parent => clampDouble(layout.maxIntrinsicLineExtent, minWidth, maxWidth),
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
...@@ -49,11 +49,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture ...@@ -49,11 +49,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
addPostFrameCallback(_handleWebFirstFrame); addPostFrameCallback(_handleWebFirstFrame);
} }
rootPipelineOwner.attach(_manifold); 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. /// The current [RendererBinding], if one has been created.
......
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