* @param {!Event} e * @return {!Promise|undefined} * @private
(e)
| 219 | * @private |
| 220 | */ |
| 221 | onMouseMove_(e) { |
| 222 | // The event explicitly states that it's a result of a touch event. |
| 223 | if (e.sourceCapabilities && e.sourceCapabilities.firesTouchEvents) { |
| 224 | this.mouseCanceled_(); |
| 225 | return undefined; |
| 226 | } |
| 227 | if (!this.boundMouseConfirmed_) { |
| 228 | this.boundMouseConfirmed_ = this.mouseConfirmed_.bind(this); |
| 229 | this.boundMouseCanceled_ = this.mouseCanceled_.bind(this); |
| 230 | } |
| 231 | // If "click" arrives within a timeout time, this is most likely a |
| 232 | // touch/mouse emulation. Otherwise, if timeout exceeded, this looks |
| 233 | // like a legitimate mouse event. |
| 234 | let unlisten; |
| 235 | const listenPromise = listenOncePromise( |
| 236 | this.win.document, |
| 237 | 'click', |
| 238 | /* capture */ undefined, |
| 239 | (unlistener) => { |
| 240 | unlisten = unlistener; |
| 241 | } |
| 242 | ); |
| 243 | return Services.timerFor(this.win) |
| 244 | .timeoutPromise(CLICK_TIMEOUT_, listenPromise) |
| 245 | .then(this.boundMouseCanceled_, () => { |
| 246 | if (unlisten) { |
| 247 | unlisten(); |
| 248 | } |
| 249 | this.boundMouseConfirmed_(); |
| 250 | }); |
| 251 | } |
| 252 | |
| 253 | /** @private */ |
| 254 | mouseConfirmed_() { |
no test coverage detected