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: Still switch to <content> Created March 8, 2018, 9:51 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-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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 357
358 createShadowTree() 358 createShadowTree()
359 { 359 {
360 // Use Shadow DOM if available as to not mess with with web pages that 360 // Use Shadow DOM if available as to not mess with with web pages that
361 // rely on the order of their own <style> tags (#309). However, creating 361 // rely on the order of their own <style> tags (#309). However, creating
362 // a shadow root breaks running CSS transitions. So we have to create 362 // a shadow root breaks running CSS transitions. So we have to create
363 // the shadow root before transistions might start (#452). 363 // the shadow root before transistions might start (#452).
364 if (!("createShadowRoot" in document.documentElement)) 364 if (!("createShadowRoot" in document.documentElement))
365 return null; 365 return null;
366 366
367 // Use Shadow DOM only on Chrome version 65 and lower. Firefox's Shadow
368 // DOM v0 implementation is slightly different (e.g. no <shadow> element),
369 // while Chrome is deprecating Shadow DOM v0 in favor of Shadow DOM v1 and
370 // user style sheets.
Sebastian Noack 2018/03/08 23:22:59 This is irrelevant. We have feature detection abov
Manish Jethani 2018/03/08 23:57:51 You're right, I've updated the comment.
371 let {application, applicationVersion} = require("info");
Sebastian Noack 2018/03/08 23:22:59 Do we use the "info" module in any other content s
Manish Jethani 2018/03/08 23:57:51 We don't. OK, I'm checking the navigator.userAgent
372 if (application != "chrome" || parseInt(applicationVersion) > 65)
Sebastian Noack 2018/03/08 23:22:59 We don't care about the application, but about the
Manish Jethani 2018/03/08 23:57:51 Acknowledged.
373 return null;
374
367 // Using shadow DOM causes issues on some Google websites, 375 // Using shadow DOM causes issues on some Google websites,
368 // including Google Docs, Gmail and Blogger (#1770, #2602, #2687). 376 // including Google Docs, Gmail and Blogger (#1770, #2602, #2687).
369 if (/\.(?:google|blogger)\.com$/.test(document.domain)) 377 if (/\.(?:google|blogger)\.com$/.test(document.domain))
370 return null; 378 return null;
371 379
372 // Finally since some users have both AdBlock and Adblock Plus installed we 380 // Finally since some users have both AdBlock and Adblock Plus installed we
373 // have to consider how the two extensions interact. For example we want to 381 // have to consider how the two extensions interact. For example we want to
374 // avoid creating the shadowRoot twice. 382 // avoid creating the shadowRoot twice.
375 let shadow = document.documentElement.shadowRoot || 383 let shadow = document.documentElement.shadowRoot ||
376 document.documentElement.createShadowRoot(); 384 document.documentElement.createShadowRoot();
377 shadow.appendChild(document.createElement("shadow")); 385 shadow.appendChild(document.createElement("content"));
378 386
379 return shadow; 387 return shadow;
380 }, 388 },
381 389
382 addSelectorsInline(selectors, groupName) 390 addSelectorsInline(selectors, groupName)
383 { 391 {
384 let style = this.styles.get(groupName); 392 let style = this.styles.get(groupName);
385 393
386 if (style) 394 if (style)
387 { 395 {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 let element = event.target; 549 let element = event.target;
542 if (/^i?frame$/.test(element.localName)) 550 if (/^i?frame$/.test(element.localName))
543 checkCollapse(element); 551 checkCollapse(element);
544 }, true); 552 }, true);
545 } 553 }
546 554
547 window.checkCollapse = checkCollapse; 555 window.checkCollapse = checkCollapse;
548 window.elemhide = elemhide; 556 window.elemhide = elemhide;
549 window.typeMap = typeMap; 557 window.typeMap = typeMap;
550 window.getURLsFromElement = getURLsFromElement; 558 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