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

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

Issue 29366556: Issue 2879 - Make "view source in separate window" command work again (Closed) Base URL: https://hg.adblockplus.org/elemhidehelper
Patch Set: Created Dec. 1, 2016, 11:03 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« lib/aardvark.js ('K') | « lib/aardvark.js ('k') | no next file » | 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 messageManager = require("messageManager"); 9 let messageManager = require("messageManager");
10 let {getNodeInfo} = require("./nodeInfo"); 10 let {getNodeInfo} = require("./nodeInfo");
11 let { 11 let {
12 state, selectElement, setAnchorElement, stopSelection 12 state, selectElement, setAnchorElement, stopSelection
13 } = require("./selection"); 13 } = require("./selection");
14 let {getParentElement} = require("./utils"); 14 let {getParentElement} = require("./utils");
15 15
16 messageManager.addMessageListener("ElemHideHelper:Command", onCommand); 16 messageManager.addMessageListener("ElemHideHelper:Command", onCommand);
17 messageManager.addMessageListener("ElemHideHelper:SerializeSelected", 17 messageManager.addMessageListener("ElemHideHelper:SerializeSelected",
18 serializeSelected); 18 serializeSelected);
19 messageManager.addMessageListener("ElemHideHelper:GetHTML", getHTML);
19 20
20 onShutdown.add(() => 21 onShutdown.add(() =>
21 { 22 {
22 messageManager.removeMessageListener("ElemHideHelper:Command", onCommand); 23 messageManager.removeMessageListener("ElemHideHelper:Command", onCommand);
23 messageManager.removeMessageListener("ElemHideHelper:SerializeSelected", 24 messageManager.removeMessageListener("ElemHideHelper:SerializeSelected",
24 serializeSelected); 25 serializeSelected);
26 messageManager.removeMessageListener("ElemHideHelper:GetHTML", getHTML);
25 }); 27 });
26 28
27 function onCommand(message) 29 function onCommand(message)
28 { 30 {
29 let command = message.data; 31 let command = message.data;
30 if (typeof exports[command] == "function") 32 if (typeof exports[command] == "function")
31 exports[command](); 33 exports[command]();
32 } 34 }
33 35
34 function serializeNode(node) 36 function serializeNode(node)
(...skipping 29 matching lines...) Expand all
64 } 66 }
65 67
66 function serializeSelected(message) 68 function serializeSelected(message)
67 { 69 {
68 messageManager.sendAsyncMessage("ElemHideHelper:Response", { 70 messageManager.sendAsyncMessage("ElemHideHelper:Response", {
69 messageId: message.data.messageId, 71 messageId: message.data.messageId,
70 serialized: serializeNode(state.selectedElement) 72 serialized: serializeNode(state.selectedElement)
71 }); 73 });
72 } 74 }
73 75
76 function getHTML(message)
77 {
78 messageManager.sendAsyncMessage("ElemHideHelper:Response", {
79 messageId: message.data.messageId,
80 html: state.selectedElement.outerHTML,
81 baseURI: state.selectedElement.baseURI
82 });
83 }
84
74 function quit() 85 function quit()
75 { 86 {
76 stopSelection(); 87 stopSelection();
77 } 88 }
78 exports.quit = quit; 89 exports.quit = quit;
79 90
80 function select() 91 function select()
81 { 92 {
82 if (!state.selectedElement) 93 if (!state.selectedElement)
83 return; 94 return;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 counter: 0, 193 counter: 0,
183 element: state.selectedElement, 194 element: state.selectedElement,
184 origVisibility: state.selectedElement.style.visibility, 195 origVisibility: state.selectedElement.style.visibility,
185 timer: Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer) 196 timer: Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer)
186 }; 197 };
187 198
188 blinkState.timer.initWithCallback(doBlink, 250, 199 blinkState.timer.initWithCallback(doBlink, 250,
189 Ci.nsITimer.TYPE_REPEATING_SLACK); 200 Ci.nsITimer.TYPE_REPEATING_SLACK);
190 } 201 }
191 exports.blinkElement = blinkElement; 202 exports.blinkElement = blinkElement;
OLDNEW
« lib/aardvark.js ('K') | « lib/aardvark.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld