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

Side by Side Diff: include.preload.js

Issue 29365801: Issue 4676 - Replace non-standard CSSStyleSheet.addRule() call by CSSStyleSheet.insertRule() (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome
Patch Set: Created Nov. 30, 2016, 1:37 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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 } 573 }
574 574
575 // Safari only allows 8192 primitive selectors to be injected at once[1], we 575 // Safari only allows 8192 primitive selectors to be injected at once[1], we
576 // therefore chunk the inserted selectors into groups of 200 to be safe. 576 // therefore chunk the inserted selectors into groups of 200 to be safe.
577 // (Chrome also has a limit, larger... but we're not certain exactly what it 577 // (Chrome also has a limit, larger... but we're not certain exactly what it
578 // is! Edge apparently has no such limit.) 578 // is! Edge apparently has no such limit.)
579 // [1] - https://github.com/WebKit/webkit/blob/1cb2227f6b2a1035f7bdc46e5ab69 debb75fc1de/Source/WebCore/css/RuleSet.h#L68 579 // [1] - https://github.com/WebKit/webkit/blob/1cb2227f6b2a1035f7bdc46e5ab69 debb75fc1de/Source/WebCore/css/RuleSet.h#L68
580 for (var i = 0; i < selectors.length; i += this.selectorGroupSize) 580 for (var i = 0; i < selectors.length; i += this.selectorGroupSize)
581 { 581 {
582 var selector = selectors.slice(i, i + this.selectorGroupSize).join(", "); 582 var selector = selectors.slice(i, i + this.selectorGroupSize).join(", ");
583 this.style.sheet.addRule(selector, "display: none !important;"); 583 this.style.sheet.insertRule(selector + "{display: none !important;}",
584 this.style.sheet.cssRules.length);
kzar 2016/11/30 13:48:20 Nit: The indentation of this line looks weird, sho
Wladimir Palant 2016/11/30 13:52:11 Ok, I've changed indentation.
584 } 585 }
585 }, 586 },
586 587
587 apply: function() 588 apply: function()
588 { 589 {
589 var selectors = null; 590 var selectors = null;
590 var propertyFiltersLoaded = false; 591 var propertyFiltersLoaded = false;
591 592
592 var checkLoaded = function() 593 var checkLoaded = function()
593 { 594 {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 checkCollapse(event.target); 639 checkCollapse(event.target);
639 }, true); 640 }, true);
640 641
641 document.addEventListener("load", function(event) 642 document.addEventListener("load", function(event)
642 { 643 {
643 var element = event.target; 644 var element = event.target;
644 if (/^i?frame$/.test(element.localName)) 645 if (/^i?frame$/.test(element.localName))
645 checkCollapse(element); 646 checkCollapse(element);
646 }, true); 647 }, true);
647 } 648 }
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