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

Side by Side Diff: include.preload.js

Issue 4734012065054720: Issue 2634 - Consider alternative URLs for element collapsing (Closed)
Patch Set: Created June 7, 2015, 3:09 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 | « include.postload.js ('k') | 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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 11 matching lines...) Expand all
22 "input": "IMAGE", 22 "input": "IMAGE",
23 "picture": "IMAGE", 23 "picture": "IMAGE",
24 "audio": "MEDIA", 24 "audio": "MEDIA",
25 "video": "MEDIA", 25 "video": "MEDIA",
26 "frame": "SUBDOCUMENT", 26 "frame": "SUBDOCUMENT",
27 "iframe": "SUBDOCUMENT", 27 "iframe": "SUBDOCUMENT",
28 "object": "OBJECT", 28 "object": "OBJECT",
29 "embed": "OBJECT" 29 "embed": "OBJECT"
30 }; 30 };
31 31
32 function getURLsFromObjectElement(element)
Sebastian Noack 2015/06/07 15:30:06 This patchsets merely moves these functions unmodi
33 {
34 var url = element.getAttribute("data");
35 if (url)
36 return [url];
37
38 for (var i = 0; i < element.children.length; i++)
39 {
40 var child = element.children[i];
41 if (child.localName != "param")
42 continue;
43
44 var name = child.getAttribute("name");
45 if (name != "movie" && // Adobe Flash
46 name != "source" && // Silverlight
47 name != "src" && // Real Media + Quicktime
48 name != "FileName") // Windows Media
49 continue;
50
51 var value = child.getAttribute("value");
52 if (!value)
53 continue;
54
55 return [value];
56 }
57
58 return [];
59 }
60
61 function getURLsFromAttributes(element)
62 {
63 var urls = [];
64
65 if (element.src)
66 urls.push(element.src);
67
68 if (element.srcset)
69 {
70 var candidates = element.srcset.split(",");
71 for (var i = 0; i < candidates.length; i++)
72 {
73 var url = candidates[i].trim().replace(/\s+\S+$/, "");
74 if (url)
75 urls.push(url);
76 }
77 }
78
79 return urls;
80 }
81
82 function getURLsFromMediaElement(element)
83 {
84 var urls = getURLsFromAttributes(element);
85
86 for (var i = 0; i < element.children.length; i++)
87 {
88 var child = element.children[i];
89 if (child.localName == "source" || child.localName == "track")
90 urls.push.apply(urls, getURLsFromAttributes(child));
91 }
92
93 if (element.poster)
94 urls.push(element.poster);
95
96 return urls;
97 }
98
99 function getURLsFromElement(element) {
100 switch (element.localName)
101 {
102 case "object":
103 return getURLsFromObjectElement(element);
104
105 case "video":
106 case "audio":
107 case "picture":
108 return getURLsFromMediaElement(element);
109 }
110
111 return getURLsFromAttributes(element);
112 }
113
32 function checkCollapse(element) 114 function checkCollapse(element)
33 { 115 {
34 var tag = element.localName; 116 var tag = element.localName;
35 if (tag in typeMap) 117 if (tag in typeMap)
36 { 118 {
37 // This element failed loading, did we block it? 119 // This element failed loading, did we block it?
38 var url = element.src; 120 var url = element.src;
39 if (!url || !/^https?:/i.test(url)) 121 if (!url || !/^https?:/i.test(url))
40 return; 122 return;
41 123
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 }, true); 380 }, true);
299 381
300 return updateStylesheet; 382 return updateStylesheet;
301 } 383 }
302 384
303 if (document instanceof HTMLDocument) 385 if (document instanceof HTMLDocument)
304 { 386 {
305 checkSitekey(); 387 checkSitekey();
306 window.updateStylesheet = init(document); 388 window.updateStylesheet = init(document);
307 } 389 }
OLDNEW
« no previous file with comments | « include.postload.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld