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

Unified Diff: lib/elemHide.js

Issue 29893628: Issue 6957 - Skip selector lookup for unknown domains (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Rebase Created Sept. 28, 2018, 6 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 | test/elemHide.js » ('j') | 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
@@ -353,21 +353,24 @@
/**
* Generates a style sheet for a given domain based on the current set of
* filters.
*
* @param {string} domain The domain.
* @param {boolean} [specificOnly=false] Whether selectors from generic
* filters should be included.
+ * @param {boolean} [includeSelectors=false] Whether the return value should
+ * include a separate list of selectors.
*
* @returns {ElemHideStyleSheet} An object containing the CSS code and the
* list of selectors.
*/
- generateStyleSheetForDomain(domain, specificOnly = false)
+ generateStyleSheetForDomain(domain, specificOnly = false,
+ includeSelectors = false)
{
let code = null;
let selectors = null;
if (domain[domain.length - 1] == ".")
domain = domain.replace(/\.+$/, "");
domain = domain.toLowerCase();
@@ -376,24 +379,34 @@
{
selectors = getConditionalSelectors(domain, true);
code = createStyleSheet(selectors);
}
else
{
let knownSuffix = getKnownSuffix(domain);
- selectors = getConditionalSelectors(knownSuffix, false);
- code = knownSuffix == "" ? getCommonStyleSheet() :
- (getDefaultStyleSheet() + createStyleSheet(selectors));
+ if (includeSelectors)
+ {
+ selectors = getConditionalSelectors(knownSuffix, false);
+ code = knownSuffix == "" ? getCommonStyleSheet() :
+ (getDefaultStyleSheet() + createStyleSheet(selectors));
- selectors = getUnconditionalSelectors().concat(selectors);
+ selectors = getUnconditionalSelectors().concat(selectors);
+ }
+ else
+ {
+ code = knownSuffix == "" ? getCommonStyleSheet() :
+ (getDefaultStyleSheet() +
+ createStyleSheet(getConditionalSelectors(knownSuffix,
+ false)));
+ }
}
- return {code, selectors};
+ return {code, selectors: includeSelectors ? selectors : null};
}
};
/**
* Splits a list of selectors into groups determined by the value of
* <code>{@link selectorGroupSize}</code>.
*
* @param {Array.<string>} selectors
« no previous file with comments | « no previous file | test/elemHide.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld