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 | 6 |
7 import 'box.dart'; | 7 import 'box.dart'; |
8 import 'object.dart'; | 8 import 'object.dart'; |
9 import '../painting/text_style.dart'; | 9 import '../painting/text_style.dart'; |
10 | 10 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 147 } |
148 | 148 |
149 double getMinIntrinsicHeight(BoxConstraints constraints) { | 149 double getMinIntrinsicHeight(BoxConstraints constraints) { |
150 return _getIntrinsicHeight(constraints); | 150 return _getIntrinsicHeight(constraints); |
151 } | 151 } |
152 | 152 |
153 double getMaxIntrinsicHeight(BoxConstraints constraints) { | 153 double getMaxIntrinsicHeight(BoxConstraints constraints) { |
154 return _getIntrinsicHeight(constraints); | 154 return _getIntrinsicHeight(constraints); |
155 } | 155 } |
156 | 156 |
| 157 double getDistanceToActualBaseline(TextBaseline baseline) { |
| 158 assert(!needsLayout); |
| 159 _layout(constraints); |
| 160 sky.Element root = _layoutRoot.rootElement; |
| 161 switch (baseline) { |
| 162 case TextBaseline.alphabetic: return root.alphabeticBaseline; |
| 163 case TextBaseline.ideographic: return root.ideographicBaseline; |
| 164 } |
| 165 } |
| 166 |
157 void performLayout() { | 167 void performLayout() { |
158 _layout(constraints); | 168 _layout(constraints); |
159 sky.Element root = _layoutRoot.rootElement; | 169 sky.Element root = _layoutRoot.rootElement; |
160 // rootElement.width always expands to fill, use maxContentWidth instead. | 170 // rootElement.width always expands to fill, use maxContentWidth instead. |
161 size = constraints.constrain(new Size(_applyFloatingPointHack(root.maxConten
tWidth), | 171 size = constraints.constrain(new Size(_applyFloatingPointHack(root.maxConten
tWidth), |
162 _applyFloatingPointHack(root.height)))
; | 172 _applyFloatingPointHack(root.height)))
; |
163 } | 173 } |
164 | 174 |
165 void paint(RenderCanvas canvas) { | 175 void paint(RenderCanvas canvas) { |
166 // Ideally we could compute the min/max intrinsic width/height with a | 176 // Ideally we could compute the min/max intrinsic width/height with a |
167 // non-destructive operation. However, currently, computing these values | 177 // non-destructive operation. However, currently, computing these values |
168 // will destroy state inside the layout root. If that happens, we need to | 178 // will destroy state inside the layout root. If that happens, we need to |
169 // get back the correct state by calling _layout again. | 179 // get back the correct state by calling _layout again. |
170 // | 180 // |
171 // TODO(abarth): Make computing the min/max intrinsic width/height a | 181 // TODO(abarth): Make computing the min/max intrinsic width/height a |
172 // non-destructive operation. | 182 // non-destructive operation. |
173 _layout(constraints); | 183 _layout(constraints); |
174 _layoutRoot.paint(canvas); | 184 _layoutRoot.paint(canvas); |
175 } | 185 } |
176 | 186 |
177 // we should probably expose a way to do precise (inter-glpyh) hit testing | 187 // we should probably expose a way to do precise (inter-glpyh) hit testing |
178 | 188 |
179 String debugDescribeSettings(String prefix) { | 189 String debugDescribeSettings(String prefix) { |
180 String result = '${super.debugDescribeSettings(prefix)}'; | 190 String result = '${super.debugDescribeSettings(prefix)}'; |
181 result += '${prefix}inline:\n${inline.toString("$prefix ")}\n'; | 191 result += '${prefix}inline:\n${inline.toString("$prefix ")}\n'; |
182 return result; | 192 return result; |
183 } | 193 } |
184 } | 194 } |
OLD | NEW |