Engine roll with updates to the ParagraphBuilder constructor (#6528)
This commit is contained in:
@@ -1 +1 @@
|
||||
a8604ba9d22d22092aa1b245aaf30b11d562b804
|
||||
9f65114e2061aa2964cc0d2baec8046fc7361ef7
|
||||
|
||||
@@ -11,9 +11,9 @@ void beginFrame(Duration timeStamp) {
|
||||
final double devicePixelRatio = ui.window.devicePixelRatio;
|
||||
final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio;
|
||||
|
||||
final ui.ParagraphBuilder paragraphBuilder = new ui.ParagraphBuilder()
|
||||
final ui.ParagraphBuilder paragraphBuilder = new ui.ParagraphBuilder(new ui.ParagraphStyle())
|
||||
..addText('Hello, world.');
|
||||
final ui.Paragraph paragraph = paragraphBuilder.build(new ui.ParagraphStyle())
|
||||
final ui.Paragraph paragraph = paragraphBuilder.build()
|
||||
..layout(new ui.ParagraphConstraints(width: logicalSize.width));
|
||||
|
||||
final ui.Rect physicalBounds = ui.Point.origin & (logicalSize * devicePixelRatio);
|
||||
|
||||
@@ -52,7 +52,7 @@ void beginFrame(Duration timeStamp) {
|
||||
|
||||
void main() {
|
||||
// To create a paragraph of text, we use ParagraphBuilder.
|
||||
ui.ParagraphBuilder builder = new ui.ParagraphBuilder()
|
||||
ui.ParagraphBuilder builder = new ui.ParagraphBuilder(new ui.ParagraphStyle())
|
||||
// We first push a style that turns the text blue.
|
||||
..pushStyle(new ui.TextStyle(color: const ui.Color(0xFF0000FF)))
|
||||
..addText('Hello, ')
|
||||
@@ -74,7 +74,7 @@ void main() {
|
||||
// which time we can apply styling that affects the entire paragraph, such as
|
||||
// left, right, or center alignment. Once built, the contents of the paragraph
|
||||
// cannot be altered, but sizing and positioning information can be updated.
|
||||
paragraph = builder.build(new ui.ParagraphStyle())
|
||||
paragraph = builder.build()
|
||||
// Next, we supply a width that the text is permitted to occupy and we ask
|
||||
// the paragraph to the visual position of each its glyphs as well as its
|
||||
// overall size, subject to its sizing constraints.
|
||||
|
||||
@@ -176,15 +176,15 @@ class TextPainter {
|
||||
return;
|
||||
_needsLayout = false;
|
||||
if (_paragraph == null) {
|
||||
ui.ParagraphBuilder builder = new ui.ParagraphBuilder();
|
||||
_text.build(builder, textScaleFactor: textScaleFactor);
|
||||
ui.ParagraphStyle paragraphStyle = _text.style?.getParagraphStyle(
|
||||
textAlign: textAlign,
|
||||
textScaleFactor: textScaleFactor,
|
||||
ellipsis: _ellipsis,
|
||||
);
|
||||
paragraphStyle ??= new ui.ParagraphStyle();
|
||||
_paragraph = builder.build(paragraphStyle);
|
||||
ui.ParagraphBuilder builder = new ui.ParagraphBuilder(paragraphStyle);
|
||||
_text.build(builder, textScaleFactor: textScaleFactor);
|
||||
_paragraph = builder.build();
|
||||
}
|
||||
_lastMinWidth = minWidth;
|
||||
_lastMaxWidth = maxWidth;
|
||||
|
||||
@@ -216,12 +216,12 @@ class RenderEditable extends RenderBox {
|
||||
ui.Paragraph _layoutTemplate;
|
||||
double get _preferredLineHeight {
|
||||
if (_layoutTemplate == null) {
|
||||
ui.ParagraphBuilder builder = new ui.ParagraphBuilder()
|
||||
ui.ParagraphBuilder builder = new ui.ParagraphBuilder(new ui.ParagraphStyle())
|
||||
..pushStyle(text.style.getTextStyle(textScaleFactor: textScaleFactor))
|
||||
..addText(_kZeroWidthSpace);
|
||||
// TODO(abarth): ParagraphBuilder#build's argument should be optional.
|
||||
// TODO(abarth): These min/max values should be the default for ui.Paragraph.
|
||||
_layoutTemplate = builder.build(new ui.ParagraphStyle())
|
||||
_layoutTemplate = builder.build()
|
||||
..layout(new ui.ParagraphConstraints(width: double.INFINITY));
|
||||
}
|
||||
return _layoutTemplate.height;
|
||||
|
||||
@@ -40,10 +40,10 @@ class RenderErrorBox extends RenderBox {
|
||||
// Generally, the much better way to draw text in a RenderObject is to
|
||||
// use the TextPainter class. If you're looking for code to crib from,
|
||||
// see the paragraph.dart file and the RenderParagraph class.
|
||||
ui.ParagraphBuilder builder = new ui.ParagraphBuilder();
|
||||
ui.ParagraphBuilder builder = new ui.ParagraphBuilder(paragraphStyle);
|
||||
builder.pushStyle(textStyle);
|
||||
builder.addText(message);
|
||||
_paragraph = builder.build(paragraphStyle);
|
||||
_paragraph = builder.build();
|
||||
}
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test("Should be able to build and layout a paragraph", () {
|
||||
ParagraphBuilder builder = new ParagraphBuilder();
|
||||
ParagraphBuilder builder = new ParagraphBuilder(new ParagraphStyle());
|
||||
builder.addText('Hello');
|
||||
Paragraph paragraph = builder.build(new ParagraphStyle());
|
||||
Paragraph paragraph = builder.build();
|
||||
expect(paragraph, isNotNull);
|
||||
|
||||
paragraph.layout(new ParagraphConstraints(width: 800.0));
|
||||
|
||||
Reference in New Issue
Block a user