| 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 '../rendering/block.dart'; | 5 import '../rendering/block.dart'; |
| 6 import '../rendering/box.dart'; | 6 import '../rendering/box.dart'; |
| 7 import '../rendering/object.dart'; | 7 import '../rendering/object.dart'; |
| 8 import 'widget.dart'; | 8 import 'widget.dart'; |
| 9 | 9 |
| 10 // return null if index is greater than index of last entry | 10 // return null if index is greater than index of last entry |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 left = middle + 1; | 93 left = middle + 1; |
| 94 } else if (_offsets[middle] > offset) { | 94 } else if (_offsets[middle] > offset) { |
| 95 right = middle - 1; | 95 right = middle - 1; |
| 96 } else { | 96 } else { |
| 97 return middle; | 97 return middle; |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 return right; | 100 return right; |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool _dirty = false; | 103 bool _dirty = true; |
| 104 | 104 |
| 105 bool retainStatefulNodeIfPossible(BlockViewport newNode) { | 105 bool retainStatefulNodeIfPossible(BlockViewport newNode) { |
| 106 retainStatefulRenderObjectWrapper(newNode); | 106 retainStatefulRenderObjectWrapper(newNode); |
| 107 if (startOffset != newNode.startOffset) { | 107 if (startOffset != newNode.startOffset) { |
| 108 _dirty = true; | 108 _dirty = true; |
| 109 startOffset = newNode.startOffset; | 109 startOffset = newNode.startOffset; |
| 110 } | 110 } |
| 111 if (token != newNode.token || builder != newNode.builder) { | 111 if (token != newNode.token || builder != newNode.builder) { |
| 112 _dirty = true; | 112 _dirty = true; |
| 113 builder = newNode.builder; | 113 builder = newNode.builder; |
| 114 token = newNode.token; | 114 token = newNode.token; |
| 115 _offsets = <double>[0.0]; | 115 _offsets = <double>[0.0]; |
| 116 } | 116 } |
| 117 return true; | 117 return true; |
| 118 } | 118 } |
| 119 | 119 |
| 120 void syncRenderObject(BlockViewport old) { | 120 void syncRenderObject(BlockViewport old) { |
| 121 super.syncRenderObject(old); | 121 super.syncRenderObject(old); |
| 122 if (_dirty) { | 122 if (_dirty) { |
| 123 root.markNeedsLayout(); | 123 root.markNeedsLayout(); |
| 124 } else { | 124 } else { |
| 125 if (_currentChildCount > 0) { | 125 if (_currentChildCount > 0) { |
| 126 assert(_currentStartIndex >= 0); | 126 assert(_currentStartIndex >= 0); |
| 127 assert(builder != null); | 127 assert(builder != null); |
| 128 assert(root != null); | 128 assert(root != null); |
| 129 int lastIndex = _currentStartIndex + _currentChildCount; | 129 int lastIndex = _currentStartIndex + _currentChildCount - 1; |
| 130 for (int index = _currentStartIndex; index <= lastIndex; index += 1) { | 130 for (int index = _currentStartIndex; index <= lastIndex; index += 1) { |
| 131 Widget widget = builder(index); | 131 Widget widget = builder(index); |
| 132 assert(widget != null); | 132 assert(widget != null); |
| 133 assert(widget.key != null); | 133 assert(widget.key != null); |
| 134 _Key key = new _Key.fromWidget(widget); | 134 _Key key = new _Key.fromWidget(widget); |
| 135 Widget oldWidget = _childrenByKey[key]; | 135 Widget oldWidget = _childrenByKey[key]; |
| 136 assert(oldWidget != null); | 136 assert(oldWidget != null); |
| 137 assert(oldWidget.root.parent == root); | 137 assert(oldWidget.root.parent == root); |
| 138 widget = syncChild(widget, oldWidget, root.childAfter(oldWidget.root))
; | 138 widget = syncChild(widget, oldWidget, root.childAfter(oldWidget.root))
; |
| 139 assert(widget != null); | 139 assert(widget != null); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 nextSibling = widget.root; | 283 nextSibling = widget.root; |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 | 286 |
| 287 _childrenByKey = newChildren; | 287 _childrenByKey = newChildren; |
| 288 _currentStartIndex = startIndex; | 288 _currentStartIndex = startIndex; |
| 289 _currentChildCount = _childrenByKey.length; | 289 _currentChildCount = _childrenByKey.length; |
| 290 } | 290 } |
| 291 | 291 |
| 292 } | 292 } |
| OLD | NEW |