| 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:sky'; | 5 import 'dart:sky'; |
| 6 | 6 |
| 7 enum FontWeight { w100, w200, w300, w400, w500, w600, w700, w800, w900 } | 7 enum FontWeight { w100, w200, w300, w400, w500, w600, w700, w800, w900 } |
| 8 const normal = FontWeight.w400; | 8 const normal = FontWeight.w400; |
| 9 const bold = FontWeight.w700; | 9 const bold = FontWeight.w700; |
| 10 | 10 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 145 } |
| 146 if (decoration != null) { | 146 if (decoration != null) { |
| 147 cssStyle['text-decoration'] = _decorationToCSSString(decoration); | 147 cssStyle['text-decoration'] = _decorationToCSSString(decoration); |
| 148 if (decorationColor != null) | 148 if (decorationColor != null) |
| 149 cssStyle['text-decoration-color'] = _colorToCSSString(decorationColor); | 149 cssStyle['text-decoration-color'] = _colorToCSSString(decorationColor); |
| 150 if (decorationStyle != null) | 150 if (decorationStyle != null) |
| 151 cssStyle['text-decoration-style'] = _decorationStyleToCSSString(decorati
onStyle); | 151 cssStyle['text-decoration-style'] = _decorationStyleToCSSString(decorati
onStyle); |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 | 154 |
| 155 @override |
| 155 bool operator ==(other) { | 156 bool operator ==(other) { |
| 156 if (identical(this, other)) | 157 if (identical(this, other)) |
| 157 return true; | 158 return true; |
| 158 return other is TextStyle && | 159 return other is TextStyle && |
| 159 color == other.color && | 160 color == other.color && |
| 160 fontFamily == other.fontFamily && | 161 fontFamily == other.fontFamily && |
| 161 fontSize == other.fontSize && | 162 fontSize == other.fontSize && |
| 162 fontWeight == other.fontWeight && | 163 fontWeight == other.fontWeight && |
| 163 textAlign == other.textAlign && | 164 textAlign == other.textAlign && |
| 164 decoration == other.decoration && | 165 decoration == other.decoration && |
| 165 decorationColor == other.decorationColor && | 166 decorationColor == other.decorationColor && |
| 166 decorationStyle == other.decorationStyle; | 167 decorationStyle == other.decorationStyle; |
| 167 } | 168 } |
| 168 | 169 |
| 170 @override |
| 169 int get hashCode { | 171 int get hashCode { |
| 170 // Use Quiver: https://github.com/domokit/mojo/issues/236 | 172 // Use Quiver: https://github.com/domokit/mojo/issues/236 |
| 171 int value = 373; | 173 int value = 373; |
| 172 value = 37 * value + color.hashCode; | 174 value = 37 * value + color.hashCode; |
| 173 value = 37 * value + fontFamily.hashCode; | 175 value = 37 * value + fontFamily.hashCode; |
| 174 value = 37 * value + fontSize.hashCode; | 176 value = 37 * value + fontSize.hashCode; |
| 175 value = 37 * value + fontWeight.hashCode; | 177 value = 37 * value + fontWeight.hashCode; |
| 176 value = 37 * value + textAlign.hashCode; | 178 value = 37 * value + textAlign.hashCode; |
| 177 value = 37 * value + decoration.hashCode; | 179 value = 37 * value + decoration.hashCode; |
| 178 value = 37 * value + decorationColor.hashCode; | 180 value = 37 * value + decorationColor.hashCode; |
| 179 value = 37 * value + decorationStyle.hashCode; | 181 value = 37 * value + decorationStyle.hashCode; |
| 180 return value; | 182 return value; |
| 181 } | 183 } |
| 182 | 184 |
| 185 @override |
| 183 String toString([String prefix = '']) { | 186 String toString([String prefix = '']) { |
| 184 List<String> result = []; | 187 List<String> result = []; |
| 185 if (color != null) | 188 if (color != null) |
| 186 result.add('${prefix}color: $color'); | 189 result.add('${prefix}color: $color'); |
| 187 // TODO(hansmuller): escape the fontFamily string. | 190 // TODO(hansmuller): escape the fontFamily string. |
| 188 if (fontFamily != null) | 191 if (fontFamily != null) |
| 189 result.add('${prefix}fontFamily: "${fontFamily}"'); | 192 result.add('${prefix}fontFamily: "${fontFamily}"'); |
| 190 if (fontSize != null) | 193 if (fontSize != null) |
| 191 result.add('${prefix}fontSize: $fontSize'); | 194 result.add('${prefix}fontSize: $fontSize'); |
| 192 if (fontWeight != null) | 195 if (fontWeight != null) |
| 193 result.add('${prefix}fontWeight: $fontWeight'); | 196 result.add('${prefix}fontWeight: $fontWeight'); |
| 194 if (textAlign != null) | 197 if (textAlign != null) |
| 195 result.add('${prefix}textAlign: $textAlign'); | 198 result.add('${prefix}textAlign: $textAlign'); |
| 196 if (decoration != null) | 199 if (decoration != null) |
| 197 result.add('${prefix}decoration: $decoration'); | 200 result.add('${prefix}decoration: $decoration'); |
| 198 if (decorationColor != null) | 201 if (decorationColor != null) |
| 199 result.add('${prefix}decorationColor: $decorationColor'); | 202 result.add('${prefix}decorationColor: $decorationColor'); |
| 200 if (decorationStyle != null) | 203 if (decorationStyle != null) |
| 201 result.add('${prefix}decorationStyle: $decorationStyle'); | 204 result.add('${prefix}decorationStyle: $decorationStyle'); |
| 202 if (result.isEmpty) | 205 if (result.isEmpty) |
| 203 return '${prefix}<no style specified>'; | 206 return '${prefix}<no style specified>'; |
| 204 return result.join('\n'); | 207 return result.join('\n'); |
| 205 } | 208 } |
| 206 } | 209 } |
| OLD | NEW |