| 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()); |
| 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 Loading... | |
| 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 | |
|
saroyanm
2015/08/11 13:50:14
Nit: please remove new line here.
Wladimir Palant
2015/08/11 13:57:06
Done.
| |
| 616 this.browser.selectedBrowser.messageManager.addMessageListener( | |
| 617 "ElemHideHelper:GetNodeInfo:Response", | |
| 618 callback | |
| 619 ); | |
| 593 this.browser.selectedBrowser.messageManager.sendAsyncMessage( | 620 this.browser.selectedBrowser.messageManager.sendAsyncMessage( |
| 594 "ElemHideHelper:GetNodeInfo", | 621 "ElemHideHelper:GetNodeInfo", |
| 595 null, | 622 messageId, |
| 596 { | 623 { |
| 597 element: elem, | 624 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 } | 625 } |
| 609 ); | 626 ); |
| 610 return false; | 627 return false; |
| 611 }, | 628 }, |
| 612 | 629 |
| 613 blinkElement: function(elem) | 630 blinkElement: function(elem) |
| 614 { | 631 { |
| 615 if (!elem) | 632 if (!elem) |
| 616 return false; | 633 return false; |
| 617 | 634 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 779 // Show help box | 796 // Show help box |
| 780 helpBox.showPopup(this.browser, -1, -1, "tooltip", "topleft", "topleft"); | 797 helpBox.showPopup(this.browser, -1, -1, "tooltip", "topleft", "topleft"); |
| 781 return true; | 798 return true; |
| 782 } | 799 } |
| 783 } | 800 } |
| 784 | 801 |
| 785 // Makes sure event handlers like Aardvark.onKeyPress always have the correct | 802 // Makes sure event handlers like Aardvark.onKeyPress always have the correct |
| 786 // this pointer set. | 803 // this pointer set. |
| 787 for (let method of ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageHide", "onMouseMove", "onAfterPaint", "quit"]) | 804 for (let method of ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageHide", "onMouseMove", "onAfterPaint", "quit"]) |
| 788 Aardvark[method] = Aardvark[method].bind(Aardvark); | 805 Aardvark[method] = Aardvark[method].bind(Aardvark); |
| OLD | NEW |