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

Unified Diff: include.preload.js

Issue 29714638: Issue 6446 - Ignore emulated selectors if unchanged (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created March 5, 2018, 10:42 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: include.preload.js
===================================================================
--- a/include.preload.js
+++ b/include.preload.js
@@ -30,16 +30,26 @@
["audio", "MEDIA"],
["video", "MEDIA"],
["frame", "SUBDOCUMENT"],
["iframe", "SUBDOCUMENT"],
["object", "OBJECT"],
["embed", "OBJECT"]
]);
+let emulatedSelectors = [];
Sebastian Noack 2018/03/06 20:17:39 Shouldn't this rather be a property on the ElemHid
Manish Jethani 2018/03/07 06:23:04 Done.
+
+function haveSelectorsChanged(selectors, oldSelectors)
+{
+ if (selectors.length != oldSelectors.length)
+ return true;
+
+ return !selectors.every((selector, index) => selector == oldSelectors[index]);
+}
+
function getURLsFromObjectElement(element)
{
let url = element.getAttribute("data");
if (url)
return [url];
for (let child of element.children)
{
@@ -449,16 +459,21 @@
).join(", ");
style.sheet.insertRule(selector + "{display: none !important;}",
style.sheet.cssRules.length);
}
},
addSelectors(selectors, filters)
{
+ if (!haveSelectorsChanged(selectors, emulatedSelectors))
+ return;
+
+ emulatedSelectors = selectors;
+
if (this.inline || this.inlineEmulated)
{
// Insert the style rules inline if we have been instructed by the
// background page to do so. This is usually the case, except on platforms
// that do support user stylesheets via the browser.tabs.insertCSS API
// (Firefox 53 onwards for now and possibly Chrome in the near future).
// Once all supported platforms have implemented this API, we can remove
// the code below. See issue #5090.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld