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

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

Issue 873803003: Specs: Change event model to support default return values. Change (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 | « sky/specs/events.md ('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 UI Events 1 UI Events
2 ========= 2 =========
3 3
4 Scope 4 Scope
5 ----- 5 -----
6 6
7 The following input devices are supported by sky: 7 The following input devices are supported by sky:
8 - fingers on multitouch screens 8 - fingers on multitouch screens
9 - mice, including mouse wheels 9 - mice, including mouse wheels
10 - styluses on screens 10 - styluses on screens
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 zoom/rotation or not. 48 zoom/rotation or not.
49 49
50 50
51 Pointer events 51 Pointer events
52 -------------- 52 --------------
53 53
54 Each touch or pointer is tracked individually. 54 Each touch or pointer is tracked individually.
55 55
56 New touches and pointers can appear and disappear over time. 56 New touches and pointers can appear and disappear over time.
57 57
58 When a new one enters the system, a 'pointer-added' event is fired at 58 Each pointer has a list of current targets.
59 the application's document.
60 59
61 When it is removed, a 'pointer-removed' event is fired at the 60 When a new one enters the system, a non-bubbling 'pointer-added' event
62 application's document. 61 is fired at the application's document, and the pointer's current
62 targets list is initialised to just that Document object.
63
64 When it is removed, a non-bubbling 'pointer-removed' event is fired at
65 the application's document and at any other objects in the pointer's
66 current targets list. Currently, at the time of a pointer-removed, the
67 list will always consist of only the document.
68
69 A pointer can be "up" or "down". Initially all pointers are "up".
63 70
64 A pointer switches from "up" to "down" when it is a touch or stylus 71 A pointer switches from "up" to "down" when it is a touch or stylus
65 that is in contact with the display surface, or when it is a mouse 72 that is in contact with the display surface, or when it is a mouse
66 that is being clicked, and from "down" back to "up" when this ends. 73 that is being clicked, and from "down" back to "up" when this ends.
67 (Note that clicking a button on a stylus doesn't change it from up to 74 (Note that clicking a button on a stylus doesn't change it from up to
68 down. A stylus can have a button pressed while "up".) In the case of a 75 down. A stylus can have a button pressed while "up".) In the case of a
69 mouse with multiple buttons, the pointer switches back to "up" only 76 mouse with multiple buttons, the pointer switches back to "up" only
70 when all the buttons have been released. 77 when all the buttons have been released.
71 78
72 When one switches from "up" to "down", the following algorithm is run: 79 When a pointer switches from "up" to "down", the following algorithm
80 is run:
73 81
74 1. Hit test the position of the pointer, let 'node' be the result. 82 1. Hit test the position of the pointer, let 'node' be the result.
75 2. Fire a pointer-down event at the layoutManager for 'node'. 83 2. Fire a bubbling pointer-down event at the layoutManager for
76 Let 'result' be the returned value. 84 'node', with an empty array as the default return value. Let
77 3. If 'result' is undefined, then fire a pointer-down event at the 85 'result1' be the returned value.
78 Element for 'node'. 86 3. If result1 is not an array of EventTarget objects, set it to the
79 Let 'result' be the returned value. 87 empty array and (if this is debug mode) report the issue.
80 4. If 'result' is undefined or is not an EventTarget, let 'result' be 88 4. Fire a bubbling pointer-down event at the Element for 'node', with
81 the application document. 89 an empty array as the default return value. Let 'result2' be the
82 5. Let 'result' capture this pointer. 90 returned value.
91 5. If result2 is not an array of EventTarget objects, set it to the
92 empty array and (if this is debug mode) report the issue.
93 6. Let result be the concatenation of result1's contents, result2's
94 contents, and the application document.
95 7. Let 'result' be this pointer's current targets.
83 96
84 A pointer that is "down" is captured -- all events for that pointer 97 When an object is one of the current targets of a pointer and no other
85 will be routed to the chosen target until the pointer goes up, 98 pointers have that object as a current target so far, and either there
86 regardless of whether it's in that target's visible area. 99 are no buttons (touch, stylus) or only the primary button is active
100 (mouse) and this is not an inverted stylus, then that pointer is
101 considered the "primary" pointer for that object. The pointer remains
102 the primary pointer for that object until the corresponding pointer-up
103 event (even if the buttons change).
87 104
88 When an object captures a pointer and it has no captured pointers so 105 When a pointer moves, a non-bubbling 'pointer-move' event is fired at
89 far, if either there are no buttons (touch, stylus) or only the 106 each of the pointer's current targets in turn (maintaining the order
90 primary button is active (mouse) and this is not an inverted stylus, 107 they had in the 'pointer-down' event, if there's more than one). If
91 then that pointer is marked as "primary" for that object. The pointer 108 the return value of a 'pointer-moved' event is 'cancel', and the
92 remains the primary pointer until the corresponding pointer-up event 109 pointer is currently down, then the pointer is canceled (see below).
93 (even if the buttons change).
94
95 When one moves, if it is "up" then a 'pointer-moved' event is fired at
96 the application's document, otherwise if it is "down" then the event
97 is fired at the object or document that was selected for the
98 'pointer-down' event (the capturing object). If the return value of a
99 'pointer-moved' event is 'cancel' then cancel the pointer.
100 110
101 When a pointer's button state changes but this doesn't impact whether 111 When a pointer's button state changes but this doesn't impact whether
102 it is "up" or "down", e.g. when a mouse with a button down gets a 112 it is "up" or "down", e.g. when a mouse with a button down gets a
103 second button down, or when a stylus' buttons change state, but the 113 second button down, or when a stylus' buttons change state, but the
104 pointer doesn't simultaneously move, then a 'pointer-moved' event is 114 pointer doesn't simultaneously move, then a 'pointer-moved' event is
105 fired anyway, with dx=dy=0. 115 fired anyway, as described above, but with dx=dy=0.
106 116
107 When one switches from "down" to "up", a 'pointer-up' event is fired 117 When a pointer switches from "down" to "up", a non-bubbling
108 at the object or document that was selected for the 'pointer-down' 118 'pointer-up' event is fired at each of the pointer's current targets
109 event (the capturing target). The buttons exposed on that event are 119 in turn (maintaining the order they had in the 'pointer-down' event,
110 those that were down immediately prior to the buttons being released. 120 if there's more than one), and then the pointer's current target list
121 is emptied except for the application's document. The buttons exposed
122 on the 'pointer-up' event are those that were down immediately prior
123 to the buttons being released.
111 124
112 At the time of a pointer-up event, if there is another pointer that is 125 At the time of a 'pointer-up' event, for each object that is a current
113 already down, captured by the same object, and is of the same kind, 126 target of the pointer, and for which the pointer is considered the
114 and that has either no buttons or only its primary button active, then 127 "primary" pointer for that object, if there is another pointer that is
115 that becomes the new primary pointer for that object before the 128 already down, which is of the same kind, which also has that object as
116 pointer-up event is sent. Otherwise, the primary pointer stops being 129 a current target, and that has either no buttons or only its primary
117 primary just after the pointer-up. 130 button active, then that pointer becomes the new "primary" pointer for
131 that object before the 'pointer-up' event is sent. Otherwise, the
132 "primary" pointer stops being "primary" just _after_ the 'pointer-up'
133 event. (This matters for whether the 'primary' field is set.)
118 134
119 When a pointer is canceled, if it is "down", pretend that the pointer 135 When a pointer is canceled, if it is "down", pretend that the pointer
120 moved to "up", send 'pointer-up' as described below, and drop all 136 moved to "up", sending 'pointer-up' as described above, and entirely
121 events for this pointer until such time as it actually changes to be 137 empty its current targets list. AFter the pointer actually switches
122 truly "up". 138 from "down" to "up", replace the current targets list with an object
139 that only contains the application's document.
123 140
124 Nothing special happens when a capturing target moves in the DOM. 141 Nothing special happens when a pointer's current target moves in the
142 DOM.
125 143
126 The x and y position of an -up or -down event always match those of 144 The x and y position of an -up or -down event always match those of
127 the previous -moved or -added event, so their dx and dy are always 0. 145 the previous -moved or -added event, so their dx and dy are always 0.
128 146
129 Positions are floating point numbers; they can have subpixel values. 147 Positions are floating point numbers; they can have subpixel values.
130 148
131 149
132 These events all bubble and their data is an object with the following 150 These data of all these events is an object with the following fields:
133 fields:
134 151
135 pointer: an integer assigned to this touch or pointer when it 152 pointer: an integer assigned to this touch or pointer when it
136 enters the system, never reused, increasing 153 enters the system, never reused, increasing
137 monotonically every time a new value is assigned, 154 monotonically every time a new value is assigned,
138 starting from 1 (if the system gets a new tap every 155 starting from 1 (if the system gets a new tap every
139 microsecond, this will cause a problem after 285 156 microsecond, this will cause a problem after 285
140 years) 157 years)
141 158
142 kind: one of 'touch', 'mouse', 'stylus', 'inverted-stylus' 159 kind: one of 'touch', 'mouse', 'stylus', 'inverted-stylus'
143 160
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 217
201 When down is true: 218 When down is true:
202 219
203 pressure: the pressure of the touch as a number ranging from 220 pressure: the pressure of the touch as a number ranging from
204 0.0, indicating a touch with no discernible pressure, 221 0.0, indicating a touch with no discernible pressure,
205 to 1.0, indicating a touch with "normal" pressure, 222 to 1.0, indicating a touch with "normal" pressure,
206 and possibly beyond, indicating a stronger touch; for 223 and possibly beyond, indicating a stronger touch; for
207 devices that do not detect pressure (e.g. mice), 224 devices that do not detect pressure (e.g. mice),
208 returns 1.0 225 returns 1.0
209 226
210 pressure-min: the minimum value that pressure can return for this 227 pressure-min: the minimum value that pressure can return for this
211 pointer 228 pointer
212 229
213 pressure-max: the maximum value that pressure can return for this 230 pressure-max: the maximum value that pressure can return for this
214 pointer 231 pointer
215 232
216 233
217 When kind is 'touch', 'stylus', or 'stylus-inverted': 234 When kind is 'touch', 'stylus', or 'stylus-inverted':
218 235
219 distance: distance of detected object from surface (e.g. 236 distance: distance of detected object from surface (e.g.
220 distance of stylus or finger from screen), if 237 distance of stylus or finger from screen), if
221 supported and down is not true, otherwise 0.0. 238 supported and down is not true, otherwise 0.0.
222 239
223 distance-min: the minimum value that distance can return for this 240 distance-min: the minimum value that distance can return for this
224 pointer (always 0.0) 241 pointer (always 0.0)
225 242
226 distance-max: the maximum value that distance can return for this 243 distance-max: the maximum value that distance can return for this
227 pointer (0.0 if not supported) 244 pointer (0.0 if not supported)
228 245
229 246
230 When kind is 'touch', 'stylus', or 'stylus-inverted' and down is true: 247 When kind is 'touch', 'stylus', or 'stylus-inverted' and down is true:
231 248
232 radius-major: the radius of the contact ellipse along the major 249 radius-major: the radius of the contact ellipse along the major
233 axis, in pixels 250 axis, in pixels
234 251
235 radius-minor: the radius of the contact ellipse along the major 252 radius-minor: the radius of the contact ellipse along the major
236 axis, in pixels 253 axis, in pixels
237 254
238 radius-min: the minimum value that could be reported for 255 radius-min: the minimum value that could be reported for
239 radius-major or radius-minor for this pointer 256 radius-major or radius-minor for this pointer
240 257
241 radius-max: the maximum value that could be reported for 258 radius-max: the maximum value that could be reported for
242 radius-major or radius-minor for this pointer 259 radius-major or radius-minor for this pointer
243 260
244 261
245 When kind is 'touch' and down is true: 262 When kind is 'touch' and down is true:
246 263
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 display, in global layout coordinates 338 display, in global layout coordinates
322 339
323 Note: The only wheels that are supported are mouse wheels and physical 340 Note: The only wheels that are supported are mouse wheels and physical
324 dials. Track balls are not reported as mouse wheels. 341 dials. Track balls are not reported as mouse wheels.
325 342
326 343
327 Text input events 344 Text input events
328 ----------------- 345 -----------------
329 346
330 TODO(ianh): keyboard events 347 TODO(ianh): keyboard events
OLDNEW
« no previous file with comments | « sky/specs/events.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698