未验证 提交 14c8c244 编写于 作者: M Mouad Debbar 提交者: GitHub

[web] Fix regression in foreground style (#22999)

上级 6ebf5c38
......@@ -1328,7 +1328,7 @@ class DomParagraphBuilder implements ui.ParagraphBuilder {
/// paragraph. Plain text is more efficient to lay out and measure than rich
/// text.
EngineParagraph? _tryBuildPlainText() {
ui.Color color = _defaultTextColor;
ui.Color? color;
ui.TextDecoration? decoration;
ui.Color? decorationColor;
ui.TextDecorationStyle? decorationStyle;
......@@ -1416,6 +1416,10 @@ class DomParagraphBuilder implements ui.ParagraphBuilder {
i++;
}
if (color == null && foreground == null) {
color = _defaultTextColor;
}
final EngineTextStyle cumulativeStyle = EngineTextStyle(
color: color,
decoration: decoration,
......@@ -1443,7 +1447,7 @@ class DomParagraphBuilder implements ui.ParagraphBuilder {
paint = foreground;
} else {
paint = ui.Paint();
paint.color = color;
paint.color = color!;
}
if (i >= _ops.length) {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
// @dart = 2.12
import 'package:test/bootstrap/browser.dart';
import 'package:test/test.dart';
import 'package:ui/src/engine.dart';
......@@ -28,10 +28,20 @@ void testMain() {
expect(paragraph.height, isNonZero);
});
test('PushStyle should not segfault after build()', () {
test('pushStyle should not segfault after build()', () {
final ParagraphBuilder paragraphBuilder =
ParagraphBuilder(ParagraphStyle());
paragraphBuilder.build();
paragraphBuilder.pushStyle(TextStyle());
});
test('the presence of foreground style should not throw', () {
final ParagraphBuilder builder = ParagraphBuilder(ParagraphStyle());
builder.pushStyle(TextStyle(
foreground: Paint()..color = const Color(0xFFABCDEF),
));
builder.addText('hi');
expect(() => builder.build(), returnsNormally);
});
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册