| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 external void remove(); // O(N) in number of descendants | 80 external void remove(); // O(N) in number of descendants |
| 81 // parentNode must be non-null | 81 // parentNode must be non-null |
| 82 | 82 |
| 83 // called when parentNode changes | 83 // called when parentNode changes |
| 84 // this is why insertBefore(), append(), et al, are O(N) -- the whole affected
subtree is walked | 84 // this is why insertBefore(), append(), et al, are O(N) -- the whole affected
subtree is walked |
| 85 // mutating the element tree from within this is strongly discouraged, since i
t will result in the | 85 // mutating the element tree from within this is strongly discouraged, since i
t will result in the |
| 86 // callbacks being invoked while the element tree is in a different state than
implied by the callbacks | 86 // callbacks being invoked while the element tree is in a different state than
implied by the callbacks |
| 87 external void parentChangeCallback(ParentNode oldParent, ParentNode newParent)
; // O(N) in descendants | 87 external void parentChangedCallback(ParentNode oldParent, ParentNode newParent
); // O(N) in descendants |
| 88 // default implementation calls attached/detached | 88 // default implementation calls attached/detached |
| 89 void attachedCallback() { } | 89 void attachedCallback() { } |
| 90 void detachedCallback() { } | 90 void detachedCallback() { } |
| 91 | 91 |
| 92 external List<ContentElement> getDestinationInsertionPoints(); // O(N) in numb
er of insertion points the node is in | 92 external List<ContentElement> getDestinationInsertionPoints(); // O(N) in numb
er of insertion points the node is in |
| 93 // returns the <content> elements to which this element was distributed | 93 // returns the <content> elements to which this element was distributed |
| 94 | 94 |
| 95 external Node cloneNode({bool deep: false}); // O(1) if deep=false, O(N) in th
e number of descendants if deep=true | 95 external Node cloneNode({bool deep: false}); // O(1) if deep=false, O(N) in th
e number of descendants if deep=true |
| 96 | 96 |
| 97 external ElementStyleDeclarationList get style; // O(1) | 97 external ElementStyleDeclarationList get style; // O(1) |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // calling setAttribute() with a null value removes the attribute | 235 // calling setAttribute() with a null value removes the attribute |
| 236 // (calling it without a value sets it to the empty string) | 236 // (calling it without a value sets it to the empty string) |
| 237 | 237 |
| 238 // Returns a new Array and new Attr instances every time. | 238 // Returns a new Array and new Attr instances every time. |
| 239 external List<Attr> getAttributes(); // O(N) in number of attributes | 239 external List<Attr> getAttributes(); // O(N) in number of attributes |
| 240 | 240 |
| 241 external Root get shadowRoot; // O(1) | 241 external Root get shadowRoot; // O(1) |
| 242 // returns the shadow root | 242 // returns the shadow root |
| 243 | 243 |
| 244 void endTagParsedCallback() { } | 244 void endTagParsedCallback() { } |
| 245 void attributeChangeCallback(String name, String oldValue, String newValue) {
} | 245 void attributeChangedCallback(String name, String oldValue, String newValue) {
} |
| 246 // name will never be null when this is called by sky | 246 // name will never be null when this is called by sky |
| 247 | 247 |
| 248 // TODO(ianh): does a node ever need to know when it's been redistributed? | 248 // TODO(ianh): does a node ever need to know when it's been redistributed? |
| 249 | 249 |
| 250 @override | 250 @override |
| 251 Type getLayoutManager() { // O(1) | 251 Type getLayoutManager() { // O(1) |
| 252 if (renderNode) | 252 if (renderNode) |
| 253 return renderNode.getProperty(phDisplay); | 253 return renderNode.getProperty(phDisplay); |
| 254 return super.getLayoutManager(); | 254 return super.getLayoutManager(); |
| 255 } | 255 } |
| 256 } | 256 } |
| 257 | 257 |
| 258 class Text extends Node { | 258 class Text extends Node { |
| 259 external Text([String value = '']); // O(1) | 259 external Text([String value = '']); // O(1) |
| 260 | 260 |
| 261 external String get value; // O(1) | 261 external String get value; // O(1) |
| 262 external void set (String value); // O(1) | 262 external void set (String value); // O(1) |
| 263 | 263 |
| 264 void valueChangeCallback(String oldValue, String newValue) { } | 264 void valueChangedCallback(String oldValue, String newValue) { } |
| 265 | 265 |
| 266 @override | 266 @override |
| 267 Type getLayoutManager() => TextLayoutManager; // O(1) | 267 Type getLayoutManager() => TextLayoutManager; // O(1) |
| 268 } | 268 } |
| 269 | 269 |
| 270 class Fragment extends ParentNode { | 270 class Fragment extends ParentNode { |
| 271 Fragment({List children}); // O(N) in number of arguments plus all their desce
ndants | 271 Fragment({List children}); // O(N) in number of arguments plus all their desce
ndants |
| 272 // children must be String, Text, or Element | 272 // children must be String, Text, or Element |
| 273 } | 273 } |
| 274 | 274 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 external bool matches(Element element); // O(F()) | 405 external bool matches(Element element); // O(F()) |
| 406 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 | 406 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 |
| 407 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 | 407 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 |
| 408 // find() and findAll() throw if the root is not one of the following: | 408 // find() and findAll() throw if the root is not one of the following: |
| 409 // - Element | 409 // - Element |
| 410 // - Fragment | 410 // - Fragment |
| 411 // - Root | 411 // - Root |
| 412 } | 412 } |
| 413 </script> | 413 </script> |
| 414 ``` | 414 ``` |
| OLD | NEW |