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

Delta Between Two Patch Sets: include.preload.js

Issue 29770568: Issue 6645 - Collapse elements through user style sheets if possible (Closed)
Left Patch Set: Addressed Manish's feedback Created May 9, 2018, 4:28 p.m.
Right Patch Set: Got rif of hasSrc variable Created May 10, 2018, 11:45 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // setting the style="..." attribute. 151 // setting the style="..." attribute.
152 if (element.localName == "video" || element.localName == "audio") 152 if (element.localName == "video" || element.localName == "audio")
153 { 153 {
154 for (let child of element.children) 154 for (let child of element.children)
155 { 155 {
156 if (child.localName == "source" || child.localName == "track") 156 if (child.localName == "source" || child.localName == "track")
157 return null; 157 return null;
158 } 158 }
159 } 159 }
160 160
161 let selector = element.localName; 161 let selector = "";
162 let hasSrc = false;
Manish Jethani 2018/05/10 01:57:17 Only one small nit, and this is totally a nit. We
Sebastian Noack 2018/05/10 11:45:33 Done.
163 for (let attr of ["src", "srcset"]) 162 for (let attr of ["src", "srcset"])
Manish Jethani 2018/05/09 23:11:09 If I understand correctly [1], srcset is only rele
Sebastian Noack 2018/05/10 01:08:22 #2 is what my current implementation does. Also co
Manish Jethani 2018/05/10 01:57:17 Ah, I didn't realize you were not breaking from th
164 { 163 {
165 let value = element.getAttribute(attr); 164 let value = element.getAttribute(attr);
166 if (value && attr in element) 165 if (value && attr in element)
167 {
168 selector += "[" + attr + "=" + CSS.escape(value) + "]"; 166 selector += "[" + attr + "=" + CSS.escape(value) + "]";
169 hasSrc = true; 167 }
170 } 168
171 } 169 return selector ? element.localName + selector : null;
172
173 return hasSrc ? selector : null;
174 } 170 }
175 171
176 function hideElement(element) 172 function hideElement(element)
177 { 173 {
178 function doHide() 174 function doHide()
179 { 175 {
180 let propertyName = "display"; 176 let propertyName = "display";
181 let propertyValue = "none"; 177 let propertyValue = "none";
182 if (element.localName == "frame") 178 if (element.localName == "frame")
183 { 179 {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 297
302 break nodes; 298 break nodes;
303 } 299 }
304 } 300 }
305 } 301 }
306 } 302 }
307 303
308 if (selectors.length > 0 || filters.length > 0) 304 if (selectors.length > 0 || filters.length > 0)
309 { 305 {
310 browser.runtime.sendMessage({ 306 browser.runtime.sendMessage({
311 type: "devtools.traceElemHide", 307 type: "hitLogger.traceElemHide",
312 selectors, filters 308 selectors, filters
313 }); 309 });
314 } 310 }
315 }, 311 },
316 312
317 onTimeout() 313 onTimeout()
318 { 314 {
319 this.checkNodes(this.changedNodes, this.selectors); 315 this.checkNodes(this.changedNodes, this.selectors);
320 this.changedNodes = []; 316 this.changedNodes = [];
321 this.timeout = null; 317 this.timeout = null;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 }, 544 },
549 545
550 hideElements(elements, filters) 546 hideElements(elements, filters)
551 { 547 {
552 for (let element of elements) 548 for (let element of elements)
553 hideElement(element); 549 hideElement(element);
554 550
555 if (this.tracer) 551 if (this.tracer)
556 { 552 {
557 browser.runtime.sendMessage({ 553 browser.runtime.sendMessage({
558 type: "devtools.traceElemHide", 554 type: "hitLogger.traceElemHide",
559 selectors: [], 555 selectors: [],
560 filters 556 filters
561 }); 557 });
562 } 558 }
563 }, 559 },
564 560
565 apply() 561 apply()
566 { 562 {
567 browser.runtime.sendMessage({type: "elemhide.getSelectors"}, response => 563 browser.runtime.sendMessage({type: "elemhide.getSelectors"}, response =>
568 { 564 {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 let element = event.target; 605 let element = event.target;
610 if (/^i?frame$/.test(element.localName)) 606 if (/^i?frame$/.test(element.localName))
611 checkCollapse(element); 607 checkCollapse(element);
612 }, true); 608 }, true);
613 } 609 }
614 610
615 window.checkCollapse = checkCollapse; 611 window.checkCollapse = checkCollapse;
616 window.elemhide = elemhide; 612 window.elemhide = elemhide;
617 window.typeMap = typeMap; 613 window.typeMap = typeMap;
618 window.getURLsFromElement = getURLsFromElement; 614 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