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

Unified Diff: lib/child/elemHideEmulation.js

Issue 29364102: Issue 4658 - Incorporate element hiding emulation filters (Closed) Base URL: https://bitbucket.org/fhd/adblockplus
Patch Set: Update adblockpluscore dependency to b1e70036624f Created Dec. 13, 2016, 5:32 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') | lib/child/main.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/child/elemHideEmulation.js
===================================================================
rename from lib/child/cssProperties.js
rename to lib/child/elemHideEmulation.js
--- a/lib/child/cssProperties.js
+++ b/lib/child/elemHideEmulation.js
@@ -26,46 +26,46 @@
let {RequestNotifier} = require("child/requestNotifier");
function getFilters(window, callback)
{
let message = {
frames: getFrames(window),
payload: {
type: "filters.get",
- what: "cssproperties"
+ what: "elemhideemulation"
}
};
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()
+ function initElemHideEmulation()
{
- let scope = {};
+ let scope = Object.assign({}, require("common"));
Services.scriptloader.loadSubScript(
- "chrome://adblockplus/content/cssProperties.js", scope);
+ "chrome://adblockplus/content/elemHideEmulation.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(
+ let handler = new scope.ElemHideEmulation(
subject, getFilters.bind(null, subject), (selectors, filters) =>
{
if (selectors.length == 0)
return;
addUserCSS(subject, selectors.map(
selector => selector + "{display: none !important;}"
).join("\n"));
@@ -89,17 +89,17 @@
{
RequestNotifier.addNodeData(subject.document, subject.top, {
contentType: "ELEMHIDE",
docDomain: docDomain,
thirdParty: false,
// TODO: Show the actual matching selector here?
location: filter.replace(/^.*?##/, ""),
filter: filter,
- filterType: "cssproperty"
+ filterType: "elemhideemulation"
});
}
}
);
handler.load(() => handler.apply());
};
@@ -110,10 +110,10 @@
false);
onShutdown.add(() =>
{
Services.obs.removeObserver(onContentWindow,
"content-document-global-created");
});
}
- initCSSPropertyFilters();
+ initElemHideEmulation();
})();
« no previous file with comments | « dependencies ('k') | lib/child/main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld