| 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 '../painting/shadows.dart'; |     9 import '../painting/shadows.dart'; | 
|    10 import 'package:vector_math/vector_math.dart'; |    10 import 'package:vector_math/vector_math.dart'; | 
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   549  |   549  | 
|   550   Size _requestedSize; |   550   Size _requestedSize; | 
|   551   Size get requestedSize => _requestedSize; |   551   Size get requestedSize => _requestedSize; | 
|   552   void set requestedSize (Size value) { |   552   void set requestedSize (Size value) { | 
|   553     if (value == _requestedSize) |   553     if (value == _requestedSize) | 
|   554       return; |   554       return; | 
|   555     _requestedSize = value; |   555     _requestedSize = value; | 
|   556     markNeedsLayout(); |   556     markNeedsLayout(); | 
|   557   } |   557   } | 
|   558  |   558  | 
|   559   void performLayout() { |   559   Size _sizeForConstraints(BoxConstraints innerConstraints) { | 
|   560     // If there's no image, we can't size ourselves automatically |   560     // If there's no image, we can't size ourselves automatically | 
|   561     if (_image == null) { |   561     if (_image == null) { | 
|   562       double width = requestedSize.width == null ? 0.0 : requestedSize.width; |   562       double width = requestedSize.width == null ? 0.0 : requestedSize.width; | 
|   563       double height = requestedSize.height == null ? 0.0 : requestedSize.height; |   563       double height = requestedSize.height == null ? 0.0 : requestedSize.height; | 
|   564       size = constraints.constrain(new Size(width, height)); |   564       return constraints.constrain(new Size(width, height)); | 
|   565       return; |  | 
|   566     } |   565     } | 
|   567  |   566  | 
|   568     // If neither height nor width are specified, use inherent image dimensions |   567     // If neither height nor width are specified, use inherent image dimensions | 
|   569     // If only one dimension is specified, adjust the other dimension to |   568     // If only one dimension is specified, adjust the other dimension to | 
|   570     // maintain the aspect ratio |   569     // maintain the aspect ratio | 
|   571     if (requestedSize.width == null) { |   570     if (requestedSize.width == null) { | 
|   572       if (requestedSize.height == null) { |   571       if (requestedSize.height == null) { | 
|   573         size = constraints.constrain(new Size(_image.width.toDouble(), _image.he
      ight.toDouble())); |   572         return constraints.constrain(new Size(_image.width.toDouble(), _image.he
      ight.toDouble())); | 
|   574       } else { |   573       } else { | 
|   575         double width = requestedSize.height * _image.width / _image.height; |   574         double width = requestedSize.height * _image.width / _image.height; | 
|   576         size = constraints.constrain(new Size(width, requestedSize.height)); |   575         return constraints.constrain(new Size(width, requestedSize.height)); | 
|   577       } |   576       } | 
|   578     } else if (requestedSize.height == null) { |   577     } else if (requestedSize.height == null) { | 
|   579       double height = requestedSize.width * _image.height / _image.width; |   578       double height = requestedSize.width * _image.height / _image.width; | 
|   580       size = constraints.constrain(new Size(requestedSize.width, height)); |   579       return constraints.constrain(new Size(requestedSize.width, height)); | 
|   581     } else { |   580     } else { | 
|   582       size = constraints.constrain(requestedSize); |   581       return constraints.constrain(requestedSize); | 
|   583     } |   582     } | 
|   584   } |   583   } | 
|   585  |   584  | 
 |   585   double getMinIntrinsicWidth(BoxConstraints constraints) { | 
 |   586     if (requestedSize.width == null && requestedSize.height == null) | 
 |   587       return constraints.constrainWidth(0.0); | 
 |   588     return _sizeForConstraints(constraints).width; | 
 |   589   } | 
 |   590  | 
 |   591   double getMaxIntrinsicWidth(BoxConstraints constraints) { | 
 |   592     return _sizeForConstraints(constraints).width; | 
 |   593   } | 
 |   594  | 
 |   595   double getMinIntrinsicHeight(BoxConstraints constraints) { | 
 |   596     if (requestedSize.width == null && requestedSize.height == null) | 
 |   597       return constraints.constrainHeight(0.0); | 
 |   598     return _sizeForConstraints(constraints).height; | 
 |   599   } | 
 |   600  | 
 |   601   double getMaxIntrinsicHeight(BoxConstraints constraints) { | 
 |   602     return _sizeForConstraints(constraints).height; | 
 |   603   } | 
 |   604  | 
 |   605   void performLayout() { | 
 |   606     size = _sizeForConstraints(constraints); | 
 |   607   } | 
 |   608  | 
|   586   void paint(RenderObjectDisplayList canvas) { |   609   void paint(RenderObjectDisplayList canvas) { | 
|   587     if (_image == null) return; |   610     if (_image == null) return; | 
|   588     bool needsScale = size.width != _image.width || size.height != _image.height
      ; |   611     bool needsScale = size.width != _image.width || size.height != _image.height
      ; | 
|   589     if (needsScale) { |   612     if (needsScale) { | 
|   590       double widthScale = size.width / _image.width; |   613       double widthScale = size.width / _image.width; | 
|   591       double heightScale = size.height / _image.height; |   614       double heightScale = size.height / _image.height; | 
|   592       canvas.save(); |   615       canvas.save(); | 
|   593       canvas.scale(widthScale, heightScale); |   616       canvas.scale(widthScale, heightScale); | 
|   594     } |   617     } | 
|   595     Paint paint = new Paint(); |   618     Paint paint = new Paint(); | 
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   790     } |   813     } | 
|   791  |   814  | 
|   792     return _cachedBackgroundPaint; |   815     return _cachedBackgroundPaint; | 
|   793   } |   816   } | 
|   794  |   817  | 
|   795   void paint(RenderObjectDisplayList canvas) { |   818   void paint(RenderObjectDisplayList canvas) { | 
|   796     assert(size.width != null); |   819     assert(size.width != null); | 
|   797     assert(size.height != null); |   820     assert(size.height != null); | 
|   798  |   821  | 
|   799     if (_decoration.backgroundColor != null || _decoration.boxShadow != null || |   822     if (_decoration.backgroundColor != null || _decoration.boxShadow != null || | 
|   800         _deocration.gradient != null) { |   823         _decoration.gradient != null) { | 
|   801       Rect rect = new Rect.fromLTRB(0.0, 0.0, size.width, size.height); |   824       Rect rect = new Rect.fromLTRB(0.0, 0.0, size.width, size.height); | 
|   802       if (_decoration.borderRadius == null) |   825       if (_decoration.borderRadius == null) | 
|   803         canvas.drawRect(rect, _backgroundPaint); |   826         canvas.drawRect(rect, _backgroundPaint); | 
|   804       else |   827       else | 
|   805         canvas.drawRRect(new sky.RRect()..setRectXY(rect, _decoration.borderRadi
      us, _decoration.borderRadius), _backgroundPaint); |   828         canvas.drawRRect(new sky.RRect()..setRectXY(rect, _decoration.borderRadi
      us, _decoration.borderRadius), _backgroundPaint); | 
|   806     } |   829     } | 
|   807  |   830  | 
|   808     if (_decoration.border != null) { |   831     if (_decoration.border != null) { | 
|   809       assert(_decoration.borderRadius == null); // TODO(abarth): Implement borde
      rs with border radius. |   832       assert(_decoration.borderRadius == null); // TODO(abarth): Implement borde
      rs with border radius. | 
|   810  |   833  | 
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1089  |  1112  | 
|  1090   void defaultPaint(RenderObjectDisplayList canvas) { |  1113   void defaultPaint(RenderObjectDisplayList canvas) { | 
|  1091     RenderBox child = firstChild; |  1114     RenderBox child = firstChild; | 
|  1092     while (child != null) { |  1115     while (child != null) { | 
|  1093       assert(child.parentData is ParentDataType); |  1116       assert(child.parentData is ParentDataType); | 
|  1094       canvas.paintChild(child, child.parentData.position); |  1117       canvas.paintChild(child, child.parentData.position); | 
|  1095       child = child.parentData.nextSibling; |  1118       child = child.parentData.nextSibling; | 
|  1096     } |  1119     } | 
|  1097   } |  1120   } | 
|  1098 } |  1121 } | 
| OLD | NEW |