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

Side by Side Diff: include.preload.js

Issue 29679796: Issue 6298 - Split injected CSS hiding rule into groups of 1,024 selectors (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created Jan. 25, 2018, 5:12 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 | lib/cssInjection.js » ('j') | lib/cssInjection.js » ('J')
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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 let subSelectors = splitSelector(selector); 423 let subSelectors = splitSelector(selector);
424 for (let subSelector of subSelectors) 424 for (let subSelector of subSelectors)
425 preparedSelectors.push("::content " + subSelector); 425 preparedSelectors.push("::content " + subSelector);
426 } 426 }
427 } 427 }
428 else 428 else
429 { 429 {
430 preparedSelectors = selectors; 430 preparedSelectors = selectors;
431 } 431 }
432 432
433 // Safari only allows 8192 primitive selectors to be injected at once[1], we 433 // Chromium's Blink engine supports only up to 8,192 selectors; more
Manish Jethani 2018/01/25 17:15:02 I've just updated this comment here because the pr
434 // therefore chunk the inserted selectors into groups of 200 to be safe. 434 // specifically, it ignores any selectors that start at index 8192 or
435 // (Chrome also has a limit, larger... but we're not certain exactly what it 435 // beyond in the list of plain selectors. In order to avoid spilling
436 // is! Edge apparently has no such limit.) 436 // outside of this range, we simply add multiple rules in groups of up to
437 // [1] - https://github.com/WebKit/webkit/blob/1cb2227f6b2a1035f7bdc46e5ab69 debb75fc1de/Source/WebCore/css/RuleSet.h#L68 437 // 200 selectors each.
438 // See issue #6298 and https://crbug.com/804179
438 for (let i = 0; i < preparedSelectors.length; i += this.selectorGroupSize) 439 for (let i = 0; i < preparedSelectors.length; i += this.selectorGroupSize)
439 { 440 {
440 let selector = preparedSelectors.slice( 441 let selector = preparedSelectors.slice(
441 i, i + this.selectorGroupSize 442 i, i + this.selectorGroupSize
442 ).join(", "); 443 ).join(", ");
443 this.style.sheet.insertRule(selector + "{display: none !important;}", 444 this.style.sheet.insertRule(selector + "{display: none !important;}",
444 this.style.sheet.cssRules.length); 445 this.style.sheet.cssRules.length);
445 } 446 }
446 }, 447 },
447 448
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 let element = event.target; 530 let element = event.target;
530 if (/^i?frame$/.test(element.localName)) 531 if (/^i?frame$/.test(element.localName))
531 checkCollapse(element); 532 checkCollapse(element);
532 }, true); 533 }, true);
533 } 534 }
534 535
535 window.checkCollapse = checkCollapse; 536 window.checkCollapse = checkCollapse;
536 window.elemhide = elemhide; 537 window.elemhide = elemhide;
537 window.typeMap = typeMap; 538 window.typeMap = typeMap;
538 window.getURLsFromElement = getURLsFromElement; 539 window.getURLsFromElement = getURLsFromElement;
OLDNEW
« no previous file with comments | « no previous file | lib/cssInjection.js » ('j') | lib/cssInjection.js » ('J')

Powered by Google App Engine
This is Rietveld