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:math' as math; | 5 import 'dart:math' as math; |
6 | 6 |
7 import 'box.dart'; | 7 import 'box.dart'; |
8 import 'object.dart'; | 8 import 'object.dart'; |
9 | 9 |
10 class BlockParentData extends BoxParentData with ContainerParentDataMixin<Render
Box> { } | 10 class BlockParentData extends BoxParentData with ContainerParentDataMixin<Render
Box> { } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 102 } |
103 | 103 |
104 double getMaxIntrinsicHeight(BoxConstraints constraints) { | 104 double getMaxIntrinsicHeight(BoxConstraints constraints) { |
105 return _getIntrinsicHeight(constraints); | 105 return _getIntrinsicHeight(constraints); |
106 } | 106 } |
107 | 107 |
108 double computeDistanceToActualBaseline(TextBaseline baseline) { | 108 double computeDistanceToActualBaseline(TextBaseline baseline) { |
109 return defaultComputeDistanceToFirstActualBaseline(baseline); | 109 return defaultComputeDistanceToFirstActualBaseline(baseline); |
110 } | 110 } |
111 | 111 |
112 bool _hasVisualOverflow = false; | |
113 | |
114 void performLayout() { | 112 void performLayout() { |
| 113 assert(constraints.maxHeight >= double.INFINITY); |
115 super.performLayout(); | 114 super.performLayout(); |
116 size = constraints.constrain(new Size(constraints.maxWidth, childrenHeight))
; | 115 size = constraints.constrain(new Size(constraints.maxWidth, childrenHeight))
; |
117 assert(!size.isInfinite); | 116 assert(!size.isInfinite); |
118 | |
119 // FIXME(eseidel): Block lays out its children with unconstrained height | |
120 // yet itself remains constrained. Remember that our children wanted to | |
121 // be taller than we are so we know to clip them (and not cause confusing | |
122 // mismatch of painting vs. hittesting). | |
123 _hasVisualOverflow = childrenHeight > size.height; | |
124 } | 117 } |
125 | 118 |
126 void paint(PaintingCanvas canvas, Offset offset) { | 119 void paint(PaintingCanvas canvas, Offset offset) { |
127 if (_hasVisualOverflow) { | |
128 canvas.save(); | |
129 canvas.clipRect(offset & size); | |
130 } | |
131 defaultPaint(canvas, offset); | 120 defaultPaint(canvas, offset); |
132 if (_hasVisualOverflow) { | |
133 canvas.restore(); | |
134 } | |
135 } | 121 } |
136 | 122 |
137 void hitTestChildren(HitTestResult result, { Point position }) { | 123 void hitTestChildren(HitTestResult result, { Point position }) { |
138 defaultHitTestChildren(result, position: position); | 124 defaultHitTestChildren(result, position: position); |
139 } | 125 } |
140 | 126 |
141 } | 127 } |
142 | 128 |
143 class RenderBlockViewport extends RenderBlockBase { | 129 class RenderBlockViewport extends RenderBlockBase { |
144 | 130 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 183 |
198 bool get sizedByParent => true; | 184 bool get sizedByParent => true; |
199 | 185 |
200 void performResize() { | 186 void performResize() { |
201 size = constraints.biggest; | 187 size = constraints.biggest; |
202 assert(!size.isInfinite); | 188 assert(!size.isInfinite); |
203 } | 189 } |
204 | 190 |
205 bool get debugDoesLayoutWithCallback => true; | 191 bool get debugDoesLayoutWithCallback => true; |
206 void performLayout() { | 192 void performLayout() { |
| 193 assert(constraints.maxHeight < double.INFINITY); |
207 if (_callback != null) { | 194 if (_callback != null) { |
208 try { | 195 try { |
209 _inCallback = true; | 196 _inCallback = true; |
210 invokeLayoutCallback(_callback); | 197 invokeLayoutCallback(_callback); |
211 } finally { | 198 } finally { |
212 _inCallback = false; | 199 _inCallback = false; |
213 } | 200 } |
214 } | 201 } |
215 super.performLayout(); | 202 super.performLayout(); |
216 } | 203 } |
217 | 204 |
218 void paint(PaintingCanvas canvas, Offset offset) { | 205 void paint(PaintingCanvas canvas, Offset offset) { |
219 canvas.save(); | 206 canvas.save(); |
220 canvas.clipRect(offset & size); | 207 canvas.clipRect(offset & size); |
221 defaultPaint(canvas, offset.translate(0.0, startOffset)); | 208 defaultPaint(canvas, offset.translate(0.0, startOffset)); |
222 canvas.restore(); | 209 canvas.restore(); |
223 } | 210 } |
224 | 211 |
225 void hitTestChildren(HitTestResult result, { Point position }) { | 212 void hitTestChildren(HitTestResult result, { Point position }) { |
226 defaultHitTestChildren(result, position: position + new Offset(0.0, -startOf
fset)); | 213 defaultHitTestChildren(result, position: position + new Offset(0.0, -startOf
fset)); |
227 } | 214 } |
228 | 215 |
229 } | 216 } |
230 | 217 |
OLD | NEW |