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

Side by Side Diff: include.preload.js

Issue 29714555: Issue 6441 - Avoid unnecessary shadow root (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created March 5, 2018, 9:47 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 | 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 disconnect() 334 disconnect()
335 { 335 {
336 document.removeEventListener("DOMContentLoaded", this.trace); 336 document.removeEventListener("DOMContentLoaded", this.trace);
337 this.observer.disconnect(); 337 this.observer.disconnect();
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 = null;
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.inlineEmulated = true;
349 this.emulatedPatterns = null; 349 this.emulatedPatterns = null;
350 350
351 this.elemHideEmulation = new ElemHideEmulation( 351 this.elemHideEmulation = new ElemHideEmulation(
352 this.addSelectors.bind(this), 352 this.addSelectors.bind(this),
353 this.hideElements.bind(this) 353 this.hideElements.bind(this)
354 ); 354 );
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 { 388 {
389 while (style.sheet.cssRules.length > 0) 389 while (style.sheet.cssRules.length > 0)
390 style.sheet.deleteRule(0); 390 style.sheet.deleteRule(0);
391 } 391 }
392 392
393 if (selectors.length == 0) 393 if (selectors.length == 0)
394 return; 394 return;
395 395
396 if (!style) 396 if (!style)
397 { 397 {
398 if (!this.shadow)
399 this.shadow = this.createShadowTree();
400
398 // Create <style> element lazily, only if we add styles. Add it to 401 // Create <style> element lazily, only if we add styles. Add it to
399 // the shadow DOM if possible. Otherwise fallback to the <head> or 402 // the shadow DOM if possible. Otherwise fallback to the <head> or
400 // <html> element. If we have injected a style element before that 403 // <html> element. If we have injected a style element before that
401 // has been removed (the sheet property is null), create a new one. 404 // has been removed (the sheet property is null), create a new one.
402 style = document.createElement("style"); 405 style = document.createElement("style");
403 (this.shadow || document.head || 406 (this.shadow || document.head ||
404 document.documentElement).appendChild(style); 407 document.documentElement).appendChild(style);
405 408
406 // It can happen that the frame already navigated to a different 409 // It can happen that the frame already navigated to a different
407 // document while we were waiting for the background page to respond. 410 // document while we were waiting for the background page to respond.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 let element = event.target; 540 let element = event.target;
538 if (/^i?frame$/.test(element.localName)) 541 if (/^i?frame$/.test(element.localName))
539 checkCollapse(element); 542 checkCollapse(element);
540 }, true); 543 }, true);
541 } 544 }
542 545
543 window.checkCollapse = checkCollapse; 546 window.checkCollapse = checkCollapse;
544 window.elemhide = elemhide; 547 window.elemhide = elemhide;
545 window.typeMap = typeMap; 548 window.typeMap = typeMap;
546 window.getURLsFromElement = getURLsFromElement; 549 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