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

Side by Side Diff: sky/sdk/lib/framework/fn.dart

Issue 1148253002: [Effen] Try to catch more misuse of fn by asserting that UINode nodes are only built when we're upd… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 7 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 library fn; 5 library fn;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:sky' as sky; 9 import 'dart:sky' as sky;
10 import 'reflect.dart' as reflect; 10 import 'reflect.dart' as reflect;
(...skipping 14 matching lines...) Expand all
25 */ 25 */
26 abstract class UINode { 26 abstract class UINode {
27 String _key; 27 String _key;
28 UINode _parent; 28 UINode _parent;
29 UINode get parent => _parent; 29 UINode get parent => _parent;
30 RenderCSS _root; 30 RenderCSS _root;
31 bool _defunct = false; 31 bool _defunct = false;
32 32
33 UINode({ Object key }) { 33 UINode({ Object key }) {
34 _key = key == null ? "$runtimeType" : "$runtimeType-$key"; 34 _key = key == null ? "$runtimeType" : "$runtimeType-$key";
35 assert(this is App || _inRenderDirtyComponents); // you should not build the UI tree ahead of time, build it only during build()
35 } 36 }
36 37
37 // Subclasses which implements Nodes that become stateful may return true 38 // Subclasses which implements Nodes that become stateful may return true
38 // if the |old| node has become stateful and should be retained. 39 // if the |old| node has become stateful and should be retained.
39 bool _willSync(UINode old) => false; 40 bool _willSync(UINode old) => false;
40 41
41 bool get interchangeable => false; // if true, then keys can be duplicated 42 bool get interchangeable => false; // if true, then keys can be duplicated
42 43
43 void _sync(UINode old, RenderCSSContainer host, RenderCSS insertBefore); 44 void _sync(UINode old, RenderCSSContainer host, RenderCSS insertBefore);
44 45
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 _sync(null, _host, _root); 923 _sync(null, _host, _root);
923 } 924 }
924 } 925 }
925 926
926 class Text extends Component { 927 class Text extends Component {
927 Text(this.data) : super(key: '*text*'); 928 Text(this.data) : super(key: '*text*');
928 final String data; 929 final String data;
929 bool get interchangeable => true; 930 bool get interchangeable => true;
930 UINode build() => new Paragraph(children: [new TextFragment(data)]); 931 UINode build() => new Paragraph(children: [new TextFragment(data)]);
931 } 932 }
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