| 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 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 String toString() => "EdgeDims($top, $right, $bottom, $left)"; | 46 String toString() => "EdgeDims($top, $right, $bottom, $left)"; |
| 47 } | 47 } |
| 48 | 48 |
| 49 class BoxConstraints { | 49 class BoxConstraints { |
| 50 const BoxConstraints({ | 50 const BoxConstraints({ |
| 51 this.minWidth: 0.0, | 51 this.minWidth: 0.0, |
| 52 this.maxWidth: double.INFINITY, | 52 this.maxWidth: double.INFINITY, |
| 53 this.minHeight: 0.0, | 53 this.minHeight: 0.0, |
| 54 this.maxHeight: double.INFINITY}); | 54 this.maxHeight: double.INFINITY}); |
| 55 | 55 |
| 56 BoxConstraints.tight(sky.Size size) | 56 BoxConstraints.tight(Size size) |
| 57 : minWidth = size.width, | 57 : minWidth = size.width, |
| 58 maxWidth = size.width, | 58 maxWidth = size.width, |
| 59 minHeight = size.height, | 59 minHeight = size.height, |
| 60 maxHeight = size.height; | 60 maxHeight = size.height; |
| 61 | 61 |
| 62 BoxConstraints.loose(sky.Size size) | 62 BoxConstraints.loose(Size size) |
| 63 : minWidth = 0.0, | 63 : minWidth = 0.0, |
| 64 maxWidth = size.width, | 64 maxWidth = size.width, |
| 65 minHeight = 0.0, | 65 minHeight = 0.0, |
| 66 maxHeight = size.height; | 66 maxHeight = size.height; |
| 67 | 67 |
| 68 BoxConstraints deflate(EdgeDims edges) { | 68 BoxConstraints deflate(EdgeDims edges) { |
| 69 assert(edges != null); | 69 assert(edges != null); |
| 70 double horizontal = edges.left + edges.right; | 70 double horizontal = edges.left + edges.right; |
| 71 double vertical = edges.top + edges.bottom; | 71 double vertical = edges.top + edges.bottom; |
| 72 return new BoxConstraints( | 72 return new BoxConstraints( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 83 final double maxHeight; | 83 final double maxHeight; |
| 84 | 84 |
| 85 double constrainWidth(double width) { | 85 double constrainWidth(double width) { |
| 86 return clamp(min: minWidth, max: maxWidth, value: width); | 86 return clamp(min: minWidth, max: maxWidth, value: width); |
| 87 } | 87 } |
| 88 | 88 |
| 89 double constrainHeight(double height) { | 89 double constrainHeight(double height) { |
| 90 return clamp(min: minHeight, max: maxHeight, value: height); | 90 return clamp(min: minHeight, max: maxHeight, value: height); |
| 91 } | 91 } |
| 92 | 92 |
| 93 sky.Size constrain(sky.Size size) { | 93 Size constrain(Size size) { |
| 94 return new sky.Size(constrainWidth(size.width), constrainHeight(size.height)
); | 94 return new Size(constrainWidth(size.width), constrainHeight(size.height)); |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool get isInfinite => maxWidth >= double.INFINITY || maxHeight >= double.INFI
NITY; | 97 bool get isInfinite => maxWidth >= double.INFINITY || maxHeight >= double.INFI
NITY; |
| 98 | 98 |
| 99 int get hashCode { | 99 int get hashCode { |
| 100 int value = 373; | 100 int value = 373; |
| 101 value = 37 * value + minWidth.hashCode; | 101 value = 37 * value + minWidth.hashCode; |
| 102 value = 37 * value + maxWidth.hashCode; | 102 value = 37 * value + maxWidth.hashCode; |
| 103 value = 37 * value + minHeight.hashCode; | 103 value = 37 * value + minHeight.hashCode; |
| 104 value = 37 * value + maxHeight.hashCode; | 104 value = 37 * value + maxHeight.hashCode; |
| 105 return value; | 105 return value; |
| 106 } | 106 } |
| 107 String toString() => "BoxConstraints($minWidth<=w<$maxWidth, $minHeight<=h<$ma
xHeight)"; | 107 String toString() => "BoxConstraints($minWidth<=w<$maxWidth, $minHeight<=h<$ma
xHeight)"; |
| 108 } | 108 } |
| 109 | 109 |
| 110 class BoxParentData extends ParentData { | 110 class BoxParentData extends ParentData { |
| 111 sky.Point position = new sky.Point(0.0, 0.0); | 111 Point position = new Point(0.0, 0.0); |
| 112 String toString() => 'position=$position'; | 112 String toString() => 'position=$position'; |
| 113 } | 113 } |
| 114 | 114 |
| 115 abstract class RenderBox extends RenderObject { | 115 abstract class RenderBox extends RenderObject { |
| 116 | 116 |
| 117 void setParentData(RenderObject child) { | 117 void setParentData(RenderObject child) { |
| 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 sky.Size getIntrinsicDimensions(BoxConstraints constraints) { | 127 Size getIntrinsicDimensions(BoxConstraints constraints) { |
| 128 return constraints.constrain(new sky.Size(0.0, 0.0)); | 128 return constraints.constrain(new Size(0.0, 0.0)); |
| 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 sky.Size(0.0, 0.0)); | 134 size = constraints.constrain(new Size(0.0, 0.0)); |
| 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, { sky.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, { sky.Point position }) { } | 150 void hitTestChildren(HitTestResult result, { Point position }) { } |
| 151 | 151 |
| 152 sky.Size size = new sky.Size(0.0, 0.0); | 152 Size size = new Size(0.0, 0.0); |
| 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 sky.Size getIntrinsicDimensions(BoxConstraints constraints) { | 162 Size getIntrinsicDimensions(BoxConstraints constraints) { |
| 163 if (child != null) | 163 if (child != null) |
| 164 return child.getIntrinsicDimensions(constraints); | 164 return child.getIntrinsicDimensions(constraints); |
| 165 return super.getIntrinsicDimensions(constraints); | 165 return super.getIntrinsicDimensions(constraints); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void performLayout() { | 168 void performLayout() { |
| 169 if (child != null) { | 169 if (child != null) { |
| 170 child.layout(constraints, parentUsesSize: true); | 170 child.layout(constraints, parentUsesSize: true); |
| 171 size = child.size; | 171 size = child.size; |
| 172 } else { | 172 } else { |
| 173 performResize(); | 173 performResize(); |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 | 176 |
| 177 void hitTestChildren(HitTestResult result, { sky.Point position }) { | 177 void hitTestChildren(HitTestResult result, { Point position }) { |
| 178 if (child != null) | 178 if (child != null) |
| 179 child.hitTest(result, position: position); | 179 child.hitTest(result, position: position); |
| 180 else | 180 else |
| 181 super.hitTestChildren(result, position: position); | 181 super.hitTestChildren(result, position: position); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void paint(RenderObjectDisplayList canvas) { | 184 void paint(RenderObjectDisplayList canvas) { |
| 185 if (child != null) | 185 if (child != null) |
| 186 child.paint(canvas); | 186 child.paint(canvas); |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 | 189 |
| 190 class RenderSizedBox extends RenderProxyBox { | 190 class RenderSizedBox extends RenderProxyBox { |
| 191 | 191 |
| 192 RenderSizedBox({ | 192 RenderSizedBox({ |
| 193 RenderBox child, | 193 RenderBox child, |
| 194 sky.Size desiredSize: sky.Size.infinite | 194 Size desiredSize: Size.infinite |
| 195 }) : super(child) { | 195 }) : super(child) { |
| 196 assert(desiredSize != null); | 196 assert(desiredSize != null); |
| 197 this.desiredSize = desiredSize; | 197 this.desiredSize = desiredSize; |
| 198 } | 198 } |
| 199 | 199 |
| 200 sky.Size _desiredSize; | 200 Size _desiredSize; |
| 201 sky.Size get desiredSize => _desiredSize; | 201 Size get desiredSize => _desiredSize; |
| 202 void set desiredSize (sky.Size value) { | 202 void set desiredSize (Size value) { |
| 203 assert(value != null); | 203 assert(value != null); |
| 204 if (_desiredSize == value) | 204 if (_desiredSize == value) |
| 205 return; | 205 return; |
| 206 _desiredSize = value; | 206 _desiredSize = value; |
| 207 markNeedsLayout(); | 207 markNeedsLayout(); |
| 208 } | 208 } |
| 209 | 209 |
| 210 sky.Size getIntrinsicDimensions(BoxConstraints constraints) { | 210 Size getIntrinsicDimensions(BoxConstraints constraints) { |
| 211 return constraints.constrain(_desiredSize); | 211 return constraints.constrain(_desiredSize); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void performLayout() { | 214 void performLayout() { |
| 215 size = constraints.constrain(_desiredSize); | 215 size = constraints.constrain(_desiredSize); |
| 216 if (child != null) | 216 if (child != null) |
| 217 child.layout(new BoxConstraints.tight(size)); | 217 child.layout(new BoxConstraints.tight(size)); |
| 218 } | 218 } |
| 219 | 219 |
| 220 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}desiredSize: ${desiredSize}\n'; | 220 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}desiredSize: ${desiredSize}\n'; |
| 221 } | 221 } |
| 222 | 222 |
| 223 class RenderClip extends RenderProxyBox { | 223 class RenderClip extends RenderProxyBox { |
| 224 RenderClip({ RenderBox child }) : super(child); | 224 RenderClip({ RenderBox child }) : super(child); |
| 225 | 225 |
| 226 void paint(RenderObjectDisplayList canvas) { | 226 void paint(RenderObjectDisplayList canvas) { |
| 227 if (child != null) { | 227 if (child != null) { |
| 228 canvas.save(); | 228 canvas.save(); |
| 229 canvas.clipRect(new sky.Rect.fromSize(size)); | 229 canvas.clipRect(new Rect.fromSize(size)); |
| 230 child.paint(canvas); | 230 child.paint(canvas); |
| 231 canvas.restore(); | 231 canvas.restore(); |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 | 235 |
| 236 class RenderPadding extends RenderBox with RenderObjectWithChildMixin<RenderBox>
{ | 236 class RenderPadding extends RenderBox with RenderObjectWithChildMixin<RenderBox>
{ |
| 237 | 237 |
| 238 RenderPadding({ EdgeDims padding, RenderBox child }) { | 238 RenderPadding({ EdgeDims padding, RenderBox child }) { |
| 239 assert(padding != null); | 239 assert(padding != null); |
| 240 this.padding = padding; | 240 this.padding = padding; |
| 241 this.child = child; | 241 this.child = child; |
| 242 } | 242 } |
| 243 | 243 |
| 244 EdgeDims _padding; | 244 EdgeDims _padding; |
| 245 EdgeDims get padding => _padding; | 245 EdgeDims get padding => _padding; |
| 246 void set padding (EdgeDims value) { | 246 void set padding (EdgeDims value) { |
| 247 assert(value != null); | 247 assert(value != null); |
| 248 if (_padding == value) | 248 if (_padding == value) |
| 249 return; | 249 return; |
| 250 _padding = value; | 250 _padding = value; |
| 251 markNeedsLayout(); | 251 markNeedsLayout(); |
| 252 } | 252 } |
| 253 | 253 |
| 254 sky.Size getIntrinsicDimensions(BoxConstraints constraints) { | 254 Size getIntrinsicDimensions(BoxConstraints constraints) { |
| 255 assert(padding != null); | 255 assert(padding != null); |
| 256 constraints = constraints.deflate(padding); | 256 constraints = constraints.deflate(padding); |
| 257 if (child == null) | 257 if (child == null) |
| 258 return super.getIntrinsicDimensions(constraints); | 258 return super.getIntrinsicDimensions(constraints); |
| 259 return child.getIntrinsicDimensions(constraints); | 259 return child.getIntrinsicDimensions(constraints); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void performLayout() { | 262 void performLayout() { |
| 263 assert(padding != null); | 263 assert(padding != null); |
| 264 BoxConstraints innerConstraints = constraints.deflate(padding); | 264 BoxConstraints innerConstraints = constraints.deflate(padding); |
| 265 if (child == null) { | 265 if (child == null) { |
| 266 size = innerConstraints.constrain( | 266 size = innerConstraints.constrain( |
| 267 new sky.Size(padding.left + padding.right, padding.top + padding.botto
m)); | 267 new Size(padding.left + padding.right, padding.top + padding.bottom)); |
| 268 return; | 268 return; |
| 269 } | 269 } |
| 270 child.layout(innerConstraints, parentUsesSize: true); | 270 child.layout(innerConstraints, parentUsesSize: true); |
| 271 assert(child.parentData is BoxParentData); | 271 assert(child.parentData is BoxParentData); |
| 272 child.parentData.position = new sky.Point(padding.left, padding.top); | 272 child.parentData.position = new Point(padding.left, padding.top); |
| 273 size = constraints.constrain(new sky.Size(padding.left + child.size.width +
padding.right, | 273 size = constraints.constrain(new Size(padding.left + child.size.width + padd
ing.right, |
| 274 padding.top + child.size.height +
padding.bottom)); | 274 padding.top + child.size.height +
padding.bottom)); |
| 275 } | 275 } |
| 276 | 276 |
| 277 void paint(RenderObjectDisplayList canvas) { | 277 void paint(RenderObjectDisplayList canvas) { |
| 278 if (child != null) | 278 if (child != null) |
| 279 canvas.paintChild(child, child.parentData.position); | 279 canvas.paintChild(child, child.parentData.position); |
| 280 } | 280 } |
| 281 | 281 |
| 282 void hitTestChildren(HitTestResult result, { sky.Point position }) { | 282 void hitTestChildren(HitTestResult result, { Point position }) { |
| 283 if (child != null) { | 283 if (child != null) { |
| 284 assert(child.parentData is BoxParentData); | 284 assert(child.parentData is BoxParentData); |
| 285 sky.Rect childBounds = new sky.Rect.fromPointAndSize(child.parentData.posi
tion, child.size); | 285 Rect childBounds = new Rect.fromPointAndSize(child.parentData.position, ch
ild.size); |
| 286 if (childBounds.contains(position)) { | 286 if (childBounds.contains(position)) { |
| 287 child.hitTest(result, position: new sky.Point(position.x - child.parentD
ata.position.x, | 287 child.hitTest(result, position: new Point(position.x - child.parentData.
position.x, |
| 288 position.y - child.parentD
ata.position.y)); | 288 position.y - child.parentD
ata.position.y)); |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 } | 291 } |
| 292 | 292 |
| 293 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}padding: ${padding}\n'; | 293 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}padding: ${padding}\n'; |
| 294 } | 294 } |
| 295 | 295 |
| 296 class RenderImage extends RenderBox { | 296 class RenderImage extends RenderBox { |
| 297 | 297 |
| 298 RenderImage(String url, sky.Size dimensions) { | 298 RenderImage(String url, Size dimensions) { |
| 299 requestedSize = dimensions; | 299 requestedSize = dimensions; |
| 300 src = url; | 300 src = url; |
| 301 } | 301 } |
| 302 | 302 |
| 303 sky.Image _image; | 303 sky.Image _image; |
| 304 String _src; | 304 String _src; |
| 305 String get src => _src; | 305 String get src => _src; |
| 306 void set src (String value) { | 306 void set src (String value) { |
| 307 if (value == _src) | 307 if (value == _src) |
| 308 return; | 308 return; |
| 309 _src = value; | 309 _src = value; |
| 310 image_cache.load(_src, (result) { | 310 image_cache.load(_src, (result) { |
| 311 _image = result; | 311 _image = result; |
| 312 if (requestedSize.width == null || requestedSize.height == null) | 312 if (requestedSize.width == null || requestedSize.height == null) |
| 313 markNeedsLayout(); | 313 markNeedsLayout(); |
| 314 markNeedsPaint(); | 314 markNeedsPaint(); |
| 315 }); | 315 }); |
| 316 } | 316 } |
| 317 | 317 |
| 318 sky.Size _requestedSize; | 318 Size _requestedSize; |
| 319 sky.Size get requestedSize => _requestedSize; | 319 Size get requestedSize => _requestedSize; |
| 320 void set requestedSize (sky.Size value) { | 320 void set requestedSize (Size value) { |
| 321 if (value == _requestedSize) | 321 if (value == _requestedSize) |
| 322 return; | 322 return; |
| 323 _requestedSize = value; | 323 _requestedSize = value; |
| 324 markNeedsLayout(); | 324 markNeedsLayout(); |
| 325 } | 325 } |
| 326 | 326 |
| 327 void performLayout() { | 327 void performLayout() { |
| 328 // If there's no image, we can't size ourselves automatically | 328 // If there's no image, we can't size ourselves automatically |
| 329 if (_image == null) { | 329 if (_image == null) { |
| 330 double width = requestedSize.width == null ? 0.0 : requestedSize.width; | 330 double width = requestedSize.width == null ? 0.0 : requestedSize.width; |
| 331 double height = requestedSize.height == null ? 0.0 : requestedSize.height; | 331 double height = requestedSize.height == null ? 0.0 : requestedSize.height; |
| 332 size = constraints.constrain(new sky.Size(width, height)); | 332 size = constraints.constrain(new Size(width, height)); |
| 333 return; | 333 return; |
| 334 } | 334 } |
| 335 | 335 |
| 336 // If neither height nor width are specified, use inherent image dimensions | 336 // If neither height nor width are specified, use inherent image dimensions |
| 337 // If only one dimension is specified, adjust the other dimension to | 337 // If only one dimension is specified, adjust the other dimension to |
| 338 // maintain the aspect ratio | 338 // maintain the aspect ratio |
| 339 if (requestedSize.width == null) { | 339 if (requestedSize.width == null) { |
| 340 if (requestedSize.height == null) { | 340 if (requestedSize.height == null) { |
| 341 size = constraints.constrain(new sky.Size(_image.width.toDouble(), _imag
e.height.toDouble())); | 341 size = constraints.constrain(new Size(_image.width.toDouble(), _image.he
ight.toDouble())); |
| 342 } else { | 342 } else { |
| 343 double width = requestedSize.height * _image.width / _image.height; | 343 double width = requestedSize.height * _image.width / _image.height; |
| 344 size = constraints.constrain(new sky.Size(width, requestedSize.height)); | 344 size = constraints.constrain(new Size(width, requestedSize.height)); |
| 345 } | 345 } |
| 346 } else if (requestedSize.height == null) { | 346 } else if (requestedSize.height == null) { |
| 347 double height = requestedSize.width * _image.height / _image.width; | 347 double height = requestedSize.width * _image.height / _image.width; |
| 348 size = constraints.constrain(new sky.Size(requestedSize.width, height)); | 348 size = constraints.constrain(new Size(requestedSize.width, height)); |
| 349 } else { | 349 } else { |
| 350 size = constraints.constrain(requestedSize); | 350 size = constraints.constrain(requestedSize); |
| 351 } | 351 } |
| 352 } | 352 } |
| 353 | 353 |
| 354 void paint(RenderObjectDisplayList canvas) { | 354 void paint(RenderObjectDisplayList canvas) { |
| 355 if (_image == null) return; | 355 if (_image == null) return; |
| 356 bool needsScale = size.width != _image.width || size.height != _image.height
; | 356 bool needsScale = size.width != _image.width || size.height != _image.height
; |
| 357 if (needsScale) { | 357 if (needsScale) { |
| 358 double widthScale = size.width / _image.width; | 358 double widthScale = size.width / _image.width; |
| 359 double heightScale = size.height / _image.height; | 359 double heightScale = size.height / _image.height; |
| 360 canvas.save(); | 360 canvas.save(); |
| 361 canvas.scale(widthScale, heightScale); | 361 canvas.scale(widthScale, heightScale); |
| 362 } | 362 } |
| 363 sky.Paint paint = new sky.Paint(); | 363 Paint paint = new Paint(); |
| 364 canvas.drawImage(_image, 0.0, 0.0, paint); | 364 canvas.drawImage(_image, 0.0, 0.0, paint); |
| 365 if (needsScale) | 365 if (needsScale) |
| 366 canvas.restore(); | 366 canvas.restore(); |
| 367 } | 367 } |
| 368 | 368 |
| 369 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}url: ${src}\n${prefix}dimensions: ${requestedSize}\n'; | 369 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}url: ${src}\n${prefix}dimensions: ${requestedSize}\n'; |
| 370 } | 370 } |
| 371 | 371 |
| 372 class BorderSide { | 372 class BorderSide { |
| 373 const BorderSide({ | 373 const BorderSide({ |
| 374 this.color: const sky.Color(0xFF000000), | 374 this.color: const Color(0xFF000000), |
| 375 this.width: 1.0 | 375 this.width: 1.0 |
| 376 }); | 376 }); |
| 377 final sky.Color color; | 377 final Color color; |
| 378 final double width; | 378 final double width; |
| 379 | 379 |
| 380 static const none = const BorderSide(width: 0.0); | 380 static const none = const BorderSide(width: 0.0); |
| 381 | 381 |
| 382 int get hashCode { | 382 int get hashCode { |
| 383 int value = 373; | 383 int value = 373; |
| 384 value = 37 * value * color.hashCode; | 384 value = 37 * value * color.hashCode; |
| 385 value = 37 * value * width.hashCode; | 385 value = 37 * value * width.hashCode; |
| 386 return value; | 386 return value; |
| 387 } | 387 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 416 String toString() => 'Border($top, $right, $bottom, $left)'; | 416 String toString() => 'Border($top, $right, $bottom, $left)'; |
| 417 } | 417 } |
| 418 | 418 |
| 419 // This must be immutable, because we won't notice when it changes | 419 // This must be immutable, because we won't notice when it changes |
| 420 class BoxDecoration { | 420 class BoxDecoration { |
| 421 const BoxDecoration({ | 421 const BoxDecoration({ |
| 422 this.backgroundColor, | 422 this.backgroundColor, |
| 423 this.border | 423 this.border |
| 424 }); | 424 }); |
| 425 | 425 |
| 426 final sky.Color backgroundColor; | 426 final Color backgroundColor; |
| 427 final Border border; | 427 final Border border; |
| 428 | 428 |
| 429 String toString([String prefix = '']) { | 429 String toString([String prefix = '']) { |
| 430 List<String> result = []; | 430 List<String> result = []; |
| 431 if (backgroundColor != null) | 431 if (backgroundColor != null) |
| 432 result.add('${prefix}backgroundColor: $backgroundColor'); | 432 result.add('${prefix}backgroundColor: $backgroundColor'); |
| 433 if (border != null) | 433 if (border != null) |
| 434 result.add('${prefix}border: $border'); | 434 result.add('${prefix}border: $border'); |
| 435 if (result.isEmpty) | 435 if (result.isEmpty) |
| 436 return '${prefix}<no decorations specified>'; | 436 return '${prefix}<no decorations specified>'; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 455 return; | 455 return; |
| 456 _decoration = value; | 456 _decoration = value; |
| 457 markNeedsPaint(); | 457 markNeedsPaint(); |
| 458 } | 458 } |
| 459 | 459 |
| 460 void paint(RenderObjectDisplayList canvas) { | 460 void paint(RenderObjectDisplayList canvas) { |
| 461 assert(size.width != null); | 461 assert(size.width != null); |
| 462 assert(size.height != null); | 462 assert(size.height != null); |
| 463 | 463 |
| 464 if (_decoration.backgroundColor != null) { | 464 if (_decoration.backgroundColor != null) { |
| 465 sky.Paint paint = new sky.Paint()..color = _decoration.backgroundColor; | 465 Paint paint = new Paint()..color = _decoration.backgroundColor; |
| 466 canvas.drawRect(new sky.Rect.fromLTRB(0.0, 0.0, size.width, size.height),
paint); | 466 canvas.drawRect(new Rect.fromLTRB(0.0, 0.0, size.width, size.height), pain
t); |
| 467 } | 467 } |
| 468 | 468 |
| 469 if (_decoration.border != null) { | 469 if (_decoration.border != null) { |
| 470 assert(_decoration.border.top != null); | 470 assert(_decoration.border.top != null); |
| 471 assert(_decoration.border.right != null); | 471 assert(_decoration.border.right != null); |
| 472 assert(_decoration.border.bottom != null); | 472 assert(_decoration.border.bottom != null); |
| 473 assert(_decoration.border.left != null); | 473 assert(_decoration.border.left != null); |
| 474 | 474 |
| 475 sky.Paint paint = new sky.Paint(); | 475 Paint paint = new Paint(); |
| 476 sky.Path path; | 476 Path path; |
| 477 | 477 |
| 478 paint.color = _decoration.border.top.color; | 478 paint.color = _decoration.border.top.color; |
| 479 path = new sky.Path(); | 479 path = new Path(); |
| 480 path.moveTo(0.0,0.0); | 480 path.moveTo(0.0,0.0); |
| 481 path.lineTo(_decoration.border.left.width, _decoration.border.top.width); | 481 path.lineTo(_decoration.border.left.width, _decoration.border.top.width); |
| 482 path.lineTo(size.width - _decoration.border.right.width, _decoration.borde
r.top.width); | 482 path.lineTo(size.width - _decoration.border.right.width, _decoration.borde
r.top.width); |
| 483 path.lineTo(size.width, 0.0); | 483 path.lineTo(size.width, 0.0); |
| 484 path.close(); | 484 path.close(); |
| 485 canvas.drawPath(path, paint); | 485 canvas.drawPath(path, paint); |
| 486 | 486 |
| 487 paint.color = _decoration.border.right.color; | 487 paint.color = _decoration.border.right.color; |
| 488 path = new sky.Path(); | 488 path = new Path(); |
| 489 path.moveTo(size.width, 0.0); | 489 path.moveTo(size.width, 0.0); |
| 490 path.lineTo(size.width - _decoration.border.right.width, _decoration.borde
r.top.width); | 490 path.lineTo(size.width - _decoration.border.right.width, _decoration.borde
r.top.width); |
| 491 path.lineTo(size.width - _decoration.border.right.width, size.height - _de
coration.border.bottom.width); | 491 path.lineTo(size.width - _decoration.border.right.width, size.height - _de
coration.border.bottom.width); |
| 492 path.lineTo(size.width, size.height); | 492 path.lineTo(size.width, size.height); |
| 493 path.close(); | 493 path.close(); |
| 494 canvas.drawPath(path, paint); | 494 canvas.drawPath(path, paint); |
| 495 | 495 |
| 496 paint.color = _decoration.border.bottom.color; | 496 paint.color = _decoration.border.bottom.color; |
| 497 path = new sky.Path(); | 497 path = new Path(); |
| 498 path.moveTo(size.width, size.height); | 498 path.moveTo(size.width, size.height); |
| 499 path.lineTo(size.width - _decoration.border.right.width, size.height - _de
coration.border.bottom.width); | 499 path.lineTo(size.width - _decoration.border.right.width, size.height - _de
coration.border.bottom.width); |
| 500 path.lineTo(_decoration.border.left.width, size.height - _decoration.borde
r.bottom.width); | 500 path.lineTo(_decoration.border.left.width, size.height - _decoration.borde
r.bottom.width); |
| 501 path.lineTo(0.0, size.height); | 501 path.lineTo(0.0, size.height); |
| 502 path.close(); | 502 path.close(); |
| 503 canvas.drawPath(path, paint); | 503 canvas.drawPath(path, paint); |
| 504 | 504 |
| 505 paint.color = _decoration.border.left.color; | 505 paint.color = _decoration.border.left.color; |
| 506 path = new sky.Path(); | 506 path = new Path(); |
| 507 path.moveTo(0.0, size.height); | 507 path.moveTo(0.0, size.height); |
| 508 path.lineTo(_decoration.border.left.width, size.height - _decoration.borde
r.bottom.width); | 508 path.lineTo(_decoration.border.left.width, size.height - _decoration.borde
r.bottom.width); |
| 509 path.lineTo(_decoration.border.left.width, _decoration.border.top.width); | 509 path.lineTo(_decoration.border.left.width, _decoration.border.top.width); |
| 510 path.lineTo(0.0,0.0); | 510 path.lineTo(0.0,0.0); |
| 511 path.close(); | 511 path.close(); |
| 512 canvas.drawPath(path, paint); | 512 canvas.drawPath(path, paint); |
| 513 } | 513 } |
| 514 | 514 |
| 515 super.paint(canvas); | 515 super.paint(canvas); |
| 516 } | 516 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 void translate(x, [double y = 0.0, double z = 0.0]) { | 555 void translate(x, [double y = 0.0, double z = 0.0]) { |
| 556 _transform.translate(x, y, z); | 556 _transform.translate(x, y, z); |
| 557 markNeedsPaint(); | 557 markNeedsPaint(); |
| 558 } | 558 } |
| 559 | 559 |
| 560 void scale(x, [double y, double z]) { | 560 void scale(x, [double y, double z]) { |
| 561 _transform.scale(x, y, z); | 561 _transform.scale(x, y, z); |
| 562 markNeedsPaint(); | 562 markNeedsPaint(); |
| 563 } | 563 } |
| 564 | 564 |
| 565 void hitTestChildren(HitTestResult result, { sky.Point position }) { | 565 void hitTestChildren(HitTestResult result, { Point position }) { |
| 566 Matrix4 inverse = new Matrix4.zero(); | 566 Matrix4 inverse = new Matrix4.zero(); |
| 567 double det = inverse.copyInverse(_transform); | 567 double det = inverse.copyInverse(_transform); |
| 568 // TODO(abarth): Check the determinant for degeneracy. | 568 // TODO(abarth): Check the determinant for degeneracy. |
| 569 | 569 |
| 570 Vector3 position3 = new Vector3(position.x, position.y, 0.0); | 570 Vector3 position3 = new Vector3(position.x, position.y, 0.0); |
| 571 Vector3 transformed3 = inverse.transform3(position3); | 571 Vector3 transformed3 = inverse.transform3(position3); |
| 572 sky.Point transformed = new sky.Point(transformed3.x, transformed3.y); | 572 Point transformed = new Point(transformed3.x, transformed3.y); |
| 573 super.hitTestChildren(result, position: transformed); | 573 super.hitTestChildren(result, position: transformed); |
| 574 } | 574 } |
| 575 | 575 |
| 576 void paint(RenderObjectDisplayList canvas) { | 576 void paint(RenderObjectDisplayList canvas) { |
| 577 canvas.save(); | 577 canvas.save(); |
| 578 canvas.concat(_transform.storage); | 578 canvas.concat(_transform.storage); |
| 579 super.paint(canvas); | 579 super.paint(canvas); |
| 580 canvas.restore(); | 580 canvas.restore(); |
| 581 } | 581 } |
| 582 | 582 |
| 583 String debugDescribeSettings(String prefix) { | 583 String debugDescribeSettings(String prefix) { |
| 584 List<String> result = _transform.toString().split('\n').map((s) => '$prefix
$s\n').toList(); | 584 List<String> result = _transform.toString().split('\n').map((s) => '$prefix
$s\n').toList(); |
| 585 result.removeLast(); | 585 result.removeLast(); |
| 586 return '${super.debugDescribeSettings(prefix)}${prefix}transform matrix:\n${
result.join()}'; | 586 return '${super.debugDescribeSettings(prefix)}${prefix}transform matrix:\n${
result.join()}'; |
| 587 } | 587 } |
| 588 } | 588 } |
| 589 | 589 |
| 590 typedef void SizeChangedCallback(sky.Size newSize); | 590 typedef void SizeChangedCallback(Size newSize); |
| 591 | 591 |
| 592 class RenderSizeObserver extends RenderProxyBox { | 592 class RenderSizeObserver extends RenderProxyBox { |
| 593 RenderSizeObserver({ | 593 RenderSizeObserver({ |
| 594 this.callback, | 594 this.callback, |
| 595 RenderBox child | 595 RenderBox child |
| 596 }) : super(child) { | 596 }) : super(child) { |
| 597 assert(callback != null); | 597 assert(callback != null); |
| 598 } | 598 } |
| 599 | 599 |
| 600 SizeChangedCallback callback; | 600 SizeChangedCallback callback; |
| 601 | 601 |
| 602 void performLayout() { | 602 void performLayout() { |
| 603 sky.Size oldSize = size; | 603 Size oldSize = size; |
| 604 | 604 |
| 605 super.performLayout(); | 605 super.performLayout(); |
| 606 | 606 |
| 607 if (oldSize != size) | 607 if (oldSize != size) |
| 608 callback(size); | 608 callback(size); |
| 609 } | 609 } |
| 610 } | 610 } |
| 611 | 611 |
| 612 // This must be immutable, because we won't notice when it changes | 612 // This must be immutable, because we won't notice when it changes |
| 613 class BoxShadow { | 613 class BoxShadow { |
| 614 const BoxShadow({ | 614 const BoxShadow({ |
| 615 this.color, | 615 this.color, |
| 616 this.offset, | 616 this.offset, |
| 617 this.blur | 617 this.blur |
| 618 }); | 618 }); |
| 619 | 619 |
| 620 final sky.Size offset; | 620 final Size offset; |
| 621 final double blur; | 621 final double blur; |
| 622 final sky.Color color; | 622 final Color color; |
| 623 } | 623 } |
| 624 | 624 |
| 625 class RenderShadowedBox extends RenderProxyBox { | 625 class RenderShadowedBox extends RenderProxyBox { |
| 626 | 626 |
| 627 RenderShadowedBox({ | 627 RenderShadowedBox({ |
| 628 BoxShadow shadow, | 628 BoxShadow shadow, |
| 629 RenderBox child | 629 RenderBox child |
| 630 }) : _shadow = shadow, super(child); | 630 }) : _shadow = shadow, super(child); |
| 631 | 631 |
| 632 BoxShadow _shadow; | 632 BoxShadow _shadow; |
| 633 BoxShadow get shadow => _shadow; | 633 BoxShadow get shadow => _shadow; |
| 634 void set shadow (BoxShadow value) { | 634 void set shadow (BoxShadow value) { |
| 635 if (value == _shadow) | 635 if (value == _shadow) |
| 636 return; | 636 return; |
| 637 _shadow = value; | 637 _shadow = value; |
| 638 markNeedsPaint(); | 638 markNeedsPaint(); |
| 639 } | 639 } |
| 640 | 640 |
| 641 sky.Paint _createShadowPaint(BoxShadow shadow) { | 641 Paint _createShadowPaint(BoxShadow shadow) { |
| 642 // TODO(eseidel): This should not be hard-coded yellow. | 642 // TODO(eseidel): This should not be hard-coded yellow. |
| 643 sky.Paint paint = new sky.Paint()..color = const sky.Color.fromARGB(255, 0,
255, 0); | 643 Paint paint = new Paint()..color = const Color.fromARGB(255, 0, 255, 0); |
| 644 var builder = new sky.LayerDrawLooperBuilder() | 644 var builder = new sky.LayerDrawLooperBuilder() |
| 645 // Shadow layer. | 645 // Shadow layer. |
| 646 ..addLayerOnTop( | 646 ..addLayerOnTop( |
| 647 new sky.DrawLooperLayerInfo() | 647 new sky.DrawLooperLayerInfo() |
| 648 ..setPaintBits(-1) | 648 ..setPaintBits(-1) |
| 649 ..setOffset(shadow.offset.toPoint()) | 649 ..setOffset(shadow.offset.toPoint()) |
| 650 ..setColorMode(sky.TransferMode.srcMode), | 650 ..setColorMode(sky.TransferMode.srcMode), |
| 651 (sky.Paint layerPaint) { | 651 (Paint layerPaint) { |
| 652 layerPaint.color = shadow.color; | 652 layerPaint.color = shadow.color; |
| 653 layerPaint.setMaskFilter( | 653 layerPaint.setMaskFilter( |
| 654 new sky.MaskFilter.Blur(sky.BlurStyle.normal, shadow.blur, highQuality
: true)); | 654 new sky.MaskFilter.Blur(sky.BlurStyle.normal, shadow.blur, highQuality
: true)); |
| 655 }) | 655 }) |
| 656 // Main layer. | 656 // Main layer. |
| 657 ..addLayerOnTop(new sky.DrawLooperLayerInfo(), (_) {}); | 657 ..addLayerOnTop(new sky.DrawLooperLayerInfo(), (_) {}); |
| 658 paint.setDrawLooper(builder.build()); | 658 paint.setDrawLooper(builder.build()); |
| 659 return paint; | 659 return paint; |
| 660 } | 660 } |
| 661 | 661 |
| 662 void paint(RenderObjectDisplayList canvas) { | 662 void paint(RenderObjectDisplayList canvas) { |
| 663 sky.Paint paint = _createShadowPaint(_shadow); | 663 Paint paint = _createShadowPaint(_shadow); |
| 664 canvas.drawRect(new sky.Rect.fromLTRB(0.0, 0.0, size.width, size.height), pa
int); | 664 canvas.drawRect(new Rect.fromLTRB(0.0, 0.0, size.width, size.height), paint)
; |
| 665 super.paint(canvas); | 665 super.paint(canvas); |
| 666 } | 666 } |
| 667 } | 667 } |
| 668 | 668 |
| 669 typedef void CustomPaintCallback(sky.Canvas canvas); | 669 typedef void CustomPaintCallback(sky.Canvas canvas); |
| 670 | 670 |
| 671 class RenderCustomPaint extends RenderProxyBox { | 671 class RenderCustomPaint extends RenderProxyBox { |
| 672 | 672 |
| 673 RenderCustomPaint({ | 673 RenderCustomPaint({ |
| 674 CustomPaintCallback callback, | 674 CustomPaintCallback callback, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 | 709 |
| 710 class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
{ | 710 class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
{ |
| 711 | 711 |
| 712 RenderView({ | 712 RenderView({ |
| 713 RenderBox child, | 713 RenderBox child, |
| 714 this.timeForRotation: const Duration(microseconds: 83333) | 714 this.timeForRotation: const Duration(microseconds: 83333) |
| 715 }) { | 715 }) { |
| 716 this.child = child; | 716 this.child = child; |
| 717 } | 717 } |
| 718 | 718 |
| 719 sky.Size _size = new sky.Size(0.0, 0.0); | 719 Size _size = new Size(0.0, 0.0); |
| 720 double get width => _size.width; | 720 double get width => _size.width; |
| 721 double get height => _size.height; | 721 double get height => _size.height; |
| 722 | 722 |
| 723 int _orientation; // 0..3 | 723 int _orientation; // 0..3 |
| 724 int get orientation => _orientation; | 724 int get orientation => _orientation; |
| 725 Duration timeForRotation; | 725 Duration timeForRotation; |
| 726 | 726 |
| 727 ViewConstraints get constraints => super.constraints as ViewConstraints; | 727 ViewConstraints get constraints => super.constraints as ViewConstraints; |
| 728 bool get sizedByParent => true; | 728 bool get sizedByParent => true; |
| 729 void performResize() { | 729 void performResize() { |
| 730 if (constraints.orientation != _orientation) { | 730 if (constraints.orientation != _orientation) { |
| 731 if (_orientation != null && child != null) | 731 if (_orientation != null && child != null) |
| 732 child.rotate(oldAngle: _orientation, newAngle: constraints.orientation,
time: timeForRotation); | 732 child.rotate(oldAngle: _orientation, newAngle: constraints.orientation,
time: timeForRotation); |
| 733 _orientation = constraints.orientation; | 733 _orientation = constraints.orientation; |
| 734 } | 734 } |
| 735 _size = new sky.Size(constraints.width, constraints.height); | 735 _size = new Size(constraints.width, constraints.height); |
| 736 assert(_size.height < double.INFINITY); | 736 assert(_size.height < double.INFINITY); |
| 737 assert(_size.width < double.INFINITY); | 737 assert(_size.width < double.INFINITY); |
| 738 } | 738 } |
| 739 void performLayout() { | 739 void performLayout() { |
| 740 if (child != null) { | 740 if (child != null) { |
| 741 child.layout(new BoxConstraints.tight(_size)); | 741 child.layout(new BoxConstraints.tight(_size)); |
| 742 assert(child.size.width == width); | 742 assert(child.size.width == width); |
| 743 assert(child.size.height == height); | 743 assert(child.size.height == height); |
| 744 } | 744 } |
| 745 } | 745 } |
| 746 | 746 |
| 747 void rotate({ int oldAngle, int newAngle, Duration time }) { | 747 void rotate({ int oldAngle, int newAngle, Duration time }) { |
| 748 assert(false); // nobody tells the screen to rotate, the whole rotate() danc
e is started from our performResize() | 748 assert(false); // nobody tells the screen to rotate, the whole rotate() danc
e is started from our performResize() |
| 749 } | 749 } |
| 750 | 750 |
| 751 bool hitTest(HitTestResult result, { sky.Point position }) { | 751 bool hitTest(HitTestResult result, { Point position }) { |
| 752 if (child != null) { | 752 if (child != null) { |
| 753 sky.Rect childBounds = new sky.Rect.fromSize(child.size); | 753 Rect childBounds = new Rect.fromSize(child.size); |
| 754 if (childBounds.contains(position)) | 754 if (childBounds.contains(position)) |
| 755 child.hitTest(result, position: position); | 755 child.hitTest(result, position: position); |
| 756 } | 756 } |
| 757 result.add(this); | 757 result.add(this); |
| 758 return true; | 758 return true; |
| 759 } | 759 } |
| 760 | 760 |
| 761 void paint(RenderObjectDisplayList canvas) { | 761 void paint(RenderObjectDisplayList canvas) { |
| 762 if (child != null) | 762 if (child != null) |
| 763 canvas.paintChild(child, new sky.Point(0.0, 0.0)); | 763 canvas.paintChild(child, new Point(0.0, 0.0)); |
| 764 } | 764 } |
| 765 | 765 |
| 766 void paintFrame() { | 766 void paintFrame() { |
| 767 RenderObject.debugDoingPaint = true; | 767 RenderObject.debugDoingPaint = true; |
| 768 RenderObjectDisplayList canvas = new RenderObjectDisplayList(sky.view.width,
sky.view.height); | 768 RenderObjectDisplayList canvas = new RenderObjectDisplayList(sky.view.width,
sky.view.height); |
| 769 paint(canvas); | 769 paint(canvas); |
| 770 sky.view.picture = canvas.endRecording(); | 770 sky.view.picture = canvas.endRecording(); |
| 771 RenderObject.debugDoingPaint = false; | 771 RenderObject.debugDoingPaint = false; |
| 772 } | 772 } |
| 773 | 773 |
| 774 } | 774 } |
| 775 | 775 |
| 776 // DEFAULT BEHAVIORS FOR RENDERBOX CONTAINERS | 776 // DEFAULT BEHAVIORS FOR RENDERBOX CONTAINERS |
| 777 abstract class RenderBoxContainerDefaultsMixin<ChildType extends RenderBox, Pare
ntDataType extends ContainerParentDataMixin<ChildType>> implements ContainerRend
erObjectMixin<ChildType, ParentDataType> { | 777 abstract class RenderBoxContainerDefaultsMixin<ChildType extends RenderBox, Pare
ntDataType extends ContainerParentDataMixin<ChildType>> implements ContainerRend
erObjectMixin<ChildType, ParentDataType> { |
| 778 | 778 |
| 779 void defaultHitTestChildren(HitTestResult result, { sky.Point position }) { | 779 void defaultHitTestChildren(HitTestResult result, { Point position }) { |
| 780 // the x, y parameters have the top left of the node's box as the origin | 780 // the x, y parameters have the top left of the node's box as the origin |
| 781 ChildType child = lastChild; | 781 ChildType child = lastChild; |
| 782 while (child != null) { | 782 while (child != null) { |
| 783 assert(child.parentData is ParentDataType); | 783 assert(child.parentData is ParentDataType); |
| 784 sky.Rect childBounds = new sky.Rect.fromPointAndSize(child.parentData.posi
tion, child.size); | 784 Rect childBounds = new Rect.fromPointAndSize(child.parentData.position, ch
ild.size); |
| 785 if (childBounds.contains(position)) { | 785 if (childBounds.contains(position)) { |
| 786 if (child.hitTest(result, position: new sky.Point(position.x - child.par
entData.position.x, | 786 if (child.hitTest(result, position: new Point(position.x - child.parentD
ata.position.x, |
| 787 position.y - child.par
entData.position.y))) | 787 position.y - child.par
entData.position.y))) |
| 788 break; | 788 break; |
| 789 } | 789 } |
| 790 child = child.parentData.previousSibling; | 790 child = child.parentData.previousSibling; |
| 791 } | 791 } |
| 792 } | 792 } |
| 793 | 793 |
| 794 void defaultPaint(RenderObjectDisplayList canvas) { | 794 void defaultPaint(RenderObjectDisplayList canvas) { |
| 795 RenderBox child = firstChild; | 795 RenderBox child = firstChild; |
| 796 while (child != null) { | 796 while (child != null) { |
| 797 assert(child.parentData is ParentDataType); | 797 assert(child.parentData is ParentDataType); |
| 798 canvas.paintChild(child, child.parentData.position); | 798 canvas.paintChild(child, child.parentData.position); |
| 799 child = child.parentData.nextSibling; | 799 child = child.parentData.nextSibling; |
| 800 } | 800 } |
| 801 } | 801 } |
| 802 } | 802 } |
| OLD | NEW |