Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1545)

Side by Side Diff: sky/sdk/lib/widgets/block_viewport.dart

Issue 1227823012: Move VariableHeightScrollable to sdk/lib/widgets (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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:collection';
6
5 import '../rendering/block.dart'; 7 import '../rendering/block.dart';
6 import '../rendering/box.dart'; 8 import '../rendering/box.dart';
7 import '../rendering/object.dart'; 9 import '../rendering/object.dart';
8 import 'widget.dart'; 10 import 'widget.dart';
9 11
10 // return null if index is greater than index of last entry 12 // return null if index is greater than index of last entry
11 typedef Widget IndexedBuilder(int index); 13 typedef Widget IndexedBuilder(int index);
12 14
15 typedef void LayoutChangedCallback(
16 int firstVisibleItemIndex,
17 int visibleItemCount,
18 UnmodifiableListView<double> itemOffsets);
19
13 class _Key { 20 class _Key {
14 const _Key(this.type, this.key); 21 const _Key(this.type, this.key);
15 factory _Key.fromWidget(Widget widget) => new _Key(widget.runtimeType, widget. key); 22 factory _Key.fromWidget(Widget widget) => new _Key(widget.runtimeType, widget. key);
16 final Type type; 23 final Type type;
17 final String key; 24 final String key;
18 bool operator ==(other) => other is _Key && other.type == type && other.key == key; 25 bool operator ==(other) => other is _Key && other.type == type && other.key == key;
19 int get hashCode => 373 * 37 * type.hashCode + key.hashCode; 26 int get hashCode => 373 * 37 * type.hashCode + key.hashCode;
20 } 27 }
21 28
22 class BlockViewport extends RenderObjectWrapper { 29 class BlockViewport extends RenderObjectWrapper {
23 BlockViewport({ this.builder, this.startOffset, this.token, String key }) 30 BlockViewport({ this.builder, this.startOffset, this.token, this.onLayoutChang ed, String key })
24 : super(key: key); 31 : super(key: key);
25 32
26 IndexedBuilder builder; 33 IndexedBuilder builder;
27 double startOffset; 34 double startOffset;
28 Object token; 35 Object token;
36 LayoutChangedCallback onLayoutChanged;
29 37
30 RenderBlockViewport get root => super.root; 38 RenderBlockViewport get root => super.root;
31 RenderBlockViewport createNode() => new RenderBlockViewport(); 39 RenderBlockViewport createNode() => new RenderBlockViewport();
32 40
33 Map<_Key, Widget> _childrenByKey = new Map<_Key, Widget>(); 41 Map<_Key, Widget> _childrenByKey = new Map<_Key, Widget>();
34 42
35 void walkChildren(WidgetTreeWalker walker) { 43 void walkChildren(WidgetTreeWalker walker) {
36 for (Widget child in _childrenByKey.values) 44 for (Widget child in _childrenByKey.values)
37 walker(child); 45 walker(child);
38 } 46 }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 root.add(widget.root, before: nextSibling); 288 root.add(widget.root, before: nextSibling);
281 } 289 }
282 widget.updateSlot(nextSibling); 290 widget.updateSlot(nextSibling);
283 nextSibling = widget.root; 291 nextSibling = widget.root;
284 } 292 }
285 } 293 }
286 294
287 _childrenByKey = newChildren; 295 _childrenByKey = newChildren;
288 _currentStartIndex = startIndex; 296 _currentStartIndex = startIndex;
289 _currentChildCount = _childrenByKey.length; 297 _currentChildCount = _childrenByKey.length;
298
299 if (onLayoutChanged != null)
300 onLayoutChanged(_currentStartIndex, _currentChildCount, new UnmodifiableLi stView<double>(_offsets));
290 } 301 }
291 302
292 } 303 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698