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

Side by Side Diff: include.preload.js

Issue 29575739: Issue 5864 - Remove previous style sheet before adding one (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created Oct. 13, 2017, 11:59 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.style = null; 345 this.style = null;
346 this.tracer = null; 346 this.tracer = null;
347 this.inject = true; 347 this.inject = true;
348 this.emulatedPatterns = null; 348 this.emulatedPatterns = null;
349 this.emulatedSelectors = 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: 200, 357 selectorGroupSize: 200,
357 358
358 createShadowTree() 359 createShadowTree()
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 { 442 {
442 // Insert the style rules inline if we have been instructed by the 443 // Insert the style rules inline if we have been instructed by the
443 // background page to do so. This is usually the case, except on platforms 444 // background page to do so. This is usually the case, except on platforms
444 // that do support user stylesheets via the chrome.tabs.insertCSS API 445 // that do support user stylesheets via the chrome.tabs.insertCSS API
445 // (Firefox 53 onwards for now and possibly Chrome in the near future). 446 // (Firefox 53 onwards for now and possibly Chrome in the near future).
446 // Once all supported platforms have implemented this API, we can remove 447 // Once all supported platforms have implemented this API, we can remove
447 // the code below. See issue #5090. 448 // the code below. See issue #5090.
448 // Related Chrome and Firefox issues: 449 // Related Chrome and Firefox issues:
449 // https://bugs.chromium.org/p/chromium/issues/detail?id=632009 450 // https://bugs.chromium.org/p/chromium/issues/detail?id=632009
450 // https://bugzilla.mozilla.org/show_bug.cgi?id=1310026 451 // https://bugzilla.mozilla.org/show_bug.cgi?id=1310026
451 this.injectSelectors(selectors, filters); 452 this.injectSelectors(selectors, filters);
Manish Jethani 2017/10/14 00:08:03 We should also do the same for when styles are inj
452 } 453 }
453 else 454 else
454 { 455 {
455 chrome.runtime.sendMessage({ 456 chrome.runtime.sendMessage({
456 type: "elemhide.injectSelectors", 457 type: "elemhide.injectSelectors",
457 selectors 458 selectors,
Manish Jethani 2017/10/14 00:08:03 Note that earlier in this function we're exiting i
Manish Jethani 2017/10/14 13:38:18 Done.
459 previousSelectors: this.emulatedSelectors
458 }); 460 });
461 this.emulatedSelectors = selectors;
459 } 462 }
460 463
461 if (this.tracer) 464 if (this.tracer)
462 this.tracer.addSelectors(selectors, filters); 465 this.tracer.addSelectors(selectors, filters);
463 }, 466 },
464 467
465 hideElements(elements, filters) 468 hideElements(elements, filters)
466 { 469 {
467 for (let element of elements) 470 for (let element of elements)
468 hideElement(element); 471 hideElement(element);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 checkCollapse(event.target); 519 checkCollapse(event.target);
517 }, true); 520 }, true);
518 521
519 document.addEventListener("load", event => 522 document.addEventListener("load", event =>
520 { 523 {
521 let element = event.target; 524 let element = event.target;
522 if (/^i?frame$/.test(element.localName)) 525 if (/^i?frame$/.test(element.localName))
523 checkCollapse(element); 526 checkCollapse(element);
524 }, true); 527 }, true);
525 } 528 }
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