OLD | NEW |
1 /** | 1 /** |
2 * @license | 2 * @license |
3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | 3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
4 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt | 4 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
5 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt | 5 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
6 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt | 6 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
7 * Code distributed by Google as part of the polymer project is also | 7 * Code distributed by Google as part of the polymer project is also |
8 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt | 8 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
9 */ | 9 */ |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 y: bcr.top, | 33 y: bcr.top, |
34 x: bcr.left | 34 x: bcr.left |
35 }; | 35 }; |
36 } | 36 } |
37 | 37 |
38 function makeEvent(type, xy, node) { | 38 function makeEvent(type, xy, node) { |
39 var props = { | 39 var props = { |
40 bubbles: true, | 40 bubbles: true, |
41 cancelable: true, | 41 cancelable: true, |
42 clientX: xy.x, | 42 clientX: xy.x, |
43 clientY: xy.y | 43 clientY: xy.y, |
| 44 // Make this a primary input. |
| 45 buttons: 1 // http://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/b
uttons |
44 }; | 46 }; |
45 var e; | 47 var e; |
46 var mousetype = type === 'tap' ? 'click' : 'mouse' + type; | 48 var mousetype = type === 'tap' ? 'click' : 'mouse' + type; |
47 if (HAS_NEW_MOUSE) { | 49 if (HAS_NEW_MOUSE) { |
48 e = new MouseEvent(mousetype, props); | 50 e = new MouseEvent(mousetype, props); |
49 } else { | 51 } else { |
50 e = document.createEvent('MouseEvent'); | 52 e = document.createEvent('MouseEvent'); |
51 e.initMouseEvent(mousetype, props.bubbles, props.cancelable, null, null, 0
, 0, | 53 e.initMouseEvent( |
52 props.clientX, props.clientY, false, false, false, false, 0, null); | 54 mousetype, props.bubbles, props.cancelable, |
| 55 null, /* view */ |
| 56 null, /* detail */ |
| 57 0, /* screenX */ |
| 58 0, /* screenY */ |
| 59 props.clientX, props.clientY, |
| 60 false, /*ctrlKey */ |
| 61 false, /*altKey */ |
| 62 false, /*shiftKey */ |
| 63 false, /*metaKey */ |
| 64 0, /*button */ |
| 65 null /*relatedTarget*/); |
53 } | 66 } |
54 node.dispatchEvent(e); | 67 node.dispatchEvent(e); |
55 } | 68 } |
56 | 69 |
57 function down(node, xy) { | 70 function down(node, xy) { |
58 xy = xy || middleOfNode(node); | 71 xy = xy || middleOfNode(node); |
59 makeEvent('down', xy, node); | 72 makeEvent('down', xy, node); |
60 } | 73 } |
61 | 74 |
62 function move(node, fromXY, toXY, steps) { | 75 function move(node, fromXY, toXY, steps) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 var xy = middleOfNode(target); | 136 var xy = middleOfNode(target); |
124 var xy2 = { | 137 var xy2 = { |
125 x: xy.x + dx, | 138 x: xy.x + dx, |
126 y: xy.y + dy | 139 y: xy.y + dy |
127 }; | 140 }; |
128 move(target, xy, xy2, steps); | 141 move(target, xy, xy2, steps); |
129 up(target, xy2); | 142 up(target, xy2); |
130 } | 143 } |
131 | 144 |
132 function keyboardEventFor(type, keyCode) { | 145 function keyboardEventFor(type, keyCode) { |
133 var event = new CustomEvent(type); | 146 var event = new CustomEvent(type, { |
| 147 bubbles: true |
| 148 }); |
134 | 149 |
135 event.keyCode = keyCode; | 150 event.keyCode = keyCode; |
136 event.code = keyCode; | 151 event.code = keyCode; |
137 | 152 |
138 return event; | 153 return event; |
139 } | 154 } |
140 | 155 |
141 function keyEventOn(target, type, keyCode) { | 156 function keyEventOn(target, type, keyCode) { |
142 target.dispatchEvent(keyboardEventFor(type, keyCode)); | 157 target.dispatchEvent(keyboardEventFor(type, keyCode)); |
143 } | 158 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 track: track, | 190 track: track, |
176 pressAndReleaseKeyOn: pressAndReleaseKeyOn, | 191 pressAndReleaseKeyOn: pressAndReleaseKeyOn, |
177 pressEnter: pressEnter, | 192 pressEnter: pressEnter, |
178 pressSpace: pressSpace, | 193 pressSpace: pressSpace, |
179 keyDownOn: keyDownOn, | 194 keyDownOn: keyDownOn, |
180 keyUpOn: keyUpOn, | 195 keyUpOn: keyUpOn, |
181 middleOfNode: middleOfNode, | 196 middleOfNode: middleOfNode, |
182 topLeftOfNode: topLeftOfNode | 197 topLeftOfNode: topLeftOfNode |
183 }; | 198 }; |
184 })(this); | 199 })(this); |
OLD | NEW |