| OLD | NEW | 
|---|
| 1 Sky DOM APIs | 1 Sky DOM APIs | 
| 2 ============ | 2 ============ | 
| 3 | 3 | 
| 4 ```dart | 4 ```dart | 
| 5 abstract class ChildNode { } | 5 // ELEMENT TREE API | 
| 6 | 6 | 
| 7 abstract class Node extends EventTarget { | 7 abstract class ChildNode { | 
| 8   external TreeScope get ownerScope; // O(1) // never null | 8   @nonnull external TreeScope get ownerScope; // O(1) | 
| 9 | 9 | 
| 10   external ParentNode get parentNode; // O(1) | 10   external ParentNode get parentNode; // O(1) | 
| 11   external Element get parentElement; // O(1) // if parentNode isn't an element,
      returns null | 11   external Element get parentElement; // O(1) // if parentNode isn't an element,
      returns null | 
| 12   external ChildNode get previousSibling; // O(1) | 12   external ChildNode get previousSibling; // O(1) | 
| 13   external ChildNode get nextSibling; // O(1) | 13   external ChildNode get nextSibling; // O(1) | 
| 14 | 14 | 
| 15   @override |  | 
| 16   external List</*@nonnull*/ EventTarget> getEventDispatchChain(); // O(N) in nu
     mber of ancestors across shadow trees |  | 
| 17   // implements EventTarget.getEventDispatchChain() |  | 
| 18   // returns the event dispatch chain (including handling shadow trees) |  | 
| 19 |  | 
| 20   // the following all throw if parentNode is null | 15   // the following all throw if parentNode is null | 
| 21   external void insertBefore(List</*@nonnull*/ ChildNode> nodes); // O(N) in num
     ber of arguments plus all their descendants | 16   external void insertBefore(@nonnull List</*@nonnull*/ ChildNode> nodes); // O(
     N) in number of arguments plus all their descendants | 
| 22   external void insertAfter(List</*@nonnull*/ ChildNode> nodes); // O(N) in numb
     er of arguments plus all their descendants | 17   external void insertAfter(@nonnull List</*@nonnull*/ ChildNode> nodes); // O(N
     ) in number of arguments plus all their descendants | 
| 23   external void replaceWith(List</*@nonnull*/ ChildNode> nodes); // O(N) in numb
     er of descendants plus arguments plus all their descendants | 18   external void replaceWith(@nonnull List</*@nonnull*/ ChildNode> nodes); // O(N
     ) in number of descendants plus arguments plus all their descendants | 
| 24   external void remove(); // O(N) in number of descendants | 19   external void remove(); // O(N) in number of descendants | 
| 25   external Node cloneNode({bool deep: false}); // O(1) if deep=false, O(N) in th
     e number of descendants if deep=true |  | 
| 26 | 20 | 
| 27   // called when parentNode changes | 21   // called when parentNode changes | 
| 28   external void parentChangeCallback(ParentNode oldParent, ParentNode newParent,
      ChildNode previousSibling, ChildNode nextSibling); // O(N) in descendants | 22   external void parentChangeCallback(ParentNode oldParent, ParentNode newParent,
      ChildNode previousSibling, ChildNode nextSibling); // O(N) in descendants | 
| 29   // default implementation calls attached/detached | 23   // default implementation calls attached/detached | 
| 30   void attachedCallback() { } | 24   void attachedCallback() { } | 
| 31   void detachedCallback() { } | 25   void detachedCallback() { } | 
| 32 | 26 | 
| 33   external List<ContentElement> getDestinationInsertionPoints(); // O(N) in numb
     er of insertion points the node is in | 27   external List<ContentElement> getDestinationInsertionPoints(); // O(N) in numb
     er of insertion points the node is in | 
| 34   // returns the <content> elements to which this element was distributed | 28   // returns the <content> elements to which this element was distributed | 
|  | 29 } | 
|  | 30 | 
|  | 31 abstract class Node extends EventTarget { | 
|  | 32   @override | 
|  | 33   external List</*@nonnull*/ EventTarget> getEventDispatchChain(); // O(N) in nu
     mber of ancestors across shadow trees | 
|  | 34   // implements EventTarget.getEventDispatchChain() | 
|  | 35   // returns the event dispatch chain (including handling shadow trees) | 
|  | 36 | 
|  | 37   external Node cloneNode({bool deep: false}); // O(1) if deep=false, O(N) in th
     e number of descendants if deep=true | 
| 35 | 38 | 
| 36   external ElementStyleDeclarationList get style; // O(1) | 39   external ElementStyleDeclarationList get style; // O(1) | 
| 37   // for nodes that aren't reachable from the Application Document, returns null | 40   // for nodes that aren't reachable from the Application Document, returns null | 
| 38   // (so in particular orphaned subtrees and nodes in module documents don't hav
     e one) | 41   // (so in particular orphaned subtrees and nodes in module documents don't hav
     e one) | 
| 39   //  -- should be updated when the node's parent chain changes (same time as, e
     .g., | 42   //  -- should be updated when the node's parent chain changes (same time as, e
     .g., | 
| 40   //     the id hashtable is updated) | 43   //     the id hashtable is updated) | 
| 41   // also always returns null for ContentElement elements and ShadowRoot nodes | 44   // also always returns null for ContentElement elements and ShadowRoot nodes | 
| 42 | 45 | 
| 43   external RenderNode get renderNode; // O(1) | 46   external RenderNode get renderNode; // O(1) | 
| 44   // this will be null until the first time it is rendered | 47   // this will be null until the first time it is rendered | 
| 45   // it becomes null again when it is taken out of the rendering (see style.md) | 48   // it becomes null again when it is taken out of the rendering (see style.md) | 
| 46 | 49 | 
| 47   LayoutManagerConstructor getLayoutManager(); // O(1) | 50   Type getLayoutManager() => null; // O(1) | 
| 48 | 51 | 
| 49   void resetLayoutManager() { // O(1) | 52   void resetLayoutManager() { // O(1) | 
| 50     if (renderNode != null) { | 53     if (renderNode != null) { | 
| 51       renderNode._layoutManager = null; | 54       renderNode._layoutManager = null; | 
| 52       renderNode._needsManager = true; | 55       renderNode._needsManager = true; | 
| 53     } | 56     } | 
| 54   } | 57   } | 
| 55 } | 58 } | 
| 56 | 59 | 
| 57 abstract class ParentNode extends Node { | 60 abstract class ParentNode extends Node { | 
| 58   external ChildNode get firstChild; // O(1) | 61   external ChildNode get firstChild; // O(1) | 
| 59   external ChildNode get lastChild; // O(1) | 62   external ChildNode get lastChild; // O(1) | 
| 60 | 63 | 
| 61   // Returns a new List every time. | 64   // Returns a new List every time. | 
| 62   external List<ChildNode> getChildNodes(); // O(N) in number of child nodes | 65   external List</*nonnull*/ ChildNode> getChildNodes(); // O(N) in number of chi
     ld nodes | 
| 63   external List<Element> getChildElements(); // O(N) in number of child nodes | 66   external List<Element> getChildElements(); // O(N) in number of child nodes | 
| 64   // TODO(ianh): might not be necessary if we have the parser drop unnecessary w
     hitespace text nodes | 67   // TODO(ianh): might not be necessary if we have the parser drop unnecessary w
     hitespace text nodes | 
| 65 | 68 | 
| 66   external void append(List<ChildNode> nodes); // O(N) in number of arguments pl
     us all their descendants | 69   external void append(@nonnull List</*nonnull*/ ChildNode> nodes); // O(N) in n
     umber of arguments plus all their descendants | 
| 67   external void prepend(List<ChildNode> nodes); // O(N) in number of arguments p
     lus all their descendants | 70   external void prepend(@nonnull List</*nonnull*/ ChildNode> nodes); // O(N) in 
     number of arguments plus all their descendants | 
| 68   external void replaceChildrenWith(List<ChildNode> nodes); // O(N) in number of
      descendants plus arguments plus all their descendants | 71   external void replaceChildrenWith(@nonnull List</*nonnull*/ ChildNode> nodes);
      // O(N) in number of descendants plus arguments plus all their descendants | 
| 69 } | 72 } | 
| 70 | 73 | 
| 71 class Attr { | 74 class Attr { | 
| 72   const Attr (this.name, [this.value = '']); // O(1) | 75   const Attr (this.name, [this.value = '']); // O(1) | 
| 73   final String name; // O(1) | 76   final String name; // O(1) | 
| 74   final String value; // O(1) | 77   final String value; // O(1) | 
| 75 } | 78 } | 
| 76 | 79 | 
| 77 abstract class Element extends ParentNode { | 80 // @tagname annotation for registering elements | 
| 78   final String tagName; // O(1) | 81 // only useful when placed on classes that inherit from Element | 
|  | 82 class tagname { | 
|  | 83   const tagname(this.value); | 
|  | 84   @nonnull final String value; | 
|  | 85 } | 
| 79 | 86 | 
| 80   external bool hasAttribute(@nonnull String name); // O(N) in number of attribu
     tes | 87 abstract class FindRoot { } | 
| 81   external String getAttribute(@nonnull String name); // O(N) in number of attri
     butes | 88 | 
|  | 89 abstract class Element extends ParentNode with ChildNode implements FindRoot { | 
|  | 90   Element({Map</*@nonnull*/ String, /*@nonnull*/ String> attributes: null, | 
|  | 91            List</*nonnull*/ ChildNode> nodes: null}); // O(M+N), M = number of a
     ttributes, N = number of nodes plus all their descendants | 
|  | 92 | 
|  | 93   @nonnull String get tagName { // O(N) in number of annotations on the class | 
|  | 94     // throws a StateError if the class doesn't have an @tagname annotation | 
|  | 95     var tagnameClass = reflectClass(tagname); | 
|  | 96     return (reflectClass(this.runtimeType).metadata.singleWhere((mirror) => mirr
     or.type == tagnameClass).reflectee as tagname).value; | 
|  | 97   } | 
|  | 98 | 
|  | 99   @nonnull external bool hasAttribute(@nonnull String name); // O(N) in number o
     f attributes | 
|  | 100   @nonnull external String getAttribute(@nonnull String name); // O(N) in number
      of attributes | 
| 82   external void setAttribute(@nonnull String name, [@nonnull String value = ''])
     ; // O(N) in number of attributes | 101   external void setAttribute(@nonnull String name, [@nonnull String value = ''])
     ; // O(N) in number of attributes | 
| 83   external void removeAttribute(@nonnull String name); // O(N) in number of attr
     ibutes | 102   external void removeAttribute(@nonnull String name); // O(N) in number of attr
     ibutes | 
| 84 | 103 | 
| 85   // Returns a new Array and new Attr instances every time. | 104   // Returns a new Array and new Attr instances every time. | 
| 86   List<Attr> getAttributes(); // O(N) in number of attributes | 105   @nonnull external List<Attr> getAttributes(); // O(N) in number of attributes | 
| 87 | 106 | 
| 88   external ShadowRoot get shadowRoot; // O(1) | 107   external ShadowRoot get shadowRoot; // O(1) | 
| 89   // returns the shadow root | 108   // returns the shadow root | 
| 90   // TODO(ianh): Should this be mutable? It would help explain how it gets set..
     . | 109   // TODO(ianh): Should this be mutable? It would help explain how it gets set..
     . | 
| 91 | 110 | 
| 92   void endTagParsedCallback() { } | 111   void endTagParsedCallback() { } | 
| 93   void attributeChangeCallback(String name, String oldValue, String newValue) { 
     } | 112   void attributeChangeCallback(String name, String oldValue, String newValue) { 
     } | 
| 94   // name will never be null when this is called by sky | 113   // name will never be null when this is called by sky | 
| 95 | 114 | 
| 96   // TODO(ianh): does a node ever need to know when it's been redistributed? | 115   // TODO(ianh): does a node ever need to know when it's been redistributed? | 
| 97 | 116 | 
| 98   @override | 117   @override | 
| 99   LayoutManagerConstructor getLayoutManager() { // O(1) | 118   Type getLayoutManager() { // O(1) | 
| 100     if (renderNode) | 119     if (renderNode) | 
| 101       return renderNode.getProperty(phDisplay); | 120       return renderNode.getProperty(phDisplay); | 
| 102     return super.getLayoutManager(); | 121     return super.getLayoutManager(); | 
| 103   } | 122   } | 
| 104 } | 123 } | 
| 105 | 124 | 
| 106 class Text extends Node { | 125 class Text extends Node with ChildNode { | 
| 107   external Text([String value = '']); // O(1) | 126   external Text([@nonnull String value = '']); // O(1) | 
| 108   // throws if value is null |  | 
| 109 | 127 | 
| 110   external String get value; // O(1) | 128   @nonnull external String get value; // O(1) | 
|  | 129   external void set (@nonnull String value); // O(1) | 
| 111 | 130 | 
| 112   void valueChangeCallback(String oldValue, String newValue) { } | 131   void valueChangeCallback(@nonnull String oldValue, @nonnull String newValue) {
      } | 
| 113 | 132 | 
| 114   @override | 133   @override | 
| 115   LayoutManagerConstructor getLayoutManager() { // O(1) | 134   Type getLayoutManager() => TextLayoutManager; // O(1) | 
| 116     return TextLayoutManager; |  | 
| 117   } |  | 
| 118 } | 135 } | 
| 119 | 136 | 
| 120 class DocumentFragment extends ParentNode { | 137 class DocumentFragment extends ParentNode implements FindRoot { | 
| 121   DocumentFragment([List<ChildNode> nodes = null]); // O(N) in number of argumen
     ts plus all their descendants | 138   DocumentFragment([List</*nonnull*/ ChildNode> nodes = null]); // O(N) in numbe
     r of arguments plus all their descendants | 
| 122 } | 139 } | 
| 123 | 140 | 
| 124 abstract class TreeScope extends ParentNode { | 141 abstract class TreeScope extends ParentNode { | 
| 125   external Document get ownerDocument; // O(1) | 142   external Document get ownerDocument; // O(1) | 
| 126   external TreeScope get parentScope; // O(1) | 143   external TreeScope get parentScope; // O(1) | 
| 127 | 144 | 
| 128   external Element findId(String id); // O(1) | 145   external Element findId(String id); // O(1) | 
| 129   // throws if id is null | 146   // throws if id is null | 
| 130 } | 147 } | 
| 131 | 148 | 
| 132 class ShadowRoot extends TreeScope { | 149 class ShadowRoot extends TreeScope implements FindRoot { | 
| 133   ShadowRoot([this._host]); // O(1) | 150   ShadowRoot([this._host]); // O(1) | 
| 134   // note that there is no way in the API to use a newly created ShadowRoot curr
     ently | 151   // note that there is no way in the API to use a newly created ShadowRoot curr
     ently | 
| 135 | 152 | 
| 136   Element _host; | 153   Element _host; | 
| 137   Element get host => _host; // O(1) | 154   Element get host => _host; // O(1) | 
| 138 } | 155 } | 
| 139 | 156 | 
| 140 // DARTIFICATION INCOMPLETE PAST THIS POINT | 157 class Document extends TreeScope implements FindRoot { | 
| 141 | 158   external Document ([List</*@nonnull*/ ChildNode> nodes = null]); // O(N) in nu
     mber of arguments plus all their descendants | 
| 142 class Document extends TreeScope { |  | 
| 143   constructor (ChildArguments... nodes); // O(N) in number of arguments plus all
      their descendants |  | 
| 144 } | 159 } | 
| 145 | 160 | 
| 146 class ApplicationDocument extends Document { | 161 class ApplicationDocument extends Document { | 
| 147   constructor (ChildArguments... nodes); // O(N) in number of /nodes/ arguments 
     plus all their descendants | 162   external ApplicationDocument ([List</*@nonnull*/ ChildNode> nodes = null]); //
      O(N) in number of /nodes/ arguments plus all their descendants | 
| 148 | 163 | 
| 149   virtual LayoutManagerConstructor getLayoutManager(); // O(1) | 164   @override | 
| 150     // returns sky.rootLayoutManager; | 165   Type getLayoutManager() => rootLayoutManager; // O(1) | 
| 151 } | 166 } | 
| 152 | 167 | 
| 153 attribute LayoutManagerConstructor rootLayoutManager; // O(1) | 168 Type rootLayoutManager = BlockLayoutManager; // O(1) | 
| 154   // initially configured to return BlockLayoutManager |  | 
| 155 | 169 | 
| 156 | 170 | 
| 157 // BUILT-IN ELEMENTS | 171 // BUILT-IN ELEMENTS | 
| 158 | 172 | 
|  | 173 @tagname('import') | 
| 159 class ImportElement extends Element { | 174 class ImportElement extends Element { | 
| 160   constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N
     ), M = number of attributes, N = number of nodes plus all their descendants | 175   //XXX ImportElement = Element; | 
| 161   constructor (ChildArguments... nodes); // shorthand |  | 
| 162   constructor (Dictionary<String> attributes); // shorthand |  | 
| 163   constructor (); // shorthand |  | 
| 164   constructor attribute String tagName; // O(1) // "import" |  | 
| 165   constructor attribute Boolean shadow; // O(1) // false |  | 
| 166 | 176 | 
| 167   virtual LayoutManagerConstructor getLayoutManager(); // O(1) | 177   @override | 
| 168     // returns null | 178   Type getLayoutManager() => null; // O(1) | 
| 169 } |  | 
| 170 class TemplateElement extends Element { |  | 
| 171   constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N
     ), M = number of attributes, N = number of nodes plus all their descendants |  | 
| 172   constructor (ChildArguments... nodes); // shorthand |  | 
| 173   constructor (Dictionary<String> attributes); // shorthand |  | 
| 174   constructor (); // shorthand |  | 
| 175   constructor attribute String tagName; // O(1) // "template" |  | 
| 176   constructor attribute Boolean shadow; // O(1) // false |  | 
| 177 |  | 
| 178   readonly attribute DocumentFragment content; // O(1) |  | 
| 179   virtual LayoutManagerConstructor getLayoutManager(); // O(1) |  | 
| 180     // returns null |  | 
| 181 } |  | 
| 182 class ScriptElement extends Element { |  | 
| 183   constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N
     ), M = number of attributes, N = number of nodes plus all their descendants |  | 
| 184   constructor (ChildArguments... nodes); // shorthand |  | 
| 185   constructor (Dictionary<String> attributes); // shorthand |  | 
| 186   constructor (); // shorthand |  | 
| 187   constructor attribute String tagName; // O(1) // "script" |  | 
| 188   constructor attribute Boolean shadow; // O(1) // false |  | 
| 189 |  | 
| 190   virtual LayoutManagerConstructor getLayoutManager(); // O(1) |  | 
| 191     // returns null |  | 
| 192 } |  | 
| 193 class StyleElement extends Element { |  | 
| 194   constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N
     ), M = number of attributes, N = number of nodes plus all their descendants |  | 
| 195   constructor (ChildArguments... nodes); // shorthand |  | 
| 196   constructor (Dictionary<String> attributes); // shorthand |  | 
| 197   constructor (); // shorthand |  | 
| 198   constructor attribute String tagName; // O(1) // "style" |  | 
| 199   constructor attribute Boolean shadow; // O(1) // false |  | 
| 200 |  | 
| 201   Array<Rule> getRules(); // O(N) in rules |  | 
| 202   virtual LayoutManagerConstructor getLayoutManager(); // O(1) |  | 
| 203     // returns null |  | 
| 204 } |  | 
| 205 class ContentElement extends Element { |  | 
| 206   constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N
     ), M = number of attributes, N = number of nodes plus all their descendants |  | 
| 207   constructor (ChildArguments... nodes); // shorthand |  | 
| 208   constructor (Dictionary<String> attributes); // shorthand |  | 
| 209   constructor (); // shorthand |  | 
| 210   constructor attribute String tagName; // O(1) // "content" |  | 
| 211   constructor attribute Boolean shadow; // O(1) // false |  | 
| 212 |  | 
| 213   Array<Node> getDistributedNodes(); // O(N) in distributed nodes |  | 
| 214   virtual LayoutManagerConstructor getLayoutManager(); // O(1) |  | 
| 215     // returns null |  | 
| 216 } |  | 
| 217 class ImgElement extends Element { |  | 
| 218   constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N
     ), M = number of attributes, N = number of nodes plus all their descendants |  | 
| 219   constructor (ChildArguments... nodes); // shorthand |  | 
| 220   constructor (Dictionary<String> attributes); // shorthand |  | 
| 221   constructor (); // shorthand |  | 
| 222   constructor attribute String tagName; // O(1) // "img" |  | 
| 223   constructor attribute Boolean shadow; // O(1) // false |  | 
| 224 |  | 
| 225   virtual LayoutManagerConstructor getLayoutManager(); // O(1) |  | 
| 226     // returns ImgElementLayoutManager |  | 
| 227 } |  | 
| 228 class DivElement extends Element { |  | 
| 229   constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N
     ), M = number of attributes, N = number of nodes plus all their descendants |  | 
| 230   constructor (ChildArguments... nodes); // shorthand |  | 
| 231   constructor (Dictionary<String> attributes); // shorthand |  | 
| 232   constructor (); // shorthand |  | 
| 233   constructor attribute String tagName; // O(1) // "div" |  | 
| 234   constructor attribute Boolean shadow; // O(1) // false |  | 
| 235 } |  | 
| 236 class SpanElement extends Element { |  | 
| 237   constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N
     ), M = number of attributes, N = number of nodes plus all their descendants |  | 
| 238   constructor (ChildArguments... nodes); // shorthand |  | 
| 239   constructor (Dictionary<String> attributes); // shorthand |  | 
| 240   constructor (); // shorthand |  | 
| 241   constructor attribute String tagName; // O(1) // "span" |  | 
| 242   constructor attribute Boolean shadow; // O(1) // false |  | 
| 243 } |  | 
| 244 class IframeElement extends Element { |  | 
| 245   constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N
     ), M = number of attributes, N = number of nodes plus all their descendants |  | 
| 246   constructor (ChildArguments... nodes); // shorthand |  | 
| 247   constructor (Dictionary<String> attributes); // shorthand |  | 
| 248   constructor (); // shorthand |  | 
| 249   constructor attribute String tagName; // O(1) // "iframe" |  | 
| 250   constructor attribute Boolean shadow; // O(1) // false |  | 
| 251 |  | 
| 252   virtual LayoutManagerConstructor getLayoutManager(); // O(1) |  | 
| 253     // returns IframeElementLayoutManager |  | 
| 254 } |  | 
| 255 class TElement extends Element { |  | 
| 256   constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N
     ), M = number of attributes, N = number of nodes plus all their descendants |  | 
| 257   constructor (ChildArguments... nodes); // shorthand |  | 
| 258   constructor (Dictionary<String> attributes); // shorthand |  | 
| 259   constructor (); // shorthand |  | 
| 260   constructor attribute String tagName; // O(1) // "t" |  | 
| 261   constructor attribute Boolean shadow; // O(1) // false |  | 
| 262 } |  | 
| 263 class AElement extends Element { |  | 
| 264   constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N
     ), M = number of attributes, N = number of nodes plus all their descendants |  | 
| 265   constructor (ChildArguments... nodes); // shorthand |  | 
| 266   constructor (Dictionary<String> attributes); // shorthand |  | 
| 267   constructor (); // shorthand |  | 
| 268   constructor attribute String tagName; // O(1) // "a" |  | 
| 269   constructor attribute Boolean shadow; // O(1) // false |  | 
| 270 } |  | 
| 271 class TitleElement extends Element { |  | 
| 272   constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N
     ), M = number of attributes, N = number of nodes plus all their descendants |  | 
| 273   constructor (ChildArguments... nodes); // shorthand |  | 
| 274   constructor (Dictionary<String> attributes); // shorthand |  | 
| 275   constructor (); // shorthand |  | 
| 276   constructor attribute String tagName; // O(1) // "title" |  | 
| 277   constructor attribute Boolean shadow; // O(1) // false |  | 
| 278 |  | 
| 279   virtual LayoutManagerConstructor getLayoutManager(); // O(1) |  | 
| 280     // returns null |  | 
| 281 } |  | 
| 282 class ErrorElement extends Element { |  | 
| 283   constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N
     ), M = number of attributes, N = number of nodes plus all their descendants |  | 
| 284   constructor (ChildArguments... nodes); // shorthand |  | 
| 285   constructor (Dictionary<String> attributes); // shorthand |  | 
| 286   constructor (); // shorthand |  | 
| 287   constructor attribute String tagName; // O(1) // "error" |  | 
| 288   constructor attribute Boolean shadow; // O(1) // false |  | 
| 289 |  | 
| 290   virtual LayoutManagerConstructor getLayoutManager(); // O(1) |  | 
| 291     // returns ErrorElementLayoutManager |  | 
| 292 } | 179 } | 
| 293 | 180 | 
| 294 interface ElementConstructor { | 181 @tagname('template') | 
| 295   constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N
     ), M = number of attributes, N = number of nodes plus all their descendants | 182 class TemplateElement extends Element { | 
| 296   constructor (ChildArguments... nodes); // shorthand | 183   //XXX TemplateElement = Element; | 
| 297   constructor (Dictionary<String> attributes); // shorthand |  | 
| 298   constructor (); // shorthand |  | 
| 299 | 184 | 
| 300   constructor attribute String tagName; | 185   // TODO(ianh): convert <template> to using a token stream instead of a Documen
     tFragment | 
| 301   constructor attribute Boolean shadow; | 186 | 
|  | 187   @nonnull external DocumentFragment get content; // O(1) | 
|  | 188 | 
|  | 189   @override | 
|  | 190   Type getLayoutManager() => null; // O(1) | 
|  | 191 } | 
|  | 192 | 
|  | 193 @tagname('script') | 
|  | 194 class ScriptElement extends Element { | 
|  | 195   //XXX ScriptElement = Element; | 
|  | 196 | 
|  | 197   @override | 
|  | 198   Type getLayoutManager() => null; // O(1) | 
|  | 199 } | 
|  | 200 | 
|  | 201 @tagname('style') | 
|  | 202 class StyleElement extends Element { | 
|  | 203   //XXX StyleElement = Element; | 
|  | 204 | 
|  | 205   @nonnull external List</*@nonnull*/ Rule> getRules(); // O(N) in rules | 
|  | 206 | 
|  | 207   @override | 
|  | 208   Type getLayoutManager() => null; // O(1) | 
|  | 209 } | 
|  | 210 | 
|  | 211 @tagname('content') | 
|  | 212 class ContentElement extends Element { | 
|  | 213   //XXX ContentElement = Element; | 
|  | 214 | 
|  | 215   @nonnull external List</*@nonnull*/ Node> getDistributedNodes(); // O(N) in di
     stributed nodes | 
|  | 216 | 
|  | 217   @override | 
|  | 218   Type getLayoutManager() => null; // O(1) | 
|  | 219 } | 
|  | 220 | 
|  | 221 @tagname('img') | 
|  | 222 class ImgElement extends Element { | 
|  | 223   //XXX ImgElement = Element; | 
|  | 224 | 
|  | 225   @override | 
|  | 226   Type getLayoutManager() => ImgElementLayoutManager; // O(1) | 
|  | 227 } | 
|  | 228 | 
|  | 229 @tagname('div') | 
|  | 230 class DivElement extends Element { | 
|  | 231   //XXX DivElement = Element; | 
|  | 232 } | 
|  | 233 | 
|  | 234 @tagname('span') | 
|  | 235 class SpanElement extends Element { | 
|  | 236   //XXX SpanElement = Element; | 
|  | 237 } | 
|  | 238 | 
|  | 239 @tagname('iframe') | 
|  | 240 class IframeElement extends Element { | 
|  | 241   //XXX IframeElement = Element; | 
|  | 242 | 
|  | 243   @override | 
|  | 244   Type getLayoutManager() => IframeElementLayoutManager; // O(1) | 
|  | 245 } | 
|  | 246 | 
|  | 247 @tagname('t') | 
|  | 248 class TElement extends Element { | 
|  | 249   //XXX TElement = Element; | 
|  | 250 } | 
|  | 251 | 
|  | 252 @tagname('a') | 
|  | 253 class AElement extends Element { | 
|  | 254   //XXX AElement = Element; | 
|  | 255 } | 
|  | 256 | 
|  | 257 @tagname('title') | 
|  | 258 class TitleElement extends Element { | 
|  | 259   //XXX TitleElement = Element; | 
|  | 260 | 
|  | 261   @override | 
|  | 262   Type getLayoutManager() => null; // O(1) | 
|  | 263 } | 
|  | 264 | 
|  | 265 class ErrorElement extends Element { | 
|  | 266   ErrorElement._create(); | 
|  | 267 | 
|  | 268   @override | 
|  | 269   Type getLayoutManager() => ErrorElementLayoutManager; // O(1) | 
| 302 } | 270 } | 
| 303 | 271 | 
| 304 class SelectorQuery { | 272 class SelectorQuery { | 
| 305   constructor (String selector); // O(F()) where F() is the complexity of the se
     lector | 273   external SelectorQuery(@nonnull String selector); // O(F()) where F() is the c
     omplexity of the selector | 
| 306 | 274 | 
| 307   Boolean matches(Element element); // O(F()) | 275   @nonnull external bool matches(@nonnull Element element); // O(F()) | 
| 308   Element? find(Element root); // O(N*F())+O(M) where N is the number of descend
     ants and M the average depth of the tree | 276   external Element find(@nonnull FindRoot root); // O(N*F())+O(M) where N is the
      number of descendants and M the average depth of the tree | 
| 309   Element? find(DocumentFragment root); // O(N*F())+O(M) where N is the number o
     f descendants and M the average depth of the tree | 277   @nonnull external List</*@nonnull*/ Element> findAll(FindRoot root); // O(N*F(
     ))+O(N*M) where N is the number of descendants and M the average depth of the tr
     ee | 
| 310   Element? find(TreeScope root); // O(N*F()) where N is the number of descendant
     s |  | 
| 311   Array<Element> findAll(Element root); // O(N*F())+O(N*M) where N is the number
      of descendants and M the average depth of the tree |  | 
| 312   Array<Element> findAll(DocumentFragment root); // O(N*F())+O(N*M) where N is t
     he number of descendants and M the average depth of the tree |  | 
| 313   Array<Element> findAll(TreeScope root); // O(N*F()) where N is the number of d
     escendants |  | 
| 314 |  | 
| 315 } | 278 } | 
| 316 ``` | 279 ``` | 
| OLD | NEW | 
|---|