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

Side by Side Diff: lib/child/nodeInfo.js

Issue 29363476: Issue 2879 - Move element selection into the content process (Closed) Base URL: https://hg.adblockplus.org/elemhidehelper
Patch Set: Addressed comments and marked extension as E10S-compatible Created Nov. 24, 2016, 2 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 | « lib/child/main.js ('k') | lib/child/selection.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 "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");
12
13 let processID = Services.appinfo.processID; 11 let processID = Services.appinfo.processID;
14 let maxNodeID = 0; 12 let maxNodeID = 0;
15 let nodes = new Map(); 13 let nodes = new Map();
16 14
17 messageManager.addMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo);
18 onShutdown.add(() =>
19 {
20 messageManager.removeMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeIn fo);
21 });
22
23 function onGetNodeInfo(message)
24 {
25 if (Cu.isCrossProcessWrapper(message.objects.element))
26 return;
27
28 let nodeInfo = getNodeInfo(message.objects.element);
29 nodeInfo.messageId = message.data;
30 messageManager.sendAsyncMessage("ElemHideHelper:GetNodeInfo:Response", nodeInf o);
31 }
32
33 function getNodeInfo(node) 15 function getNodeInfo(node)
34 { 16 {
35 let nodeData = getNodeData(node); 17 let nodeData = getNodeData(node);
36 if (nodeData) 18 if (nodeData)
37 { 19 {
38 let nodeID = processID + "-" + (++maxNodeID); 20 let nodeID = processID + "-" + (++maxNodeID);
39 nodes.set(nodeID, {document: node.ownerDocument, style: null}); 21 nodes.set(nodeID, {document: node.ownerDocument, style: null});
40 return { 22 return {
41 host: node.ownerDocument.defaultView.location.hostname, 23 host: node.ownerDocument.defaultView.location.hostname,
42 nodeData: nodeData, 24 nodeData: nodeData,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 84
103 result.customCSS = {selected: "", checked: false}; 85 result.customCSS = {selected: "", checked: false};
104 return result; 86 return result;
105 } 87 }
106 88
107 function forgetNode(nodeID) 89 function forgetNode(nodeID)
108 { 90 {
109 nodes.delete(nodeID); 91 nodes.delete(nodeID);
110 } 92 }
111 exports.forgetNode = forgetNode; 93 exports.forgetNode = forgetNode;
OLDNEW
« no previous file with comments | « lib/child/main.js ('k') | lib/child/selection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld