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

Unified Diff: sky/sdk/lib/widgets/block_viewport.dart

Issue 1225093007: Make sure to sync the widgets even when we don't do a relayout. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/widgets/block_viewport.dart
diff --git a/sky/sdk/lib/widgets/block_viewport.dart b/sky/sdk/lib/widgets/block_viewport.dart
index 9b5395f798465d4420303ee1a34d43f63d36b722..e53240ae823b3fcd54ee5911301fff1814014299 100644
--- a/sky/sdk/lib/widgets/block_viewport.dart
+++ b/sky/sdk/lib/widgets/block_viewport.dart
@@ -81,6 +81,8 @@ class BlockViewport extends RenderObjectWrapper {
// end of the last one. If there's no children, then the only offset
// is 0.0.
List<double> _offsets = <double>[0.0];
+ int _currentStartIndex = 0;
+ int _currentChildCount = 0;
int _findIndexForOffsetBeforeOrAt(double offset) {
int left = 0;
@@ -117,8 +119,28 @@ class BlockViewport extends RenderObjectWrapper {
void syncRenderObject(BlockViewport old) {
super.syncRenderObject(old);
- if (_dirty)
+ if (_dirty) {
root.markNeedsLayout();
+ } else {
+ if (_currentChildCount > 0) {
+ assert(_currentStartIndex >= 0);
+ assert(builder != null);
+ assert(root != null);
+ int lastIndex = _currentStartIndex + _currentChildCount;
+ for (int index = _currentStartIndex; index <= lastIndex; index += 1) {
+ Widget widget = builder(index);
+ assert(widget != null);
+ assert(widget.key != null);
+ _Key key = new _Key.fromWidget(widget);
+ Widget oldWidget = _childrenByKey[key];
+ assert(oldWidget != null);
+ assert(oldWidget.root.parent == root);
+ widget = syncChild(widget, oldWidget, root.childAfter(oldWidget.root));
+ assert(widget != null);
+ _childrenByKey[key] = widget;
+ }
+ }
+ }
}
Widget _getWidget(int index, BoxConstraints innerConstraints) {
@@ -149,6 +171,8 @@ class BlockViewport extends RenderObjectWrapper {
}
void layout(BoxConstraints constraints) {
+ if (!_dirty)
+ return;
_dirty = false;
Map<_Key, Widget> newChildren = new Map<_Key, Widget>();
@@ -261,6 +285,8 @@ class BlockViewport extends RenderObjectWrapper {
}
_childrenByKey = newChildren;
+ _currentStartIndex = startIndex;
+ _currentChildCount = _childrenByKey.length;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698