Skip to content

Commit 5f8e75a

Browse files
committed
Revert "Engine/LibTxt/dart:ui impl of TextHeightBehavior (flutter#15087)"
This reverts commit cbf4536.
1 parent 9e2ba63 commit 5f8e75a

File tree

10 files changed

+22
-422
lines changed

10 files changed

+22
-422
lines changed

lib/ui/text.dart

Lines changed: 12 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -429,94 +429,6 @@ enum TextDecorationStyle {
429429
wavy
430430
}
431431

432-
/// {@template flutter.dart:ui.textHeightBehavior}
433-
/// Defines how the paragraph will apply [TextStyle.height] to the ascent of the
434-
/// first line and descent of the last line.
435-
///
436-
/// Each boolean value represents whether the [TextStyle.height] modifier will
437-
/// be applied to the corresponding metric. By default, all properties are true,
438-
/// and [TextStyle.height] is applied as normal. When set to false, the font's
439-
/// default ascent will be used.
440-
/// {@endtemplate}
441-
class TextHeightBehavior {
442-
443-
/// Creates a new TextHeightBehavior object.
444-
///
445-
/// * applyHeightToFirstAscent: When true, the [TextStyle.height] modifier
446-
/// will be applied to the ascent of the first line. When false, the font's
447-
/// default ascent will be used.
448-
/// * applyHeightToLastDescent: When true, the [TextStyle.height] modifier
449-
/// will be applied to the descent of the last line. When false, the font's
450-
/// default descent will be used.
451-
///
452-
/// All properties default to true (height modifications applied as normal).
453-
const TextHeightBehavior({
454-
this.applyHeightToFirstAscent = true,
455-
this.applyHeightToLastDescent = true,
456-
});
457-
458-
/// Creates a new TextHeightBehavior object from an encoded form.
459-
///
460-
/// See [encode] for the creation of the encoded form.
461-
const TextHeightBehavior.fromEncoded(int encoded) : applyHeightToFirstAscent = (encoded & 0x1) == 0,
462-
applyHeightToLastDescent = (encoded & 0x2) == 0;
463-
464-
465-
/// Whether to apply the [TextStyle.height] modifier to the ascent of the first
466-
/// line in the paragraph.
467-
///
468-
/// When true, the [TextStyle.height] modifier will be applied to to the ascent
469-
/// of the first line. When false, the font's default ascent will be used and
470-
/// the [TextStyle.height] will have no effect on the ascent of the first line.
471-
///
472-
/// This property only has effect if a non-null [TextStyle.height] is specified.
473-
///
474-
/// Defaults to true (height modifications applied as normal).
475-
final bool applyHeightToFirstAscent;
476-
477-
/// Whether to apply the [TextStyle.height] modifier to the descent of the last
478-
/// line in the paragraph.
479-
///
480-
/// When true, the [TextStyle.height] modifier will be applied to to the descent
481-
/// of the last line. When false, the font's default descent will be used and
482-
/// the [TextStyle.height] will have no effect on the descent of the last line.
483-
///
484-
/// This property only has effect if a non-null [TextStyle.height] is specified.
485-
///
486-
/// Defaults to true (height modifications applied as normal).
487-
final bool applyHeightToLastDescent;
488-
489-
/// Returns an encoded int representation of this object.
490-
int encode() {
491-
return (applyHeightToFirstAscent ? 0 : 1 << 0) | (applyHeightToLastDescent ? 0 : 1 << 1);
492-
}
493-
494-
@override
495-
bool operator ==(dynamic other) {
496-
if (other.runtimeType != runtimeType)
497-
return false;
498-
return other is TextHeightBehavior
499-
&& other.applyHeightToFirstAscent == applyHeightToFirstAscent
500-
&& other.applyHeightToLastDescent == applyHeightToLastDescent;
501-
}
502-
503-
@override
504-
int get hashCode {
505-
return hashValues(
506-
applyHeightToFirstAscent,
507-
applyHeightToLastDescent,
508-
);
509-
}
510-
511-
@override
512-
String toString() {
513-
return 'TextHeightBehavior('
514-
'applyHeightToFirstAscent: $applyHeightToFirstAscent, '
515-
'applyHeightToLastDescent: $applyHeightToLastDescent'
516-
')';
517-
}
518-
}
519-
520432
/// Determines if lists [a] and [b] are deep equivalent.
521433
///
522434
/// Returns true if the lists are both null, or if they are both non-null, have
@@ -834,23 +746,20 @@ class TextStyle {
834746
//
835747
// - Element 5: The value of |maxLines|.
836748
//
837-
// - Element 6: The encoded value of |textHeightBehavior|.
838-
//
839749
Int32List _encodeParagraphStyle(
840750
TextAlign textAlign,
841751
TextDirection textDirection,
842752
int maxLines,
843753
String fontFamily,
844754
double fontSize,
845755
double height,
846-
TextHeightBehavior textHeightBehavior,
847756
FontWeight fontWeight,
848757
FontStyle fontStyle,
849758
StrutStyle strutStyle,
850759
String ellipsis,
851760
Locale locale,
852761
) {
853-
final Int32List result = Int32List(7); // also update paragraph_builder.cc
762+
final Int32List result = Int32List(6); // also update paragraph_builder.cc
854763
if (textAlign != null) {
855764
result[0] |= 1 << 1;
856765
result[1] = textAlign.index;
@@ -871,32 +780,28 @@ Int32List _encodeParagraphStyle(
871780
result[0] |= 1 << 5;
872781
result[5] = maxLines;
873782
}
874-
if (textHeightBehavior != null) {
875-
result[0] |= 1 << 6;
876-
result[6] = textHeightBehavior.encode();
877-
}
878783
if (fontFamily != null) {
879-
result[0] |= 1 << 7;
784+
result[0] |= 1 << 6;
880785
// Passed separately to native.
881786
}
882787
if (fontSize != null) {
883-
result[0] |= 1 << 8;
788+
result[0] |= 1 << 7;
884789
// Passed separately to native.
885790
}
886791
if (height != null) {
887-
result[0] |= 1 << 9;
792+
result[0] |= 1 << 8;
888793
// Passed separately to native.
889794
}
890795
if (strutStyle != null) {
891-
result[0] |= 1 << 10;
796+
result[0] |= 1 << 9;
892797
// Passed separately to native.
893798
}
894799
if (ellipsis != null) {
895-
result[0] |= 1 << 11;
800+
result[0] |= 1 << 10;
896801
// Passed separately to native.
897802
}
898803
if (locale != null) {
899-
result[0] |= 1 << 12;
804+
result[0] |= 1 << 11;
900805
// Passed separately to native.
901806
}
902807
return result;
@@ -937,9 +842,6 @@ class ParagraphStyle {
937842
/// the line height to take the height as defined by the font, which may not
938843
/// be exactly the height of the `fontSize`.
939844
///
940-
/// * `textHeightBehavior`: Specifies how the `height` multiplier is
941-
/// applied to ascent of the first line and the descent of the last line.
942-
///
943845
/// * `fontWeight`: The typeface thickness to use when painting the text
944846
/// (e.g., bold).
945847
///
@@ -967,7 +869,6 @@ class ParagraphStyle {
967869
String fontFamily,
968870
double fontSize,
969871
double height,
970-
TextHeightBehavior textHeightBehavior,
971872
FontWeight fontWeight,
972873
FontStyle fontStyle,
973874
StrutStyle strutStyle,
@@ -980,7 +881,6 @@ class ParagraphStyle {
980881
fontFamily,
981882
fontSize,
982883
height,
983-
textHeightBehavior,
984884
fontWeight,
985885
fontStyle,
986886
strutStyle,
@@ -1029,14 +929,11 @@ class ParagraphStyle {
1029929
'fontWeight: ${ _encoded[0] & 0x008 == 0x008 ? FontWeight.values[_encoded[3]] : "unspecified"}, '
1030930
'fontStyle: ${ _encoded[0] & 0x010 == 0x010 ? FontStyle.values[_encoded[4]] : "unspecified"}, '
1031931
'maxLines: ${ _encoded[0] & 0x020 == 0x020 ? _encoded[5] : "unspecified"}, '
1032-
'textHeightBehavior: ${
1033-
_encoded[0] & 0x040 == 0x040 ?
1034-
TextHeightBehavior.fromEncoded(_encoded[6]).toString() : "unspecified"}, '
1035-
'fontFamily: ${ _encoded[0] & 0x080 == 0x080 ? _fontFamily : "unspecified"}, '
1036-
'fontSize: ${ _encoded[0] & 0x100 == 0x100 ? _fontSize : "unspecified"}, '
1037-
'height: ${ _encoded[0] & 0x200 == 0x200 ? "${_height}x" : "unspecified"}, '
1038-
'ellipsis: ${ _encoded[0] & 0x400 == 0x400 ? "\"$_ellipsis\"" : "unspecified"}, '
1039-
'locale: ${ _encoded[0] & 0x800 == 0x800 ? _locale : "unspecified"}'
932+
'fontFamily: ${ _encoded[0] & 0x040 == 0x040 ? _fontFamily : "unspecified"}, '
933+
'fontSize: ${ _encoded[0] & 0x080 == 0x080 ? _fontSize : "unspecified"}, '
934+
'height: ${ _encoded[0] & 0x100 == 0x100 ? "${_height}x" : "unspecified"}, '
935+
'ellipsis: ${ _encoded[0] & 0x200 == 0x200 ? "\"$_ellipsis\"" : "unspecified"}, '
936+
'locale: ${ _encoded[0] & 0x400 == 0x400 ? _locale : "unspecified"}'
1040937
')';
1041938
}
1042939
}

lib/ui/text/paragraph_builder.cc

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,12 @@ const int psTextDirectionIndex = 2;
7575
const int psFontWeightIndex = 3;
7676
const int psFontStyleIndex = 4;
7777
const int psMaxLinesIndex = 5;
78-
const int psTextHeightBehaviorIndex = 6;
79-
const int psFontFamilyIndex = 7;
80-
const int psFontSizeIndex = 8;
81-
const int psHeightIndex = 9;
82-
const int psStrutStyleIndex = 10;
83-
const int psEllipsisIndex = 11;
84-
const int psLocaleIndex = 12;
78+
const int psFontFamilyIndex = 6;
79+
const int psFontSizeIndex = 7;
80+
const int psHeightIndex = 8;
81+
const int psStrutStyleIndex = 9;
82+
const int psEllipsisIndex = 10;
83+
const int psLocaleIndex = 11;
8584

8685
const int psTextAlignMask = 1 << psTextAlignIndex;
8786
const int psTextDirectionMask = 1 << psTextDirectionIndex;
@@ -91,7 +90,6 @@ const int psMaxLinesMask = 1 << psMaxLinesIndex;
9190
const int psFontFamilyMask = 1 << psFontFamilyIndex;
9291
const int psFontSizeMask = 1 << psFontSizeIndex;
9392
const int psHeightMask = 1 << psHeightIndex;
94-
const int psTextHeightBehaviorMask = 1 << psTextHeightBehaviorIndex;
9593
const int psStrutStyleMask = 1 << psStrutStyleIndex;
9694
const int psEllipsisMask = 1 << psEllipsisIndex;
9795
const int psLocaleMask = 1 << psLocaleIndex;
@@ -267,10 +265,6 @@ ParagraphBuilder::ParagraphBuilder(
267265
style.has_height_override = true;
268266
}
269267

270-
if (mask & psTextHeightBehaviorMask) {
271-
style.text_height_behavior = encoded[psTextHeightBehaviorIndex];
272-
}
273-
274268
if (mask & psStrutStyleMask) {
275269
decodeStrut(strutData, strutFontFamilies, style);
276270
}

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class SkParagraphStyle implements ui.ParagraphStyle {
2525
String fontFamily,
2626
double fontSize,
2727
double height,
28-
ui.TextHeightBehavior textHeightBehavior,
2928
ui.FontWeight fontWeight,
3029
ui.FontStyle fontStyle,
3130
ui.StrutStyle strutStyle,
@@ -39,7 +38,6 @@ class SkParagraphStyle implements ui.ParagraphStyle {
3938
fontFamily,
4039
fontSize,
4140
height,
42-
textHeightBehavior,
4341
fontWeight,
4442
fontStyle,
4543
ellipsis,
@@ -87,7 +85,6 @@ class SkParagraphStyle implements ui.ParagraphStyle {
8785
String fontFamily,
8886
double fontSize,
8987
double height,
90-
ui.TextHeightBehavior textHeightBehavior,
9188
ui.FontWeight fontWeight,
9289
ui.FontStyle fontStyle,
9390
String ellipsis,
@@ -132,10 +129,6 @@ class SkParagraphStyle implements ui.ParagraphStyle {
132129
skParagraphStyle['heightMultiplier'] = height;
133130
}
134131

135-
if (textHeightBehavior != null) {
136-
skParagraphStyle['textHeightBehavior'] = textHeightBehavior.encode();
137-
}
138-
139132
if (maxLines != null) {
140133
skParagraphStyle['maxLines'] = maxLines;
141134
}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ class EngineParagraphStyle implements ui.ParagraphStyle {
457457
String fontFamily,
458458
double fontSize,
459459
double height,
460-
ui.TextHeightBehavior textHeightBehavior,
461460
ui.FontWeight fontWeight,
462461
ui.FontStyle fontStyle,
463462
ui.StrutStyle strutStyle,
@@ -471,7 +470,6 @@ class EngineParagraphStyle implements ui.ParagraphStyle {
471470
_fontFamily = fontFamily,
472471
_fontSize = fontSize,
473472
_height = height,
474-
_textHeightBehavior = textHeightBehavior,
475473
// TODO(b/128317744): add support for strut style.
476474
_strutStyle = strutStyle,
477475
_ellipsis = ellipsis,
@@ -485,7 +483,6 @@ class EngineParagraphStyle implements ui.ParagraphStyle {
485483
final String _fontFamily;
486484
final double _fontSize;
487485
final double _height;
488-
final ui.TextHeightBehavior _textHeightBehavior;
489486
final EngineStrutStyle _strutStyle;
490487
final String _ellipsis;
491488
final ui.Locale _locale;
@@ -539,7 +536,6 @@ class EngineParagraphStyle implements ui.ParagraphStyle {
539536
_fontFamily == typedOther._fontFamily ||
540537
_fontSize == typedOther._fontSize ||
541538
_height == typedOther._height ||
542-
_textHeightBehavior == typedOther._textHeightBehavior ||
543539
_ellipsis == typedOther._ellipsis ||
544540
_locale == typedOther._locale;
545541
}
@@ -560,7 +556,6 @@ class EngineParagraphStyle implements ui.ParagraphStyle {
560556
'fontFamily: ${_fontFamily ?? "unspecified"}, '
561557
'fontSize: ${_fontSize != null ? _fontSize.toStringAsFixed(1) : "unspecified"}, '
562558
'height: ${_height != null ? "${_height.toStringAsFixed(1)}x" : "unspecified"}, '
563-
'textHeightBehavior: ${_textHeightBehavior ?? "unspecified"}, '
564559
'ellipsis: ${_ellipsis != null ? "\"$_ellipsis\"" : "unspecified"}, '
565560
'locale: ${_locale ?? "unspecified"}'
566561
')';

0 commit comments

Comments
 (0)