Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: sky/sdk/lib/framework/rendering/box.dart

Issue 1164303002: Introduce sky.Sky.zero (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'dart:math' as math; 5 import 'dart:math' as math;
6 import 'dart:sky' as sky; 6 import 'dart:sky' as sky;
7 import 'dart:typed_data'; 7 import 'dart:typed_data';
8 import 'object.dart'; 8 import 'object.dart';
9 import 'package:vector_math/vector_math.dart'; 9 import 'package:vector_math/vector_math.dart';
10 import 'package:sky/framework/net/image_cache.dart' as image_cache; 10 import 'package:sky/framework/net/image_cache.dart' as image_cache;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (child.parentData is! BoxParentData) 118 if (child.parentData is! BoxParentData)
119 child.parentData = new BoxParentData(); 119 child.parentData = new BoxParentData();
120 } 120 }
121 121
122 // override this to report what dimensions you would have if you 122 // override this to report what dimensions you would have if you
123 // were laid out with the given constraints this can walk the tree 123 // were laid out with the given constraints this can walk the tree
124 // if it must, but it should be as cheap as possible; just get the 124 // if it must, but it should be as cheap as possible; just get the
125 // dimensions and nothing else (e.g. don't calculate hypothetical 125 // dimensions and nothing else (e.g. don't calculate hypothetical
126 // child positions if they're not needed to determine dimensions) 126 // child positions if they're not needed to determine dimensions)
127 Size getIntrinsicDimensions(BoxConstraints constraints) { 127 Size getIntrinsicDimensions(BoxConstraints constraints) {
128 return constraints.constrain(new Size(0.0, 0.0)); 128 return constraints.constrain(Size.zero);
129 } 129 }
130 130
131 BoxConstraints get constraints => super.constraints as BoxConstraints; 131 BoxConstraints get constraints => super.constraints as BoxConstraints;
132 void performResize() { 132 void performResize() {
133 // default behaviour for subclasses that have sizedByParent = true 133 // default behaviour for subclasses that have sizedByParent = true
134 size = constraints.constrain(new Size(0.0, 0.0)); 134 size = constraints.constrain(Size.zero);
135 assert(size.height < double.INFINITY); 135 assert(size.height < double.INFINITY);
136 assert(size.width < double.INFINITY); 136 assert(size.width < double.INFINITY);
137 } 137 }
138 void performLayout() { 138 void performLayout() {
139 // descendants have to either override performLayout() to set both 139 // descendants have to either override performLayout() to set both
140 // width and height and lay out children, or, set sizedByParent to 140 // width and height and lay out children, or, set sizedByParent to
141 // true so that performResize()'s logic above does its thing. 141 // true so that performResize()'s logic above does its thing.
142 assert(sizedByParent); 142 assert(sizedByParent);
143 } 143 }
144 144
145 bool hitTest(HitTestResult result, { Point position }) { 145 bool hitTest(HitTestResult result, { Point position }) {
146 hitTestChildren(result, position: position); 146 hitTestChildren(result, position: position);
147 result.add(this); 147 result.add(this);
148 return true; 148 return true;
149 } 149 }
150 void hitTestChildren(HitTestResult result, { Point position }) { } 150 void hitTestChildren(HitTestResult result, { Point position }) { }
151 151
152 Size size = new Size(0.0, 0.0); 152 Size size = Size.zero;
153 153
154 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}size: ${size}\n'; 154 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}size: ${size}\n';
155 } 155 }
156 156
157 abstract class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin< RenderBox> { 157 abstract class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin< RenderBox> {
158 RenderProxyBox(RenderBox child) { 158 RenderProxyBox(RenderBox child) {
159 this.child = child; 159 this.child = child;
160 } 160 }
161 161
162 Size getIntrinsicDimensions(BoxConstraints constraints) { 162 Size getIntrinsicDimensions(BoxConstraints constraints) {
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 715
716 class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> { 716 class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> {
717 717
718 RenderView({ 718 RenderView({
719 RenderBox child, 719 RenderBox child,
720 this.timeForRotation: const Duration(microseconds: 83333) 720 this.timeForRotation: const Duration(microseconds: 83333)
721 }) { 721 }) {
722 this.child = child; 722 this.child = child;
723 } 723 }
724 724
725 Size _size = new Size(0.0, 0.0); 725 Size _size = Size.zero;
726 double get width => _size.width; 726 double get width => _size.width;
727 double get height => _size.height; 727 double get height => _size.height;
728 728
729 int _orientation; // 0..3 729 int _orientation; // 0..3
730 int get orientation => _orientation; 730 int get orientation => _orientation;
731 Duration timeForRotation; 731 Duration timeForRotation;
732 732
733 ViewConstraints get constraints => super.constraints as ViewConstraints; 733 ViewConstraints get constraints => super.constraints as ViewConstraints;
734 bool get sizedByParent => true; 734 bool get sizedByParent => true;
735 void performResize() { 735 void performResize() {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 799
800 void defaultPaint(RenderObjectDisplayList canvas) { 800 void defaultPaint(RenderObjectDisplayList canvas) {
801 RenderBox child = firstChild; 801 RenderBox child = firstChild;
802 while (child != null) { 802 while (child != null) {
803 assert(child.parentData is ParentDataType); 803 assert(child.parentData is ParentDataType);
804 canvas.paintChild(child, child.parentData.position); 804 canvas.paintChild(child, child.parentData.position);
805 child = child.parentData.nextSibling; 805 child = child.parentData.nextSibling;
806 } 806 }
807 } 807 }
808 } 808 }
OLDNEW
« sky/examples/raw/sector_layout.dart ('K') | « sky/examples/raw/sector_layout.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698