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

Side by Side Diff: include.preload.js

Issue 29564767: Issue 242 - Use user style sheets on Chromium (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Do not check error message Created Feb. 1, 2018, 10:37 a.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') | 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 clearTimeout(this.timeout); 338 clearTimeout(this.timeout);
339 } 339 }
340 }; 340 };
341 341
342 function ElemHide() 342 function ElemHide()
343 { 343 {
344 this.shadow = this.createShadowTree(); 344 this.shadow = this.createShadowTree();
345 this.styles = new Map(); 345 this.styles = new Map();
346 this.tracer = null; 346 this.tracer = null;
347 this.inline = true; 347 this.inline = true;
348 this.inlineEmulated = true;
348 this.emulatedPatterns = null; 349 this.emulatedPatterns = null;
349 350
350 this.elemHideEmulation = new ElemHideEmulation( 351 this.elemHideEmulation = new ElemHideEmulation(
351 this.addSelectors.bind(this), 352 this.addSelectors.bind(this),
352 this.hideElements.bind(this) 353 this.hideElements.bind(this)
353 ); 354 );
354 } 355 }
355 ElemHide.prototype = { 356 ElemHide.prototype = {
356 selectorGroupSize: 1024, 357 selectorGroupSize: 1024,
357 358
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 let selector = preparedSelectors.slice( 447 let selector = preparedSelectors.slice(
447 i, i + this.selectorGroupSize 448 i, i + this.selectorGroupSize
448 ).join(", "); 449 ).join(", ");
449 style.sheet.insertRule(selector + "{display: none !important;}", 450 style.sheet.insertRule(selector + "{display: none !important;}",
450 style.sheet.cssRules.length); 451 style.sheet.cssRules.length);
451 } 452 }
452 }, 453 },
453 454
454 addSelectors(selectors, filters) 455 addSelectors(selectors, filters)
455 { 456 {
456 if (this.inline) 457 if (this.inline || this.inlineEmulated)
457 { 458 {
458 // Insert the style rules inline if we have been instructed by the 459 // Insert the style rules inline if we have been instructed by the
459 // background page to do so. This is usually the case, except on platforms 460 // background page to do so. This is usually the case, except on platforms
460 // that do support user stylesheets via the browser.tabs.insertCSS API 461 // that do support user stylesheets via the browser.tabs.insertCSS API
461 // (Firefox 53 onwards for now and possibly Chrome in the near future). 462 // (Firefox 53 onwards for now and possibly Chrome in the near future).
462 // Once all supported platforms have implemented this API, we can remove 463 // Once all supported platforms have implemented this API, we can remove
463 // the code below. See issue #5090. 464 // the code below. See issue #5090.
464 // Related Chrome and Firefox issues: 465 // Related Chrome and Firefox issues:
465 // https://bugs.chromium.org/p/chromium/issues/detail?id=632009 466 // https://bugs.chromium.org/p/chromium/issues/detail?id=632009
466 // https://bugzilla.mozilla.org/show_bug.cgi?id=1310026 467 // https://bugzilla.mozilla.org/show_bug.cgi?id=1310026
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 browser.runtime.sendMessage({type: "elemhide.getSelectors"}, response => 500 browser.runtime.sendMessage({type: "elemhide.getSelectors"}, response =>
500 { 501 {
501 if (this.tracer) 502 if (this.tracer)
502 this.tracer.disconnect(); 503 this.tracer.disconnect();
503 this.tracer = null; 504 this.tracer = null;
504 505
505 if (response.trace) 506 if (response.trace)
506 this.tracer = new ElementHidingTracer(); 507 this.tracer = new ElementHidingTracer();
507 508
508 this.inline = response.inline; 509 this.inline = response.inline;
510 this.inlineEmulated = !!response.inlineEmulated;
509 511
510 if (this.inline) 512 if (this.inline)
511 this.addSelectorsInline(response.selectors, "standard"); 513 this.addSelectorsInline(response.selectors, "standard");
512 514
513 if (this.tracer) 515 if (this.tracer)
514 this.tracer.addSelectors(response.selectors); 516 this.tracer.addSelectors(response.selectors);
515 517
516 this.elemHideEmulation.apply(response.emulatedPatterns); 518 this.elemHideEmulation.apply(response.emulatedPatterns);
517 }); 519 });
518 } 520 }
(...skipping 16 matching lines...) Expand all
535 let element = event.target; 537 let element = event.target;
536 if (/^i?frame$/.test(element.localName)) 538 if (/^i?frame$/.test(element.localName))
537 checkCollapse(element); 539 checkCollapse(element);
538 }, true); 540 }, true);
539 } 541 }
540 542
541 window.checkCollapse = checkCollapse; 543 window.checkCollapse = checkCollapse;
542 window.elemhide = elemhide; 544 window.elemhide = elemhide;
543 window.typeMap = typeMap; 545 window.typeMap = typeMap;
544 window.getURLsFromElement = getURLsFromElement; 546 window.getURLsFromElement = getURLsFromElement;
OLDNEW
« no previous file with comments | « no previous file | lib/cssInjection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld