Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This Source Code is subject to the terms of the Mozilla Public License | 2 * This Source Code is subject to the terms of the Mozilla Public License |
3 * version 2.0 (the "License"). You can obtain a copy of the License at | 3 * version 2.0 (the "License"). You can obtain a copy of the License at |
4 * http://mozilla.org/MPL/2.0/. | 4 * http://mozilla.org/MPL/2.0/. |
5 */ | 5 */ |
6 | 6 |
7 let {Prefs} = require("prefs"); | 7 let {Prefs} = require("prefs"); |
8 | 8 |
9 // Make sure to stop selection when we are uninstalled | 9 // Make sure to stop selection when we are uninstalled |
10 onShutdown.add(() => Aardvark.quit()); | 10 onShutdown.add(() => Aardvark.quit()); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 this.doCommand("quit", null); | 247 this.doCommand("quit", null); |
248 }, | 248 }, |
249 | 249 |
250 onMouseMove: function(event) | 250 onMouseMove: function(event) |
251 { | 251 { |
252 this.mouseX = event.screenX; | 252 this.mouseX = event.screenX; |
253 this.mouseY = event.screenY; | 253 this.mouseY = event.screenY; |
254 | 254 |
255 this.hideSelection(); | 255 this.hideSelection(); |
256 if (!this.browser) | 256 if (!this.browser) |
257 return; // hideSelection() called quit() | 257 { |
saroyanm
2015/08/10 14:58:12
Nit: I think make sense to move comment before if
| |
258 // hideSelection() called quit() | |
259 return; | |
260 } | |
258 | 261 |
259 let x = event.clientX; | 262 let x = event.clientX; |
260 let y = event.clientY; | 263 let y = event.clientY; |
261 | 264 |
262 // We might have coordinates relative to a frame, recalculate relative to to p window | 265 // We might have coordinates relative to a frame, recalculate relative to to p window |
263 let node = event.target; | 266 let node = event.target; |
264 while (node && node.ownerDocument && node.ownerDocument.defaultView && node. ownerDocument.defaultView.frameElement) | 267 while (node && node.ownerDocument && node.ownerDocument.defaultView && node. ownerDocument.defaultView.frameElement) |
265 { | 268 { |
266 node = node.ownerDocument.defaultView.frameElement; | 269 node = node.ownerDocument.defaultView.frameElement; |
267 let rect = node.getBoundingClientRect(); | 270 let rect = node.getBoundingClientRect(); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 { | 393 { |
391 this.prevPos = pos; | 394 this.prevPos = pos; |
392 this.paintNode.addEventListener("MozAfterPaint", this.onAfterPaint, false) ; | 395 this.paintNode.addEventListener("MozAfterPaint", this.onAfterPaint, false) ; |
393 } | 396 } |
394 }, | 397 }, |
395 | 398 |
396 hideSelection: function() | 399 hideSelection: function() |
397 { | 400 { |
398 try | 401 try |
399 { | 402 { |
400 if (this.boxElem.parentNode) | 403 if (this.boxElem.parentNode) |
saroyanm
2015/08/10 14:58:12
I wander if this is the only case where we are usi
Wladimir Palant
2015/08/10 21:10:11
No, it's not, and the other places might still pro
| |
401 this.boxElem.parentNode.removeChild(this.boxElem); | 404 this.boxElem.parentNode.removeChild(this.boxElem); |
402 } | 405 } |
403 catch (e) | 406 catch (e) |
404 { | 407 { |
405 // Are we using CPOW whose process is gone? Quit! | 408 // Are we using CPOW whose process is gone? Quit! |
409 // Clear some variables to prevent recursion (quit will call us again). | |
406 this.boxElem = {}; | 410 this.boxElem = {}; |
saroyanm
2015/08/10 14:58:12
Shouldn't we reset this.boxElem value and paintNod
Wladimir Palant
2015/08/10 21:10:11
No, because quit() will call hideSelection() again
| |
407 this.paintNode = null; | 411 this.paintNode = null; |
408 this.quit(); | 412 this.quit(); |
409 return; | 413 return; |
410 } | 414 } |
411 | 415 |
412 if (this.paintNode) | 416 if (this.paintNode) |
413 this.paintNode.removeEventListener("MozAfterPaint", this.onAfterPaint, fal se); | 417 this.paintNode.removeEventListener("MozAfterPaint", this.onAfterPaint, fal se); |
414 | 418 |
415 this.paintNode = null; | 419 this.paintNode = null; |
416 this.prevPos = null; | 420 this.prevPos = null; |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
775 // Show help box | 779 // Show help box |
776 helpBox.showPopup(this.browser, -1, -1, "tooltip", "topleft", "topleft"); | 780 helpBox.showPopup(this.browser, -1, -1, "tooltip", "topleft", "topleft"); |
777 return true; | 781 return true; |
778 } | 782 } |
779 } | 783 } |
780 | 784 |
781 // Makes sure event handlers like Aardvark.onKeyPress always have the correct | 785 // Makes sure event handlers like Aardvark.onKeyPress always have the correct |
782 // this pointer set. | 786 // this pointer set. |
783 for (let method of ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageHide", "onMouseMove", "onAfterPaint", "quit"]) | 787 for (let method of ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageHide", "onMouseMove", "onAfterPaint", "quit"]) |
784 Aardvark[method] = Aardvark[method].bind(Aardvark); | 788 Aardvark[method] = Aardvark[method].bind(Aardvark); |
LEFT | RIGHT |