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

Delta Between Two Patch Sets: lib/child/nodeInfo.js

Issue 29362609: Issue 2879 - Restructure existing process script, split it up into multiple modules (Closed) Base URL: https://hg.adblockplus.org/elemhidehelper
Left Patch Set: Created Nov. 17, 2016, 8:36 a.m.
Right Patch Set: Fixed line length Created Dec. 1, 2016, 9:39 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/child/main.js ('k') | lib/child/preview.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 "use strict"; 7 "use strict";
8 8
9 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); 9 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
10 10
11 let messageManager = require("messageManager"); 11 let messageManager = require("messageManager");
12 12
13 let processID = Services.appinfo.processID; 13 let processID = Services.appinfo.processID;
14 let maxNodeID = 0; 14 let maxNodeID = 0;
15 let nodes = new Map(); 15 let nodes = new Map();
16 16
17 messageManager.addMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo); 17 messageManager.addMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo);
18 onShutdown.add(() => 18 onShutdown.add(() =>
19 { 19 {
20 messageManager.removeMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeIn fo); 20 messageManager.removeMessageListener("ElemHideHelper:GetNodeInfo",
saroyanm 2016/11/24 17:46:11 Nit: Exceeding 80 chars.
Wladimir Palant 2016/12/01 09:40:49 Done.
21 onGetNodeInfo);
21 }); 22 });
22 23
23 function onGetNodeInfo(message) 24 function onGetNodeInfo(message)
24 { 25 {
25 if (Cu.isCrossProcessWrapper(message.objects.element)) 26 if (Cu.isCrossProcessWrapper(message.objects.element))
26 return; 27 return;
27 28
28 let nodeInfo = getNodeInfo(message.objects.element); 29 let nodeInfo = getNodeInfo(message.objects.element);
29 nodeInfo.messageId = message.data; 30 nodeInfo.messageId = message.data;
30 messageManager.sendAsyncMessage("ElemHideHelper:GetNodeInfo:Response", nodeInf o); 31 messageManager.sendAsyncMessage("ElemHideHelper:GetNodeInfo:Response",
saroyanm 2016/11/24 17:46:11 Nit: Exceeding 80 chars.
Wladimir Palant 2016/12/01 09:40:49 Done.
32 nodeInfo);
31 } 33 }
32 34
33 function getNodeInfo(node) 35 function getNodeInfo(node)
34 { 36 {
35 let nodeData = getNodeData(node); 37 let nodeData = getNodeData(node);
36 if (nodeData) 38 if (nodeData)
37 { 39 {
38 let nodeID = processID + "-" + (++maxNodeID); 40 let nodeID = processID + "-" + (++maxNodeID);
39 nodes.set(nodeID, {document: node.ownerDocument, style: null}); 41 nodes.set(nodeID, {document: node.ownerDocument, style: null});
40 return { 42 return {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 104
103 result.customCSS = {selected: "", checked: false}; 105 result.customCSS = {selected: "", checked: false};
104 return result; 106 return result;
105 } 107 }
106 108
107 function forgetNode(nodeID) 109 function forgetNode(nodeID)
108 { 110 {
109 nodes.delete(nodeID); 111 nodes.delete(nodeID);
110 } 112 }
111 exports.forgetNode = forgetNode; 113 exports.forgetNode = forgetNode;
LEFTRIGHT

Powered by Google App Engine
This is Rietveld