| 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' as sky; | 5 import 'dart:sky' as sky; |
| 6 import 'box.dart'; | 6 import 'box.dart'; |
| 7 import 'object.dart'; | 7 import 'object.dart'; |
| 8 | 8 |
| 9 class RenderInline extends RenderObject { | 9 class RenderInline extends RenderObject { |
| 10 RenderInline(this.data); | 10 RenderInline(this.data); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 int get hashCode { | 61 int get hashCode { |
| 62 // Use Quiver: https://github.com/domokit/mojo/issues/236 | 62 // Use Quiver: https://github.com/domokit/mojo/issues/236 |
| 63 int value = 373; | 63 int value = 373; |
| 64 value = 37 * value + color.hashCode; | 64 value = 37 * value + color.hashCode; |
| 65 value = 37 * value + fontSize.hashCode; | 65 value = 37 * value + fontSize.hashCode; |
| 66 value = 37 * value + fontWeight.hashCode; | 66 value = 37 * value + fontWeight.hashCode; |
| 67 value = 37 * value + textAlign.hashCode; | 67 value = 37 * value + textAlign.hashCode; |
| 68 return value; | 68 return value; |
| 69 } | 69 } |
| 70 |
| 71 String toString([String prefix = '']) { |
| 72 List<String> result = []; |
| 73 if (color != null) |
| 74 result.add('${prefix}color: $color'); |
| 75 if (fontSize != null) |
| 76 result.add('${prefix}fontSize: $fontSize'); |
| 77 if (fontWeight != null) |
| 78 result.add('${prefix}fontWeight: fontWeight'); |
| 79 if (textAlign != null) |
| 80 result.add('${prefix}textAlign: textAlign'); |
| 81 if (result.isEmpty) |
| 82 return '${prefix}<no style specified>'; |
| 83 return result.join('\n'); |
| 84 } |
| 70 } | 85 } |
| 71 | 86 |
| 72 // Unfortunately, using full precision floating point here causes bad layouts | 87 // Unfortunately, using full precision floating point here causes bad layouts |
| 73 // because floating point math isn't associative. If we add and subtract | 88 // because floating point math isn't associative. If we add and subtract |
| 74 // padding, for example, we'll get different values when we estimate sizes and | 89 // padding, for example, we'll get different values when we estimate sizes and |
| 75 // when we actually compute layout because the operations will end up associated | 90 // when we actually compute layout because the operations will end up associated |
| 76 // differently. To work around this problem for now, we round fractional pixel | 91 // differently. To work around this problem for now, we round fractional pixel |
| 77 // values up to the nearest whole pixel value. The right long-term fix is to do | 92 // values up to the nearest whole pixel value. The right long-term fix is to do |
| 78 // layout using fixed precision arithmetic. | 93 // layout using fixed precision arithmetic. |
| 79 double _applyFloatingPointHack(double layoutValue) { | 94 double _applyFloatingPointHack(double layoutValue) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 TextAlign.right: 'right', | 204 TextAlign.right: 'right', |
| 190 TextAlign.center: 'center', | 205 TextAlign.center: 'center', |
| 191 }[style.textAlign]; | 206 }[style.textAlign]; |
| 192 } | 207 } |
| 193 } | 208 } |
| 194 _layoutRoot.paint(canvas); | 209 _layoutRoot.paint(canvas); |
| 195 } | 210 } |
| 196 | 211 |
| 197 // we should probably expose a way to do precise (inter-glpyh) hit testing | 212 // we should probably expose a way to do precise (inter-glpyh) hit testing |
| 198 | 213 |
| 199 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}color: ${color}\n${prefix}text: ${text}\n'; | 214 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}style:\n${style.toString("$prefix ")}\n${prefix}text: ${text}\
n'; |
| 200 } | 215 } |
| OLD | NEW |