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

Delta Between Two Patch Sets: include.preload.js

Issue 29714555: Issue 6441 - Avoid unnecessary shadow root (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Use Shadow DOM v0 only on Chrome 65 and lower Created March 8, 2018, 9:50 p.m.
Right Patch Set: Improve user agent check Created March 9, 2018, 12:32 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 367 // Both Firefox and Chrome 66+ support user style sheets, so we can avoid
368 // DOM v0 implementation is slightly different (e.g. no <shadow> element), 368 // creating an unnecessary shadow root on these platforms.
369 // while Chrome is deprecating Shadow DOM v0 in favor of Shadow DOM v1 and 369 let match = /\bChrome\/(\d+)/.exec(navigator.userAgent);
370 // user style sheets. 370 if (!match || match[1] >= 66)
371 let {application, applicationVersion} = require("info");
372 if (application != "chrome" || parseInt(applicationVersion) > 65)
373 return null; 371 return null;
374 372
375 // Using shadow DOM causes issues on some Google websites, 373 // Using shadow DOM causes issues on some Google websites,
376 // including Google Docs, Gmail and Blogger (#1770, #2602, #2687). 374 // including Google Docs, Gmail and Blogger (#1770, #2602, #2687).
377 if (/\.(?:google|blogger)\.com$/.test(document.domain)) 375 if (/\.(?:google|blogger)\.com$/.test(document.domain))
378 return null; 376 return null;
379 377
380 // Finally since some users have both AdBlock and Adblock Plus installed we 378 // Finally since some users have both AdBlock and Adblock Plus installed we
381 // have to consider how the two extensions interact. For example we want to 379 // have to consider how the two extensions interact. For example we want to
382 // avoid creating the shadowRoot twice. 380 // avoid creating the shadowRoot twice.
383 let shadow = document.documentElement.shadowRoot || 381 let shadow = document.documentElement.shadowRoot ||
384 document.documentElement.createShadowRoot(); 382 document.documentElement.createShadowRoot();
385 shadow.appendChild(document.createElement("shadow")); 383 shadow.appendChild(document.createElement("content"));
386 384
387 return shadow; 385 return shadow;
388 }, 386 },
389 387
390 addSelectorsInline(selectors, groupName) 388 addSelectorsInline(selectors, groupName)
391 { 389 {
392 let style = this.styles.get(groupName); 390 let style = this.styles.get(groupName);
393 391
394 if (style) 392 if (style)
395 { 393 {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 let element = event.target; 547 let element = event.target;
550 if (/^i?frame$/.test(element.localName)) 548 if (/^i?frame$/.test(element.localName))
551 checkCollapse(element); 549 checkCollapse(element);
552 }, true); 550 }, true);
553 } 551 }
554 552
555 window.checkCollapse = checkCollapse; 553 window.checkCollapse = checkCollapse;
556 window.elemhide = elemhide; 554 window.elemhide = elemhide;
557 window.typeMap = typeMap; 555 window.typeMap = typeMap;
558 window.getURLsFromElement = getURLsFromElement; 556 window.getURLsFromElement = getURLsFromElement;
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld