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

Commit 6fc9776

Browse files
Remove migration flag and unused header files
1 parent ba3218b commit 6fc9776

File tree

17 files changed

+12
-204
lines changed

17 files changed

+12
-204
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5857,7 +5857,6 @@ ORIGIN: ../../../flutter/lib/ui/text/asset_manager_font_provider.cc + ../../../f
58575857
ORIGIN: ../../../flutter/lib/ui/text/asset_manager_font_provider.h + ../../../flutter/LICENSE
58585858
ORIGIN: ../../../flutter/lib/ui/text/font_collection.cc + ../../../flutter/LICENSE
58595859
ORIGIN: ../../../flutter/lib/ui/text/font_collection.h + ../../../flutter/LICENSE
5860-
ORIGIN: ../../../flutter/lib/ui/text/line_metrics.h + ../../../flutter/LICENSE
58615860
ORIGIN: ../../../flutter/lib/ui/text/paragraph.cc + ../../../flutter/LICENSE
58625861
ORIGIN: ../../../flutter/lib/ui/text/paragraph.h + ../../../flutter/LICENSE
58635862
ORIGIN: ../../../flutter/lib/ui/text/paragraph_builder.cc + ../../../flutter/LICENSE
@@ -8718,7 +8717,6 @@ FILE: ../../../flutter/lib/ui/text/asset_manager_font_provider.cc
87188717
FILE: ../../../flutter/lib/ui/text/asset_manager_font_provider.h
87198718
FILE: ../../../flutter/lib/ui/text/font_collection.cc
87208719
FILE: ../../../flutter/lib/ui/text/font_collection.h
8721-
FILE: ../../../flutter/lib/ui/text/line_metrics.h
87228720
FILE: ../../../flutter/lib/ui/text/paragraph.cc
87238721
FILE: ../../../flutter/lib/ui/text/paragraph.h
87248722
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
@@ -3355,23 +3355,6 @@ abstract class ParagraphBuilder {
33553355
/// [Paragraph].
33563356
factory ParagraphBuilder(ParagraphStyle style) = _NativeParagraphBuilder;
33573357

3358-
/// Whether the rounding hack enabled by default in SkParagraph and TextPainter
3359-
/// is disabled.
3360-
///
3361-
/// Do not rely on this getter as it exists for migration purposes only and
3362-
/// will soon be removed.
3363-
@Deprecated('''
3364-
The shouldDisableRoundingHack flag is for internal migration purposes only and should not be used.
3365-
''')
3366-
static bool get shouldDisableRoundingHack => _shouldDisableRoundingHack;
3367-
static bool _shouldDisableRoundingHack = true;
3368-
/// Do not call this method as it is for migration purposes only and will soon
3369-
/// be removed.
3370-
// ignore: use_setters_to_change_properties
3371-
static void setDisableRoundingHack(bool disableRoundingHack) {
3372-
_shouldDisableRoundingHack = disableRoundingHack;
3373-
}
3374-
33753358
/// The number of placeholders currently in the paragraph.
33763359
int get placeholderCount;
33773360

@@ -3489,11 +3472,10 @@ base class _NativeParagraphBuilder extends NativeFieldWrapperClass1 implements P
34893472
style._height ?? 0,
34903473
style._ellipsis ?? '',
34913474
_encodeLocale(style._locale),
3492-
!ParagraphBuilder.shouldDisableRoundingHack,
34933475
);
34943476
}
34953477

3496-
@Native<Void Function(Handle, Handle, Handle, Handle, Handle, Double, Double, Handle, Handle, Bool)>(symbol: 'ParagraphBuilder::Create')
3478+
@Native<Void Function(Handle, Handle, Handle, Handle, Handle, Double, Double, Handle, Handle)>(symbol: 'ParagraphBuilder::Create')
34973479
external void _constructor(
34983480
Int32List encoded,
34993481
ByteData? strutData,
@@ -3503,7 +3485,7 @@ base class _NativeParagraphBuilder extends NativeFieldWrapperClass1 implements P
35033485
double height,
35043486
String ellipsis,
35053487
String locale,
3506-
bool applyRoundingHack);
3488+
);
35073489

35083490
@override
35093491
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
@@ -374,7 +374,6 @@ class CanvasKitRenderer implements Renderer {
374374
strutStyle: strutStyle,
375375
ellipsis: ellipsis,
376376
locale: locale,
377-
applyRoundingHack: !ui.ParagraphBuilder.shouldDisableRoundingHack,
378377
);
379378

380379
@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/text/canvas_paragraph.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ class CanvasParagraph implements ui.Paragraph {
9494
// `30.5` then the TextPainter in the framework will ceil the `30.5` width
9595
// which will result in a width of `40.0` that's higher than the constraint
9696
// width.
97-
if (!ui.ParagraphBuilder.shouldDisableRoundingHack) {
98-
constraints = ui.ParagraphConstraints(width: constraints.width.floorToDouble());
99-
}
100-
10197
if (constraints == _lastUsedConstraints) {
10298
return;
10399
}

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/canvaskit/text_test.dart

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,7 @@ void testMain() {
204204
expect(bottomRight?.writingDirection, ui.TextDirection.ltr);
205205
});
206206

207-
test('rounding hack disabled by default', () {
208-
expect(ui.ParagraphBuilder.shouldDisableRoundingHack, isTrue);
209-
207+
test('rounding hack disabled', () {
210208
const double fontSize = 1.25;
211209
const String text = '12345';
212210
assert((fontSize * text.length).truncate() != fontSize * text.length);
@@ -226,32 +224,6 @@ void testMain() {
226224
}
227225
});
228226

229-
test('setDisableRoundinghHack to false works in tests', () {
230-
bool assertsEnabled = false;
231-
assert(() {
232-
assertsEnabled = true;
233-
return true;
234-
}());
235-
if (!assertsEnabled){
236-
return;
237-
}
238-
239-
if (ui.ParagraphBuilder.shouldDisableRoundingHack) {
240-
ui.ParagraphBuilder.setDisableRoundingHack(false);
241-
addTearDown(() => ui.ParagraphBuilder.setDisableRoundingHack(true));
242-
}
243-
244-
assert(!ui.ParagraphBuilder.shouldDisableRoundingHack);
245-
const double fontSize = 1.25;
246-
const String text = '12345';
247-
assert((fontSize * text.length).truncate() != fontSize * text.length);
248-
final ui.ParagraphBuilder builder = ui.ParagraphBuilder(ui.ParagraphStyle(fontSize: fontSize, fontFamily: 'FlutterTest'));
249-
builder.addText(text);
250-
final ui.Paragraph paragraph = builder.build()
251-
..layout(const ui.ParagraphConstraints(width: text.length * fontSize));
252-
expect(paragraph.computeLineMetrics().length, greaterThan(1));
253-
});
254-
255227
// TODO(hterkelsen): https://github.com/flutter/flutter/issues/71520
256228
}, skip: isSafari || isFirefox);
257229
}

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;

testing/dart/paragraph_test.dart

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -333,42 +333,10 @@ void main() {
333333
}
334334
});
335335

336-
test('can set disableRoundingHack to false in tests', () {
337-
bool assertsEnabled = false;
338-
assert(() {
339-
assertsEnabled = true;
340-
return true;
341-
}());
342-
if (!assertsEnabled){
343-
return;
344-
}
345-
const double fontSize = 1.25;
346-
const String text = '12345';
347-
assert((fontSize * text.length).truncate() != fontSize * text.length);
348-
// ignore: deprecated_member_use
349-
final bool roundingHackWasDisabled = ParagraphBuilder.shouldDisableRoundingHack;
350-
if (roundingHackWasDisabled) {
351-
ParagraphBuilder.setDisableRoundingHack(false);
352-
}
353-
// ignore: deprecated_member_use
354-
assert(!ParagraphBuilder.shouldDisableRoundingHack);
355-
final ParagraphBuilder builder = ParagraphBuilder(ParagraphStyle(fontSize: fontSize));
356-
builder.addText(text);
357-
final Paragraph paragraph = builder.build()
358-
..layout(const ParagraphConstraints(width: text.length * fontSize));
359-
expect(paragraph.computeLineMetrics().length, greaterThan(1));
360-
361-
if (roundingHackWasDisabled) {
362-
ParagraphBuilder.setDisableRoundingHack(true);
363-
}
364-
});
365-
366-
test('rounding hack disabled by default', () {
336+
test('rounding hack disabled', () {
367337
const double fontSize = 1.25;
368338
const String text = '12345';
369339
assert((fontSize * text.length).truncate() != fontSize * text.length);
370-
// ignore: deprecated_member_use
371-
expect(ParagraphBuilder.shouldDisableRoundingHack, isTrue);
372340
final ParagraphBuilder builder = ParagraphBuilder(ParagraphStyle(fontSize: fontSize));
373341
builder.addText(text);
374342
final Paragraph paragraph = builder.build()

third_party/txt/src/skia/paragraph_builder_skia.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ skt::ParagraphStyle ParagraphBuilderSkia::TxtToSkia(const ParagraphStyle& txt) {
139139

140140
skia.turnHintingOff();
141141
skia.setReplaceTabCharacters(true);
142-
skia.setApplyRoundingHack(txt.apply_rounding_hack);
142+
skia.setApplyRoundingHack(false);
143143

144144
return skia;
145145
}

0 commit comments

Comments
 (0)