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

Side by Side Diff: lib/aardvark.js

Issue 29323426: Issue 2878 - Element Hiding Helper is stuck in a bad state after a tab crash (Closed)
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:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 {
258 // hideSelection() called quit()
259 return;
260 }
256 261
257 let x = event.clientX; 262 let x = event.clientX;
258 let y = event.clientY; 263 let y = event.clientY;
259 264
260 // 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
261 let node = event.target; 266 let node = event.target;
262 while (node && node.ownerDocument && node.ownerDocument.defaultView && node. ownerDocument.defaultView.frameElement) 267 while (node && node.ownerDocument && node.ownerDocument.defaultView && node. ownerDocument.defaultView.frameElement)
263 { 268 {
264 node = node.ownerDocument.defaultView.frameElement; 269 node = node.ownerDocument.defaultView.frameElement;
265 let rect = node.getBoundingClientRect(); 270 let rect = node.getBoundingClientRect();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 this.paintNode = doc.defaultView; 391 this.paintNode = doc.defaultView;
387 if (this.paintNode) 392 if (this.paintNode)
388 { 393 {
389 this.prevPos = pos; 394 this.prevPos = pos;
390 this.paintNode.addEventListener("MozAfterPaint", this.onAfterPaint, false) ; 395 this.paintNode.addEventListener("MozAfterPaint", this.onAfterPaint, false) ;
391 } 396 }
392 }, 397 },
393 398
394 hideSelection: function() 399 hideSelection: function()
395 { 400 {
396 if (this.boxElem.parentNode) 401 try
397 this.boxElem.parentNode.removeChild(this.boxElem); 402 {
403 if (this.boxElem.parentNode)
404 this.boxElem.parentNode.removeChild(this.boxElem);
405 }
406 catch (e)
407 {
408 // Are we using CPOW whose process is gone? Quit!
409 // Clear some variables to prevent recursion (quit will call us again).
410 this.boxElem = {};
411 this.paintNode = null;
412 this.quit();
413 return;
414 }
398 415
399 if (this.paintNode) 416 if (this.paintNode)
400 this.paintNode.removeEventListener("MozAfterPaint", this.onAfterPaint, fal se); 417 this.paintNode.removeEventListener("MozAfterPaint", this.onAfterPaint, fal se);
418
401 this.paintNode = null; 419 this.paintNode = null;
402 this.prevPos = null; 420 this.prevPos = null;
403 }, 421 },
404 422
405 getWindowSize: function(wnd) 423 getWindowSize: function(wnd)
406 { 424 {
407 return [wnd.innerWidth, wnd.document.documentElement.clientHeight]; 425 return [wnd.innerWidth, wnd.document.documentElement.clientHeight];
408 }, 426 },
409 427
410 getElementPosition: function(element) 428 getElementPosition: function(element)
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 // Show help box 779 // Show help box
762 helpBox.showPopup(this.browser, -1, -1, "tooltip", "topleft", "topleft"); 780 helpBox.showPopup(this.browser, -1, -1, "tooltip", "topleft", "topleft");
763 return true; 781 return true;
764 } 782 }
765 } 783 }
766 784
767 // Makes sure event handlers like Aardvark.onKeyPress always have the correct 785 // Makes sure event handlers like Aardvark.onKeyPress always have the correct
768 // this pointer set. 786 // this pointer set.
769 for (let method of ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageHide", "onMouseMove", "onAfterPaint", "quit"]) 787 for (let method of ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageHide", "onMouseMove", "onAfterPaint", "quit"])
770 Aardvark[method] = Aardvark[method].bind(Aardvark); 788 Aardvark[method] = Aardvark[method].bind(Aardvark);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld