mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Remove ParagraphStyle.lineCount, which has been superseded by maxLines (#3390)
Fixes https://github.com/flutter/flutter/issues/7723
This commit is contained in:
parent
d317fb3b9d
commit
cd34b0ef39
@ -378,16 +378,15 @@ class TextStyle {
|
||||
//
|
||||
// - Element 3: The enum index of the |fontStyle|.
|
||||
//
|
||||
// - Element 4: The value of |lineCount|.
|
||||
// - Element 4: The value of |maxLines|.
|
||||
//
|
||||
Int32List _encodeParagraphStyle(TextAlign textAlign,
|
||||
FontWeight fontWeight,
|
||||
FontStyle fontStyle,
|
||||
int lineCount,
|
||||
int maxLines,
|
||||
String fontFamily,
|
||||
double fontSize,
|
||||
double lineHeight,
|
||||
int maxLines,
|
||||
String ellipsis) {
|
||||
Int32List result = new Int32List(5);
|
||||
if (textAlign != null) {
|
||||
@ -402,9 +401,9 @@ Int32List _encodeParagraphStyle(TextAlign textAlign,
|
||||
result[0] |= 1 << 3;
|
||||
result[3] = fontStyle.index;
|
||||
}
|
||||
if (lineCount != null) {
|
||||
if (maxLines != null) {
|
||||
result[0] |= 1 << 4;
|
||||
result[4] = lineCount;
|
||||
result[4] = maxLines;
|
||||
}
|
||||
if (fontFamily != null) {
|
||||
result[0] |= 1 << 5;
|
||||
@ -418,12 +417,8 @@ Int32List _encodeParagraphStyle(TextAlign textAlign,
|
||||
result[0] |= 1 << 7;
|
||||
// Passed separately to native.
|
||||
}
|
||||
if (maxLines != null) {
|
||||
result[0] |= 1 << 8;
|
||||
// Passed separately to native.
|
||||
}
|
||||
if (ellipsis != null) {
|
||||
result[0] |= 1 << 9;
|
||||
result[0] |= 1 << 8;
|
||||
// Passed separately to native.
|
||||
}
|
||||
return result;
|
||||
@ -436,7 +431,7 @@ class ParagraphStyle {
|
||||
/// * `textAlign`: The alignment of the text within the lines of the paragraph.
|
||||
/// * `fontWeight`: The typeface thickness to use when painting the text (e.g., bold).
|
||||
/// * `fontStyle`: The typeface variant to use when drawing the letters (e.g., italics).
|
||||
/// * `lineCount`: Currently not implemented.
|
||||
/// * `maxLines`: The maximum number of lines painted.
|
||||
/// * `fontFamily`: The name of the font to use when painting the text (e.g., Roboto).
|
||||
/// * `fontSize`: The size of glyphs (in logical pixels) to use when painting the text.
|
||||
/// * `lineHeight`: The minimum height of the line boxes, as a multiple of the font size.
|
||||
@ -445,34 +440,28 @@ class ParagraphStyle {
|
||||
TextAlign textAlign,
|
||||
FontWeight fontWeight,
|
||||
FontStyle fontStyle,
|
||||
int lineCount,
|
||||
int maxLines,
|
||||
String fontFamily,
|
||||
double fontSize,
|
||||
double lineHeight,
|
||||
int maxLines,
|
||||
String ellipsis
|
||||
}) : _encoded = _encodeParagraphStyle(textAlign,
|
||||
fontWeight,
|
||||
fontStyle,
|
||||
lineCount,
|
||||
maxLines,
|
||||
fontFamily,
|
||||
fontSize,
|
||||
lineHeight,
|
||||
maxLines,
|
||||
ellipsis),
|
||||
_fontFamily = fontFamily,
|
||||
_fontSize = fontSize,
|
||||
_lineHeight = lineHeight,
|
||||
_maxLines = maxLines,
|
||||
_ellipsis = ellipsis {
|
||||
assert(lineCount == null);
|
||||
}
|
||||
_ellipsis = ellipsis;
|
||||
|
||||
final Int32List _encoded;
|
||||
final String _fontFamily;
|
||||
final double _fontSize;
|
||||
final double _lineHeight;
|
||||
final int _maxLines;
|
||||
final String _ellipsis;
|
||||
|
||||
bool operator ==(dynamic other) {
|
||||
@ -484,7 +473,6 @@ class ParagraphStyle {
|
||||
if ( _fontFamily != typedOther._fontFamily ||
|
||||
_fontSize != typedOther._fontSize ||
|
||||
_lineHeight != typedOther._lineHeight ||
|
||||
_maxLines != typedOther._maxLines ||
|
||||
_ellipsis != typedOther._ellipsis)
|
||||
return false;
|
||||
for (int index = 0; index < _encoded.length; index += 1) {
|
||||
@ -494,19 +482,18 @@ class ParagraphStyle {
|
||||
return true;
|
||||
}
|
||||
|
||||
int get hashCode => hashValues(hashList(_encoded), _lineHeight, _maxLines, _ellipsis);
|
||||
int get hashCode => hashValues(hashList(_encoded), _lineHeight, _ellipsis);
|
||||
|
||||
String toString() {
|
||||
return 'ParagraphStyle('
|
||||
'textAlign: ${ _encoded[0] & 0x02 == 0x02 ? TextAlign.values[_encoded[1]] : "unspecified"}, '
|
||||
'fontWeight: ${ _encoded[0] & 0x04 == 0x04 ? FontWeight.values[_encoded[2]] : "unspecified"}, '
|
||||
'fontStyle: ${ _encoded[0] & 0x08 == 0x08 ? FontStyle.values[_encoded[3]] : "unspecified"}, '
|
||||
'lineCount: ${ _encoded[0] & 0x10 == 0x10 ? _encoded[4] : "unspecified"}, '
|
||||
'maxLines: ${ _encoded[0] & 0x10 == 0x10 ? _encoded[4] : "unspecified"}, '
|
||||
'fontFamily: ${ _encoded[0] & 0x20 == 0x20 ? _fontFamily : "unspecified"}, '
|
||||
'fontSize: ${ _encoded[0] & 0x40 == 0x40 ? _fontSize : "unspecified"}, '
|
||||
'lineHeight: ${ _encoded[0] & 0x80 == 0x80 ? "${_lineHeight}x" : "unspecified"}, '
|
||||
'maxLines: ${ _encoded[0] & 0x100 == 0x100 ? _maxLines : "unspecified"}, '
|
||||
'ellipsis: ${ _encoded[0] & 0x200 == 0x200 ? "\"$_ellipsis\"" : "unspecified"}'
|
||||
'ellipsis: ${ _encoded[0] & 0x100 == 0x100 ? "\"$_ellipsis\"" : "unspecified"}'
|
||||
')';
|
||||
}
|
||||
}
|
||||
@ -734,8 +721,8 @@ abstract class Paragraph extends NativeFieldWrapperClass2 {
|
||||
class ParagraphBuilder extends NativeFieldWrapperClass2 {
|
||||
/// Creates a [ParagraphBuilder] object, which is used to create a
|
||||
/// [Paragraph].
|
||||
ParagraphBuilder(ParagraphStyle style) { _constructor(style._encoded, style._fontFamily, style._fontSize, style._lineHeight, style._maxLines, style._ellipsis); }
|
||||
void _constructor(Int32List encoded, String fontFamily, double fontSize, double lineHeight, int maxLines, String ellipsis) native "ParagraphBuilder_constructor";
|
||||
ParagraphBuilder(ParagraphStyle style) { _constructor(style._encoded, style._fontFamily, style._fontSize, style._lineHeight, style._ellipsis); }
|
||||
void _constructor(Int32List encoded, String fontFamily, double fontSize, double lineHeight, String ellipsis) native "ParagraphBuilder_constructor";
|
||||
|
||||
/// Applies the given style to the added text until [pop] is called.
|
||||
///
|
||||
|
||||
@ -53,20 +53,19 @@ const int tsHeightMask = 1 << tsHeightIndex;
|
||||
const int psTextAlignIndex = 1;
|
||||
const int psFontWeightIndex = 2;
|
||||
const int psFontStyleIndex = 3;
|
||||
// index 4 reserved for LineCount
|
||||
const int psMaxLinesIndex = 4;
|
||||
const int psFontFamilyIndex = 5;
|
||||
const int psFontSizeIndex = 6;
|
||||
const int psLineHeightIndex = 7;
|
||||
const int psMaxLinesIndex = 8;
|
||||
const int psEllipsisIndex = 9;
|
||||
const int psEllipsisIndex = 8;
|
||||
|
||||
const int psTextAlignMask = 1 << psTextAlignIndex;
|
||||
const int psFontWeightMask = 1 << psFontWeightIndex;
|
||||
const int psFontStyleMask = 1 << psFontStyleIndex;
|
||||
const int psMaxLinesMask = 1 << psMaxLinesIndex;
|
||||
const int psFontFamilyMask = 1 << psFontFamilyIndex;
|
||||
const int psFontSizeMask = 1 << psFontSizeIndex;
|
||||
const int psLineHeightMask = 1 << psLineHeightIndex;
|
||||
const int psMaxLinesMask = 1 << psMaxLinesIndex;
|
||||
const int psEllipsisMask = 1 << psEllipsisIndex;
|
||||
|
||||
float getComputedSizeFromSpecifiedSize(float specifiedSize) {
|
||||
@ -102,7 +101,6 @@ PassRefPtr<RenderStyle> decodeParagraphStyle(
|
||||
const std::string& fontFamily,
|
||||
double fontSize,
|
||||
double lineHeight,
|
||||
int maxLines,
|
||||
const std::string& ellipsis) {
|
||||
FTL_DCHECK(encoded.num_elements() == 5);
|
||||
|
||||
@ -148,7 +146,7 @@ PassRefPtr<RenderStyle> decodeParagraphStyle(
|
||||
style->setLineHeight(Length(lineHeight * 100.0, Percent));
|
||||
|
||||
if (mask & psMaxLinesMask)
|
||||
style->setMaxLines(maxLines);
|
||||
style->setMaxLines(encoded[psMaxLinesIndex]);
|
||||
|
||||
if (mask & psEllipsisMask)
|
||||
style->setEllipsis(AtomicString::fromUTF8(ellipsis.c_str()));
|
||||
@ -179,7 +177,7 @@ FOR_EACH_BINDING(DART_NATIVE_CALLBACK)
|
||||
|
||||
void ParagraphBuilder::RegisterNatives(tonic::DartLibraryNatives* natives) {
|
||||
natives->Register(
|
||||
{{"ParagraphBuilder_constructor", ParagraphBuilder_constructor, 7, true},
|
||||
{{"ParagraphBuilder_constructor", ParagraphBuilder_constructor, 6, true},
|
||||
FOR_EACH_BINDING(DART_REGISTER_NATIVE)});
|
||||
}
|
||||
|
||||
@ -188,22 +186,20 @@ ftl::RefPtr<ParagraphBuilder> ParagraphBuilder::create(
|
||||
const std::string& fontFamily,
|
||||
double fontSize,
|
||||
double lineHeight,
|
||||
int maxLines,
|
||||
const std::string& ellipsis) {
|
||||
return ftl::MakeRefCounted<ParagraphBuilder>(
|
||||
encoded, fontFamily, fontSize, lineHeight, maxLines, ellipsis);
|
||||
encoded, fontFamily, fontSize, lineHeight, ellipsis);
|
||||
}
|
||||
|
||||
ParagraphBuilder::ParagraphBuilder(tonic::Int32List& encoded,
|
||||
const std::string& fontFamily,
|
||||
double fontSize,
|
||||
double lineHeight,
|
||||
int maxLines,
|
||||
const std::string& ellipsis) {
|
||||
createRenderView();
|
||||
|
||||
RefPtr<RenderStyle> paragraphStyle = decodeParagraphStyle(
|
||||
m_renderView->style(), encoded, fontFamily, fontSize, lineHeight, maxLines, ellipsis);
|
||||
m_renderView->style(), encoded, fontFamily, fontSize, lineHeight, ellipsis);
|
||||
encoded.Release();
|
||||
|
||||
m_renderParagraph = new RenderParagraph();
|
||||
|
||||
@ -25,7 +25,6 @@ class ParagraphBuilder : public ftl::RefCountedThreadSafe<ParagraphBuilder>,
|
||||
const std::string& fontFamily,
|
||||
double fontSize,
|
||||
double lineHeight,
|
||||
int maxLines,
|
||||
const std::string& ellipsis);
|
||||
|
||||
~ParagraphBuilder() override;
|
||||
@ -49,7 +48,6 @@ class ParagraphBuilder : public ftl::RefCountedThreadSafe<ParagraphBuilder>,
|
||||
const std::string& fontFamily,
|
||||
double fontSize,
|
||||
double lineHeight,
|
||||
int maxLines,
|
||||
const std::string& ellipsis);
|
||||
|
||||
void createRenderView();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user