Index: chrome/content/processScript.js |
=================================================================== |
rename from chrome/content/actor.jsm |
rename to chrome/content/processScript.js |
--- a/chrome/content/actor.jsm |
+++ b/chrome/content/processScript.js |
@@ -1,17 +1,14 @@ |
/* |
* This Source Code is subject to the terms of the Mozilla Public License |
* version 2.0 (the "License"). You can obtain a copy of the License at |
* http://mozilla.org/MPL/2.0/. |
*/ |
-let EXPORTED_SYMBOLS = ["shutdown", "getNodeInfo", "togglePreview", |
- "forgetNode"]; |
- |
const Ci = Components.interfaces; |
const Cu = Components.utils; |
let {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {}); |
let {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {}); |
let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); |
let processID = Services.appinfo.processID; |
@@ -20,40 +17,66 @@ let nodes = new Map(); |
let name = "elemhidehelper"; |
let actor = { |
constructorFun: Actor, |
constructorName: name, |
name: name |
}; |
+addMessageListener("ElemHideHelper:Shutdown", onShutdown); |
+addMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo); |
+addMessageListener("ElemHideHelper:Preview", onTogglePreview); |
+ |
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
|
DebuggerServer.addTabActor(actor, name); |
-var shutdown = (function() |
+var onShutdown = (function() |
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.
|
{ |
let executed = false; |
return function() |
{ |
if (!executed) |
{ |
executed = true; |
+ |
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
|
+ removeMessageListener("ElemHideHelper:Shutdown", onShutdown); |
+ removeMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo); |
+ removeMessageListener("ElemHideHelper:Preview", onTogglePreview); |
+ |
try |
{ |
DebuggerServer.removeTabActor(actor); |
} |
catch (e) |
{ |
// The call above will throw in the content process despite succeeding, |
// see https://bugzilla.mozilla.org/show_bug.cgi?id=1189780. |
Cu.reportError(e); |
} |
} |
} |
})(); |
+function onGetNodeInfo(message) |
+{ |
+ if (Cu.isCrossProcessWrapper(message.objects.element)) |
+ return; |
+ |
+ let nodeInfo = getNodeInfo(message.objects.element); |
+ nodeInfo.messageId = message.data; |
+ sendAsyncMessage("ElemHideHelper:GetNodeInfo:Response", nodeInfo); |
+} |
+ |
+function onTogglePreview(message) |
+{ |
+ togglePreview(message.data.nodeID, message.data.stylesheetData); |
+ if (message.data.forgetNode) |
+ forgetNode(message.data.nodeID); |
+} |
+ |
function Actor(connection, tabActor) |
{ |
} |
Actor.prototype = { |
requestTypes: { |
nodeinfo: function(request, connection) |
{ |