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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 17 matching lines...) Expand all
28 ["input", "IMAGE"], 28 ["input", "IMAGE"],
29 ["picture", "IMAGE"], 29 ["picture", "IMAGE"],
30 ["audio", "MEDIA"], 30 ["audio", "MEDIA"],
31 ["video", "MEDIA"], 31 ["video", "MEDIA"],
32 ["frame", "SUBDOCUMENT"], 32 ["frame", "SUBDOCUMENT"],
33 ["iframe", "SUBDOCUMENT"], 33 ["iframe", "SUBDOCUMENT"],
34 ["object", "OBJECT"], 34 ["object", "OBJECT"],
35 ["embed", "OBJECT"] 35 ["embed", "OBJECT"]
36 ]); 36 ]);
37 37
38 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.
39
40 function haveSelectorsChanged(selectors, oldSelectors)
41 {
42 if (selectors.length != oldSelectors.length)
43 return true;
44
45 return !selectors.every((selector, index) => selector == oldSelectors[index]);
46 }
47
38 function getURLsFromObjectElement(element) 48 function getURLsFromObjectElement(element)
39 { 49 {
40 let url = element.getAttribute("data"); 50 let url = element.getAttribute("data");
41 if (url) 51 if (url)
42 return [url]; 52 return [url];
43 53
44 for (let child of element.children) 54 for (let child of element.children)
45 { 55 {
46 if (child.localName != "param") 56 if (child.localName != "param")
47 continue; 57 continue;
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 let selector = preparedSelectors.slice( 457 let selector = preparedSelectors.slice(
448 i, i + this.selectorGroupSize 458 i, i + this.selectorGroupSize
449 ).join(", "); 459 ).join(", ");
450 style.sheet.insertRule(selector + "{display: none !important;}", 460 style.sheet.insertRule(selector + "{display: none !important;}",
451 style.sheet.cssRules.length); 461 style.sheet.cssRules.length);
452 } 462 }
453 }, 463 },
454 464
455 addSelectors(selectors, filters) 465 addSelectors(selectors, filters)
456 { 466 {
467 if (!haveSelectorsChanged(selectors, emulatedSelectors))
468 return;
469
470 emulatedSelectors = selectors;
471
457 if (this.inline || this.inlineEmulated) 472 if (this.inline || this.inlineEmulated)
458 { 473 {
459 // Insert the style rules inline if we have been instructed by the 474 // Insert the style rules inline if we have been instructed by the
460 // background page to do so. This is usually the case, except on platforms 475 // background page to do so. This is usually the case, except on platforms
461 // that do support user stylesheets via the browser.tabs.insertCSS API 476 // that do support user stylesheets via the browser.tabs.insertCSS API
462 // (Firefox 53 onwards for now and possibly Chrome in the near future). 477 // (Firefox 53 onwards for now and possibly Chrome in the near future).
463 // Once all supported platforms have implemented this API, we can remove 478 // Once all supported platforms have implemented this API, we can remove
464 // the code below. See issue #5090. 479 // the code below. See issue #5090.
465 // Related Chrome and Firefox issues: 480 // Related Chrome and Firefox issues:
466 // https://bugs.chromium.org/p/chromium/issues/detail?id=632009 481 // https://bugs.chromium.org/p/chromium/issues/detail?id=632009
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 let element = event.target; 552 let element = event.target;
538 if (/^i?frame$/.test(element.localName)) 553 if (/^i?frame$/.test(element.localName))
539 checkCollapse(element); 554 checkCollapse(element);
540 }, true); 555 }, true);
541 } 556 }
542 557
543 window.checkCollapse = checkCollapse; 558 window.checkCollapse = checkCollapse;
544 window.elemhide = elemhide; 559 window.elemhide = elemhide;
545 window.typeMap = typeMap; 560 window.typeMap = typeMap;
546 window.getURLsFromElement = getURLsFromElement; 561 window.getURLsFromElement = getURLsFromElement;
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld