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

Side by Side Diff: lib/aardvark.js

Issue 29332902: Issue 3443 - Use process script instead of a frame script in Element Hiding Helper (Closed)
Patch Set: Created Dec. 21, 2015, 12:45 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
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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 this.browser = null; 582 this.browser = null;
583 this.commentElem = null; 583 this.commentElem = null;
584 this.lockedAnchor = null; 584 this.lockedAnchor = null;
585 this.boxElem = null; 585 this.boxElem = null;
586 E = id => null; 586 E = id => null;
587 return false; 587 return false;
588 }, 588 },
589 589
590 select: function(elem) 590 select: function(elem)
591 { 591 {
592 if (!elem) 592 if (!elem || !this.window)
saroyanm 2015/12/21 16:48:55 Not sure how this fix is related to current issue.
Wladimir Palant 2015/12/21 19:14:15 I guess it's not. This merely silences an exceptio
593 return false; 593 return false;
594 594
595 let browser = this.browser; 595 let messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"]
596 if ("selectedBrowser" in browser) // tabbrowser element 596 .getService(Ci.nsIMessageBroadcaster);
597 browser = browser.selectedBrowser;
598
599 let messageId = ++messageCounter; 597 let messageId = ++messageCounter;
600 let callback = (message) => 598 let callback = (message) =>
601 { 599 {
602 let response = message.data; 600 let response = message.data;
603 if (response.messageId != messageId) 601 if (response.messageId != messageId)
604 return; 602 return;
605 603
606 browser.messageManager.removeMessageListener( 604 messageManager.removeMessageListener(
607 "ElemHideHelper:GetNodeInfo:Response", 605 "ElemHideHelper:GetNodeInfo:Response",
608 callback 606 callback
609 ); 607 );
610 608
611 if (!response.nodeData) 609 if (!response.nodeData)
612 return; 610 return;
613 611
614 this.window.openDialog("chrome://elemhidehelper/content/composer.xul", 612 this.window.openDialog("chrome://elemhidehelper/content/composer.xul",
615 "_blank", "chrome,centerscreen,resizable,dialog=no", response); 613 "_blank", "chrome,centerscreen,resizable,dialog=no", response);
616 this.quit(); 614 this.quit();
617 }; 615 };
618 616
619 browser.messageManager.addMessageListener( 617 messageManager.addMessageListener(
620 "ElemHideHelper:GetNodeInfo:Response", 618 "ElemHideHelper:GetNodeInfo:Response",
621 callback 619 callback
622 ); 620 );
623 browser.messageManager.sendAsyncMessage( 621 messageManager.broadcastAsyncMessage(
624 "ElemHideHelper:GetNodeInfo", 622 "ElemHideHelper:GetNodeInfo",
625 messageId, 623 messageId,
626 { 624 {
627 element: elem 625 element: elem
628 } 626 }
629 ); 627 );
630 return false; 628 return false;
631 }, 629 },
632 630
633 blinkElement: function(elem) 631 blinkElement: function(elem)
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 // Show help box 797 // Show help box
800 helpBox.showPopup(this.browser, -1, -1, "tooltip", "topleft", "topleft"); 798 helpBox.showPopup(this.browser, -1, -1, "tooltip", "topleft", "topleft");
801 return true; 799 return true;
802 } 800 }
803 } 801 }
804 802
805 // Makes sure event handlers like Aardvark.onKeyPress always have the correct 803 // Makes sure event handlers like Aardvark.onKeyPress always have the correct
806 // this pointer set. 804 // this pointer set.
807 for (let method of ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageHide", "onMouseMove", "onAfterPaint", "quit"]) 805 for (let method of ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageHide", "onMouseMove", "onAfterPaint", "quit"])
808 Aardvark[method] = Aardvark[method].bind(Aardvark); 806 Aardvark[method] = Aardvark[method].bind(Aardvark);
OLDNEW

Powered by Google App Engine
This is Rietveld