@@ -1460,157 +1460,86 @@ String fontWeightIndexToCss({int fontWeightIndex = 3}) {
14601460
14611461/// Applies a paragraph [style] to an [element] , translating the properties to
14621462/// their corresponding CSS equivalents.
1463- ///
1464- /// If [previousStyle] is not null, updates only the mismatching attributes.
14651463void _applyParagraphStyleToElement ({
14661464 required html.HtmlElement element,
14671465 required EngineParagraphStyle style,
1468- EngineParagraphStyle ? previousStyle,
14691466}) {
14701467 assert (element != null ); // ignore: unnecessary_null_comparison
14711468 assert (style != null ); // ignore: unnecessary_null_comparison
14721469 // TODO(yjbanov): What do we do about ParagraphStyle._locale and ellipsis?
14731470 final html.CssStyleDeclaration cssStyle = element.style;
1474- if (previousStyle == null ) {
1475- if (style._textAlign != null ) {
1476- cssStyle.textAlign = textAlignToCssValue (
1477- style._textAlign, style._textDirection ?? ui.TextDirection .ltr);
1478- }
1479- if (style._lineHeight != null ) {
1480- cssStyle.lineHeight = '${style ._lineHeight }' ;
1481- }
1482- if (style._textDirection != null ) {
1483- cssStyle.direction = _textDirectionToCss (style._textDirection);
1484- }
1485- if (style._fontSize != null ) {
1486- cssStyle.fontSize = '${style ._fontSize !.floor ()}px' ;
1487- }
1488- if (style._fontWeight != null ) {
1489- cssStyle.fontWeight = fontWeightToCss (style._fontWeight);
1490- }
1491- if (style._fontStyle != null ) {
1492- cssStyle.fontStyle =
1493- style._fontStyle == ui.FontStyle .normal ? 'normal' : 'italic' ;
1494- }
1495- cssStyle.fontFamily = canonicalizeFontFamily (style._effectiveFontFamily);
1496- } else {
1497- if (style._textAlign != previousStyle._textAlign) {
1498- cssStyle.textAlign = textAlignToCssValue (
1499- style._textAlign, style._textDirection ?? ui.TextDirection .ltr);
1500- }
1501- if (style._lineHeight != previousStyle._lineHeight) {
1502- cssStyle.lineHeight = '${style ._lineHeight }' ;
1503- }
1504- if (style._textDirection != previousStyle._textDirection) {
1505- cssStyle.direction = _textDirectionToCss (style._textDirection);
1506- }
1507- if (style._fontSize != previousStyle._fontSize) {
1508- cssStyle.fontSize =
1509- style._fontSize != null ? '${style ._fontSize !.floor ()}px' : null ;
1510- }
1511- if (style._fontWeight != previousStyle._fontWeight) {
1512- cssStyle.fontWeight = fontWeightToCss (style._fontWeight);
1513- }
1514- if (style._fontStyle != previousStyle._fontStyle) {
1515- cssStyle.fontStyle = style._fontStyle != null
1516- ? (style._fontStyle == ui.FontStyle .normal ? 'normal' : 'italic' )
1517- : null ;
1518- }
1519- if (style._fontFamily != previousStyle._fontFamily) {
1520- cssStyle.fontFamily = canonicalizeFontFamily (style._fontFamily);
1521- }
1471+
1472+ if (style._textAlign != null ) {
1473+ cssStyle.textAlign = textAlignToCssValue (
1474+ style._textAlign, style._textDirection ?? ui.TextDirection .ltr);
1475+ }
1476+ if (style._lineHeight != null ) {
1477+ cssStyle.lineHeight = '${style ._lineHeight }' ;
1478+ }
1479+ if (style._textDirection != null ) {
1480+ cssStyle.direction = _textDirectionToCss (style._textDirection);
1481+ }
1482+ if (style._fontSize != null ) {
1483+ cssStyle.fontSize = '${style ._fontSize !.floor ()}px' ;
1484+ }
1485+ if (style._fontWeight != null ) {
1486+ cssStyle.fontWeight = fontWeightToCss (style._fontWeight);
1487+ }
1488+ if (style._fontStyle != null ) {
1489+ cssStyle.fontStyle =
1490+ style._fontStyle == ui.FontStyle .normal ? 'normal' : 'italic' ;
15221491 }
1492+ cssStyle.fontFamily = canonicalizeFontFamily (style._effectiveFontFamily);
15231493}
15241494
15251495/// Applies a text [style] to an [element] , translating the properties to their
15261496/// corresponding CSS equivalents.
15271497///
1528- /// If [previousStyle] is not null, updates only the mismatching attributes.
15291498/// If [isSpan] is true, the text element is a span within richtext and
15301499/// should not assign effectiveFontFamily if fontFamily was not specified.
15311500void _applyTextStyleToElement ({
15321501 required html.HtmlElement element,
15331502 required EngineTextStyle style,
1534- EngineTextStyle ? previousStyle,
15351503 bool isSpan = false ,
15361504}) {
15371505 assert (element != null ); // ignore: unnecessary_null_comparison
15381506 assert (style != null ); // ignore: unnecessary_null_comparison
15391507 bool updateDecoration = false ;
15401508 final html.CssStyleDeclaration cssStyle = element.style;
1541- if (previousStyle == null ) {
1542- final ui.Color ? color = style._foreground? .color ?? style._color;
1543- if (color != null ) {
1544- cssStyle.color = colorToCssString (color);
1545- }
1546- if (style._fontSize != null ) {
1547- cssStyle.fontSize = '${style ._fontSize !.floor ()}px' ;
1548- }
1549- if (style._fontWeight != null ) {
1550- cssStyle.fontWeight = fontWeightToCss (style._fontWeight);
1551- }
1552- if (style._fontStyle != null ) {
1553- cssStyle.fontStyle =
1554- style._fontStyle == ui.FontStyle .normal ? 'normal' : 'italic' ;
1555- }
1556- // For test environment use effectiveFontFamily since we need to
1557- // consistently use Ahem font.
1558- if (isSpan && ! ui.debugEmulateFlutterTesterEnvironment) {
1559- cssStyle.fontFamily = canonicalizeFontFamily (style._fontFamily);
1560- } else {
1561- cssStyle.fontFamily =
1562- canonicalizeFontFamily (style._effectiveFontFamily);
1563- }
1564- if (style._letterSpacing != null ) {
1565- cssStyle.letterSpacing = '${style ._letterSpacing }px' ;
1566- }
1567- if (style._wordSpacing != null ) {
1568- cssStyle.wordSpacing = '${style ._wordSpacing }px' ;
1569- }
1570- if (style._decoration != null ) {
1571- updateDecoration = true ;
1572- }
1573- if (style._shadows != null ) {
1574- cssStyle.textShadow = _shadowListToCss (style._shadows! );
1575- }
1576- } else {
1577- if (style._color != previousStyle._color ||
1578- style._foreground != previousStyle._foreground) {
1579- final ui.Color ? color = style._foreground? .color ?? style._color;
1580- cssStyle.color = colorToCssString (color);
1581- }
1582-
1583- if (style._fontSize != previousStyle._fontSize) {
1584- cssStyle.fontSize =
1585- style._fontSize != null ? '${style ._fontSize !.floor ()}px' : null ;
1586- }
1587-
1588- if (style._fontWeight != previousStyle._fontWeight) {
1589- cssStyle.fontWeight = fontWeightToCss (style._fontWeight);
1590- }
15911509
1592- if (style._fontStyle != previousStyle._fontStyle) {
1593- cssStyle.fontStyle = style._fontStyle != null
1594- ? style._fontStyle == ui.FontStyle .normal ? 'normal' : 'italic'
1595- : null ;
1596- }
1597- if (style._fontFamily != previousStyle._fontFamily) {
1598- cssStyle.fontFamily = canonicalizeFontFamily (style._fontFamily);
1599- }
1600- if (style._letterSpacing != previousStyle._letterSpacing) {
1601- cssStyle.letterSpacing = '${style ._letterSpacing }px' ;
1602- }
1603- if (style._wordSpacing != previousStyle._wordSpacing) {
1604- cssStyle.wordSpacing = '${style ._wordSpacing }px' ;
1605- }
1606- if (style._decoration != previousStyle._decoration ||
1607- style._decorationStyle != previousStyle._decorationStyle ||
1608- style._decorationColor != previousStyle._decorationColor) {
1609- updateDecoration = true ;
1610- }
1611- if (style._shadows != previousStyle._shadows) {
1612- cssStyle.textShadow = _shadowListToCss (style._shadows! );
1613- }
1510+ final ui.Color ? color = style._foreground? .color ?? style._color;
1511+ if (color != null ) {
1512+ cssStyle.color = colorToCssString (color);
1513+ }
1514+ if (style._fontSize != null ) {
1515+ cssStyle.fontSize = '${style ._fontSize !.floor ()}px' ;
1516+ }
1517+ if (style._fontWeight != null ) {
1518+ cssStyle.fontWeight = fontWeightToCss (style._fontWeight);
1519+ }
1520+ if (style._fontStyle != null ) {
1521+ cssStyle.fontStyle =
1522+ style._fontStyle == ui.FontStyle .normal ? 'normal' : 'italic' ;
1523+ }
1524+ // For test environment use effectiveFontFamily since we need to
1525+ // consistently use Ahem font.
1526+ if (isSpan && ! ui.debugEmulateFlutterTesterEnvironment) {
1527+ cssStyle.fontFamily = canonicalizeFontFamily (style._fontFamily);
1528+ } else {
1529+ cssStyle.fontFamily =
1530+ canonicalizeFontFamily (style._effectiveFontFamily);
1531+ }
1532+ if (style._letterSpacing != null ) {
1533+ cssStyle.letterSpacing = '${style ._letterSpacing }px' ;
1534+ }
1535+ if (style._wordSpacing != null ) {
1536+ cssStyle.wordSpacing = '${style ._wordSpacing }px' ;
1537+ }
1538+ if (style._decoration != null ) {
1539+ updateDecoration = true ;
1540+ }
1541+ if (style._shadows != null ) {
1542+ cssStyle.textShadow = _shadowListToCss (style._shadows! );
16141543 }
16151544
16161545 if (updateDecoration) {
@@ -1705,19 +1634,11 @@ String _shadowListToCss(List<ui.Shadow> shadows) {
17051634void _applyTextBackgroundToElement ({
17061635 required html.HtmlElement element,
17071636 required EngineTextStyle style,
1708- EngineTextStyle ? previousStyle,
17091637}) {
17101638 final ui.Paint ? newBackground = style._background;
1711- if (previousStyle == null ) {
1712- if (newBackground != null ) {
1713- domRenderer.setElementStyle (
1714- element, 'background-color' , colorToCssString (newBackground.color));
1715- }
1716- } else {
1717- if (newBackground != previousStyle._background) {
1718- domRenderer.setElementStyle (
1719- element, 'background-color' , colorToCssString (newBackground! .color));
1720- }
1639+ if (newBackground != null ) {
1640+ domRenderer.setElementStyle (
1641+ element, 'background-color' , colorToCssString (newBackground.color));
17211642 }
17221643}
17231644
0 commit comments