Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e10c0ae

Browse files
Reland "Remove migration flag and unused header files #50216" (#50259)
Forgot to update a pinned dependency in the previous attempt: flutter/tests#340 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent 7e30318 commit e10c0ae

18 files changed

+13
-214
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35661,7 +35661,6 @@ ORIGIN: ../../../flutter/lib/ui/text/asset_manager_font_provider.cc + ../../../f
3566135661
ORIGIN: ../../../flutter/lib/ui/text/asset_manager_font_provider.h + ../../../flutter/LICENSE
3566235662
ORIGIN: ../../../flutter/lib/ui/text/font_collection.cc + ../../../flutter/LICENSE
3566335663
ORIGIN: ../../../flutter/lib/ui/text/font_collection.h + ../../../flutter/LICENSE
35664-
ORIGIN: ../../../flutter/lib/ui/text/line_metrics.h + ../../../flutter/LICENSE
3566535664
ORIGIN: ../../../flutter/lib/ui/text/paragraph.cc + ../../../flutter/LICENSE
3566635665
ORIGIN: ../../../flutter/lib/ui/text/paragraph.h + ../../../flutter/LICENSE
3566735666
ORIGIN: ../../../flutter/lib/ui/text/paragraph_builder.cc + ../../../flutter/LICENSE
@@ -38517,7 +38516,6 @@ FILE: ../../../flutter/lib/ui/text/asset_manager_font_provider.cc
3851738516
FILE: ../../../flutter/lib/ui/text/asset_manager_font_provider.h
3851838517
FILE: ../../../flutter/lib/ui/text/font_collection.cc
3851938518
FILE: ../../../flutter/lib/ui/text/font_collection.h
38520-
FILE: ../../../flutter/lib/ui/text/line_metrics.h
3852138519
FILE: ../../../flutter/lib/ui/text/paragraph.cc
3852238520
FILE: ../../../flutter/lib/ui/text/paragraph.h
3852338521
FILE: ../../../flutter/lib/ui/text/paragraph_builder.cc

lib/ui/BUILD.gn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ source_set("ui") {
123123
"text/asset_manager_font_provider.h",
124124
"text/font_collection.cc",
125125
"text/font_collection.h",
126-
"text/line_metrics.h",
127126
"text/paragraph.cc",
128127
"text/paragraph.h",
129128
"text/paragraph_builder.cc",

lib/ui/text.dart

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3376,23 +3376,6 @@ abstract class ParagraphBuilder {
33763376
/// [Paragraph].
33773377
factory ParagraphBuilder(ParagraphStyle style) = _NativeParagraphBuilder;
33783378

3379-
/// Whether the rounding hack enabled by default in SkParagraph and TextPainter
3380-
/// is disabled.
3381-
///
3382-
/// Do not rely on this getter as it exists for migration purposes only and
3383-
/// will soon be removed.
3384-
@Deprecated('''
3385-
The shouldDisableRoundingHack flag is for internal migration purposes only and should not be used.
3386-
''')
3387-
static bool get shouldDisableRoundingHack => _shouldDisableRoundingHack;
3388-
static bool _shouldDisableRoundingHack = true;
3389-
/// Do not call this method as it is for migration purposes only and will soon
3390-
/// be removed.
3391-
// ignore: use_setters_to_change_properties
3392-
static void setDisableRoundingHack(bool disableRoundingHack) {
3393-
_shouldDisableRoundingHack = disableRoundingHack;
3394-
}
3395-
33963379
/// The number of placeholders currently in the paragraph.
33973380
int get placeholderCount;
33983381

@@ -3510,11 +3493,10 @@ base class _NativeParagraphBuilder extends NativeFieldWrapperClass1 implements P
35103493
style._height ?? 0,
35113494
style._ellipsis ?? '',
35123495
_encodeLocale(style._locale),
3513-
!ParagraphBuilder.shouldDisableRoundingHack,
35143496
);
35153497
}
35163498

3517-
@Native<Void Function(Handle, Handle, Handle, Handle, Handle, Double, Double, Handle, Handle, Bool)>(symbol: 'ParagraphBuilder::Create')
3499+
@Native<Void Function(Handle, Handle, Handle, Handle, Handle, Double, Double, Handle, Handle)>(symbol: 'ParagraphBuilder::Create')
35183500
external void _constructor(
35193501
Int32List encoded,
35203502
ByteData? strutData,
@@ -3524,7 +3506,7 @@ base class _NativeParagraphBuilder extends NativeFieldWrapperClass1 implements P
35243506
double height,
35253507
String ellipsis,
35263508
String locale,
3527-
bool applyRoundingHack);
3509+
);
35283510

35293511
@override
35303512
int get placeholderCount => _placeholderCount;

lib/ui/text/line_metrics.h

Lines changed: 0 additions & 62 deletions
This file was deleted.

lib/ui/text/paragraph.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "flutter/fml/message_loop.h"
99
#include "flutter/lib/ui/dart_wrapper.h"
1010
#include "flutter/lib/ui/painting/canvas.h"
11-
#include "flutter/lib/ui/text/line_metrics.h"
1211
#include "flutter/third_party/txt/src/txt/paragraph.h"
1312

1413
namespace flutter {

lib/ui/text/paragraph_builder.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,11 @@ void ParagraphBuilder::Create(Dart_Handle wrapper,
151151
double fontSize,
152152
double height,
153153
const std::u16string& ellipsis,
154-
const std::string& locale,
155-
bool applyRoundingHack) {
154+
const std::string& locale) {
156155
UIDartState::ThrowIfUIOperationsProhibited();
157156
auto res = fml::MakeRefCounted<ParagraphBuilder>(
158157
encoded_handle, strutData, fontFamily, strutFontFamilies, fontSize,
159-
height, ellipsis, locale, applyRoundingHack);
158+
height, ellipsis, locale);
160159
res->AssociateWithDartWrapper(wrapper);
161160
}
162161

@@ -231,8 +230,7 @@ ParagraphBuilder::ParagraphBuilder(
231230
double fontSize,
232231
double height,
233232
const std::u16string& ellipsis,
234-
const std::string& locale,
235-
bool applyRoundingHack) {
233+
const std::string& locale) {
236234
int32_t mask = 0;
237235
txt::ParagraphStyle style;
238236
{
@@ -293,7 +291,6 @@ ParagraphBuilder::ParagraphBuilder(
293291
if (mask & kPSLocaleMask) {
294292
style.locale = locale;
295293
}
296-
style.apply_rounding_hack = applyRoundingHack;
297294

298295
FontCollection& font_collection = UIDartState::Current()
299296
->platform_configuration()

lib/ui/text/paragraph_builder.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ class ParagraphBuilder : public RefCountedDartWrappable<ParagraphBuilder> {
3030
double fontSize,
3131
double height,
3232
const std::u16string& ellipsis,
33-
const std::string& locale,
34-
bool applyRoundingHack);
33+
const std::string& locale);
3534

3635
~ParagraphBuilder() override;
3736

@@ -77,8 +76,7 @@ class ParagraphBuilder : public RefCountedDartWrappable<ParagraphBuilder> {
7776
double fontSize,
7877
double height,
7978
const std::u16string& ellipsis,
80-
const std::string& locale,
81-
bool applyRoundingHack);
79+
const std::string& locale);
8280

8381
std::unique_ptr<txt::ParagraphBuilder> m_paragraph_builder_;
8482
};

lib/web_ui/lib/src/engine/canvaskit/renderer.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ class CanvasKitRenderer implements Renderer {
379379
strutStyle: strutStyle,
380380
ellipsis: ellipsis,
381381
locale: locale,
382-
applyRoundingHack: !ui.ParagraphBuilder.shouldDisableRoundingHack,
383382
);
384383

385384
@override

lib/web_ui/lib/src/engine/canvaskit/text.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class CkParagraphStyle implements ui.ParagraphStyle {
3333
ui.StrutStyle? strutStyle,
3434
String? ellipsis,
3535
ui.Locale? locale,
36-
bool applyRoundingHack = true,
3736
}) : skParagraphStyle = toSkParagraphStyle(
3837
textAlign,
3938
textDirection,
@@ -47,7 +46,6 @@ class CkParagraphStyle implements ui.ParagraphStyle {
4746
strutStyle,
4847
ellipsis,
4948
locale,
50-
applyRoundingHack,
5149
),
5250
_textAlign = textAlign,
5351
_textDirection = textDirection,
@@ -163,7 +161,6 @@ class CkParagraphStyle implements ui.ParagraphStyle {
163161
ui.StrutStyle? strutStyle,
164162
String? ellipsis,
165163
ui.Locale? locale,
166-
bool applyRoundingHack,
167164
) {
168165
final SkParagraphStyleProperties properties = SkParagraphStyleProperties();
169166

@@ -200,7 +197,7 @@ class CkParagraphStyle implements ui.ParagraphStyle {
200197
properties.replaceTabCharacters = true;
201198
properties.textStyle = toSkTextStyleProperties(
202199
fontFamily, fontSize, height, fontWeight, fontStyle);
203-
properties.applyRoundingHack = applyRoundingHack;
200+
properties.applyRoundingHack = false;
204201

205202
return canvasKit.ParagraphStyle(properties);
206203
}

lib/web_ui/lib/src/engine/skwasm/skwasm_impl/paragraph.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,10 +746,8 @@ class SkwasmParagraphStyle extends SkwasmObjectWrapper<RawParagraphStyle> implem
746746
skStringFree(localeHandle);
747747
}
748748
paragraphStyleSetTextStyle(handle, textStyleHandle);
749+
paragraphStyleSetApplyRoundingHack(handle, false);
749750

750-
if (ui.ParagraphBuilder.shouldDisableRoundingHack) {
751-
paragraphStyleSetApplyRoundingHack(handle, false);
752-
}
753751
return SkwasmParagraphStyle._(
754752
handle,
755753
textStyle,

lib/web_ui/lib/src/engine/text/canvas_paragraph.dart

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,6 @@ class CanvasParagraph implements ui.Paragraph {
8787

8888
@override
8989
void layout(ui.ParagraphConstraints constraints) {
90-
// When constraint width has a decimal place, we floor it to avoid getting
91-
// a layout width that's higher than the constraint width.
92-
//
93-
// For example, if constraint width is `30.8` and the text has a width of
94-
// `30.5` then the TextPainter in the framework will ceil the `30.5` width
95-
// which will result in a width of `40.0` that's higher than the constraint
96-
// width.
97-
if (!ui.ParagraphBuilder.shouldDisableRoundingHack) {
98-
constraints = ui.ParagraphConstraints(width: constraints.width.floorToDouble());
99-
}
100-
10190
if (constraints == _lastUsedConstraints) {
10291
return;
10392
}

lib/web_ui/lib/text.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -733,13 +733,6 @@ abstract class ParagraphBuilder {
733733
factory ParagraphBuilder(ParagraphStyle style) =>
734734
engine.renderer.createParagraphBuilder(style);
735735

736-
static bool get shouldDisableRoundingHack => _shouldDisableRoundingHack;
737-
static bool _shouldDisableRoundingHack = true;
738-
// ignore: use_setters_to_change_properties
739-
static void setDisableRoundingHack(bool disableRoundingHack) {
740-
_shouldDisableRoundingHack = disableRoundingHack;
741-
}
742-
743736
void pushStyle(TextStyle style);
744737
void pop();
745738
void addText(String text);

lib/web_ui/test/html/text/canvas_paragraph_test.dart

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -777,21 +777,6 @@ Future<void> testMain() async {
777777
expect(paragraph.longestLine, 50.0);
778778
});
779779

780-
test('$CanvasParagraph.width should be a whole integer when shouldDisableRoundingHack is false', () {
781-
if (ui.ParagraphBuilder.shouldDisableRoundingHack) {
782-
ui.ParagraphBuilder.setDisableRoundingHack(false);
783-
addTearDown(() => ui.ParagraphBuilder.setDisableRoundingHack(true));
784-
}
785-
// The paragraph width is only rounded to a whole integer if
786-
// shouldDisableRoundingHack is false.
787-
assert(!ui.ParagraphBuilder.shouldDisableRoundingHack);
788-
final ui.Paragraph paragraph = plain(ahemStyle, 'abc');
789-
paragraph.layout(const ui.ParagraphConstraints(width: 30.8));
790-
791-
expect(paragraph.width, 30);
792-
expect(paragraph.height, 10);
793-
});
794-
795780
test('Render after dispose', () async {
796781
final ui.Paragraph paragraph = plain(ahemStyle, 'abc');
797782
paragraph.layout(const ui.ParagraphConstraints(width: 30.8));

lib/web_ui/test/html/text_test.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,7 @@ Future<void> testMain() async {
200200
expect(bottomRight?.graphemeClusterLayoutBounds, const Rect.fromLTWH(0.0, 0.0, 10.0, 10.0));
201201
}, skip: domIntl.v8BreakIterator == null); // Intended: Intl.v8breakiterator is needed for correctly breaking grapheme clusters.
202202

203-
test('Can disable rounding hack', () {
204-
if (!ParagraphBuilder.shouldDisableRoundingHack) {
205-
ParagraphBuilder.setDisableRoundingHack(true);
206-
addTearDown(() => ParagraphBuilder.setDisableRoundingHack(false));
207-
}
208-
assert(ParagraphBuilder.shouldDisableRoundingHack);
203+
test('disable rounding hack', () {
209204
const double fontSize = 1;
210205
const String text = '12345';
211206
const double letterSpacing = 0.25;

lib/web_ui/test/ui/line_metrics_test.dart

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ Future<void> testMain() async {
9797
expect(bottomRight?.writingDirection, ui.TextDirection.ltr);
9898
});
9999

100-
test('rounding hack disabled by default', () {
101-
expect(ui.ParagraphBuilder.shouldDisableRoundingHack, isTrue);
102-
100+
test('rounding hack is always disabled', () {
103101
const double fontSize = 1.25;
104102
const String text = '12345';
105103
assert((fontSize * text.length).truncate() != fontSize * text.length);
@@ -118,30 +116,4 @@ Future<void> testMain() async {
118116
expect(metrics, hasLength(1));
119117
}
120118
}, skip: isHtml); // The rounding hack doesn't apply to the html renderer
121-
122-
test('setDisableRoundingHack to false works in tests', () {
123-
bool assertsEnabled = false;
124-
assert(() {
125-
assertsEnabled = true;
126-
return true;
127-
}());
128-
if (!assertsEnabled){
129-
return;
130-
}
131-
132-
if (ui.ParagraphBuilder.shouldDisableRoundingHack) {
133-
ui.ParagraphBuilder.setDisableRoundingHack(false);
134-
addTearDown(() => ui.ParagraphBuilder.setDisableRoundingHack(true));
135-
}
136-
137-
assert(!ui.ParagraphBuilder.shouldDisableRoundingHack);
138-
const double fontSize = 1.25;
139-
const String text = '12345';
140-
assert((fontSize * text.length).truncate() != fontSize * text.length);
141-
final ui.ParagraphBuilder builder = ui.ParagraphBuilder(ui.ParagraphStyle(fontSize: fontSize, fontFamily: 'FlutterTest'));
142-
builder.addText(text);
143-
final ui.Paragraph paragraph = builder.build()
144-
..layout(const ui.ParagraphConstraints(width: text.length * fontSize));
145-
expect(paragraph.computeLineMetrics().length, greaterThan(1));
146-
}, skip: isHtml); // The rounding hack doesn't apply to the html renderer
147119
}

0 commit comments

Comments
 (0)