[web] Remove unnecessary CSS styles on <p> elements (flutter/engine#32043)

This commit is contained in:
Mouad Debbar
2022-03-28 11:20:02 -04:00
committed by GitHub
parent b9e823406d
commit d2cb53b4b1
10 changed files with 106 additions and 258 deletions

View File

@@ -525,20 +525,15 @@ void applyGlobalCssRulesToSheet(
// TODO(web): use more efficient CSS selectors; descendant selectors are slow.
// More info: https://csswizardry.com/2011/09/writing-efficient-css-selectors
// This undoes browser's default layout attributes for paragraphs. We
// compute paragraph layout ourselves.
if (isFirefox) {
// For firefox set line-height, otherwise textx at same font-size will
// measure differently in ruler.
//
// - See: https://github.com/flutter/flutter/issues/44803
sheet.insertRule(
'flt-ruler-host p, flt-scene p '
'{ margin: 0; line-height: 100%;}',
sheet.cssRules.length);
} else {
sheet.insertRule(
'flt-ruler-host p, flt-scene p '
'{ margin: 0; }',
sheet.cssRules.length);
'flt-paragraph, flt-span {line-height: 100%;}',
sheet.cssRules.length,
);
}
// This undoes browser's default painting and layout attributes of range

View File

@@ -9,7 +9,6 @@ import 'package:ui/ui.dart' as ui;
import '../embedder.dart';
import '../html/bitmap_canvas.dart';
import '../profiler.dart';
import '../util.dart';
import 'layout_service.dart';
import 'paint_service.dart';
import 'paragraph.dart';
@@ -148,11 +147,10 @@ class CanvasParagraph implements ui.Paragraph {
html.HtmlElement _createDomElement() {
final html.HtmlElement rootElement =
html.document.createElement('p') as html.HtmlElement;
html.document.createElement('flt-paragraph') as html.HtmlElement;
// 1. Set paragraph-level styles.
_applyNecessaryParagraphStyles(element: rootElement, style: paragraphStyle);
_applySpanStylesToParagraph(element: rootElement, spans: spans);
final html.CssStyleDeclaration cssStyle = rootElement.style;
cssStyle
..position = 'absolute'
@@ -175,7 +173,7 @@ class CanvasParagraph implements ui.Paragraph {
final RangeBox box = boxes[j++];
if (box is SpanBox) {
lastSpanElement = html.document.createElement('span') as html.HtmlElement;
lastSpanElement = html.document.createElement('flt-span') as html.HtmlElement;
applyTextStyleToElement(
element: lastSpanElement,
style: box.span.style,
@@ -253,67 +251,6 @@ class CanvasParagraph implements ui.Paragraph {
}
}
/// Applies a paragraph [style] to an [element], translating the properties to
/// their corresponding CSS equivalents.
///
/// As opposed to [_applyParagraphStyleToElement], this method only applies
/// styles that are necessary at the paragraph level. Other styles (e.g. font
/// size) are always applied at the span level so they aren't needed at the
/// paragraph level.
void _applyNecessaryParagraphStyles({
required html.HtmlElement element,
required EngineParagraphStyle style,
}) {
final html.CssStyleDeclaration cssStyle = element.style;
// TODO(mdebbar): Now that we absolutely position each span inside the
// paragraph, do we still need these style on <p>?
if (style.textAlign != null) {
cssStyle.textAlign = textAlignToCssValue(
style.textAlign, style.textDirection ?? ui.TextDirection.ltr);
}
if (style.lineHeight != null) {
cssStyle.lineHeight = '${style.lineHeight}';
}
if (style.textDirection != null) {
cssStyle.direction = textDirectionToCss(style.textDirection);
}
}
/// Applies some span-level style to a paragraph [element].
///
/// For example, it looks for the greatest font size among spans, and applies it
/// to the paragraph. While this seems to have no effect, it prevents the
/// paragraph from inheriting its font size from the body tag, which leads to
/// incorrect vertical alignment of spans.
void _applySpanStylesToParagraph({
required html.HtmlElement element,
required List<ParagraphSpan> spans,
}) {
double fontSize = 0.0;
String? fontFamily;
for (final ParagraphSpan span in spans) {
if (span is FlatTextSpan) {
final double? spanFontSize = span.style.fontSize;
if (spanFontSize != null && spanFontSize > fontSize) {
fontSize = spanFontSize;
if (span.style.isFontFamilyProvided) {
fontFamily = span.style.effectiveFontFamily;
}
}
}
}
final html.CssStyleDeclaration cssStyle = element.style;
if (fontSize != 0.0) {
cssStyle.fontSize = '${fontSize}px';
}
if (fontFamily != null) {
cssStyle.fontFamily = canonicalizeFontFamily(fontFamily);
}
}
void _positionSpanElement(html.Element element, EngineLineMetrics line, RangeBox box) {
final ui.Rect boxRect = box.toTextBox(line, forPainting: true).toRect();
element.style

View File

@@ -759,51 +759,6 @@ void applyTextStyleToElement({
}
}
html.Element createPlaceholderElement({
required ParagraphPlaceholder placeholder,
}) {
final html.Element element = html.document.createElement('span');
final html.CssStyleDeclaration style = element.style;
style
..display = 'inline-block'
..width = '${placeholder.width}px'
..height = '${placeholder.height}px'
..verticalAlign = _placeholderAlignmentToCssVerticalAlign(placeholder);
return element;
}
String _placeholderAlignmentToCssVerticalAlign(
ParagraphPlaceholder placeholder,
) {
// For more details about the vertical-align CSS property, see:
// - https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align
switch (placeholder.alignment) {
case ui.PlaceholderAlignment.top:
return 'top';
case ui.PlaceholderAlignment.middle:
return 'middle';
case ui.PlaceholderAlignment.bottom:
return 'bottom';
case ui.PlaceholderAlignment.aboveBaseline:
return 'baseline';
case ui.PlaceholderAlignment.belowBaseline:
return '-${placeholder.height}px';
case ui.PlaceholderAlignment.baseline:
// In CSS, the placeholder is already placed above the baseline. But
// Flutter's `baselineOffset` assumes the placeholder is placed below the
// baseline. That's why we need to subtract the placeholder's height from
// `baselineOffset`.
final double offset = placeholder.baselineOffset - placeholder.height;
return '${offset}px';
}
}
String _shadowListToCss(List<ui.Shadow> shadows) {
if (shadows.isEmpty) {
return '';
@@ -881,37 +836,6 @@ String? _decorationStyleToCssString(ui.TextDecorationStyle decorationStyle) {
}
}
/// Converts [textDirection] to its corresponding CSS value.
///
/// This value is used for the "direction" CSS property, e.g.:
///
/// ```css
/// direction: rtl;
/// ```
String? textDirectionToCss(ui.TextDirection? textDirection) {
if (textDirection == null) {
return null;
}
return textDirectionIndexToCss(textDirection.index);
}
String? textDirectionIndexToCss(int textDirectionIndex) {
switch (textDirectionIndex) {
case 0:
return 'rtl';
case 1:
return null; // ltr is the default
}
assert(() {
throw AssertionError(
'Failed to convert text direction $textDirectionIndex to CSS',
);
}());
return null;
}
/// Converts [align] to its corresponding CSS value.
///
/// This value is used as the "text-align" CSS property, e.g.:

View File

@@ -95,7 +95,7 @@ class TextHeightStyle {
class TextDimensions {
TextDimensions(this._element);
final html.HtmlElement _element;
final html.Element _element;
html.Rectangle<num>? _cachedBoundingClientRect;
void _invalidateBoundsCache() {
@@ -165,7 +165,7 @@ class TextHeightRuler {
// Elements used to measure the line-height metric.
late final html.HtmlElement _probe = _createProbe();
late final html.HtmlElement _host = _createHost();
final TextDimensions _dimensions = TextDimensions(html.ParagraphElement());
final TextDimensions _dimensions = TextDimensions(html.document.createElement('flt-paragraph'));
/// The alphabetic baseline for this ruler's [textHeightStyle].
late final double alphabeticBaseline = _probe.getBoundingClientRect().bottom.toDouble();

View File

@@ -66,7 +66,7 @@ void _runDomTests(HostNode hostNode) {
hostNode.nodes.addAll(<html.Node>[
html.document.createElement('div'),
target,
html.document.createElement('span'),
html.document.createElement('flt-span'),
html.document.createElement('div'),
]);
});

View File

@@ -513,10 +513,10 @@ void testMain() {
renderedLayers[char] = pushChild(builder, char, oldLayer: renderedLayers[char]);
}
final SurfaceScene scene = builder.build();
final List<html.Element> pTags = scene.webOnlyRootElement!.querySelectorAll('p');
final List<html.Element> pTags = scene.webOnlyRootElement!.querySelectorAll('flt-paragraph');
expect(pTags, hasLength(string.length));
expect(
scene.webOnlyRootElement!.querySelectorAll('p').map((html.Element p) => p.innerText).join(''),
scene.webOnlyRootElement!.querySelectorAll('flt-paragraph').map((html.Element p) => p.innerText).join(''),
string,
);
renderedLayers.removeWhere((String key, ui.EngineLayer value) => !string.contains(key));

View File

@@ -171,7 +171,7 @@ Future<void> testMain() async {
canvas.drawParagraph(paragraph, Offset(8.5, 8.5 + innerClip.top));
expect(
canvas.rootElement.querySelectorAll('p').map<String>((html.Element e) => e.innerText).toList(),
canvas.rootElement.querySelectorAll('flt-paragraph').map<String>((html.Element e) => e.innerText).toList(),
<String>['Am I blurry?', 'Am I blurry?'],
reason: 'Expected to render text using HTML',
);
@@ -229,7 +229,7 @@ Future<void> testMain() async {
canvas.drawParagraph(paragraph, const Offset(180, 50));
expect(
canvas.rootElement.querySelectorAll('p').map<String?>((html.Element e) => e.text).toList(),
canvas.rootElement.querySelectorAll('flt-paragraph').map<String?>((html.Element e) => e.text).toList(),
<String>[text],
reason: 'Expected to render text using HTML',
);

View File

@@ -872,7 +872,7 @@ void _testCullRectComputation() {
final html.Element sceneElement = builder.build().webOnlyRootElement!;
expect(
sceneElement
.querySelectorAll('p')
.querySelectorAll('flt-paragraph')
.map<String>((html.Element e) => e.innerText)
.toList(),
<String>['Am I blurry?', 'Am I blurry?'],

View File

@@ -50,11 +50,11 @@ Future<void> testMain() async {
paragraph.layout(const ParagraphConstraints(width: double.infinity));
expectOuterHtml(
paragraph,
'<p style="${paragraphStyle(fontSize: 13)}">'
'<span style="${spanStyle(top: 0, left: 0, width: 13*5, fontSize: 13)}">'
'<flt-paragraph style="${paragraphStyle()}">'
'<flt-span style="${spanStyle(top: 0, left: 0, width: 13*5, fontSize: 13)}">'
'Hello'
'</span>'
'</p>',
'</flt-span>'
'</flt-paragraph>',
ignorePositions: !isBlink,
);
@@ -62,14 +62,14 @@ Future<void> testMain() async {
paragraph.layout(const ParagraphConstraints(width: 39.0));
expectOuterHtml(
paragraph,
'<p style="${paragraphStyle(fontSize: 13)}">'
'<span style="${spanStyle(top: 0, left: 0, width: 13*3, fontSize: 13)}">'
'<flt-paragraph style="${paragraphStyle()}">'
'<flt-span style="${spanStyle(top: 0, left: 0, width: 13*3, fontSize: 13)}">'
'Hel'
'</span>'
'<span style="${spanStyle(top: 13, left: 0, width: 13*2, fontSize: 13)}">'
'</flt-span>'
'<flt-span style="${spanStyle(top: 13, left: 0, width: 13*2, fontSize: 13)}">'
'lo'
'</span>'
'</p>',
'</flt-span>'
'</flt-paragraph>',
ignorePositions: !isBlink,
);
@@ -94,11 +94,11 @@ Future<void> testMain() async {
paragraph.layout(const ParagraphConstraints(width: double.infinity));
expect(
paragraph.toDomElement().outerHtml,
'<p style="${paragraphStyle()}">'
'<span style="${spanStyle(top: 0, left: 0, width: 14*5)}">'
'<flt-paragraph style="${paragraphStyle()}">'
'<flt-span style="${spanStyle(top: 0, left: 0, width: 14*5)}">'
'Hello'
'</span>'
'</p>',
'</flt-span>'
'</flt-paragraph>',
);
final FlatTextSpan textSpan = paragraph.spans.single as FlatTextSpan;
@@ -118,11 +118,11 @@ Future<void> testMain() async {
paragraph.layout(const ParagraphConstraints(width: double.infinity));
expect(
paragraph.toDomElement().outerHtml,
'<p style="${paragraphStyle()}">'
'<span style="${spanStyle(top: 0, left: 0, width: 14*5)}">'
'<flt-paragraph style="${paragraphStyle()}">'
'<flt-span style="${spanStyle(top: 0, left: 0, width: 14*5)}">'
'Hello'
'</span>'
'</p>',
'</flt-span>'
'</flt-paragraph>',
);
});
@@ -139,11 +139,11 @@ Future<void> testMain() async {
paragraph.layout(const ParagraphConstraints(width: 100.0));
expect(
paragraph.toDomElement().outerHtml,
'<p style="${paragraphStyle()}">'
'<span style="${spanStyle(top: 0, left: 0, width: 14*4)}">'
'<flt-paragraph style="${paragraphStyle()}">'
'<flt-span style="${spanStyle(top: 0, left: 0, width: 14*4)}">'
'Hell...'
'</span>'
'</p>',
'</flt-span>'
'</flt-paragraph>',
);
});
@@ -167,11 +167,11 @@ Future<void> testMain() async {
paragraph.layout(const ParagraphConstraints(width: double.infinity));
expectOuterHtml(
paragraph,
'<p style="${paragraphStyle(lineHeight: 1.5, fontSize: 9)}">'
'<span style="${spanStyle(top: 0, left: 0, width: (9+2)*5, lineHeight: 1.5, fontSize: 9, fontWeight: 'bold', fontStyle: 'italic', letterSpacing: 2)}">'
'<flt-paragraph style="${paragraphStyle()}">'
'<flt-span style="${spanStyle(top: 0, left: 0, width: (9+2)*5, lineHeight: 1.5, fontSize: 9, fontWeight: 'bold', fontStyle: 'italic', letterSpacing: 2)}">'
'Hello'
'</span>'
'</p>',
'</flt-span>'
'</flt-paragraph>',
ignorePositions: !isBlink,
);
@@ -206,17 +206,17 @@ Future<void> testMain() async {
paragraph.layout(const ParagraphConstraints(width: double.infinity));
expectOuterHtml(
paragraph,
'<p style="${paragraphStyle(fontSize: 13)}">'
'<span style="${spanStyle(top: 0, left: 0, width: 13*5, fontSize: 13, fontWeight: 'bold')}">'
'<flt-paragraph style="${paragraphStyle()}">'
'<flt-span style="${spanStyle(top: 0, left: 0, width: 13*5, fontSize: 13, fontWeight: 'bold')}">'
'Hello'
'</span>'
'<span style="${spanStyle(top: 0, left: 65, width: 13*1, fontSize: 13, fontStyle: 'italic')}">'
'</flt-span>'
'<flt-span style="${spanStyle(top: 0, left: 65, width: 13*1, fontSize: 13, fontStyle: 'italic')}">'
' '
'</span>'
'<span style="${spanStyle(top: 0, left: 78, width: 13*5, fontSize: 13, fontStyle: 'italic')}">'
'</flt-span>'
'<flt-span style="${spanStyle(top: 0, left: 78, width: 13*5, fontSize: 13, fontStyle: 'italic')}">'
'world'
'</span>'
'</p>',
'</flt-span>'
'</flt-paragraph>',
ignorePositions: !isBlink,
);
@@ -224,18 +224,17 @@ Future<void> testMain() async {
paragraph.layout(const ParagraphConstraints(width: 75.0));
expectOuterHtml(
paragraph,
'<p style="${paragraphStyle(fontSize: 13)}">'
'<span style="${spanStyle(top: 0, left: 0, width: 13*5, fontSize: 13, fontWeight: 'bold')}">'
'<flt-paragraph style="${paragraphStyle()}">'
'<flt-span style="${spanStyle(top: 0, left: 0, width: 13*5, fontSize: 13, fontWeight: 'bold')}">'
'Hello'
'</span>'
// Trailing space.
'<span style="${spanStyle(top: 0, left: 65, width: 0, fontSize: 13, fontStyle: 'italic')}">'
'</flt-span>'
'<flt-span style="${spanStyle(top: 0, left: 65, width: 0, fontSize: 13, fontStyle: 'italic')}">'
' '
'</span>'
'<span style="${spanStyle(top: 13, left: 0, width: 13*5, fontSize: 13, fontStyle: 'italic')}">'
'</flt-span>'
'<flt-span style="${spanStyle(top: 13, left: 0, width: 13*5, fontSize: 13, fontStyle: 'italic')}">'
'world'
'</span>'
'</p>',
'</flt-span>'
'</flt-paragraph>',
ignorePositions: !isBlink,
);
@@ -280,20 +279,20 @@ Future<void> testMain() async {
paragraph.layout(const ParagraphConstraints(width: double.infinity));
expectOuterHtml(
paragraph,
'<p style="${paragraphStyle(fontSize: 13)}">'
'<span style="${spanStyle(top: 0, left: 0, width: 13*5, lineHeight: 2, fontSize: 13, fontWeight: 'bold')}">'
'<flt-paragraph style="${paragraphStyle()}">'
'<flt-span style="${spanStyle(top: 0, left: 0, width: 13*5, lineHeight: 2, fontSize: 13, fontWeight: 'bold')}">'
'Hello'
'</span>'
'<span style="${spanStyle(top: 6, left: 65, width: 13*1, fontSize: 13, fontWeight: 'bold', fontStyle: 'italic')}">'
'</flt-span>'
'<flt-span style="${spanStyle(top: 6, left: 65, width: 13*1, fontSize: 13, fontWeight: 'bold', fontStyle: 'italic')}">'
' '
'</span>'
'<span style="${spanStyle(top: 6, left: 78, width: 13*5, fontSize: 13, fontWeight: 'bold', fontStyle: 'italic')}">'
'</flt-span>'
'<flt-span style="${spanStyle(top: 6, left: 78, width: 13*5, fontSize: 13, fontWeight: 'bold', fontStyle: 'italic')}">'
'world'
'</span>'
'<span style="${spanStyle(top: 6, left: 143, width: 13*1, fontSize: 13, fontWeight: 'normal', fontStyle: 'italic')}">'
'</flt-span>'
'<flt-span style="${spanStyle(top: 6, left: 143, width: 13*1, fontSize: 13, fontWeight: 'normal', fontStyle: 'italic')}">'
'!'
'</span>'
'</p>',
'</flt-span>'
'</flt-paragraph>',
ignorePositions: !isBlink,
);
@@ -348,20 +347,20 @@ Future<void> testMain() async {
paragraph.layout(const ParagraphConstraints(width: double.infinity));
expectOuterHtml(
paragraph,
'<p style="${paragraphStyle(fontSize: 13)}">'
'<span style="${spanStyle(top: 0, left: 0, width: 13*5, fontSize: 13)}">'
'<flt-paragraph style="${paragraphStyle()}">'
'<flt-span style="${spanStyle(top: 0, left: 0, width: 13*5, fontSize: 13)}">'
'First'
'</span>'
'<span style="${spanStyle(top: 13, left: 0, width: 13*6, fontSize: 13)}">'
'</flt-span>'
'<flt-span style="${spanStyle(top: 13, left: 0, width: 13*6, fontSize: 13)}">'
'Second'
'</span>'
'<span style="${spanStyle(top: 13, left: 78, width: 13*1, fontSize: 13)}">'
'</flt-span>'
'<flt-span style="${spanStyle(top: 13, left: 78, width: 13*1, fontSize: 13)}">'
' '
'</span>'
'<span style="${spanStyle(top: 13, left: 91, width: 13*13, fontSize: 13, fontStyle: 'italic')}">'
'</flt-span>'
'<flt-span style="${spanStyle(top: 13, left: 91, width: 13*13, fontSize: 13, fontStyle: 'italic')}">'
'ThirdLongLine'
'</span>'
'</p>',
'</flt-span>'
'</flt-paragraph>',
ignorePositions: !isBlink,
);
@@ -369,21 +368,21 @@ Future<void> testMain() async {
paragraph.layout(const ParagraphConstraints(width: 180.0));
expectOuterHtml(
paragraph,
'<p style="${paragraphStyle(fontSize: 13)}">'
'<span style="${spanStyle(top: 0, left: 0, width: 13*5, fontSize: 13)}">'
'<flt-paragraph style="${paragraphStyle()}">'
'<flt-span style="${spanStyle(top: 0, left: 0, width: 13*5, fontSize: 13)}">'
'First'
'</span>'
'<span style="${spanStyle(top: 13, left: 0, width: 13*6, fontSize: 13)}">'
'</flt-span>'
'<flt-span style="${spanStyle(top: 13, left: 0, width: 13*6, fontSize: 13)}">'
'Second'
'</span>'
'</flt-span>'
// Trailing space.
'<span style="${spanStyle(top: 13, left: 78, width: 0, fontSize: 13)}">'
'<flt-span style="${spanStyle(top: 13, left: 78, width: 0, fontSize: 13)}">'
' '
'</span>'
'<span style="${spanStyle(top: 26, left: 0, width: 13*13, fontSize: 13, fontStyle: 'italic')}">'
'</flt-span>'
'<flt-span style="${spanStyle(top: 26, left: 0, width: 13*13, fontSize: 13, fontStyle: 'italic')}">'
'ThirdLongLine'
'</span>'
'</p>',
'</flt-span>'
'</flt-paragraph>',
ignorePositions: !isBlink,
);
});
@@ -411,23 +410,23 @@ Future<void> testMain() async {
paragraph.layout(const ParagraphConstraints(width: double.infinity));
expectOuterHtml(
paragraph,
'<p style="${paragraphStyle(fontSize: 18, fontFamily: 'second')}">'
'<span style="${spanStyle(top: null, left: null, width: null, fontSize: 12, fontFamily: 'first')}">'
'<flt-paragraph style="${paragraphStyle()}">'
'<flt-span style="${spanStyle(top: null, left: null, width: null, fontSize: 12, fontFamily: 'first')}">'
'First'
'</span>'
'<span style="${spanStyle(top: null, left: null, width: null, fontSize: 12, fontFamily: 'first')}">'
'</flt-span>'
'<flt-span style="${spanStyle(top: null, left: null, width: null, fontSize: 12, fontFamily: 'first')}">'
' '
'</span>'
'<span style="${spanStyle(top: null, left: null, width: null, fontSize: 18, fontFamily: 'second')}">'
'</flt-span>'
'<flt-span style="${spanStyle(top: null, left: null, width: null, fontSize: 18, fontFamily: 'second')}">'
'Second'
'</span>'
'<span style="${spanStyle(top: null, left: null, width: null, fontSize: 18, fontFamily: 'second')}">'
'</flt-span>'
'<flt-span style="${spanStyle(top: null, left: null, width: null, fontSize: 18, fontFamily: 'second')}">'
' '
'</span>'
'<span style="${spanStyle(top: null, left: null, width: null, fontSize: 10, fontFamily: 'third')}">'
'</flt-span>'
'<flt-span style="${spanStyle(top: null, left: null, width: null, fontSize: 10, fontFamily: 'third')}">'
'Third'
'</span>'
'</p>',
'</flt-span>'
'</flt-paragraph>',
// Since we are using unknown font families, we can't predict the text
// measurements.
ignorePositions: true,
@@ -439,15 +438,8 @@ Future<void> testMain() async {
const String defaultFontFamily = 'Ahem';
const num defaultFontSize = 14;
String paragraphStyle({
String fontFamily = defaultFontFamily,
num fontSize = defaultFontSize,
num? lineHeight,
}) {
String paragraphStyle() {
return <String>[
if (lineHeight != null) 'line-height: $lineHeight;',
'font-size: ${fontSize}px;',
'font-family: ${fontFamilyToAttribute(fontFamily)};',
'position: absolute;',
'white-space: pre;',
].join(' ');

View File

@@ -224,8 +224,8 @@ Future<void> testMain() async {
final CanvasParagraph paragraph = builder.build() as CanvasParagraph;
paragraph.layout(const ParagraphConstraints(width: 800.0));
expect(paragraph.plainText, 'abcdef');
final List<SpanElement> spans =
paragraph.toDomElement().querySelectorAll('span');
final List<Element> spans =
paragraph.toDomElement().querySelectorAll('flt-span');
expect(spans[0].style.fontFamily, 'Ahem, $fallback, sans-serif');
// The nested span here should not set it's family to default sans-serif.
expect(spans[1].style.fontFamily, 'Ahem, $fallback, sans-serif');
@@ -245,7 +245,7 @@ Future<void> testMain() async {
), 'Hello');
paragraph.layout(constrain(double.infinity));
expect(paragraph.toDomElement().style.fontFamily,
expect(paragraph.toDomElement().children.single.style.fontFamily,
'SomeFont, $fallback, sans-serif');
debugEmulateFlutterTesterEnvironment = true;
@@ -265,7 +265,7 @@ Future<void> testMain() async {
), 'Hello');
paragraph.layout(constrain(double.infinity));
expect(paragraph.toDomElement().style.fontFamily, 'serif');
expect(paragraph.toDomElement().children.single.style.fontFamily, 'serif');
debugEmulateFlutterTesterEnvironment = true;
});
@@ -280,7 +280,7 @@ Future<void> testMain() async {
), 'Hello');
paragraph.layout(constrain(double.infinity));
expect(paragraph.toDomElement().style.fontFamily,
expect(paragraph.toDomElement().children.single.style.fontFamily,
'"MyFont 2000", $fallback, sans-serif');
debugEmulateFlutterTesterEnvironment = true;