Remove extra shadows from Web Engine EngineParagraphStyle (flutter/engine#13805)

This commit is contained in:
Gary Qian 2019-11-13 11:13:46 -08:00 committed by GitHub
parent 3cdd5f6ef6
commit d4a5a15200
2 changed files with 4 additions and 32 deletions

View File

@ -18,7 +18,6 @@ class EngineParagraph implements ui.Paragraph {
@required ui.TextAlign textAlign,
@required ui.TextDirection textDirection,
@required ui.Paint background,
@required List<ui.Shadow> shadows,
}) : assert((plainText == null && paint == null) ||
(plainText != null && paint != null)),
_paragraphElement = paragraphElement,
@ -27,8 +26,7 @@ class EngineParagraph implements ui.Paragraph {
_textAlign = textAlign,
_textDirection = textDirection,
_paint = paint,
_background = background,
_shadows = shadows;
_background = background;
final html.HtmlElement _paragraphElement;
final ParagraphGeometricStyle _geometricStyle;
@ -37,7 +35,6 @@ class EngineParagraph implements ui.Paragraph {
final ui.TextAlign _textAlign;
final ui.TextDirection _textDirection;
final ui.Paint _background;
final List<ui.Shadow> _shadows;
@visibleForTesting
String get plainText => _plainText;
@ -325,7 +322,6 @@ class EngineParagraphStyle implements ui.ParagraphStyle {
ui.StrutStyle strutStyle,
String ellipsis,
ui.Locale locale,
List<ui.Shadow> shadows,
}) : _textAlign = textAlign,
_textDirection = textDirection,
_fontWeight = fontWeight,
@ -337,8 +333,7 @@ class EngineParagraphStyle implements ui.ParagraphStyle {
// TODO(b/128317744): add support for strut style.
_strutStyle = strutStyle,
_ellipsis = ellipsis,
_locale = locale,
_shadows = shadows;
_locale = locale;
final ui.TextAlign _textAlign;
final ui.TextDirection _textDirection;
@ -351,7 +346,6 @@ class EngineParagraphStyle implements ui.ParagraphStyle {
final EngineStrutStyle _strutStyle;
final String _ellipsis;
final ui.Locale _locale;
final List<ui.Shadow> _shadows;
String get _effectiveFontFamily {
if (assertionsEnabled) {
@ -419,8 +413,7 @@ class EngineParagraphStyle implements ui.ParagraphStyle {
'fontSize: ${_fontSize != null ? _fontSize.toStringAsFixed(1) : "unspecified"}, '
'height: ${_height != null ? "${_height.toStringAsFixed(1)}x" : "unspecified"}, '
'ellipsis: ${_ellipsis != null ? "\"$_ellipsis\"" : "unspecified"}, '
'locale: ${_locale ?? "unspecified"}, '
'shadows: ${_shadows ?? "unspecified"}'
'locale: ${_locale ?? "unspecified"}'
')';
} else {
return super.toString();
@ -913,7 +906,6 @@ class EngineParagraphBuilder implements ui.ParagraphBuilder {
wordSpacing: wordSpacing,
decoration: _textDecorationToCssString(decoration, decorationStyle),
ellipsis: _paragraphStyle._ellipsis,
shadows: shadows,
),
plainText: '',
paint: paint,
@ -967,7 +959,6 @@ class EngineParagraphBuilder implements ui.ParagraphBuilder {
wordSpacing: wordSpacing,
decoration: _textDecorationToCssString(decoration, decorationStyle),
ellipsis: _paragraphStyle._ellipsis,
shadows: shadows,
),
plainText: plainText,
paint: paint,
@ -1011,7 +1002,6 @@ class EngineParagraphBuilder implements ui.ParagraphBuilder {
lineHeight: _paragraphStyle._height,
maxLines: _paragraphStyle._maxLines,
ellipsis: _paragraphStyle._ellipsis,
shadows: _paragraphStyle._shadows,
),
plainText: null,
paint: null,
@ -1098,9 +1088,6 @@ void _applyParagraphStyleToElement({
if (style._effectiveFontFamily != null) {
cssStyle.fontFamily = canonicalizeFontFamily(style._effectiveFontFamily);
}
if (style._shadows != null) {
cssStyle.textShadow = _shadowListToCss(style._shadows);
}
} else {
if (style._textAlign != previousStyle._textAlign) {
cssStyle.textAlign = textAlignToCssValue(
@ -1127,9 +1114,6 @@ void _applyParagraphStyleToElement({
if (style._fontFamily != previousStyle._fontFamily) {
cssStyle.fontFamily = canonicalizeFontFamily(style._fontFamily);
}
if (style._shadows != previousStyle._shadows) {
cssStyle.textShadow = _shadowListToCss(style._shadows);
}
}
}

View File

@ -17,7 +17,6 @@ class ParagraphGeometricStyle {
this.wordSpacing,
this.decoration,
this.ellipsis,
this.shadows,
});
final ui.FontWeight fontWeight;
@ -30,7 +29,6 @@ class ParagraphGeometricStyle {
final double wordSpacing;
final String decoration;
final String ellipsis;
final List<ui.Shadow> shadows;
// Since all fields above are primitives, cache hashcode since ruler lookups
// use this style as key.
@ -111,8 +109,7 @@ class ParagraphGeometricStyle {
letterSpacing == typedOther.letterSpacing &&
wordSpacing == typedOther.wordSpacing &&
decoration == typedOther.decoration &&
ellipsis == typedOther.ellipsis &&
shadows == typedOther.shadows;
ellipsis == typedOther.ellipsis;
}
@override
@ -127,12 +124,8 @@ class ParagraphGeometricStyle {
wordSpacing,
decoration,
ellipsis,
_hashShadows(shadows),
);
int _hashShadows(List<ui.Shadow> shadows) =>
(shadows == null ? '' : _shadowListToCss(shadows)).hashCode;
@override
String toString() {
if (assertionsEnabled) {
@ -144,7 +137,6 @@ class ParagraphGeometricStyle {
' wordSpacing: $wordSpacing,'
' decoration: $decoration,'
' ellipsis: $ellipsis,'
' shadows: $shadows,'
')';
} else {
return super.toString();
@ -249,10 +241,6 @@ class TextDimensions {
if (style.lineHeight != null) {
_element.style.lineHeight = style.lineHeight.toString();
}
final List<ui.Shadow> shadowList = style.shadows;
if (shadowList != null) {
_element.style.textShadow = _shadowListToCss(shadowList);
}
_invalidateBoundsCache();
}