| 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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 UINode build(); | 952 UINode build(); |
| 952 } | 953 } |
| 953 | 954 |
| 954 class Container extends Component { | 955 class Container extends Component { |
| 955 final UINode child; | 956 final UINode child; |
| 956 final BoxConstraints constraints; | 957 final BoxConstraints constraints; |
| 957 final BoxDecoration decoration; | 958 final BoxDecoration decoration; |
| 958 final EdgeDims margin; | 959 final EdgeDims margin; |
| 959 final EdgeDims padding; | 960 final EdgeDims padding; |
| 960 final Matrix4 transform; | 961 final Matrix4 transform; |
| 961 final Size desiredSize; | 962 final double width; |
| 963 final double height; |
| 962 | 964 |
| 963 Container({ | 965 Container({ |
| 964 Object key, | 966 Object key, |
| 965 this.child, | 967 this.child, |
| 966 this.constraints, | 968 this.constraints, |
| 967 this.decoration, | 969 this.decoration, |
| 968 this.desiredSize, | 970 this.width, |
| 971 this.height, |
| 969 this.margin, | 972 this.margin, |
| 970 this.padding, | 973 this.padding, |
| 971 this.transform | 974 this.transform |
| 972 }) : super(key: key); | 975 }) : super(key: key); |
| 973 | 976 |
| 974 UINode build() { | 977 UINode build() { |
| 975 UINode current = child; | 978 UINode current = child; |
| 976 | 979 |
| 980 if (child == null && width == null && height == null) |
| 981 current = new SizedBox(); |
| 982 |
| 977 if (padding != null) | 983 if (padding != null) |
| 978 current = new Padding(padding: padding, child: current); | 984 current = new Padding(padding: padding, child: current); |
| 979 | 985 |
| 980 if (decoration != null) | 986 if (decoration != null) |
| 981 current = new DecoratedBox(decoration: decoration, child: current); | 987 current = new DecoratedBox(decoration: decoration, child: current); |
| 982 | 988 |
| 983 if (desiredSize != null) | 989 if (width != null || height != null) |
| 984 current = new SizedBox(desiredSize: desiredSize, child: current); | 990 current = new SizedBox( |
| 991 width: width == null ? double.INFINITY : width, |
| 992 height: height == null ? double.INFINITY : height, |
| 993 child: current |
| 994 ); |
| 985 | 995 |
| 986 if (constraints != null) | 996 if (constraints != null) |
| 987 current = new ConstrainedBox(constraints: constraints, child: current); | 997 current = new ConstrainedBox(constraints: constraints, child: current); |
| 988 | 998 |
| 989 if (margin != null) | 999 if (margin != null) |
| 990 current = new Padding(padding: margin, child: current); | 1000 current = new Padding(padding: margin, child: current); |
| 991 | 1001 |
| 992 if (transform != null) | 1002 if (transform != null) |
| 993 current = new Transform(transform: transform, child: current); | 1003 current = new Transform(transform: transform, child: current); |
| 994 | 1004 |
| 995 if (current == null) | |
| 996 current = new SizedBox(); | |
| 997 | |
| 998 return current; | 1005 return current; |
| 999 } | 1006 } |
| 1000 } | 1007 } |
| 1001 | 1008 |
| 1002 class _AppView extends AppView { | 1009 class _AppView extends AppView { |
| 1003 _AppView() : super(null); | 1010 _AppView() : super(null); |
| 1004 | 1011 |
| 1005 void dispatchEvent(sky.Event event, HitTestResult result) { | 1012 void dispatchEvent(sky.Event event, HitTestResult result) { |
| 1006 super.dispatchEvent(event, result); | 1013 super.dispatchEvent(event, result); |
| 1007 | 1014 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1036 assert(root.parent is RenderView); | 1043 assert(root.parent is RenderView); |
| 1037 } | 1044 } |
| 1038 } | 1045 } |
| 1039 | 1046 |
| 1040 class Text extends Component { | 1047 class Text extends Component { |
| 1041 Text(this.data) : super(key: '*text*'); | 1048 Text(this.data) : super(key: '*text*'); |
| 1042 final String data; | 1049 final String data; |
| 1043 bool get interchangeable => true; | 1050 bool get interchangeable => true; |
| 1044 UINode build() => new Paragraph(text: data); | 1051 UINode build() => new Paragraph(text: data); |
| 1045 } | 1052 } |
| OLD | NEW |