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

Side by Side Diff: sky/specs/events.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/dom.md ('k') | sky/specs/idl.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 Event Model
2 ===============
3
4 ```javascript
5 // EVENTS
6
7 class Event {
8 constructor (String type, Boolean bubbles = true, any data = null); // O(1)
9 readonly attribute String type; // O(1)
10 readonly attribute Boolean bubbles; // O(1)
11 attribute any data; // O(1)
12
13 readonly attribute EventTarget target; // O(1)
14 attribute Boolean handled; // O(1)
15 attribute any result; // O(1)
16
17 // TODO(ianh): do events get blocked at scope boundaries, e.g. focus events when both sides are in the scope?
18 // TODO(ianh): do events get retargetted, e.g. focus when leaving a custom e lement?
19 }
20
21 callback EventListener any (Event event);
22 // if the return value is not undefined:
23 // assign it to event.result
24 // set event.handled to true
25
26 abstract class EventTarget {
27 any dispatchEvent(Event event); // O(N) in total number of listeners for thi s type in the chain
28 // sets event.handled to false and event.result to undefined
29 // makes a record of the event target chain by calling getEventDispatchCha in()
30 // invokes all the handlers on the chain in turn
31 // returns event.result
32 virtual Array<EventTarget> getEventDispatchChain(); // O(1) // returns []
33 void addEventListener(String type, EventListener listener); // O(1)
34 void removeEventListener(String type, EventListener listener); // O(N) in ev ent listeners with that type
35 private Array<String> getRegisteredEventListenerTypes(); // O(N)
36 private Array<EventListener> getRegisteredEventListenersForType(String type) ; // O(N)
37 }
38
39 class CustomEventTarget : EventTarget { // implemented in JS
40 constructor (); // O(1)
41 attribute EventTarget parentNode; // getter O(1), setter O(N) in height of t ree, throws if this would make a loop
42
43 virtual Array<EventTarget> getEventDispatchChain(); // O(N) in height of tre e // implements EventTarget.getEventDispatchChain()
44 // let result = [];
45 // let node = this;
46 // while (node) {
47 // result.push(node);
48 // node = node.parentNode;
49 // }
50 // return result;
51
52 // you can inherit from this to make your object into an event target
53 // or you can inherit from EventTarget and implement your own getEventDispat chChain()
54 }
55 ```
OLDNEW
« no previous file with comments | « sky/specs/dom.md ('k') | sky/specs/idl.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698