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

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

Issue 819223005: Specs: Gesture API framework (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 | 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
(Empty)
1 Gestures
2 ========
3
4 ```javascript
5
6 callback GestureCallback void (Event event);
7
8 abstract class Gesture {
9 constructor ();
10
11 // Gestures cycle through states:
12 // - idle: nothing is going on
13 // - buffering: the GestureChooser is passing in some events, but
14 // hasn't yet committed to using this Gesture, and this Gesture
15 // hasn't yet decided that this set of events isn't interesting.
16 // - forwarding: this Gesture is still interesting and the
17 // GestureChooser has decided to use this Gesture so events are
18 // being sent along
19 // - discarding: this Gesture got cancelled or didn't match the
20 // pattern
21
22 Boolean processEvent(Event event);
23 // as the events are received, they get examined to see if they fit
24 // the pattern for the gesture; if they do, then returns true, else,
25 // returns false
26 // - returning true after false has been returned is a contract
27 // violation unless active became false in between
28 // TODO(ianh): replace processEvent()'s return value with an enum:
29 // - acceptable (true and active is true)
30 // - discarding (false but active is still true)
31 // - finished (false and active is now false)
32 // - in such a world, the contract would be that you can't return
33 // 'acceptable' after returning 'discarding' without first
34 // returning 'finished'
35
36 void accept(GestureCallback callback);
37 // send the buffered gesture events to callback, and use that
38 // callback for all future Gesture events until the gesture is
39 // complete
40 // - call this immediately after getting a positive result from
41 // processEvent()
42
43 readonly attribute Boolean active; // not idle (buffering, forwarding, or disc arding)
44 readonly attribute Boolean accepted; // true if active and accept() has been c alled (forwarding or discarding)
45 readonly attribute Boolean discarding; // true if active and processEvent() ha s returned false (discarding)
46 // 'active' is currently part of the contract between Gesture and GestureChoos er (the other two are not)
47
48 }
49
50 class GestureChooser : EventTarget {
51 constructor (EventTarget? target = null, Array<Gesture> candidates = []);
52 // throws if any of the candidates are active
53
54 readonly attribute EventTarget? target;
55 void setTarget(EventTarget? target);
56
57 Array<Gesture> getGestures();
58 void addGesture(Gesture candidate);
59 // throw if candidates.active is true
60 void removeGesture(Gesture candidate);
61 // if active is true and candidate was the last Gesture in our list
62 // to be active, set active and accepted to false
63
64 // while target is not null and the list of candidates is not empty,
65 // ensures that it is registered as an event listener for
66 // pointer-down, pointer-move, and pointer-up events on the target;
67 // when the target changes, or when the list of candidates is
68 // emptied, unregisters itself
69
70 readonly attribute Boolean active; // at least one of the gestures is active ( initially false)
71 readonly attribute Boolean accepted; // we accepted a gesture since the last t ime active was false (initially false)
72 // any time one of the pointer events is received:
73 // - let /candidates/ be a list of gestures, initially empty
74 // - if none of the registered gestures are active, then add all of
75 // them to /candidates/ otherwise, add all the active ones to
76 // /candidates/
77 // - call processEvent() with the event on all the Gestures in
78 // /candidates/
79 // - if accepted is false, and exactly one of the processEvent()
80 // methods returned true, then set accepted to true and call that
81 // Gesture's accept() method, passing it a method that fires the
82 // provided event on the current target (if not null)
83 // - if all the processEvent() methods returned false, and all the
84 // Gestures are no longer active, then set active and accepted to
85 // false; otherwise, set active to true
86 }
87 ```
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698