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

Unified Diff: lib/child/cssProperties.js

Issue 29340904: Issue 4001 - Update dependency on adblockpluscore to revision d576e2dac412 (Closed)
Patch Set: Created April 27, 2016, 6:28 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dependencies ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/child/cssProperties.js
===================================================================
--- a/lib/child/cssProperties.js
+++ b/lib/child/cssProperties.js
@@ -19,71 +19,64 @@
(function()
{
let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
let {port} = require("messaging");
let {getFrames} = require("child/utils");
- let senderWindow = null;
-
- let scope = {
- ext: {
- backgroundPage: {
- sendMessage: function(payload, callback)
- {
- let message = {payload, frames: getFrames(senderWindow)};
- if (typeof callback == "function")
- port.emitWithResponse("ext_message", message).then(callback);
- else
- port.emit("ext_message", message);
- }
+ function getFilters(window, callback)
+ {
+ let message = {
+ frames: getFrames(window),
+ payload: {
+ type: "filters.get",
+ what: "cssproperties"
}
- }
- };
+ };
+ port.emitWithResponse("ext_message", message).then(callback);
+ }
function addUserCSS(window, cssCode)
{
let uri = Services.io.newURI("data:text/css," + encodeURIComponent(cssCode),
null, null);
let utils = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
utils.loadSheet(uri, Ci.nsIDOMWindowUtils.USER_SHEET);
}
function initCSSPropertyFilters()
{
+ let scope = {};
Services.scriptloader.loadSubScript(
"chrome://adblockplus/content/cssProperties.js", scope);
let onContentWindow = (subject, topic, data) =>
{
if (!(subject instanceof Ci.nsIDOMWindow))
return;
let onReady = event =>
{
subject.removeEventListener("load", onReady);
- let handler = new scope.CSSPropertyFilters(subject, selectors =>
- {
- if (selectors.length == 0)
- return;
+ let handler = new scope.CSSPropertyFilters(
+ subject, getFilters.bind(null, subject), selectors =>
+ {
+ if (selectors.length == 0)
+ return;
- addUserCSS(subject, selectors.map(
- selector => selector + "{display: none !important;}"
- ).join("\n"));
- });
+ addUserCSS(subject, selectors.map(
+ selector => selector + "{display: none !important;}"
+ ).join("\n"));
+ }
+ );
- // HACK: The content script just calls ext.backgroundPage.sendMessage
- // without indicating which window this is about. We'll store the window
- // here because we know that messaging happens synchronously.
- senderWindow = subject;
handler.load(() => handler.apply());
- senderWindow = null;
};
subject.addEventListener("load", onReady);
};
Services.obs.addObserver(onContentWindow, "content-document-global-created",
false);
onShutdown.add(() =>
« no previous file with comments | « dependencies ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld