| OLD | NEW |
| 1 Sky DOM APIs | 1 Sky DOM APIs |
| 2 ============ | 2 ============ |
| 3 | 3 |
| 4 ```dart | 4 ```dart |
| 5 SKY MODULE | 5 SKY MODULE |
| 6 <!-- part of dart:sky --> | 6 <!-- part of dart:sky --> |
| 7 | 7 |
| 8 <script> | 8 <script> |
| 9 // ELEMENT TREE API | 9 // ELEMENT TREE API |
| 10 | 10 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 const tagname(this.name); | 190 const tagname(this.name); |
| 191 final String name; | 191 final String name; |
| 192 void init(DeclarationMirror target, Module module) { | 192 void init(DeclarationMirror target, Module module) { |
| 193 assert(target is ClassMirror); | 193 assert(target is ClassMirror); |
| 194 if (!target.isSubclassOf(reflectClass(Element))) | 194 if (!target.isSubclassOf(reflectClass(Element))) |
| 195 throw Error('@tagname can only be used on descendants of Element'); | 195 throw Error('@tagname can only be used on descendants of Element'); |
| 196 module.registerElement(name, (target as ClassMirror).reflectedType); | 196 module.registerElement(name, (target as ClassMirror).reflectedType); |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 | 199 |
| 200 abstract class Element extends ParentNode with Node { | 200 abstract class Element extends ParentNode { |
| 201 external Element({Map<String, String> attributes: null, | 201 external Element({Map<String, String> attributes: null, |
| 202 List children: null, | 202 List children: null, |
| 203 Module hostModule: null}); // O(M+N), M = number of attribute
s, N = number of children nodes plus all their descendants | 203 Module hostModule: null}); // O(M+N), M = number of attribute
s, N = number of children nodes plus all their descendants |
| 204 // initialises the internal attributes table, which is a ordered list | 204 // initialises the internal attributes table, which is a ordered list |
| 205 // appends the given children nodes | 205 // appends the given children nodes |
| 206 // children must be String, Text, or Element | 206 // children must be String, Text, or Element |
| 207 // if this.needsShadow, creates a shadow tree | 207 // if this.needsShadow, creates a shadow tree |
| 208 | 208 |
| 209 String get tagName { // O(N) in number of annotations on the class | 209 String get tagName { // O(N) in number of annotations on the class |
| 210 // throws a StateError if the class doesn't have an @tagname annotation | 210 // throws a StateError if the class doesn't have an @tagname annotation |
| (...skipping 22 matching lines...) Expand all Loading... |
| 233 // TODO(ianh): does a node ever need to know when it's been redistributed? | 233 // TODO(ianh): does a node ever need to know when it's been redistributed? |
| 234 | 234 |
| 235 @override | 235 @override |
| 236 Type getLayoutManager() { // O(1) | 236 Type getLayoutManager() { // O(1) |
| 237 if (renderNode) | 237 if (renderNode) |
| 238 return renderNode.getProperty(phDisplay); | 238 return renderNode.getProperty(phDisplay); |
| 239 return super.getLayoutManager(); | 239 return super.getLayoutManager(); |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 | 242 |
| 243 class Text extends Node with Node { | 243 class Text extends Node { |
| 244 external Text([String value = '']); // O(1) | 244 external Text([String value = '']); // O(1) |
| 245 | 245 |
| 246 external String get value; // O(1) | 246 external String get value; // O(1) |
| 247 external void set (String value); // O(1) | 247 external void set (String value); // O(1) |
| 248 | 248 |
| 249 void valueChangeCallback(String oldValue, String newValue) { } | 249 void valueChangeCallback(String oldValue, String newValue) { } |
| 250 | 250 |
| 251 @override | 251 @override |
| 252 Type getLayoutManager() => TextLayoutManager; // O(1) | 252 Type getLayoutManager() => TextLayoutManager; // O(1) |
| 253 } | 253 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 external bool matches(Element element); // O(F()) | 385 external bool matches(Element element); // O(F()) |
| 386 external Element find(Node root); // O(N*F())+O(M) where N is the number of de
scendants and M the average depth of the tree | 386 external Element find(Node root); // O(N*F())+O(M) where N is the number of de
scendants and M the average depth of the tree |
| 387 external List<Element> findAll(Node root); // O(N*F())+O(N*M) where N is the n
umber of descendants and M the average depth of the tree | 387 external List<Element> findAll(Node root); // O(N*F())+O(N*M) where N is the n
umber of descendants and M the average depth of the tree |
| 388 // find() and findAll() throw if the root is not one of the following: | 388 // find() and findAll() throw if the root is not one of the following: |
| 389 // - Element | 389 // - Element |
| 390 // - Fragment | 390 // - Fragment |
| 391 // - Root | 391 // - Root |
| 392 } | 392 } |
| 393 </script> | 393 </script> |
| 394 ``` | 394 ``` |
| OLD | NEW |