| Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 { | 246 { | 
| 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) | |
| 257 return; // hideSelection() called quit() | |
| 
 
saroyanm
2015/08/10 14:58:12
Nit: I think make sense to move comment before if
 
 | |
| 256 | 258 | 
| 257 let x = event.clientX; | 259 let x = event.clientX; | 
| 258 let y = event.clientY; | 260 let y = event.clientY; | 
| 259 | 261 | 
| 260 // We might have coordinates relative to a frame, recalculate relative to to p window | 262 // We might have coordinates relative to a frame, recalculate relative to to p window | 
| 261 let node = event.target; | 263 let node = event.target; | 
| 262 while (node && node.ownerDocument && node.ownerDocument.defaultView && node. ownerDocument.defaultView.frameElement) | 264 while (node && node.ownerDocument && node.ownerDocument.defaultView && node. ownerDocument.defaultView.frameElement) | 
| 263 { | 265 { | 
| 264 node = node.ownerDocument.defaultView.frameElement; | 266 node = node.ownerDocument.defaultView.frameElement; | 
| 265 let rect = node.getBoundingClientRect(); | 267 let rect = node.getBoundingClientRect(); | 
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 this.paintNode = doc.defaultView; | 388 this.paintNode = doc.defaultView; | 
| 387 if (this.paintNode) | 389 if (this.paintNode) | 
| 388 { | 390 { | 
| 389 this.prevPos = pos; | 391 this.prevPos = pos; | 
| 390 this.paintNode.addEventListener("MozAfterPaint", this.onAfterPaint, false) ; | 392 this.paintNode.addEventListener("MozAfterPaint", this.onAfterPaint, false) ; | 
| 391 } | 393 } | 
| 392 }, | 394 }, | 
| 393 | 395 | 
| 394 hideSelection: function() | 396 hideSelection: function() | 
| 395 { | 397 { | 
| 396 if (this.boxElem.parentNode) | 398 try | 
| 397 this.boxElem.parentNode.removeChild(this.boxElem); | 399 { | 
| 400 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); | |
| 402 } | |
| 403 catch (e) | |
| 404 { | |
| 405 // Are we using CPOW whose process is gone? Quit! | |
| 406 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; | |
| 408 this.quit(); | |
| 409 return; | |
| 410 } | |
| 398 | 411 | 
| 399 if (this.paintNode) | 412 if (this.paintNode) | 
| 400 this.paintNode.removeEventListener("MozAfterPaint", this.onAfterPaint, fal se); | 413 this.paintNode.removeEventListener("MozAfterPaint", this.onAfterPaint, fal se); | 
| 414 | |
| 401 this.paintNode = null; | 415 this.paintNode = null; | 
| 402 this.prevPos = null; | 416 this.prevPos = null; | 
| 403 }, | 417 }, | 
| 404 | 418 | 
| 405 getWindowSize: function(wnd) | 419 getWindowSize: function(wnd) | 
| 406 { | 420 { | 
| 407 return [wnd.innerWidth, wnd.document.documentElement.clientHeight]; | 421 return [wnd.innerWidth, wnd.document.documentElement.clientHeight]; | 
| 408 }, | 422 }, | 
| 409 | 423 | 
| 410 getElementPosition: function(element) | 424 getElementPosition: function(element) | 
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 761 // Show help box | 775 // Show help box | 
| 762 helpBox.showPopup(this.browser, -1, -1, "tooltip", "topleft", "topleft"); | 776 helpBox.showPopup(this.browser, -1, -1, "tooltip", "topleft", "topleft"); | 
| 763 return true; | 777 return true; | 
| 764 } | 778 } | 
| 765 } | 779 } | 
| 766 | 780 | 
| 767 // Makes sure event handlers like Aardvark.onKeyPress always have the correct | 781 // Makes sure event handlers like Aardvark.onKeyPress always have the correct | 
| 768 // this pointer set. | 782 // this pointer set. | 
| 769 for (let method of ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageHide", "onMouseMove", "onAfterPaint", "quit"]) | 783 for (let method of ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageHide", "onMouseMove", "onAfterPaint", "quit"]) | 
| 770 Aardvark[method] = Aardvark[method].bind(Aardvark); | 784 Aardvark[method] = Aardvark[method].bind(Aardvark); | 
| OLD | NEW |