| 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 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 enum _SyncOperation { IDENTICAL, INSERTION, STATEFUL, STATELESS, REMOVAL } | 56 enum _SyncOperation { IDENTICAL, INSERTION, STATEFUL, STATELESS, REMOVAL } |
| 57 | 57 |
| 58 /* | 58 /* |
| 59 * All Effen nodes derive from UINode. All nodes have a _parent, a _key and | 59 * All Effen nodes derive from UINode. All nodes have a _parent, a _key and |
| 60 * can be sync'd. | 60 * can be sync'd. |
| 61 */ | 61 */ |
| 62 abstract class UINode { | 62 abstract class UINode { |
| 63 String _key; | 63 String _key; |
| 64 UINode _parent; | 64 UINode _parent; |
| 65 UINode get parent => _parent; |
| 65 sky.Node _root; | 66 sky.Node _root; |
| 66 bool _defunct = false; | 67 bool _defunct = false; |
| 67 | 68 |
| 68 UINode({ Object key }) { | 69 UINode({ Object key }) { |
| 69 _key = key == null ? "$runtimeType" : "$runtimeType-$key"; | 70 _key = key == null ? "$runtimeType" : "$runtimeType-$key"; |
| 70 } | 71 } |
| 71 | 72 |
| 72 // Subclasses which implements Nodes that become stateful may return true | 73 // Subclasses which implements Nodes that become stateful may return true |
| 73 // if the |old| node has become stateful and should be retained. | 74 // if the |old| node has become stateful and should be retained. |
| 74 bool _willSync(UINode old) => false; | 75 bool _willSync(UINode old) => false; |
| 75 | 76 |
| 76 void _sync(UINode old, sky.ParentNode host, sky.Node insertBefore); | 77 void _sync(UINode old, sky.ParentNode host, sky.Node insertBefore); |
| 77 | 78 |
| 78 void _remove() { | 79 void _remove() { |
| 79 _defunct = true; | 80 _defunct = true; |
| 80 _root = null; | 81 _root = null; |
| 82 handleRemoved(); |
| 81 } | 83 } |
| 84 void handleRemoved() { } |
| 82 | 85 |
| 83 int _nodeDepth; | 86 int _nodeDepth; |
| 84 void _ensureDepth() { | 87 void _ensureDepth() { |
| 85 if (_nodeDepth == null) { | 88 if (_nodeDepth == null) { |
| 86 if (_parent != null) { | 89 if (_parent != null) { |
| 87 _parent._ensureDepth(); | 90 _parent._ensureDepth(); |
| 88 _nodeDepth = _parent._nodeDepth + 1; | 91 _nodeDepth = _parent._nodeDepth + 1; |
| 89 } else { | 92 } else { |
| 90 _nodeDepth = 0; | 93 _nodeDepth = 0; |
| 91 } | 94 } |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 | 928 |
| 926 abstract class App extends Component { | 929 abstract class App extends Component { |
| 927 sky.Node _host; | 930 sky.Node _host; |
| 928 | 931 |
| 929 App() : super(stateful: true) { | 932 App() : super(stateful: true) { |
| 930 _host = sky.document.createElement('div'); | 933 _host = sky.document.createElement('div'); |
| 931 sky.document.appendChild(_host); | 934 sky.document.appendChild(_host); |
| 932 _scheduleComponentForRender(this); | 935 _scheduleComponentForRender(this); |
| 933 } | 936 } |
| 934 } | 937 } |
| OLD | NEW |