| 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:async'; | 5 import 'dart:async'; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
| 8 import 'dart:sky' as sky; | 8 import 'dart:sky' as sky; |
| 9 | 9 |
| 10 import '../base/hit_test.dart'; | 10 import '../base/hit_test.dart'; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 String _key; | 39 String _key; |
| 40 String get key => _key; | 40 String get key => _key; |
| 41 | 41 |
| 42 Widget _parent; | 42 Widget _parent; |
| 43 Widget get parent => _parent; | 43 Widget get parent => _parent; |
| 44 | 44 |
| 45 bool _mounted = false; | 45 bool _mounted = false; |
| 46 bool _wasMounted = false; | 46 bool _wasMounted = false; |
| 47 bool get mounted => _mounted; | 47 bool get mounted => _mounted; |
| 48 static bool _notifyingMountStatus = false; | 48 static bool _notifyingMountStatus = false; |
| 49 static Set<Widget> _mountedChanged = new HashSet<Widget>(); | 49 static List<Widget> _mountedChanged = new List<Widget>(); |
| 50 | 50 |
| 51 void setParent(Widget newParent) { | 51 void setParent(Widget newParent) { |
| 52 assert(!_notifyingMountStatus); | 52 assert(!_notifyingMountStatus); |
| 53 _parent = newParent; | 53 _parent = newParent; |
| 54 if (newParent == null) { | 54 if (newParent == null) { |
| 55 if (_mounted) { | 55 if (_mounted) { |
| 56 _mounted = false; | 56 _mounted = false; |
| 57 _mountedChanged.add(this); | 57 _mountedChanged.add(this); |
| 58 } | 58 } |
| 59 } else { | 59 } else { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 if (node == null) { | 135 if (node == null) { |
| 136 // the child in this slot has gone away | 136 // the child in this slot has gone away |
| 137 assert(oldNode.mounted); | 137 assert(oldNode.mounted); |
| 138 oldNode.detachRoot(); | 138 oldNode.detachRoot(); |
| 139 removeChild(oldNode); | 139 removeChild(oldNode); |
| 140 assert(!oldNode.mounted); | 140 assert(!oldNode.mounted); |
| 141 return null; | 141 return null; |
| 142 } | 142 } |
| 143 | 143 |
| 144 if (oldNode != null && | 144 if (oldNode != null) { |
| 145 oldNode.runtimeType == node.runtimeType && | 145 if (oldNode.runtimeType == node.runtimeType && oldNode.key == node.key) { |
| 146 oldNode.key == node.key && | 146 if (node._retainStatefulNodeIfPossible(oldNode)) { |
| 147 node._retainStatefulNodeIfPossible(oldNode)) { | 147 assert(oldNode.mounted); |
| 148 assert(oldNode.mounted); | 148 assert(!node.mounted); |
| 149 assert(!node.mounted); | 149 oldNode._sync(node, slot); |
| 150 oldNode._sync(node, slot); | 150 assert(oldNode.root is RenderObject); |
| 151 assert(oldNode.root is RenderObject); | 151 return oldNode; |
| 152 return oldNode; | 152 } |
| 153 } | 153 } else { |
| 154 | 154 assert(oldNode.mounted); |
| 155 if (oldNode != null && | 155 oldNode.detachRoot(); |
| 156 (oldNode.runtimeType != node.runtimeType || oldNode.key != node.key)) { | 156 removeChild(oldNode); |
| 157 assert(oldNode.mounted); | 157 oldNode = null; |
| 158 oldNode.detachRoot(); | 158 } |
| 159 removeChild(oldNode); | |
| 160 oldNode = null; | |
| 161 } | 159 } |
| 162 | 160 |
| 163 assert(!node.mounted); | 161 assert(!node.mounted); |
| 164 node.setParent(this); | 162 node.setParent(this); |
| 165 node._sync(oldNode, slot); | 163 node._sync(oldNode, slot); |
| 166 assert(node.root is RenderObject); | 164 assert(node.root is RenderObject); |
| 167 return node; | 165 return node; |
| 168 } | 166 } |
| 169 | 167 |
| 170 String toString() { | 168 String toString() { |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 if (root.parent == null) { | 997 if (root.parent == null) { |
| 1000 // we haven't attached it yet | 998 // we haven't attached it yet |
| 1001 assert(_container.child == null); | 999 assert(_container.child == null); |
| 1002 _container.child = root; | 1000 _container.child = root; |
| 1003 } | 1001 } |
| 1004 assert(root.parent == _container); | 1002 assert(root.parent == _container); |
| 1005 } | 1003 } |
| 1006 | 1004 |
| 1007 Widget build() => builder(); | 1005 Widget build() => builder(); |
| 1008 } | 1006 } |
| OLD | NEW |