1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-24 19:33:01 +01:00
Raymond Hill 2018-07-23 09:54:25 -04:00
parent 597f856417
commit 12118e83aa
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -45,7 +45,8 @@ let reHasCSSCombinators = /[ >+~]/,
proceduralDict = new Map(),
nodesToProcess = new Set(),
shouldProcessDeclarativeComplex = false,
shouldProcessProcedural = false;
shouldProcessProcedural = false,
loggedSelectors = new Set();
/******************************************************************************/
@ -70,15 +71,17 @@ let processDeclarativeSimple = function(node, out) {
}
for ( let selector of simpleDeclarativeSet ) {
if (
node !== document && node.matches(selector) ||
node.querySelector(selector) !== null
(node === document || node.matches(selector) === false) &&
(node.querySelector(selector) === null)
) {
continue;
}
out.push(sanitizedSelectors.get(selector) || selector);
simpleDeclarativeSet.delete(selector);
simpleDeclarativeStr = undefined;
loggedSelectors.add(selector);
if ( simpleDeclarativeSet.size === 0 ) { return; }
}
}
};
/******************************************************************************/
@ -94,6 +97,7 @@ let processDeclarativeComplex = function(out) {
out.push(sanitizedSelectors.get(selector) || selector);
complexDeclarativeSet.delete(selector);
complexDeclarativeStr = undefined;
loggedSelectors.add(selector);
if ( complexDeclarativeSet.size === 0 ) { return; }
}
};
@ -117,8 +121,9 @@ let processTimer = new vAPI.SafeAnimationFrame(() => {
processTimer.clear();
let toLog = [];
if ( nodesToProcess.size !== 0 && simpleDeclarativeSet.size !== 0 ) {
if ( nodesToProcess.has(document) ) {
nodesToProcess = new Set([ document ]);
if ( nodesToProcess.size !== 1 && nodesToProcess.has(document) ) {
nodesToProcess.clear();
nodesToProcess.add(document);
}
for ( let node of nodesToProcess ) {
processDeclarativeSimple(node, toLog);
@ -177,12 +182,16 @@ let handlers = {
logNow = [];
for ( let entry of (changes.declarative || []) ) {
for ( let selector of entry[0].split(',\n') ) {
if ( entry[1] === 'display:none!important;' ) {
if ( entry[1] !== 'display:none!important;' ) {
logNow.push(selector + ':style(' + entry[1] + ')');
continue;
}
if ( reHasPseudoClass.test(selector) ) {
let sanitized = selector.replace(reHasPseudoClass, '');
sanitizedSelectors.set(sanitized, selector);
selector = sanitized;
}
if ( loggedSelectors.has(selector) ) { continue; }
if ( reHasCSSCombinators.test(selector) ) {
complexDeclarativeSet.add(selector);
complexDeclarativeStr = undefined;
@ -190,9 +199,6 @@ let handlers = {
simpleDeclarativeSet.add(selector);
simpleDeclarativeStr = undefined;
}
} else {
logNow.push(selector + ':style(' + entry[1] + ')');
}
}
}
if ( logNow.length !== 0 ) {