Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: sky/specs/dom.md

Issue 824773002: Specs: Split apis.md into dom.md, events.md, idl.md, and move the remainder into README.md and modu… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/specs/apis.md ('k') | sky/specs/events.md » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 Sky DOM APIs
2 ============
3
4 ```javascript
5
6 // DOM
7
8 typedef ChildNode (Element or Text);
9 typedef ChildArgument (Element or Text or String);
10
11 abstract class Node : EventTarget { // implemented in C++
12 readonly attribute TreeScope? ownerScope; // O(1)
13
14 readonly attribute ParentNode? parentNode; // O(1)
15 readonly attribute Element? parentElement; // O(1) // if parentNode isn't an e lement, returns null
16 readonly attribute ChildNode? previousSibling; // O(1)
17 readonly attribute ChildNode? nextSibling; // O(1)
18
19 virtual Array<EventTarget> getEventDispatchChain(); // O(N) in number of ances tors across shadow trees // implements EventTarget.getEventDispatchChain()
20 // returns the event dispatch chain (including handling shadow trees)
21
22 // the following all throw if parentNode is null
23 void insertBefore(ChildArgument... nodes); // O(N) in number of arguments plus all their descendants
24 void insertAfter(ChildArgument... nodes); // O(N) in number of arguments plus all their descendants
25 void replaceWith(ChildArgument... nodes); // O(N) in number of descendants plu s arguments plus all their descendants
26 void remove(); // O(N) in number of descendants
27 Node cloneNode(Boolean deep = false); // O(1) if deep=false, O(N) in the numbe r of descendants if deep=true
28
29 // called when parentNode changes
30 virtual void parentChangeCallback(ParentNode? oldParent, ParentNode? newParent , ChildNode? previousSibling, ChildNode? nextSibling); // O(N) in descendants (c alls attached/detached)
31 virtual void attachedCallback(); // noop
32 virtual void detachedCallback(); // noop
33 }
34
35 abstract class ParentNode : Node {
36 readonly attribute ChildNode? firstChild; // O(1)
37 readonly attribute ChildNode? lastChild; // O(1)
38
39 // Returns a new Array every time.
40 Array<ChildNode> getChildNodes(); // O(N) in number of child nodes
41 Array<Element> getChildElements(); // O(N) in number of child nodes // TODO(ia nh): might not be necessary if we have the parser drop unnecessary whitespace te xt nodes
42
43 void append(ChildArgument... nodes); // O(N) in number of arguments plus all t heir descendants
44 void prepend(ChildArgument... nodes); // O(N) in number of arguments plus all their descendants
45 void replaceChildrenWith(ChildArgument... nodes); // O(N) in number of descend ants plus arguments plus all their descendants
46 }
47
48 class Attr {
49 constructor (String name, String value = ''); // O(1)
50 readonly attribute String name; // O(1)
51 readonly attribute String value; // O(1)
52 }
53
54 abstract class Element : ParentNode {
55 readonly attribute String tagName; // O(1)
56
57 Boolean hasAttribute(String name); // O(N) in number of attributes
58 String getAttribute(String name); // O(N) in number of attributes
59 void setAttribute(String name, String value = ''); // O(N) in number of attrib utes
60 void removeAttribute(String name); // O(N) in number of attributes
61
62 // Returns a new Array and new Attr instances every time.
63 Array<Attr> getAttributes(); // O(N) in number of attributes
64
65 readonly attribute ShadowRoot? shadowRoot; // O(1) // returns the shadow root
66 Array<ContentElement> getDestinationInsertionPoints(); // O(N) in number of in sertion points the node is in
67
68 virtual void endTagParsedCallback(); // noop
69 virtual void attributeChangeCallback(String name, String? oldValue, String? ne wValue); // noop
70 // TODO(ianh): does a node ever need to know when it's been redistributed?
71
72 readonly attribute ElementStyleDeclarationList style; // O(1)
73 readonly attribute RenderNode? renderNode; // O(1)
74 // this will be null until the first time it is rendered
75 virtual LayoutManagerConstructor getLayoutManager(); // O(1)
76 // default implementation looks up the 'display' property and returns the va lue:
77 // if (renderNode)
78 // return renderNode.getProperty(phDisplay);
79 // return null;
80 void resetLayoutManager(); // O(1)
81 // if renderNode is non-null:
82 // sets renderNode.layoutManager to null
83 // sets renderNode.needsManager to true
84 }
85
86 class Text : Node {
87 constructor (String value = ''); // O(1)
88 attribute String value; // O(1)
89
90 void replaceWith(String node); // O(1) // special case override of Node.replac eWith()
91
92 virtual void valueChangeCallback(String? oldValue, String? newValue); // noop
93 }
94
95 class DocumentFragment : ParentNode {
96 constructor (ChildArguments... nodes); // O(N) in number of arguments plus all their descendants
97 }
98
99 abstract class TreeScope : ParentNode {
100 readonly attribute Document? ownerDocument; // O(1)
101 readonly attribute TreeScope? parentScope; // O(1)
102
103 Element? findId(String id); // O(1)
104 }
105
106 class ShadowRoot : TreeScope {
107 constructor (Element host); // O(1) // note that there is no way in the API to use a newly created ShadowRoot
108 readonly attribute Element host; // O(1)
109 }
110
111 class Document : TreeScope {
112 constructor (ChildArguments... nodes); // O(N) in number of arguments plus all their descendants
113 }
114
115 class SelectorQuery {
116 constructor (String selector); // O(F()) where F() is the complexity of the se lector
117
118 Boolean matches(Element element); // O(F())
119 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
120 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
121 Element? find(TreeScope root); // O(N*F()) where N is the number of descendant s
122 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
123 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
124 Array<Element> findAll(TreeScope root); // O(N*F()) where N is the number of d escendants
125 }
126
127
128 // BUILT-IN ELEMENTS
129
130 class ImportElement : Element {
131 constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N ), M = number of attributes, N = number of nodes plus all their descendants
132 constructor (ChildArguments... nodes); // shorthand
133 constructor (Dictionary<String> attributes); // shorthand
134 constructor (); // shorthand
135 constructor attribute String tagName; // O(1) // "import"
136 constructor attribute Boolean shadow; // O(1) // false
137 }
138 class TemplateElement : Element {
139 constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N ), M = number of attributes, N = number of nodes plus all their descendants
140 constructor (ChildArguments... nodes); // shorthand
141 constructor (Dictionary<String> attributes); // shorthand
142 constructor (); // shorthand
143 constructor attribute String tagName; // O(1) // "template"
144 constructor attribute Boolean shadow; // O(1) // false
145
146 readonly attribute DocumentFragment content; // O(1)
147 }
148 class ScriptElement : Element {
149 constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N ), M = number of attributes, N = number of nodes plus all their descendants
150 constructor (ChildArguments... nodes); // shorthand
151 constructor (Dictionary<String> attributes); // shorthand
152 constructor (); // shorthand
153 constructor attribute String tagName; // O(1) // "script"
154 constructor attribute Boolean shadow; // O(1) // false
155 }
156 class StyleElement : Element {
157 constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N ), M = number of attributes, N = number of nodes plus all their descendants
158 constructor (ChildArguments... nodes); // shorthand
159 constructor (Dictionary<String> attributes); // shorthand
160 constructor (); // shorthand
161 constructor attribute String tagName; // O(1) // "style"
162 constructor attribute Boolean shadow; // O(1) // false
163
164 Array<Rule> getRules(); // O(N) in rules
165 }
166 class ContentElement : Element {
167 constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N ), M = number of attributes, N = number of nodes plus all their descendants
168 constructor (ChildArguments... nodes); // shorthand
169 constructor (Dictionary<String> attributes); // shorthand
170 constructor (); // shorthand
171 constructor attribute String tagName; // O(1) // "content"
172 constructor attribute Boolean shadow; // O(1) // false
173
174 Array<Node> getDistributedNodes(); // O(N) in distributed nodes
175 }
176 class ImgElement : Element {
177 constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N ), M = number of attributes, N = number of nodes plus all their descendants
178 constructor (ChildArguments... nodes); // shorthand
179 constructor (Dictionary<String> attributes); // shorthand
180 constructor (); // shorthand
181 constructor attribute String tagName; // O(1) // "img"
182 constructor attribute Boolean shadow; // O(1) // false
183 }
184 class DivElement : Element {
185 constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N ), M = number of attributes, N = number of nodes plus all their descendants
186 constructor (ChildArguments... nodes); // shorthand
187 constructor (Dictionary<String> attributes); // shorthand
188 constructor (); // shorthand
189 constructor attribute String tagName; // O(1) // "div"
190 constructor attribute Boolean shadow; // O(1) // false
191 }
192 class SpanElement : Element {
193 constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N ), M = number of attributes, N = number of nodes plus all their descendants
194 constructor (ChildArguments... nodes); // shorthand
195 constructor (Dictionary<String> attributes); // shorthand
196 constructor (); // shorthand
197 constructor attribute String tagName; // O(1) // "span"
198 constructor attribute Boolean shadow; // O(1) // false
199 }
200 class IframeElement : Element {
201 constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N ), M = number of attributes, N = number of nodes plus all their descendants
202 constructor (ChildArguments... nodes); // shorthand
203 constructor (Dictionary<String> attributes); // shorthand
204 constructor (); // shorthand
205 constructor attribute String tagName; // O(1) // "iframe"
206 constructor attribute Boolean shadow; // O(1) // false
207 }
208 class TElement : Element {
209 constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N ), M = number of attributes, N = number of nodes plus all their descendants
210 constructor (ChildArguments... nodes); // shorthand
211 constructor (Dictionary<String> attributes); // shorthand
212 constructor (); // shorthand
213 constructor attribute String tagName; // O(1) // "t"
214 constructor attribute Boolean shadow; // O(1) // false
215 }
216 class AElement : Element {
217 constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N ), M = number of attributes, N = number of nodes plus all their descendants
218 constructor (ChildArguments... nodes); // shorthand
219 constructor (Dictionary<String> attributes); // shorthand
220 constructor (); // shorthand
221 constructor attribute String tagName; // O(1) // "a"
222 constructor attribute Boolean shadow; // O(1) // false
223 }
224 class TitleElement : Element {
225 constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N ), M = number of attributes, N = number of nodes plus all their descendants
226 constructor (ChildArguments... nodes); // shorthand
227 constructor (Dictionary<String> attributes); // shorthand
228 constructor (); // shorthand
229 constructor attribute String tagName; // O(1) // "title"
230 constructor attribute Boolean shadow; // O(1) // false
231 }
232 class ErrorElement : Element {
233 constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N ), M = number of attributes, N = number of nodes plus all their descendants
234 constructor (ChildArguments... nodes); // shorthand
235 constructor (Dictionary<String> attributes); // shorthand
236 constructor (); // shorthand
237 constructor attribute String tagName; // O(1) // "error"
238 constructor attribute Boolean shadow; // O(1) // false
239 }
240
241 callback InternalElementConstructor void (Module module);
242 dictionary ElementRegistration {
243 String tagName;
244 Boolean shadow = false;
245 InternalElementConstructor? constructor = null;
246 }
247
248 interface ElementConstructor {
249 constructor (Dictionary<String> attributes, ChildArguments... nodes); // O(M+N ), M = number of attributes, N = number of nodes plus all their descendants
250 constructor (ChildArguments... nodes); // shorthand
251 constructor (Dictionary<String> attributes); // shorthand
252 constructor (); // shorthand
253
254 constructor attribute String tagName;
255 constructor attribute Boolean shadow;
256 }
257 ```
OLDNEW
« no previous file with comments | « sky/specs/apis.md ('k') | sky/specs/events.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698