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

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

Issue 699083005: Specs: define registerElement() a little differently, so that the code (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/examples/radio.sky ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 APIs 1 APIs
2 ==== 2 ====
3 3
4 The Sky core API 4 The Sky core API
5 ---------------- 5 ----------------
6 6
7 ```javascript 7 ```javascript
8 module 'sky:core' { 8 module 'sky:core' {
9 9
10 // EVENTS 10 // EVENTS
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 constructor (Dictionary attributes); // shorthand 252 constructor (Dictionary attributes); // shorthand
253 constructor (); // shorthand 253 constructor (); // shorthand
254 constructor attribute String tagName; // O(1) // "error" 254 constructor attribute String tagName; // O(1) // "error"
255 constructor attribute Boolean shadow; // O(1) // false 255 constructor attribute Boolean shadow; // O(1) // false
256 } 256 }
257 257
258 258
259 259
260 // MODULES 260 // MODULES
261 261
262 callback InternalElementConstructor void (Module module);
262 dictionary ElementRegistration { 263 dictionary ElementRegistration {
263 String tagName; 264 String tagName;
264 Boolean shadow = false; 265 Boolean shadow = false;
265 Object prototype = Element; 266 InternalElementConstructor? constructor = null;
266 } 267 }
267 268
268 interface ElementConstructor { 269 interface ElementConstructor {
269 constructor (Dictionary attributes, ChildArguments... nodes); // O(M+N), M = number of attributes, N = number of nodes plus all their descendants 270 constructor (Dictionary attributes, ChildArguments... nodes); // O(M+N), M = number of attributes, N = number of nodes plus all their descendants
270 constructor (ChildArguments... nodes); // shorthand 271 constructor (ChildArguments... nodes); // shorthand
271 constructor (Dictionary attributes); // shorthand 272 constructor (Dictionary attributes); // shorthand
272 constructor (); // shorthand 273 constructor (); // shorthand
273 274
274 constructor attribute String tagName; 275 constructor attribute String tagName;
275 constructor attribute Boolean shadow; 276 constructor attribute Boolean shadow;
276 } 277 }
277 278
278 abstract class AbstractModule : EventTarget { 279 abstract class AbstractModule : EventTarget {
279 readonly attribute Document document; // O(1) // the Documentof the module o r application 280 readonly attribute Document document; // O(1) // the Documentof the module o r application
280 Promise<any> import(String url); // O(Yikes) // returns the module's exports 281 Promise<any> import(String url); // O(Yikes) // returns the module's exports
281 282
282 readonly attribute String url; 283 readonly attribute String url;
283 284
284 ElementConstructor registerElement(ElementRegistration options); // O(1) 285 ElementConstructor registerElement(ElementRegistration options); // O(1)
285 // if you call registerElement() with an object that was created by 286 // if you call registerElement() with an object that was created by
286 // registerElement(), it just returns the object after registering it, 287 // registerElement(), it just returns the object after registering it,
287 // rather than creating a new constructor 288 // rather than creating a new constructor
288 // otherwise, it proceeds as follows: 289 // otherwise, it proceeds as follows:
289 // 0. let prototype be the prototype passed in (defaulting to Element) 290 // 1. let constructor be the constructor passed in, if any
290 // 1. let constructor be prototype.constructor 291 // 2. let prototype be the constructor's prototype; if there is no
291 // 2. create a new Function that: 292 // constructor, let prototype be Element
292 // 0. throws if not called as a constructor 293 // 3. create a new Function that:
293 // 1. initialises the shadow tree is shadow on the options is true 294 // 1. throws if not called as a constructor
294 // 2. calls constructor, if it's not null, with the module as the argum ent 295 // 2. creates an actual Element object
295 // 3. let that new Function's prototype be the aforementioned prototype 296 // 3. initialises the shadow tree if shadow on the options is true
296 // 4. let that new Function have tagName and shadow properties set to 297 // 4. calls constructor, if it's not null, with the module as the argum ent
297 // the values passed in 298 // 4. let that new Function's prototype be the aforementioned prototype
298 // 5. register the new element 299 // 5. let that new Function have tagName and shadow properties set to
300 // the values passed in on options
301 // 6. register the new element
299 302
300 ScriptElement? currentScript; // O(1) // returns the <script> element curren tly being executed if any, and if it's in this module; else null 303 ScriptElement? currentScript; // O(1) // returns the <script> element curren tly being executed if any, and if it's in this module; else null
301 } 304 }
302 305
303 class Module : AbstractModule { 306 class Module : AbstractModule {
304 constructor (Application application, Document document, String url); // O(1 ) 307 constructor (Application application, Document document, String url); // O(1 )
305 readonly attribute Application application; // O(1) 308 readonly attribute Application application; // O(1)
306 309
307 attribute any exports; // O(1) // defaults to the module's document 310 attribute any exports; // O(1) // defaults to the module's document
308 } 311 }
309 312
310 class Application : AbstractModule { 313 class Application : AbstractModule {
311 constructor (Document document, String url); // O(1) 314 constructor (Document document, String url); // O(1)
312 attribute String title; // O(1) 315 attribute String title; // O(1)
313 } 316 }
314 317
315 // see script.md for a description of the global object, though note that 318 // see script.md for a description of the global object, though note that
316 // the sky core module doesn't use it or affect it in any way. 319 // the sky core module doesn't use it or affect it in any way.
317 320
318 } 321 }
319 ``` 322 ```
320 323
321 TODO(ianh): is it ok that you can do
322 module.application.registerElement()? we need application so that a
323 module can implement <title> and get to application.title...
324
325 TODO(ianh): event loop 324 TODO(ianh): event loop
326 325
327 TODO(ianh): define the DOM APIs listed above, including firing the 326 TODO(ianh): define the DOM APIs listed above, including firing the
328 change callbacks 327 change callbacks
329 328
330 TODO(ianh): schedule microtask, schedule task, requestAnimationFrame, 329 TODO(ianh): schedule microtask, schedule task, requestAnimationFrame,
331 custom element callbacks... 330 custom element callbacks...
332 331
333 332
334 333
(...skipping 13 matching lines...) Expand all
348 Sky IDL works more or less the same as Web IDL but the syntax is a bit 347 Sky IDL works more or less the same as Web IDL but the syntax is a bit
349 different. 348 different.
350 349
351 ```javascript 350 ```javascript
352 module 'sky:modulename' { 351 module 'sky:modulename' {
353 352
354 // this is a comment 353 // this is a comment
355 354
356 typedef NewType OldType; // useful when OldType is a commonly-used union 355 typedef NewType OldType; // useful when OldType is a commonly-used union
357 356
357 callback CallbackName ReturnType (ArgumentType argumentName);
358
358 class ClassName { 359 class ClassName {
359 // a class corresponds to a JavaScript prototype 360 // a class corresponds to a JavaScript prototype
360 // corresponds to a WebIDL 'interface' 361 // corresponds to a WebIDL 'interface'
361 } 362 }
362 363
363 abstract class Superclass { 364 abstract class Superclass {
364 // an abstract class can't have a constructor 365 // an abstract class can't have a constructor
365 // in every other respect it is the same as a regular class 366 // in every other respect it is the same as a regular class
366 } 367 }
367 368
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 the core mojo fabric JS API sky:mojo:fabric:core 488 the core mojo fabric JS API sky:mojo:fabric:core
488 the asyncWait/cancelWait mojo fabric JS API (interface to IPC thread) sky:moj o:fabric:ipc 489 the asyncWait/cancelWait mojo fabric JS API (interface to IPC thread) sky:moj o:fabric:ipc
489 the mojom for the shell, proxying through C++ so that the shell pipe isn't exp osed sky:mojo:shell 490 the mojom for the shell, proxying through C++ so that the shell pipe isn't exp osed sky:mojo:shell
490 the sky API sky:core 491 the sky API sky:core
491 the sky debug symbols for private APIs sky:debug 492 the sky debug symbols for private APIs sky:debug
492 ``` 493 ```
493 494
494 TODO(ianh): determine if we want to separate the "this" from the 495 TODO(ianh): determine if we want to separate the "this" from the
495 Document, especially for Modules, so that exposing a module's element 496 Document, especially for Modules, so that exposing a module's element
496 doesn't expose the module's exports attribute. 497 doesn't expose the module's exports attribute.
OLDNEW
« no previous file with comments | « sky/examples/radio.sky ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698