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

Unified Diff: include.preload.js

Issue 29737561: Issue 6539, 6782 - Implement support for snippets (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Rename Content to ContentFiltering Created July 19, 2018, 1:53 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 | « composer.postload.js ('k') | lib/scriptInjection.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include.preload.js
===================================================================
--- a/include.preload.js
+++ b/include.preload.js
@@ -17,17 +17,17 @@
"use strict";
let {splitSelector} = require("./adblockpluscore/lib/common");
let {ElemHideEmulation} =
require("./adblockpluscore/lib/content/elemHideEmulation");
// This variable is also used by our other content scripts.
-let elemhide;
+let contentFiltering;
const typeMap = new Map([
["img", "IMAGE"],
["input", "IMAGE"],
["picture", "IMAGE"],
["audio", "MEDIA"],
["video", "MEDIA"],
["frame", "SUBDOCUMENT"],
@@ -221,17 +221,17 @@
{
if (collapse)
{
if (selector)
{
if (!collapsingSelectors.has(selector))
{
collapsingSelectors.add(selector);
- elemhide.addSelectors([selector], null, "collapsing", true);
+ contentFiltering.addSelectors([selector], null, "collapsing", true);
}
}
else
{
hideElement(element);
}
}
}
@@ -389,30 +389,30 @@
disconnect()
{
document.removeEventListener("DOMContentLoaded", this.trace);
this.observer.disconnect();
clearTimeout(this.timeout);
}
};
-function ElemHide()
+function ContentFiltering()
{
this.shadow = this.createShadowTree();
this.styles = new Map();
this.tracer = null;
this.inline = true;
this.inlineEmulated = true;
this.elemHideEmulation = new ElemHideEmulation(
this.addSelectors.bind(this),
this.hideElements.bind(this)
);
}
-ElemHide.prototype = {
+ContentFiltering.prototype = {
selectorGroupSize: 1024,
createShadowTree()
{
// Use Shadow DOM if available as to not mess with with web pages that
// rely on the order of their own <style> tags (#309). However, creating
// a shadow root breaks running CSS transitions. So we have to create
// the shadow root before transistions might start (#452).
@@ -553,19 +553,22 @@
browser.runtime.sendMessage({
type: "hitLogger.traceElemHide",
selectors: [],
filters
});
}
},
- apply()
+ apply(filterTypes)
{
- browser.runtime.sendMessage({type: "elemhide.getSelectors"}, response =>
+ browser.runtime.sendMessage({
+ type: "content.applyFilters", filterTypes
+ },
+ response =>
{
if (this.tracer)
this.tracer.disconnect();
this.tracer = null;
if (response.trace)
this.tracer = new ElementHidingTracer();
@@ -587,28 +590,28 @@
});
}
};
if (document instanceof HTMLDocument)
{
checkSitekey();
- elemhide = new ElemHide();
- elemhide.apply();
+ contentFiltering = new ContentFiltering();
+ contentFiltering.apply();
document.addEventListener("error", event =>
{
checkCollapse(event.target);
}, true);
document.addEventListener("load", event =>
{
let element = event.target;
if (/^i?frame$/.test(element.localName))
checkCollapse(element);
}, true);
}
window.checkCollapse = checkCollapse;
-window.elemhide = elemhide;
+window.contentFiltering = contentFiltering;
window.typeMap = typeMap;
window.getURLsFromElement = getURLsFromElement;
« no previous file with comments | « composer.postload.js ('k') | lib/scriptInjection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld