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

Delta Between Two Patch Sets: include.preload.js

Issue 29670575: Issue 5899 - Use CSS attribute selectors for collapsing media elements (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Rebase Created April 19, 2018, 9:53 p.m.
Right Patch Set: Compare child name directly Created April 19, 2018, 9:56 p.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 | lib/cssInjection.js » ('j') | 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 if (!element.getAttribute("src")) 139 if (!element.getAttribute("src"))
140 return false; 140 return false;
141 141
142 for (let child of element.children) 142 for (let child of element.children)
143 { 143 {
144 // If the <video> or <audio> element contains any <source> or <track> 144 // If the <video> or <audio> element contains any <source> or <track>
145 // children, we cannot address it in CSS by the source URL; in that case we 145 // children, we cannot address it in CSS by the source URL; in that case we
146 // don't "collapse" it using a CSS selector but rather hide it directly by 146 // don't "collapse" it using a CSS selector but rather hide it directly by
147 // setting the style="..." attribute. 147 // setting the style="..." attribute.
148 if (["source", "track"].includes(child.localName)) 148 if (child.localName == "source" || child.localName == "track")
149 return false; 149 return false;
150 } 150 }
151 151
152 return true; 152 return true;
153 } 153 }
154 154
155 function collapseMediaElement(element, srcValue) 155 function collapseMediaElement(element, srcValue)
156 { 156 {
157 if (!srcValue) 157 if (!srcValue)
158 return; 158 return;
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 let element = event.target; 598 let element = event.target;
599 if (/^i?frame$/.test(element.localName)) 599 if (/^i?frame$/.test(element.localName))
600 checkCollapse(element); 600 checkCollapse(element);
601 }, true); 601 }, true);
602 } 602 }
603 603
604 window.checkCollapse = checkCollapse; 604 window.checkCollapse = checkCollapse;
605 window.elemhide = elemhide; 605 window.elemhide = elemhide;
606 window.typeMap = typeMap; 606 window.typeMap = typeMap;
607 window.getURLsFromElement = getURLsFromElement; 607 window.getURLsFromElement = getURLsFromElement;
LEFTRIGHT

Powered by Google App Engine
This is Rietveld