| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 sky.Element styleNode = sky.document.createElement('style'); | 45 sky.Element styleNode = sky.document.createElement('style'); |
| 46 styleNode.setChild(new sky.Text(".$className { $styles }")); | 46 styleNode.setChild(new sky.Text(".$className { $styles }")); |
| 47 sky.document.appendChild(styleNode); | 47 sky.document.appendChild(styleNode); |
| 48 return new Style._internal(className); | 48 return new Style._internal(className); |
| 49 }); | 49 }); |
| 50 } | 50 } |
| 51 | 51 |
| 52 Style._internal(this._className); | 52 Style._internal(this._className); |
| 53 } | 53 } |
| 54 | 54 |
| 55 abstract class ContentNode extends Node { | |
| 56 Node content; | |
| 57 | |
| 58 ContentNode(Node content) : this.content = content, super(key: content._key); | |
| 59 | |
| 60 void _sync(Node old, sky.ParentNode host, sky.Node insertBefore) { | |
| 61 Node oldContent = old == null ? null : (old as ContentNode).content; | |
| 62 content = _syncChild(content, oldContent, host, insertBefore); | |
| 63 _root = content._root; | |
| 64 } | |
| 65 | |
| 66 void _remove() { | |
| 67 _removeChild(content); | |
| 68 super._remove(); | |
| 69 } | |
| 70 } | |
| 71 | |
| 72 class StyleNode extends ContentNode { | |
| 73 final Style style; | |
| 74 | |
| 75 StyleNode(Node content, this.style): super(content); | |
| 76 } | |
| 77 | |
| 78 void _parentInsertBefore(sky.ParentNode parent, | 55 void _parentInsertBefore(sky.ParentNode parent, |
| 79 sky.Node node, | 56 sky.Node node, |
| 80 sky.Node ref) { | 57 sky.Node ref) { |
| 81 if (ref != null) { | 58 if (ref != null) { |
| 82 ref.insertBefore([node]); | 59 ref.insertBefore([node]); |
| 83 } else { | 60 } else { |
| 84 parent.appendChild(node); | 61 parent.appendChild(node); |
| 85 } | 62 } |
| 86 } | 63 } |
| 87 | 64 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 } | 164 } |
| 188 node._sync(oldNode, host, insertBefore); | 165 node._sync(oldNode, host, insertBefore); |
| 189 if (oldNode != null) | 166 if (oldNode != null) |
| 190 oldNode._defunct = true; | 167 oldNode._defunct = true; |
| 191 | 168 |
| 192 assert(node._root is sky.Node); | 169 assert(node._root is sky.Node); |
| 193 return node; | 170 return node; |
| 194 } | 171 } |
| 195 } | 172 } |
| 196 | 173 |
| 174 abstract class ContentNode extends Node { |
| 175 Node content; |
| 176 |
| 177 ContentNode(Node content) : this.content = content, super(key: content._key); |
| 178 |
| 179 void _sync(Node old, sky.ParentNode host, sky.Node insertBefore) { |
| 180 Node oldContent = old == null ? null : (old as ContentNode).content; |
| 181 content = _syncChild(content, oldContent, host, insertBefore); |
| 182 _root = content._root; |
| 183 } |
| 184 |
| 185 void _remove() { |
| 186 _removeChild(content); |
| 187 super._remove(); |
| 188 } |
| 189 } |
| 190 |
| 191 class StyleNode extends ContentNode { |
| 192 final Style style; |
| 193 |
| 194 StyleNode(Node content, this.style): super(content); |
| 195 } |
| 196 |
| 197 /* | 197 /* |
| 198 * RenderNodes correspond to a desired state of a sky.Node. They are fully | 198 * RenderNodes correspond to a desired state of a sky.Node. They are fully |
| 199 * immutable, with one exception: A Node which is a Component which lives within | 199 * immutable, with one exception: A Node which is a Component which lives within |
| 200 * an Element's children list, may be replaced with the "old" instance if it | 200 * an Element's children list, may be replaced with the "old" instance if it |
| 201 * has become stateful. | 201 * has become stateful. |
| 202 */ | 202 */ |
| 203 abstract class RenderNode extends Node { | 203 abstract class RenderNode extends Node { |
| 204 | 204 |
| 205 static final Map<sky.Node, RenderNode> _nodeMap = | 205 static final Map<sky.Node, RenderNode> _nodeMap = |
| 206 new HashMap<sky.Node, RenderNode>(); | 206 new HashMap<sky.Node, RenderNode>(); |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 | 894 |
| 895 abstract class App extends Component { | 895 abstract class App extends Component { |
| 896 sky.Node _host; | 896 sky.Node _host; |
| 897 | 897 |
| 898 App() : super(stateful: true) { | 898 App() : super(stateful: true) { |
| 899 _host = sky.document.createElement('div'); | 899 _host = sky.document.createElement('div'); |
| 900 sky.document.appendChild(_host); | 900 sky.document.appendChild(_host); |
| 901 _scheduleComponentForRender(this); | 901 _scheduleComponentForRender(this); |
| 902 } | 902 } |
| 903 } | 903 } |
| OLD | NEW |