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