| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 canvas.clipRect(offset & size); | 140 canvas.clipRect(offset & size); |
| 141 } | 141 } |
| 142 super.paint(canvas, offset); | 142 super.paint(canvas, offset); |
| 143 if (_hasVisualOverflow) { | 143 if (_hasVisualOverflow) { |
| 144 canvas.restore(); | 144 canvas.restore(); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 } | 148 } |
| 149 | 149 |
| 150 class RenderBlockViewport extends RenderBlockBase { |
| 151 |
| 152 // sizes itself to the given constraints |
| 153 // at the start of layout, calls callback |
| 154 |
| 155 RenderBlockViewport({ |
| 156 LayoutCallback callback, |
| 157 List<RenderBox> children, |
| 158 double startOffset: 0.0 |
| 159 }) : _callback = callback, _startOffset = startOffset, super(children: childre
n); |
| 160 |
| 161 bool _inCallback = false; |
| 162 |
| 163 LayoutCallback _callback; |
| 164 LayoutCallback get callback => _callback; |
| 165 void set callback(LayoutCallback value) { |
| 166 assert(!_inCallback); |
| 167 if (value == _callback) |
| 168 return; |
| 169 _callback = value; |
| 170 markNeedsLayout(); |
| 171 } |
| 172 |
| 173 // you can set this from within the callback if necessary |
| 174 double _startOffset; |
| 175 double get startOffset => _startOffset; |
| 176 void set startOffset(double value) { |
| 177 if (value == _startOffset) |
| 178 return; |
| 179 _startOffset = value; |
| 180 if (!_inCallback) |
| 181 markNeedsLayout(); |
| 182 } |
| 183 |
| 184 bool get sizedByParent => true; |
| 185 |
| 186 void performResize() { |
| 187 size = constraints.biggest; |
| 188 assert(!size.isInfinite); |
| 189 } |
| 190 |
| 191 bool get debugDoesLayoutWithCallback => true; |
| 192 void performLayout() { |
| 193 if (_callback != null) { |
| 194 try { |
| 195 _inCallback = true; |
| 196 invokeLayoutCallback(_callback); |
| 197 } finally { |
| 198 _inCallback = false; |
| 199 } |
| 200 } |
| 201 super.performLayout(); |
| 202 } |
| 203 |
| 204 void paint(PaintingCanvas canvas, Offset offset) { |
| 205 canvas.save(); |
| 206 canvas.clipRect(offset & size); |
| 207 super.paint(canvas, offset.translate(0.0, _startOffset)); |
| 208 canvas.restore(); |
| 209 } |
| 210 |
| 211 } |
| OLD | NEW |