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

Side by Side Diff: lib/aardvark.js

Issue 29323439: Issue 2877 - Element Hiding Helper causes tab to crash when selecting some elements (Closed)
Patch Set: Removed extra newline Created Aug. 11, 2015, 1:56 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 | « chrome/content/frameScript.js ('k') | 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());
11 11
12 // To be replaced when selection starts 12 // To be replaced when selection starts
13 function E(id) {return null;} 13 function E(id) {return null;}
14 14
15 let messageCounter = 0;
16
15 /********************************* 17 /*********************************
16 * Minimal element creation code * 18 * Minimal element creation code *
17 *********************************/ 19 *********************************/
18 20
19 function createElement(doc, tagName, attrs, children) 21 function createElement(doc, tagName, attrs, children)
20 { 22 {
21 let el = doc.createElement(tagName); 23 let el = doc.createElement(tagName);
22 if (attrs) 24 if (attrs)
23 for (let key in attrs) 25 for (let key in attrs)
24 el.setAttribute(key, attrs[key]); 26 el.setAttribute(key, attrs[key]);
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 this.boxElem = null; 585 this.boxElem = null;
584 E = id => null; 586 E = id => null;
585 return false; 587 return false;
586 }, 588 },
587 589
588 select: function(elem) 590 select: function(elem)
589 { 591 {
590 if (!elem) 592 if (!elem)
591 return false; 593 return false;
592 594
595 let messageId = ++messageCounter;
596 let callback = (message) =>
597 {
598 let response = message.data;
599 if (response.messageId != messageId)
600 return;
601
602 this.browser.selectedBrowser.messageManager.removeMessageListener(
603 "ElemHideHelper:GetNodeInfo:Response",
604 callback
605 );
606
607 if (!response.nodeData)
608 return;
609
610 this.window.openDialog("chrome://elemhidehelper/content/composer.xul",
611 "_blank", "chrome,centerscreen,resizable,dialog=no", response);
612 this.quit();
613 };
614
615 this.browser.selectedBrowser.messageManager.addMessageListener(
616 "ElemHideHelper:GetNodeInfo:Response",
617 callback
618 );
593 this.browser.selectedBrowser.messageManager.sendAsyncMessage( 619 this.browser.selectedBrowser.messageManager.sendAsyncMessage(
594 "ElemHideHelper:GetNodeInfo", 620 "ElemHideHelper:GetNodeInfo",
595 null, 621 messageId,
596 { 622 {
597 element: elem, 623 element: elem
598 callback: (response) =>
599 {
600 response = JSON.parse(response);
601 if (!response.nodeData)
602 return;
603
604 this.window.openDialog("chrome://elemhidehelper/content/composer.xul",
605 "_blank", "chrome,centerscreen,resizable,dialog=no", response);
606 this.quit();
607 }
608 } 624 }
609 ); 625 );
610 return false; 626 return false;
611 }, 627 },
612 628
613 blinkElement: function(elem) 629 blinkElement: function(elem)
614 { 630 {
615 if (!elem) 631 if (!elem)
616 return false; 632 return false;
617 633
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 // Show help box 795 // Show help box
780 helpBox.showPopup(this.browser, -1, -1, "tooltip", "topleft", "topleft"); 796 helpBox.showPopup(this.browser, -1, -1, "tooltip", "topleft", "topleft");
781 return true; 797 return true;
782 } 798 }
783 } 799 }
784 800
785 // Makes sure event handlers like Aardvark.onKeyPress always have the correct 801 // Makes sure event handlers like Aardvark.onKeyPress always have the correct
786 // this pointer set. 802 // this pointer set.
787 for (let method of ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageHide", "onMouseMove", "onAfterPaint", "quit"]) 803 for (let method of ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageHide", "onMouseMove", "onAfterPaint", "quit"])
788 Aardvark[method] = Aardvark[method].bind(Aardvark); 804 Aardvark[method] = Aardvark[method].bind(Aardvark);
OLDNEW
« no previous file with comments | « chrome/content/frameScript.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld