Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: lib/src/property.dart

Issue 873313003: Cleanup some ambiguous and incorrect types and disable a case that in analyzer.dart that seems like… (Closed) Base URL: git@github.com:dart-lang/csslib.git@master
Patch Set: ptal Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/polyfill.dart ('k') | lib/src/tree.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 int g = Color.hexToInt(_argb.substring(nextIndex, nextIndex + 2)); 177 int g = Color.hexToInt(_argb.substring(nextIndex, nextIndex + 2));
178 nextIndex += 2; 178 nextIndex += 2;
179 int b = Color.hexToInt(_argb.substring(nextIndex, nextIndex + 2)); 179 int b = Color.hexToInt(_argb.substring(nextIndex, nextIndex + 2));
180 return new Rgba(r, g, b, a); 180 return new Rgba(r, g, b, a);
181 } 181 }
182 182
183 Hsla get hsla => new Hsla.fromRgba(rgba); 183 Hsla get hsla => new Hsla.fromRgba(rgba);
184 184
185 int get argbValue => Color.hexToInt(_argb); 185 int get argbValue => Color.hexToInt(_argb);
186 186
187 bool operator ==(Object other) => Color.equal(this, other); 187 bool operator ==(other) => Color.equal(this, other);
188 188
189 String toHexArgbString() => _argb; 189 String toHexArgbString() => _argb;
190 190
191 Color darker(num amount) { 191 Color darker(num amount) {
192 Rgba newRgba = Color._createNewTintShadeFromRgba(rgba, -amount); 192 Rgba newRgba = Color._createNewTintShadeFromRgba(rgba, -amount);
193 return new Color.hex("${newRgba.toHexArgbString()}"); 193 return new Color.hex("${newRgba.toHexArgbString()}");
194 } 194 }
195 195
196 Color lighter(num amount) { 196 Color lighter(num amount) {
197 Rgba newRgba = Color._createNewTintShadeFromRgba(rgba, amount); 197 Rgba newRgba = Color._createNewTintShadeFromRgba(rgba, amount);
198 return new Color.hex("${newRgba.toHexArgbString()}"); 198 return new Color.hex("${newRgba.toHexArgbString()}");
199 } 199 }
200 200
201 static bool equal(ColorBase curr, Object other) { 201 static bool equal(ColorBase curr, other) {
202 if (other is Color) { 202 if (other is Color) {
203 Color o = other; 203 Color o = other;
204 return o.toHexArgbString() == curr.toHexArgbString(); 204 return o.toHexArgbString() == curr.toHexArgbString();
205 } else if (other is Rgba) { 205 } else if (other is Rgba) {
206 Rgba rgb = other; 206 Rgba rgb = other;
207 return rgb.toHexArgbString() == curr.toHexArgbString(); 207 return rgb.toHexArgbString() == curr.toHexArgbString();
208 } else if (other is Hsla) { 208 } else if (other is Hsla) {
209 Hsla hsla = other; 209 Hsla hsla = other;
210 return hsla.toHexArgbString() == curr.toHexArgbString(); 210 return hsla.toHexArgbString() == curr.toHexArgbString();
211 } else { 211 } else {
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 return v2; 594 return v2;
595 } 595 }
596 596
597 if ((3 * vH) < 2) { 597 if ((3 * vH) < 2) {
598 return (v1 + (v2 - v1) * ((2 / 3 - vH) * 6)); 598 return (v1 + (v2 - v1) * ((2 / 3 - vH) * 6));
599 } 599 }
600 600
601 return v1; 601 return v1;
602 } 602 }
603 603
604 bool operator ==(Object other) => Color.equal(this, other); 604 bool operator ==(other) => Color.equal(this, other);
605 605
606 String get cssExpression { 606 String get cssExpression {
607 if (a == null) { 607 if (a == null) {
608 return "#${Color.convertToHexString(r, g, b)}"; 608 return "#${Color.convertToHexString(r, g, b)}";
609 } else { 609 } else {
610 return "rgba($r,$g,$b,$a)"; 610 return "rgba($r,$g,$b,$a)";
611 } 611 }
612 } 612 }
613 613
614 String toHexArgbString() => Color.convertToHexString(r, g, b, a); 614 String toHexArgbString() => Color.convertToHexString(r, g, b, a);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 /** 756 /**
757 * Returns number as percentage 0..100. 757 * Returns number as percentage 0..100.
758 */ 758 */
759 num get lightnessPercentage => (_l * 100).round(); 759 num get lightnessPercentage => (_l * 100).round();
760 760
761 /** 761 /**
762 * Returns number as 0..1 762 * Returns number as 0..1
763 */ 763 */
764 num get alpha => _a; 764 num get alpha => _a;
765 765
766 bool operator ==(Object other) => Color.equal(this, other); 766 bool operator ==(other) => Color.equal(this, other);
767 767
768 String get cssExpression => (_a == null) ? 768 String get cssExpression => (_a == null) ?
769 "hsl($hueDegrees,$saturationPercentage,$lightnessPercentage)" : 769 "hsl($hueDegrees,$saturationPercentage,$lightnessPercentage)" :
770 "hsla($hueDegrees,$saturationPercentage,$lightnessPercentage,$_a)"; 770 "hsla($hueDegrees,$saturationPercentage,$lightnessPercentage,$_a)";
771 771
772 String toHexArgbString() => new Rgba.fromHsla(this).toHexArgbString(); 772 String toHexArgbString() => new Rgba.fromHsla(this).toHexArgbString();
773 773
774 int get argbValue => Color.hexToInt(this.toHexArgbString()); 774 int get argbValue => Color.hexToInt(this.toHexArgbString());
775 775
776 Color get color => new Color.createHsla(_h, _s, _l, _a); 776 Color get color => new Color.createHsla(_h, _s, _l, _a);
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 } else { 1092 } else {
1093 return (size != null) ? size * 1.2 : null; 1093 return (size != null) ? size * 1.2 : null;
1094 } 1094 }
1095 } 1095 }
1096 1096
1097 int get hashCode { 1097 int get hashCode {
1098 // TODO(jimhug): Lot's of potential collisions here. List of fonts, etc. 1098 // TODO(jimhug): Lot's of potential collisions here. List of fonts, etc.
1099 return size.toInt() % family[0].hashCode; 1099 return size.toInt() % family[0].hashCode;
1100 } 1100 }
1101 1101
1102 bool operator ==(Object other) { 1102 bool operator ==(other) {
1103 if (other is! Font) return false; 1103 if (other is! Font) return false;
1104 Font o = other; 1104 Font o = other;
1105 return o.size == size && o.family == family && o.weight == weight && 1105 return o.size == size && o.family == family && o.weight == weight &&
1106 o.lineHeight == lineHeight && o.style == style && o.variant == variant; 1106 o.lineHeight == lineHeight && o.style == style && o.variant == variant;
1107 } 1107 }
1108 1108
1109 // TODO(terry): This is fragile should probably just iterate through the list 1109 // TODO(terry): This is fragile should probably just iterate through the list
1110 // of fonts construction the font-family string. 1110 // of fonts construction the font-family string.
1111 /** Return fonts as a comma seperated list sans the square brackets. */ 1111 /** Return fonts as a comma seperated list sans the square brackets. */
1112 String get _fontsAsString { 1112 String get _fontsAsString {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 num get width => (left != null ? left : 0) + (right != null ? right : 0); 1214 num get width => (left != null ? left : 0) + (right != null ? right : 0);
1215 1215
1216 /** 1216 /**
1217 * The total size of the vertical edges. Equal to [top] + [bottom], where 1217 * The total size of the vertical edges. Equal to [top] + [bottom], where
1218 * null is interpreted as 0px. 1218 * null is interpreted as 0px.
1219 */ 1219 */
1220 num get height => (top != null ? top : 0) + (bottom != null ? bottom : 0); 1220 num get height => (top != null ? top : 0) + (bottom != null ? bottom : 0);
1221 } 1221 }
1222 1222
1223 _mergeVal(x, y) => y != null ? y : x; 1223 _mergeVal(x, y) => y != null ? y : x;
OLDNEW
« no previous file with comments | « lib/src/polyfill.dart ('k') | lib/src/tree.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698