Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/aardvark.js

Issue 29323426: Issue 2878 - Element Hiding Helper is stuck in a bad state after a tab crash (Closed)
Left Patch Set: Created Aug. 10, 2015, 11:45 a.m.
Right Patch Set: Improved comments Created Aug. 10, 2015, 9:09 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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
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
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);
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld