From 7145784436f8667f1f179ad6a2097dd3058e1a68 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Sat, 16 Jan 2016 14:08:28 -0800 Subject: [PATCH] Rename ViewConstraints to ViewConfiguration And rootConstraints to configuration. This type and its variable have nothing to do with Constraints. Fixes https://github.com/flutter/flutter/issues/829 --- .../benchmark/stocks/layout_bench.dart | 6 ++--- .../flutter/lib/src/rendering/binding.dart | 2 +- packages/flutter/lib/src/rendering/view.dart | 24 +++++++++---------- .../test/rendering/rendering_tester.dart | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/flutter/benchmark/stocks/layout_bench.dart b/packages/flutter/benchmark/stocks/layout_bench.dart index 11adc48032..903a3209ad 100644 --- a/packages/flutter/benchmark/stocks/layout_bench.dart +++ b/packages/flutter/benchmark/stocks/layout_bench.dart @@ -22,15 +22,15 @@ void main() { tester.pump(const Duration(seconds: 1)); // Complete drawer animation }); - ViewConstraints big = const ViewConstraints(size: const Size(360.0, 640.0)); - ViewConstraints small = const ViewConstraints(size: const Size(355.0, 635.0)); + ViewConfiguration big = const ViewConfiguration(size: const Size(360.0, 640.0)); + ViewConfiguration small = const ViewConfiguration(size: const Size(355.0, 635.0)); RenderView renderView = WidgetFlutterBinding.instance.renderView; Stopwatch watch = new Stopwatch() ..start(); for (int i = 0; i < _kNumberOfIterations || _kRunForever; ++i) { - renderView.rootConstraints = (i % 2 == 0) ? big : small; + renderView.configuration = (i % 2 == 0) ? big : small; RenderObject.flushLayout(); } diff --git a/packages/flutter/lib/src/rendering/binding.dart b/packages/flutter/lib/src/rendering/binding.dart index 1edbd7df40..fe19003396 100644 --- a/packages/flutter/lib/src/rendering/binding.dart +++ b/packages/flutter/lib/src/rendering/binding.dart @@ -58,7 +58,7 @@ abstract class Renderer extends Scheduler void handleMetricsChanged() { assert(renderView != null); - renderView.rootConstraints = new ViewConstraints(size: ui.window.size); + renderView.configuration = new ViewConfiguration(size: ui.window.size); } void _handlePersistentFrameCallback(Duration timeStamp) { diff --git a/packages/flutter/lib/src/rendering/view.dart b/packages/flutter/lib/src/rendering/view.dart index b316ad60e5..c468ce0835 100644 --- a/packages/flutter/lib/src/rendering/view.dart +++ b/packages/flutter/lib/src/rendering/view.dart @@ -15,8 +15,8 @@ import 'layer.dart'; import 'object.dart'; /// The layout constraints for the root render object. -class ViewConstraints { - const ViewConstraints({ +class ViewConfiguration { + const ViewConfiguration({ this.size: Size.zero, this.orientation }); @@ -55,12 +55,12 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin int _orientation; // 0..3 /// The constraints used for the root layout. - ViewConstraints get rootConstraints => _rootConstraints; - ViewConstraints _rootConstraints; - void set rootConstraints(ViewConstraints value) { - if (rootConstraints == value) + ViewConfiguration get configuration => _configuration; + ViewConfiguration _configuration; + void set configuration(ViewConfiguration value) { + if (configuration == value) return; - _rootConstraints = value; + _configuration = value; markNeedsLayout(); } @@ -85,12 +85,12 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin } void performLayout() { - if (rootConstraints.orientation != _orientation) { + if (configuration.orientation != _orientation) { if (_orientation != null && child != null) - child.rotate(oldAngle: _orientation, newAngle: rootConstraints.orientation, time: timeForRotation); - _orientation = rootConstraints.orientation; + child.rotate(oldAngle: _orientation, newAngle: configuration.orientation, time: timeForRotation); + _orientation = configuration.orientation; } - _size = rootConstraints.size; + _size = configuration.size; assert(!_size.isInfinite); if (child != null) @@ -146,6 +146,6 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin // call to ${super.debugDescribeSettings(prefix)} is omitted because the root superclasses don't include any interesting information for this class settings.add('window size: ${ui.window.size} (in device pixels)'); settings.add('device pixel ratio: ${ui.window.devicePixelRatio} (device pixels per logical pixel)'); - settings.add('root constraints: $rootConstraints (in logical pixels)'); + settings.add('configuration: $configuration (in logical pixels)'); } } diff --git a/packages/flutter/test/rendering/rendering_tester.dart b/packages/flutter/test/rendering/rendering_tester.dart index cc67af2c88..2b620ad79c 100644 --- a/packages/flutter/test/rendering/rendering_tester.dart +++ b/packages/flutter/test/rendering/rendering_tester.dart @@ -11,7 +11,7 @@ const Size _kTestViewSize = const Size(800.0, 600.0); class TestRenderView extends RenderView { TestRenderView() { - rootConstraints = new ViewConstraints(size: _kTestViewSize); + configuration = new ViewConfiguration(size: _kTestViewSize); } void scheduleInitialFrame() { scheduleInitialLayout();