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

Unified Diff: lib/elemHide.js

Issue 29774573: Issue 6652 - Do not push to unconditional selectors array (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Remove blank line Created May 9, 2018, 3:45 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/elemHide.js
===================================================================
--- a/lib/elemHide.js
+++ b/lib/elemHide.js
@@ -58,16 +58,28 @@
/**
* Lookup table, lists of element hiding exceptions by selector
* @type {Map.<string,Filter>}
*/
let exceptions = new Map();
/**
+ * Returns a list of selectors that apply on each website unconditionally.
kzar 2018/05/10 10:59:49 Please could you also remove this unrelated change
Manish Jethani 2018/05/11 04:07:10 Well if we're going to keep the function available
kzar 2018/05/11 11:23:43 Gotya, OK that makes sense. This LGTM then, I'd p
+ * @returns {string[]}
+ */
+function getUnconditionalSelectors()
+{
+ if (!unconditionalSelectors)
+ unconditionalSelectors = [...filterBySelector.keys()];
+
+ return unconditionalSelectors;
+}
+
+/**
* Container for element hiding filters
* @class
*/
let ElemHide = exports.ElemHide = {
/**
* Removes all known filters
*/
clear()
@@ -199,27 +211,16 @@
if (list[i].isActiveOnDomain(docDomain))
return list[i];
}
return null;
},
/**
- * Returns a list of selectors that apply on each website unconditionally.
- * @returns {string[]}
- */
- getUnconditionalSelectors()
- {
- if (!unconditionalSelectors)
- unconditionalSelectors = [...filterBySelector.keys()];
- return unconditionalSelectors.slice();
- },
-
- /**
* Constant used by getSelectorsForDomain to return all selectors applying to
* a particular hostname.
*/
ALL_MATCHING: 0,
/**
* Constant used by getSelectorsForDomain to exclude selectors which apply to
* all websites without exception.
@@ -243,18 +244,16 @@
* List of selectors.
*/
getSelectorsForDomain(domain, criteria)
{
let selectors = [];
if (typeof criteria == "undefined")
criteria = ElemHide.ALL_MATCHING;
- if (criteria < ElemHide.NO_UNCONDITIONAL)
- selectors = this.getUnconditionalSelectors();
let specificOnly = (criteria >= ElemHide.SPECIFIC_ONLY);
let excluded = new Set();
let currentDomain = domain ? domain.toUpperCase() : "";
// This code is a performance hot-spot, which is why we've made certain
// micro-optimisations. Please be careful before making changes.
while (true)
@@ -281,11 +280,14 @@
if (currentDomain == "")
break;
let nextDot = currentDomain.indexOf(".");
currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1);
}
+ if (criteria < ElemHide.NO_UNCONDITIONAL)
+ selectors = getUnconditionalSelectors().concat(selectors);
+
return selectors;
}
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld