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

Side by Side Diff: chrome/content/processScript.js

Issue 29332902: Issue 3443 - Use process script instead of a frame script in Element Hiding Helper (Closed)
Patch Set: Addressed comments Created Dec. 21, 2015, 7:13 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') | lib/aardvark.js » ('j') | 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 EXPORTED_SYMBOLS = ["shutdown", "getNodeInfo", "togglePreview",
8 "forgetNode"];
9
10 const Ci = Components.interfaces; 7 const Ci = Components.interfaces;
11 const Cu = Components.utils; 8 const Cu = Components.utils;
12 9
13 let {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {}); 10 let {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
14 let {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm ", {}); 11 let {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm ", {});
15 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); 12 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
16 13
17 let processID = Services.appinfo.processID; 14 let processID = Services.appinfo.processID;
18 let maxNodeID = 0; 15 let maxNodeID = 0;
19 let nodes = new Map(); 16 let nodes = new Map();
20 17
21 let name = "elemhidehelper"; 18 let name = "elemhidehelper";
22 let actor = { 19 let actor = {
23 constructorFun: Actor, 20 constructorFun: Actor,
24 constructorName: name, 21 constructorName: name,
25 name: name 22 name: name
26 }; 23 };
27 24
25 addMessageListener("ElemHideHelper:Shutdown", onShutdown);
26 addMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo);
27 addMessageListener("ElemHideHelper:Preview", onTogglePreview);
28
28 DebuggerServer.addTabActor(actor, name); 29 DebuggerServer.addTabActor(actor, name);
29 30
30 var shutdown = (function() 31 function onShutdown()
31 { 32 {
32 let executed = false; 33 removeMessageListener("ElemHideHelper:Shutdown", onShutdown);
33 return function() 34 removeMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo);
35 removeMessageListener("ElemHideHelper:Preview", onTogglePreview);
36
37 try
34 { 38 {
35 if (!executed) 39 DebuggerServer.removeTabActor(actor);
36 {
37 executed = true;
38 try
39 {
40 DebuggerServer.removeTabActor(actor);
41 }
42 catch (e)
43 {
44 // The call above will throw in the content process despite succeeding,
45 // see https://bugzilla.mozilla.org/show_bug.cgi?id=1189780.
46 Cu.reportError(e);
47 }
48 }
49 } 40 }
50 })(); 41 catch (e)
42 {
43 // The call above will throw in the content process despite succeeding,
44 // see https://bugzilla.mozilla.org/show_bug.cgi?id=1189780.
45 Cu.reportError(e);
46 }
47 }
48
49 function onGetNodeInfo(message)
50 {
51 if (Cu.isCrossProcessWrapper(message.objects.element))
52 return;
53
54 let nodeInfo = getNodeInfo(message.objects.element);
55 nodeInfo.messageId = message.data;
56 sendAsyncMessage("ElemHideHelper:GetNodeInfo:Response", nodeInfo);
57 }
58
59 function onTogglePreview(message)
60 {
61 togglePreview(message.data.nodeID, message.data.stylesheetData);
62 if (message.data.forgetNode)
63 forgetNode(message.data.nodeID);
64 }
51 65
52 function Actor(connection, tabActor) 66 function Actor(connection, tabActor)
53 { 67 {
54 } 68 }
55 69
56 Actor.prototype = { 70 Actor.prototype = {
57 requestTypes: { 71 requestTypes: {
58 nodeinfo: function(request, connection) 72 nodeinfo: function(request, connection)
59 { 73 {
60 let nodeActor = connection.getActor(request.nodeActor); 74 let nodeActor = connection.getActor(request.nodeActor);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // forget this node then. 176 // forget this node then.
163 forgetNode(nodeID); 177 forgetNode(nodeID);
164 } 178 }
165 } 179 }
166 } 180 }
167 181
168 function forgetNode(nodeID) 182 function forgetNode(nodeID)
169 { 183 {
170 nodes.delete(nodeID); 184 nodes.delete(nodeID);
171 } 185 }
OLDNEW
« no previous file with comments | « chrome/content/frameScript.js ('k') | lib/aardvark.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld