LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 */ | 60 */ |
61 let styleURL = null; | 61 let styleURL = null; |
62 | 62 |
63 /** | 63 /** |
64 * Global stylesheet that should be loaded into content windows. | 64 * Global stylesheet that should be loaded into content windows. |
65 * @type nsIStyleSheet | 65 * @type nsIStyleSheet |
66 */ | 66 */ |
67 let styleSheet = null; | 67 let styleSheet = null; |
68 | 68 |
69 /** | 69 /** |
70 * Use new way of injecting styles per Window that exists since Firefox 33. | 70 * Use the new way of injecting styles per window that exists since Firefox 33. |
71 * @type boolean | 71 * @type boolean |
72 */ | 72 */ |
73 let useNew = ('preloadSheet' in Utils.styleService); | 73 let useNew = ('preloadSheet' in Utils.styleService); |
74 | 74 |
75 /** | 75 /** |
76 * Element hiding component | 76 * Element hiding component |
77 * @class | 77 * @class |
78 */ | 78 */ |
79 let ElemHide = exports.ElemHide = | 79 let ElemHide = exports.ElemHide = |
80 { | 80 { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 { | 134 { |
135 if (topic != "content-document-global-created") | 135 if (topic != "content-document-global-created") |
136 return; | 136 return; |
137 | 137 |
138 if (!Prefs.enabled) | 138 if (!Prefs.enabled) |
139 return; | 139 return; |
140 | 140 |
141 if (Policy.shouldNeverBlockWindow(subject)) | 141 if (Policy.shouldNeverBlockWindow(subject)) |
142 return; | 142 return; |
143 | 143 |
144 try | 144 if (styleSheet) |
145 { | 145 { |
146 let utils = subject.QueryInterface(Ci.nsIInterfaceRequestor) | 146 try |
147 .getInterface(Ci.nsIDOMWindowUtils); | 147 { |
148 utils.addSheet(styleSheet, Ci.nsIStyleSheetService.USER_SHEET); | 148 let utils = subject.QueryInterface(Ci.nsIInterfaceRequestor) |
149 } | 149 .getInterface(Ci.nsIDOMWindowUtils); |
150 catch (e) | 150 utils.addSheet(styleSheet, Ci.nsIStyleSheetService.USER_SHEET); |
151 { | 151 } |
152 Cu.reportError(e); | 152 catch (e) |
| 153 { |
| 154 Cu.reportError(e); |
| 155 } |
153 } | 156 } |
154 }, | 157 }, |
155 | 158 |
156 /** | 159 /** |
157 * Removes all known filters | 160 * Removes all known filters |
158 */ | 161 */ |
159 clear: function() | 162 clear: function() |
160 { | 163 { |
161 filterByKey = Object.create(null); | 164 filterByKey = Object.create(null); |
162 keyByFilter = Object.create(null); | 165 keyByFilter = Object.create(null); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 { | 328 { |
326 ElemHide.isDirty = false; | 329 ElemHide.isDirty = false; |
327 | 330 |
328 ElemHide.unapply(); | 331 ElemHide.unapply(); |
329 TimeLine.log("ElemHide.unapply() finished"); | 332 TimeLine.log("ElemHide.unapply() finished"); |
330 | 333 |
331 if (!noFilters) | 334 if (!noFilters) |
332 { | 335 { |
333 try | 336 try |
334 { | 337 { |
335 if (!useNew) { | 338 if (!useNew) |
336 Utils.styleService.loadAndRegisterSheet(styleURL, Ci.nsIStyleSheet
Service.USER_SHEET); | 339 Utils.styleService.loadAndRegisterSheet(styleURL, Ci.nsIStyleSheet
Service.USER_SHEET); |
337 } else { | 340 else |
338 styleSheet = Utils.styleService.preloadSheet(styleURL, Ci.nsIStyle
SheetService.USER_SHEET); | 341 styleSheet = Utils.styleService.preloadSheet(styleURL, Ci.nsIStyle
SheetService.USER_SHEET); |
339 } | |
340 ElemHide.applied = true; | 342 ElemHide.applied = true; |
341 } | 343 } |
342 catch (e) | 344 catch (e) |
343 { | 345 { |
344 Cu.reportError(e); | 346 Cu.reportError(e); |
345 } | 347 } |
346 TimeLine.log("Applying stylesheet finished"); | 348 TimeLine.log("Applying stylesheet finished"); |
347 } | 349 } |
348 | 350 |
349 FilterNotifier.triggerListeners("elemhideupdate"); | 351 FilterNotifier.triggerListeners("elemhideupdate"); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 | 459 |
458 if (specificOnly && (!domains || domains[""])) | 460 if (specificOnly && (!domains || domains[""])) |
459 continue; | 461 continue; |
460 | 462 |
461 if (filter.isActiveOnDomain(domain) && !this.getException(filter, domain)) | 463 if (filter.isActiveOnDomain(domain) && !this.getException(filter, domain)) |
462 result.push(filter.selector); | 464 result.push(filter.selector); |
463 } | 465 } |
464 return result; | 466 return result; |
465 } | 467 } |
466 }; | 468 }; |
LEFT | RIGHT |