From 5497ba182fd850ac11c43e220bc8f48f6c9d5a38 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Fri, 29 Apr 2016 11:19:35 -0700 Subject: [PATCH] Update engine (#3637) Turns out there were more clients of the old paragraph API than I expected. This patch migrates them to the new API. --- bin/cache/engine.version | 2 +- examples/layers/raw/hello_world.dart | 3 +-- examples/layers/raw/text.dart | 11 +++++------ packages/flutter/lib/src/rendering/editable_line.dart | 8 ++------ packages/flutter/lib/src/rendering/error.dart | 9 +++++---- .../flutter/test/engine/paragraph_builder_test.dart | 7 +------ 6 files changed, 15 insertions(+), 25 deletions(-) diff --git a/bin/cache/engine.version b/bin/cache/engine.version index b6185bd363..1c73717562 100644 --- a/bin/cache/engine.version +++ b/bin/cache/engine.version @@ -1 +1 @@ -28fbcc3a38d94281ba2a77426fda0e157a563735 +a25959370a0181c41794e512bbc8983ae8071238 diff --git a/examples/layers/raw/hello_world.dart b/examples/layers/raw/hello_world.dart index 6fe0a24578..b4dc232400 100644 --- a/examples/layers/raw/hello_world.dart +++ b/examples/layers/raw/hello_world.dart @@ -15,8 +15,7 @@ void beginFrame(Duration timeStamp) { final ui.ParagraphBuilder paragraphBuilder = new ui.ParagraphBuilder() ..addText('Hello, world.'); final ui.Paragraph paragraph = paragraphBuilder.build(new ui.ParagraphStyle()) - ..maxWidth = logicalSize.width - ..layout(); + ..layout(new ui.ParagraphConstraints(width: logicalSize.width)); final ui.Rect physicalBounds = ui.Point.origin & (logicalSize * devicePixelRatio); final ui.PictureRecorder recorder = new ui.PictureRecorder(); diff --git a/examples/layers/raw/text.dart b/examples/layers/raw/text.dart index 5f8f6acdd8..e8c36fba1e 100644 --- a/examples/layers/raw/text.dart +++ b/examples/layers/raw/text.dart @@ -21,7 +21,7 @@ ui.Picture paint(ui.Rect paintBounds) { // The paint method of Pargraph draws the contents of the paragraph unto the // given canvas. - canvas.drawParagraph(paragraph, new ui.Offset(paragraph.maxWidth / -2.0, (paragraph.maxWidth / 2.0) - 125)); + canvas.drawParagraph(paragraph, new ui.Offset(paragraph.width / -2.0, (paragraph.width / 2.0) - 125)); return recorder.endRecording(); } @@ -72,11 +72,10 @@ void main() { // 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()) - // Next, we supply a maximum width that the text is permitted to occupy. - ..maxWidth = 180.0 - // ... and we ask the paragraph to the visual position of each its glyphs as - // well as its overall size, subject to its sizing constraints. - ..layout(); + // 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. + ..layout(new ui.ParagraphConstraints(width: 180.0)); // Finally, we register our beginFrame callback and kick off the first frame. ui.window.onBeginFrame = beginFrame; diff --git a/packages/flutter/lib/src/rendering/editable_line.dart b/packages/flutter/lib/src/rendering/editable_line.dart index ddfc10ffc4..10851f90f3 100644 --- a/packages/flutter/lib/src/rendering/editable_line.dart +++ b/packages/flutter/lib/src/rendering/editable_line.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:ui' as ui show Paragraph, ParagraphBuilder, ParagraphStyle, TextBox; +import 'dart:ui' as ui show Paragraph, ParagraphBuilder, ParagraphConstraints, ParagraphStyle, TextBox; import 'package:flutter/gestures.dart'; @@ -157,11 +157,7 @@ class RenderEditableLine extends RenderBox { // 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()) - ..minWidth = 0.0 - ..maxWidth = double.INFINITY - ..minHeight = 0.0 - ..maxHeight = double.INFINITY - ..layout(); + ..layout(new ui.ParagraphConstraints(width: double.INFINITY)); } return _layoutTemplate.height; } diff --git a/packages/flutter/lib/src/rendering/error.dart b/packages/flutter/lib/src/rendering/error.dart index f72a364d2b..7274b5d0b6 100644 --- a/packages/flutter/lib/src/rendering/error.dart +++ b/packages/flutter/lib/src/rendering/error.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:ui' as ui show Paragraph, ParagraphBuilder, ParagraphStyle, TextStyle; +import 'dart:ui' as ui show Paragraph, ParagraphBuilder, ParagraphConstraints, ParagraphStyle, TextStyle; import 'box.dart'; import 'object.dart'; @@ -103,16 +103,17 @@ class RenderErrorBox extends RenderBox { void paint(PaintingContext context, Offset offset) { try { context.canvas.drawRect(offset & size, new Paint() .. color = backgroundColor); + double width; if (_paragraph != null) { // See the comment in the RenderErrorBox constructor. This is not the // code you want to be copying and pasting. :-) if (parent is RenderBox) { RenderBox parentBox = parent; - _paragraph.maxWidth = parentBox.size.width; + width = parentBox.size.width; } else { - _paragraph.maxWidth = size.width; + width = size.width; } - _paragraph.layout(); + _paragraph.layout(new ui.ParagraphConstraints(width: width)); context.canvas.drawParagraph(_paragraph, offset); } } catch (e) { } diff --git a/packages/flutter/test/engine/paragraph_builder_test.dart b/packages/flutter/test/engine/paragraph_builder_test.dart index 5f29e1260d..8b625335d0 100644 --- a/packages/flutter/test/engine/paragraph_builder_test.dart +++ b/packages/flutter/test/engine/paragraph_builder_test.dart @@ -13,12 +13,7 @@ void main() { Paragraph paragraph = builder.build(new ParagraphStyle()); expect(paragraph, isNotNull); - paragraph.minWidth = 0.0; - paragraph.maxWidth = 800.0; - paragraph.minHeight = 0.0; - paragraph.maxHeight = 600.0; - - paragraph.layout(); + paragraph.layout(new ParagraphConstraints(width: 800.0)); expect(paragraph.width, isNonZero); expect(paragraph.height, isNonZero); });