| OLD | NEW |
| 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 Cu.import("resource://gre/modules/Services.jsm"); | 7 Cu.import("resource://gre/modules/Services.jsm"); |
| 8 | 8 |
| 9 let {Prefs} = require("prefs"); | 9 let {Prefs} = require("prefs"); |
| 10 let {WindowObserver} = require("windowObserver"); | 10 let {WindowObserver} = require("windowObserver"); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // Use random marker class | 26 // Use random marker class |
| 27 let elementMarkerClass = null; | 27 let elementMarkerClass = null; |
| 28 { | 28 { |
| 29 let rnd = []; | 29 let rnd = []; |
| 30 let offset = "a".charCodeAt(0); | 30 let offset = "a".charCodeAt(0); |
| 31 for (let i = 0; i < 20; i++) | 31 for (let i = 0; i < 20; i++) |
| 32 rnd.push(offset + Math.random() * 26); | 32 rnd.push(offset + Math.random() * 26); |
| 33 | 33 |
| 34 elementMarkerClass = String.fromCharCode.apply(String, rnd); | 34 elementMarkerClass = String.fromCharCode.apply(String, rnd); |
| 35 } | 35 } |
| 36 exports.elementMarkerClass = elementMarkerClass; |
| 36 | 37 |
| 37 // Load CSS asynchronously | 38 // Load CSS asynchronously |
| 38 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.ns
IXMLHttpRequest); | 39 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.ns
IXMLHttpRequest); |
| 39 request.open("GET", "chrome://elemhidehelper/content/elementmarker.css"); | 40 request.open("GET", "chrome://elemhidehelper/content/elementmarker.css"); |
| 40 request.overrideMimeType("text/plain"); | 41 request.overrideMimeType("text/plain"); |
| 41 request.addEventListener("load", function(event) | 42 request.addEventListener("load", function(event) |
| 42 { | 43 { |
| 43 if (onShutdown.done) | 44 if (onShutdown.done) |
| 44 return; | 45 return; |
| 45 | 46 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 68 { | 69 { |
| 69 let type = window.document.documentElement.getAttribute("windowtype"); | 70 let type = window.document.documentElement.getAttribute("windowtype"); |
| 70 if (!(type in knownWindowTypes) || window._ehhWrapper) | 71 if (!(type in knownWindowTypes) || window._ehhWrapper) |
| 71 return; | 72 return; |
| 72 | 73 |
| 73 window.document.documentElement.appendChild(overlay.cloneNode(true)); | 74 window.document.documentElement.appendChild(overlay.cloneNode(true)); |
| 74 | 75 |
| 75 let style = window.document.createProcessingInstruction("xml-stylesheet",
'class="elemhidehelper-node" href="chrome://elemhidehelper/skin/overlay.css" typ
e="text/css"'); | 76 let style = window.document.createProcessingInstruction("xml-stylesheet",
'class="elemhidehelper-node" href="chrome://elemhidehelper/skin/overlay.css" typ
e="text/css"'); |
| 76 window.document.insertBefore(style, window.document.firstChild); | 77 window.document.insertBefore(style, window.document.firstChild); |
| 77 | 78 |
| 78 window._ehhWrapper = new WindowWrapper(window, elementMarkerClass); | 79 window._ehhWrapper = new WindowWrapper(window); |
| 79 }, | 80 }, |
| 80 | 81 |
| 81 removeFromWindow: function(window) | 82 removeFromWindow: function(window) |
| 82 { | 83 { |
| 83 if (!window._ehhWrapper) | 84 if (!window._ehhWrapper) |
| 84 return; | 85 return; |
| 85 | 86 |
| 86 window._ehhWrapper.shutdown(); | 87 window._ehhWrapper.shutdown(); |
| 87 delete window._ehhWrapper; | 88 delete window._ehhWrapper; |
| 88 | 89 |
| 89 let element = window.document.getElementById(overlay.getAttribute("id")); | 90 let element = window.document.getElementById(overlay.getAttribute("id")); |
| 90 if (element) | 91 if (element) |
| 91 element.parentNode.removeChild(element); | 92 element.parentNode.removeChild(element); |
| 92 | 93 |
| 93 for (let child = window.document.firstChild; child; child = child.nextSibl
ing) | 94 for (let child = window.document.firstChild; child; child = child.nextSibl
ing) |
| 94 if (child.nodeType == child.PROCESSING_INSTRUCTION_NODE && child.data.in
dexOf("elemhidehelper-node") >= 0) | 95 if (child.nodeType == child.PROCESSING_INSTRUCTION_NODE && child.data.in
dexOf("elemhidehelper-node") >= 0) |
| 95 child.parentNode.removeChild(child); | 96 child.parentNode.removeChild(child); |
| 96 } | 97 } |
| 97 }); | 98 }); |
| 98 }, false); | 99 }, false); |
| 99 request.send(null); | 100 request.send(null); |
| OLD | NEW |