Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 const Ci = Components.interfaces; | 7 const Ci = Components.interfaces; |
8 const Cu = Components.utils; | 8 const Cu = Components.utils; |
9 | 9 |
10 let {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {}); | 10 let {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {}); |
11 let {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm ", {}); | 11 let {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm ", {}); |
12 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); | 12 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); |
13 | 13 |
14 let processID = Services.appinfo.processID; | 14 let processID = Services.appinfo.processID; |
15 let maxNodeID = 0; | 15 let maxNodeID = 0; |
16 let nodes = new Map(); | 16 let nodes = new Map(); |
17 | 17 |
18 let name = "elemhidehelper"; | 18 let name = "elemhidehelper"; |
19 let actor = { | 19 let actor = { |
20 constructorFun: Actor, | 20 constructorFun: Actor, |
21 constructorName: name, | 21 constructorName: name, |
22 name: name | 22 name: name |
23 }; | 23 }; |
24 | 24 |
25 addMessageListener("ElemHideHelper:Shutdown", onShutdown); | 25 addMessageListener("ElemHideHelper:Shutdown", onShutdown); |
26 addMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo); | 26 addMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo); |
27 addMessageListener("ElemHideHelper:Preview", onTogglePreview); | 27 addMessageListener("ElemHideHelper:Preview", onTogglePreview); |
28 | 28 |
saroyanm
2015/12/21 16:48:55
Nit: No new line should be needed here.
Wladimir Palant
2015/12/21 19:14:15
I disagree - I'd rather separate functional blocks
| |
29 DebuggerServer.addTabActor(actor, name); | 29 DebuggerServer.addTabActor(actor, name); |
30 | 30 |
31 var onShutdown = (function() | 31 function onShutdown() |
saroyanm
2015/12/21 16:48:55
I think it's something that I pointed in another r
Wladimir Palant
2015/12/21 19:14:15
True, this is no longer necessary. In fact, the co
saroyanm
2015/12/23 10:57:05
Looks good.
| |
32 { | 32 { |
33 let executed = false; | 33 removeMessageListener("ElemHideHelper:Shutdown", onShutdown); |
34 return function() | 34 removeMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo); |
35 removeMessageListener("ElemHideHelper:Preview", onTogglePreview); | |
36 | |
37 try | |
35 { | 38 { |
36 if (!executed) | 39 DebuggerServer.removeTabActor(actor); |
37 { | |
38 executed = true; | |
39 | |
saroyanm
2015/12/21 16:48:55
Nit: No new line should be needed here.
Wladimir Palant
2015/12/21 19:14:15
Same as above - I'd rather separate functional blo
| |
40 removeMessageListener("ElemHideHelper:Shutdown", onShutdown); | |
41 removeMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo); | |
42 removeMessageListener("ElemHideHelper:Preview", onTogglePreview); | |
43 | |
44 try | |
45 { | |
46 DebuggerServer.removeTabActor(actor); | |
47 } | |
48 catch (e) | |
49 { | |
50 // The call above will throw in the content process despite succeeding, | |
51 // see https://bugzilla.mozilla.org/show_bug.cgi?id=1189780. | |
52 Cu.reportError(e); | |
53 } | |
54 } | |
55 } | 40 } |
56 })(); | 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 } | |
57 | 48 |
58 function onGetNodeInfo(message) | 49 function onGetNodeInfo(message) |
59 { | 50 { |
60 if (Cu.isCrossProcessWrapper(message.objects.element)) | 51 if (Cu.isCrossProcessWrapper(message.objects.element)) |
61 return; | 52 return; |
62 | 53 |
63 let nodeInfo = getNodeInfo(message.objects.element); | 54 let nodeInfo = getNodeInfo(message.objects.element); |
64 nodeInfo.messageId = message.data; | 55 nodeInfo.messageId = message.data; |
65 sendAsyncMessage("ElemHideHelper:GetNodeInfo:Response", nodeInfo); | 56 sendAsyncMessage("ElemHideHelper:GetNodeInfo:Response", nodeInfo); |
66 } | 57 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 // forget this node then. | 176 // forget this node then. |
186 forgetNode(nodeID); | 177 forgetNode(nodeID); |
187 } | 178 } |
188 } | 179 } |
189 } | 180 } |
190 | 181 |
191 function forgetNode(nodeID) | 182 function forgetNode(nodeID) |
192 { | 183 { |
193 nodes.delete(nodeID); | 184 nodes.delete(nodeID); |
194 } | 185 } |
LEFT | RIGHT |