| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** Representations of CSS styles. */ | 5 /** Representations of CSS styles. */ |
| 6 | 6 |
| 7 part of csslib.parser; | 7 part of csslib.parser; |
| 8 | 8 |
| 9 // TODO(terry): Prune down this file we do need some of the code in this file | 9 // TODO(terry): Prune down this file we do need some of the code in this file |
| 10 // for darker, lighter, how to represent a Font, etc but alot of | 10 // for darker, lighter, how to represent a Font, etc but alot of |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 case _rgbCss: | 271 case _rgbCss: |
| 272 return Color.convertToHexString(args[0], args[1], args[2]); | 272 return Color.convertToHexString(args[0], args[1], args[2]); |
| 273 case _rgbaCss: | 273 case _rgbaCss: |
| 274 return Color.convertToHexString(args[0], args[1], args[2], args[3]); | 274 return Color.convertToHexString(args[0], args[1], args[2], args[3]); |
| 275 case _hslCss: | 275 case _hslCss: |
| 276 return new Hsla(args[0], args[1], args[2]).toHexArgbString(); | 276 return new Hsla(args[0], args[1], args[2]).toHexArgbString(); |
| 277 case _hslaCss: | 277 case _hslaCss: |
| 278 return new Hsla(args[0], args[1], args[2], args[3]).toHexArgbString(); | 278 return new Hsla(args[0], args[1], args[2], args[3]).toHexArgbString(); |
| 279 default: | 279 default: |
| 280 // Type not defined UnsupportedOperationException should have thrown. | 280 // Type not defined UnsupportedOperationException should have thrown. |
| 281 assert(true); | 281 assert(false); |
| 282 break; | 282 break; |
| 283 } | 283 } |
| 284 } | 284 } |
| 285 return null; |
| 285 } | 286 } |
| 286 | 287 |
| 287 static int hexToInt(String hex) => int.parse(hex, radix: 16); | 288 static int hexToInt(String hex) => int.parse(hex, radix: 16); |
| 288 | 289 |
| 289 static String convertToHexString(int r, int g, int b, [num a]) { | 290 static String convertToHexString(int r, int g, int b, [num a]) { |
| 290 String rHex = Color._numAs2DigitHex(Color._clamp(r, 0, 255)); | 291 String rHex = Color._numAs2DigitHex(Color._clamp(r, 0, 255)); |
| 291 String gHex = Color._numAs2DigitHex(Color._clamp(g, 0, 255)); | 292 String gHex = Color._numAs2DigitHex(Color._clamp(g, 0, 255)); |
| 292 String bHex = Color._numAs2DigitHex(Color._clamp(b, 0, 255)); | 293 String bHex = Color._numAs2DigitHex(Color._clamp(b, 0, 255)); |
| 293 String aHex = (a != null) | 294 String aHex = (a != null) |
| 294 ? Color._numAs2DigitHex((Color._clamp(a, 0, 1) * 255).round()) | 295 ? Color._numAs2DigitHex((Color._clamp(a, 0, 1) * 255).round()) |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 int get hashCode => toHexArgbString().hashCode; | 779 int get hashCode => toHexArgbString().hashCode; |
| 779 } | 780 } |
| 780 | 781 |
| 781 /** X,Y position. */ | 782 /** X,Y position. */ |
| 782 class PointXY implements _StyleProperty { | 783 class PointXY implements _StyleProperty { |
| 783 final num x, y; | 784 final num x, y; |
| 784 const PointXY(this.x, this.y); | 785 const PointXY(this.x, this.y); |
| 785 | 786 |
| 786 String get cssExpression { | 787 String get cssExpression { |
| 787 // TODO(terry): TBD | 788 // TODO(terry): TBD |
| 789 return null; |
| 788 } | 790 } |
| 789 } | 791 } |
| 790 | 792 |
| 791 // TODO(terry): Implement style and color. | 793 // TODO(terry): Implement style and color. |
| 792 /** | 794 /** |
| 793 * Supports border for measuring with layout. | 795 * Supports border for measuring with layout. |
| 794 */ | 796 */ |
| 795 class Border implements _StyleProperty { | 797 class Border implements _StyleProperty { |
| 796 final int top, left, bottom, right; | 798 final int top, left, bottom, right; |
| 797 | 799 |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 num get width => (left != null ? left : 0) + (right != null ? right : 0); | 1226 num get width => (left != null ? left : 0) + (right != null ? right : 0); |
| 1225 | 1227 |
| 1226 /** | 1228 /** |
| 1227 * The total size of the vertical edges. Equal to [top] + [bottom], where | 1229 * The total size of the vertical edges. Equal to [top] + [bottom], where |
| 1228 * null is interpreted as 0px. | 1230 * null is interpreted as 0px. |
| 1229 */ | 1231 */ |
| 1230 num get height => (top != null ? top : 0) + (bottom != null ? bottom : 0); | 1232 num get height => (top != null ? top : 0) + (bottom != null ? bottom : 0); |
| 1231 } | 1233 } |
| 1232 | 1234 |
| 1233 _mergeVal(x, y) => y != null ? y : x; | 1235 _mergeVal(x, y) => y != null ? y : x; |
| OLD | NEW |