Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 library fn; | 5 library fn; |
| 6 | 6 |
| 7 import 'app.dart'; | 7 import 'app.dart'; |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:collection'; | 9 import 'dart:collection'; |
| 10 import 'dart:mirrors'; | 10 import 'dart:mirrors'; |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 super.syncRenderObject(old); | 401 super.syncRenderObject(old); |
| 402 root.decoration = decoration; | 402 root.decoration = decoration; |
| 403 } | 403 } |
| 404 } | 404 } |
| 405 | 405 |
| 406 class SizedBox extends OneChildRenderObjectWrapper { | 406 class SizedBox extends OneChildRenderObjectWrapper { |
| 407 RenderSizedBox root; | 407 RenderSizedBox root; |
| 408 final Size desiredSize; | 408 final Size desiredSize; |
| 409 | 409 |
| 410 SizedBox({ | 410 SizedBox({ |
| 411 this.desiredSize: sky.Size.infinite, | 411 double width: double.INFINITY, |
| 412 double height: double.INFINITY, | |
| 412 UINode child, | 413 UINode child, |
| 413 Object key | 414 Object key |
| 414 }) : super(child: child, key: key); | 415 }) : desiredSize = new Size(width, height), super(child: child, key: key); |
| 415 | 416 |
| 416 RenderSizedBox createNode() => new RenderSizedBox(desiredSize: desiredSize); | 417 RenderSizedBox createNode() => new RenderSizedBox(desiredSize: desiredSize); |
| 417 | 418 |
| 418 void syncRenderObject(SizedBox old) { | 419 void syncRenderObject(SizedBox old) { |
| 419 super.syncRenderObject(old); | 420 super.syncRenderObject(old); |
| 420 root.desiredSize = desiredSize; | 421 root.desiredSize = desiredSize; |
| 421 } | 422 } |
| 422 } | 423 } |
| 423 | 424 |
| 424 class ConstrainedBox extends OneChildRenderObjectWrapper { | 425 class ConstrainedBox extends OneChildRenderObjectWrapper { |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 948 UINode build(); | 949 UINode build(); |
| 949 } | 950 } |
| 950 | 951 |
| 951 class Container extends Component { | 952 class Container extends Component { |
| 952 final UINode child; | 953 final UINode child; |
| 953 final BoxConstraints constraints; | 954 final BoxConstraints constraints; |
| 954 final BoxDecoration decoration; | 955 final BoxDecoration decoration; |
| 955 final EdgeDims margin; | 956 final EdgeDims margin; |
| 956 final EdgeDims padding; | 957 final EdgeDims padding; |
| 957 final Matrix4 transform; | 958 final Matrix4 transform; |
| 958 final Size desiredSize; | 959 final double width; |
| 960 final double height; | |
| 959 | 961 |
| 960 Container({ | 962 Container({ |
| 961 Object key, | 963 Object key, |
| 962 this.child, | 964 this.child, |
| 963 this.constraints, | 965 this.constraints, |
| 964 this.decoration, | 966 this.decoration, |
| 965 this.desiredSize, | 967 this.width, |
| 968 this.height, | |
| 966 this.margin, | 969 this.margin, |
| 967 this.padding, | 970 this.padding, |
| 968 this.transform | 971 this.transform |
| 969 }) : super(key: key); | 972 }) : super(key: key); |
| 970 | 973 |
| 971 UINode build() { | 974 UINode build() { |
| 972 UINode current = child; | 975 UINode current = child; |
| 973 | 976 |
| 977 if (child == null && width == null && height == null) | |
| 978 current = new SizedBox(); | |
| 979 | |
| 974 if (padding != null) | 980 if (padding != null) |
| 975 current = new Padding(padding: padding, child: current); | 981 current = new Padding(padding: padding, child: current); |
| 976 | 982 |
| 977 if (decoration != null) | 983 if (decoration != null) |
| 978 current = new DecoratedBox(decoration: decoration, child: current); | 984 current = new DecoratedBox(decoration: decoration, child: current); |
| 979 | 985 |
| 980 if (desiredSize != null) | 986 if (width != null && height != null) |
| 981 current = new SizedBox(desiredSize: desiredSize, child: current); | 987 current = new SizedBox(width: width, height: height, child: current); |
| 988 else if (width != null) | |
| 989 current = new SizedBox(width: width, child: current); | |
| 990 else if (height != null) | |
| 991 current = new SizedBox(height: height, child: current); | |
|
abarth-chromium
2015/06/08 21:09:01
if (width != null || height != null)
current = n
| |
| 982 | 992 |
| 983 if (constraints != null) | 993 if (constraints != null) |
| 984 current = new ConstrainedBox(constraints: constraints); | 994 current = new ConstrainedBox(constraints: constraints); |
| 985 | 995 |
| 986 if (margin != null) | 996 if (margin != null) |
| 987 current = new Padding(padding: margin, child: current); | 997 current = new Padding(padding: margin, child: current); |
| 988 | 998 |
| 989 if (transform != null) | 999 if (transform != null) |
| 990 current = new Transform(transform: transform, child: current); | 1000 current = new Transform(transform: transform, child: current); |
| 991 | 1001 |
| 992 if (current == null) | |
| 993 current = new SizedBox(); | |
| 994 | |
| 995 return current; | 1002 return current; |
| 996 } | 1003 } |
| 997 } | 1004 } |
| 998 | 1005 |
| 999 class _AppView extends AppView { | 1006 class _AppView extends AppView { |
| 1000 _AppView() : super(null); | 1007 _AppView() : super(null); |
| 1001 | 1008 |
| 1002 void dispatchEvent(sky.Event event, HitTestResult result) { | 1009 void dispatchEvent(sky.Event event, HitTestResult result) { |
| 1003 super.dispatchEvent(event, result); | 1010 super.dispatchEvent(event, result); |
| 1004 | 1011 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1033 assert(root.parent is RenderView); | 1040 assert(root.parent is RenderView); |
| 1034 } | 1041 } |
| 1035 } | 1042 } |
| 1036 | 1043 |
| 1037 class Text extends Component { | 1044 class Text extends Component { |
| 1038 Text(this.data) : super(key: '*text*'); | 1045 Text(this.data) : super(key: '*text*'); |
| 1039 final String data; | 1046 final String data; |
| 1040 bool get interchangeable => true; | 1047 bool get interchangeable => true; |
| 1041 UINode build() => new Paragraph(text: data); | 1048 UINode build() => new Paragraph(text: data); |
| 1042 } | 1049 } |
| OLD | NEW |