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

Side by Side Diff: include.preload.js

Issue 6317759025643520: Issue 1396 - Avoid infinite recursion when collapsing <input type="image"> elements (Closed)
Patch Set: Created Sept. 24, 2014, 11:09 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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 10 matching lines...) Expand all
21 "img": "IMAGE", 21 "img": "IMAGE",
22 "input": "IMAGE", 22 "input": "IMAGE",
23 "audio": "MEDIA", 23 "audio": "MEDIA",
24 "video": "MEDIA", 24 "video": "MEDIA",
25 "frame": "SUBDOCUMENT", 25 "frame": "SUBDOCUMENT",
26 "iframe": "SUBDOCUMENT" 26 "iframe": "SUBDOCUMENT"
27 }; 27 };
28 28
29 function checkCollapse(element) 29 function checkCollapse(element)
30 { 30 {
31 // <input type="image"> elements try to load their image again
32 // when the "display" CSS property is changed by the
33 // collapsing code below. So we have to bail out, if collapsing
34 // is already in progress, to avoid an infinite recursion.
35 if (element._collapsing)
36 return;
Wladimir Palant 2014/09/24 14:57:00 Interesting, a load triggered for an element with
Thomas Greiner 2014/09/24 15:08:29 That's what I checked before and it does have the
Sebastian Noack 2014/09/24 16:42:40 The only thing the standard defines for that parti
Sebastian Noack 2014/09/24 17:04:58 Done, though it wasn't actually that simply. I als
37
31 var tag = element.localName; 38 var tag = element.localName;
32 if (tag in typeMap) 39 if (tag in typeMap)
33 { 40 {
34 // This element failed loading, did we block it? 41 // This element failed loading, did we block it?
35 var url = element.src; 42 var url = element.src;
36 if (!url) 43 if (!url)
37 return; 44 return;
38 45
39 ext.backgroundPage.sendMessage( 46 ext.backgroundPage.sendMessage(
40 { 47 {
41 type: "should-collapse", 48 type: "should-collapse",
42 url: url, 49 url: url,
43 mediatype: typeMap[tag] 50 mediatype: typeMap[tag]
44 }, 51 },
45 52
46 function(response) 53 function(response)
47 { 54 {
48 if (response && element.parentNode) 55 if (response && element.parentNode)
49 { 56 {
57 element._collapsing = true;
Thomas Greiner 2014/09/24 12:35:32 This makes us quite easily distinguishable from ot
Sebastian Noack 2014/09/24 12:50:09 No, it doesn't. Content scripts run in a different
Thomas Greiner 2014/09/24 14:14:54 I can confirm that custom properties are not part
58
50 // <frame> cannot be removed, doing that will mess up the frameset 59 // <frame> cannot be removed, doing that will mess up the frameset
51 if (tag == "frame") 60 if (tag == "frame")
52 element.style.setProperty("visibility", "hidden", "important"); 61 element.style.setProperty("visibility", "hidden", "important");
53 else 62 else
54 element.style.setProperty("display", "none", "important"); 63 element.style.setProperty("display", "none", "important");
55 } 64 }
56 } 65 }
57 ); 66 );
58 } 67 }
59 } 68 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 }, true); 208 }, true);
200 209
201 ext.backgroundPage.sendMessage({type: "get-selectors"}, setElemhideCSSRules); 210 ext.backgroundPage.sendMessage({type: "get-selectors"}, setElemhideCSSRules);
202 } 211 }
203 212
204 if (document instanceof HTMLDocument) 213 if (document instanceof HTMLDocument)
205 { 214 {
206 checkSitekey(); 215 checkSitekey();
207 init(document); 216 init(document);
208 } 217 }
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