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

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

Issue 1222393002: Trivial parts of https://codereview.chromium.org/1218183009/ so that that patch isn't confused by v… (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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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: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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 setParent(null); 117 setParent(null);
118 } 118 }
119 119
120 void removeChild(Widget node) { 120 void removeChild(Widget node) {
121 node.remove(); 121 node.remove();
122 } 122 }
123 123
124 void detachRoot(); 124 void detachRoot();
125 125
126 // Returns the child which should be retained as the child of this node. 126 // Returns the child which should be retained as the child of this node.
127 Widget syncChild(Widget node, Widget oldNode, dynamic slot) { 127 Widget syncChild(Widget newNode, Widget oldNode, dynamic slot) {
128 128
129 assert(oldNode is! Component || (oldNode is Component && !oldNode._disqualif iedFromEverAppearingAgain)); // TODO(ianh): Simplify this once the analyzer is c leverer 129 assert(oldNode is! Component ||
130 (oldNode is Component && !oldNode._disqualifiedFromEverAppearingAgain )); // TODO(ianh): Simplify this once the analyzer is cleverer
130 131
131 if (node == oldNode) { 132 if (newNode == oldNode) {
132 assert(node == null || node.mounted); 133 assert(newNode == null || newNode.mounted);
133 assert(node is! RenderObjectWrapper || (node is RenderObjectWrapper && nod e._ancestor != null)); // TODO(ianh): Simplify this once the analyzer is clevere r 134 assert(newNode is! RenderObjectWrapper ||
134 return node; // Nothing to do. Subtrees must be identical. 135 (newNode is RenderObjectWrapper && newNode._ancestor != null)); // TODO(ianh): Simplify this once the analyzer is cleverer
136 return newNode; // Nothing to do. Subtrees must be identical.
135 } 137 }
136 138
137 if (node == null) { 139 if (newNode == null) {
138 // the child in this slot has gone away 140 // the child in this slot has gone away
139 assert(oldNode.mounted); 141 assert(oldNode.mounted);
140 oldNode.detachRoot(); 142 oldNode.detachRoot();
141 removeChild(oldNode); 143 removeChild(oldNode);
142 assert(!oldNode.mounted); 144 assert(!oldNode.mounted);
143 return null; 145 return null;
144 } 146 }
145 147
146 if (oldNode != null) { 148 if (oldNode != null) {
147 if (oldNode.runtimeType == node.runtimeType && oldNode.key == node.key) { 149 if (oldNode.runtimeType == newNode.runtimeType && oldNode.key == newNode.k ey) {
148 if (node._retainStatefulNodeIfPossible(oldNode)) { 150 if (newNode._retainStatefulNodeIfPossible(oldNode)) {
149 assert(oldNode.mounted); 151 assert(oldNode.mounted);
150 assert(!node.mounted); 152 assert(!newNode.mounted);
151 oldNode.setParent(this); 153 oldNode.setParent(this);
152 oldNode._sync(node, slot); 154 oldNode._sync(newNode, slot);
153 assert(oldNode.root is RenderObject); 155 assert(oldNode.root is RenderObject);
154 return oldNode; 156 return oldNode;
155 } 157 }
156 } else { 158 } else {
157 assert(oldNode.mounted); 159 assert(oldNode.mounted);
158 oldNode.detachRoot(); 160 oldNode.detachRoot();
159 removeChild(oldNode); 161 removeChild(oldNode);
160 oldNode = null; 162 oldNode = null;
161 } 163 }
162 } 164 }
163 165
164 assert(!node.mounted); 166 assert(!newNode.mounted);
165 node.setParent(this); 167 newNode.setParent(this);
166 node._sync(oldNode, slot); 168 newNode._sync(oldNode, slot);
167 assert(node.root is RenderObject); 169 assert(newNode.root is RenderObject);
168 return node; 170 return newNode;
169 } 171 }
170 172
171 String toString() { 173 String toString() {
172 if (key == null) 174 if (key == null)
173 return '$runtimeType(unkeyed)'; 175 return '$runtimeType(unkeyed)';
174 return '$runtimeType("$key")'; 176 return '$runtimeType("$key")';
175 } 177 }
176 178
177 } 179 }
178 180
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 final int _order; 431 final int _order;
430 static int _currentOrder = 0; 432 static int _currentOrder = 0;
431 433
432 // There are three cases here: 434 // There are three cases here:
433 // 1) Building for the first time: 435 // 1) Building for the first time:
434 // assert(_built == null && old == null) 436 // assert(_built == null && old == null)
435 // 2) Re-building (because a dirty flag got set): 437 // 2) Re-building (because a dirty flag got set):
436 // assert(_built != null && old == null) 438 // assert(_built != null && old == null)
437 // 3) Syncing against an old version 439 // 3) Syncing against an old version
438 // assert(_built == null && old != null) 440 // assert(_built == null && old != null)
439 void _sync(Widget old, dynamic slot) { 441 void _sync(Component old, dynamic slot) {
440 assert(_built == null || old == null); 442 assert(_built == null || old == null);
441 assert(!_disqualifiedFromEverAppearingAgain); 443 assert(!_disqualifiedFromEverAppearingAgain);
442 444
443 Component oldComponent = old as Component;
444
445 _slot = slot; 445 _slot = slot;
446 446
447 var oldBuilt; 447 var oldBuilt;
448 if (oldComponent == null) { 448 if (old == null) {
449 oldBuilt = _built; 449 oldBuilt = _built;
450 } else { 450 } else {
451 assert(_built == null); 451 assert(_built == null);
452 oldBuilt = oldComponent._built; 452 oldBuilt = old._built;
453 } 453 }
454 454
455 int lastOrder = _currentOrder; 455 int lastOrder = _currentOrder;
456 _currentOrder = _order; 456 _currentOrder = _order;
457 _currentlyBuilding = this; 457 _currentlyBuilding = this;
458 _built = build(); 458 _built = build();
459 assert(_built != null); 459 assert(_built != null);
460 _currentlyBuilding = null; 460 _currentlyBuilding = null;
461 _currentOrder = lastOrder; 461 _currentOrder = lastOrder;
462 462
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 if (root.parent == null) { 1011 if (root.parent == null) {
1012 // we haven't attached it yet 1012 // we haven't attached it yet
1013 assert(_container.child == null); 1013 assert(_container.child == null);
1014 _container.child = root; 1014 _container.child = root;
1015 } 1015 }
1016 assert(root.parent == _container); 1016 assert(root.parent == _container);
1017 } 1017 }
1018 1018
1019 Widget build() => builder(); 1019 Widget build() => builder();
1020 } 1020 }
OLDNEW
« 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