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

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

Issue 861013002: Specs: specced TapGesture, added some TODOs around events, and put in a placeholder for ScrollGestu… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 | « no previous file | sky/specs/gestures.md » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 Sky Event Model 1 Sky Event Model
2 =============== 2 ===============
3 3
4 ```javascript 4 ```javascript
5 // EVENTS 5 // EVENTS
6 6
7 class Event { 7 class Event {
8 constructor (String type, Boolean bubbles = true, any data = null); // O(1) 8 constructor (String type, Boolean bubbles = true, any data = null); // O(1)
9 readonly attribute String type; // O(1) 9 readonly attribute String type; // O(1)
10 readonly attribute Boolean bubbles; // O(1) 10 readonly attribute Boolean bubbles; // O(1)
11 attribute any data; // O(1) 11 attribute any data; // O(1)
12 12
13 readonly attribute EventTarget target; // O(1) 13 readonly attribute EventTarget target; // O(1)
14 attribute Boolean handled; // O(1) 14 attribute Boolean handled; // O(1)
15 attribute any result; // O(1) 15 attribute any result; // O(1)
16 16
17 // TODO(ianh): do events get blocked at scope boundaries, e.g. focus events when both sides are in the scope? 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? 18 // TODO(ianh): do events get retargetted, e.g. focus when leaving a custom e lement?
19 } 19 }
20 20
21 // TODO(ianh): decide if we're using this generic Event class and
22 // allowing any arbitrary properties to be set on it, or if we're
23 // going to use subclasses (and drop "type"). If we use subclasses
24 // then how will declarative event handling work in frameworks?
25 // (consider that multiple modules can each have their own FooEvent
26 // class with the same name...)
27 //
28 // The advantage of this would be the ability to enforce (or at
29 // least better catch) incorrect uses of the API, e.g. to make sure
30 // people don't stop on themselves in 'pointer-down' capture.
31
21 callback EventListener any (Event event); 32 callback EventListener any (Event event);
22 // if the return value is not undefined: 33 // if the return value is not undefined:
23 // assign it to event.result 34 // assign it to event.result
24 // set event.handled to true 35 // set event.handled to true
25 36
26 abstract class EventTarget { 37 abstract class EventTarget {
27 any dispatchEvent(Event event); // O(N) in total number of listeners for thi s type in the chain 38 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 39 // sets event.handled to false and event.result to undefined
29 // makes a record of the event target chain by calling getEventDispatchCha in() 40 // makes a record of the event target chain by calling getEventDispatchCha in()
30 // invokes all the handlers on the chain in turn 41 // invokes all the handlers on the chain in turn
(...skipping 15 matching lines...) Expand all
46 // while (node) { 57 // while (node) {
47 // result.push(node); 58 // result.push(node);
48 // node = node.parentNode; 59 // node = node.parentNode;
49 // } 60 // }
50 // return result; 61 // return result;
51 62
52 // you can inherit from this to make your object into an event target 63 // 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() 64 // or you can inherit from EventTarget and implement your own getEventDispat chChain()
54 } 65 }
55 ``` 66 ```
OLDNEW
« no previous file with comments | « no previous file | sky/specs/gestures.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698