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

Side by Side Diff: composer.postload.js

Issue 29371763: Issue 4795 - Use modern JavaScript syntax (Closed)
Patch Set: Define and destructure backgroundPage more consistently, fix minor whitespace errors Created Jan. 18, 2017, 7:34 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
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 if (!(element instanceof HTMLElement) || element.localName == "area") 73 if (!(element instanceof HTMLElement) || element.localName == "area")
74 element = element.parentElement; 74 element = element.parentElement;
75 75
76 // If image maps are used mouse events occur for the <area> element. 76 // If image maps are used mouse events occur for the <area> element.
77 // But we have to block the image associated with the <map> element. 77 // But we have to block the image associated with the <map> element.
78 else if (element.localName == "map") 78 else if (element.localName == "map")
79 { 79 {
80 let images = document.querySelectorAll("img[usemap]"); 80 let images = document.querySelectorAll("img[usemap]");
81 let image = null; 81 let image = null;
82 82
83 for (let i = 0; i < images.length; i++) 83 for (let currentImage of images)
84 { 84 {
85 let usemap = images[i].getAttribute("usemap"); 85 let usemap = currentImage.getAttribute("usemap");
86 let index = usemap.indexOf("#"); 86 let index = usemap.indexOf("#");
87 87
88 if (index != -1 && usemap.substr(index + 1) == element.name) 88 if (index != -1 && usemap.substr(index + 1) == element.name)
89 { 89 {
90 image = images[i]; 90 image = currentImage;
91 break; 91 break;
92 } 92 }
93 } 93 }
94 94
95 element = image; 95 element = image;
96 } 96 }
97 97
98 // Finally, if none of the above is true, check whether we can generate 98 // Finally, if none of the above is true, check whether we can generate
99 // any filters for this element. Otherwise fall back to its parent element. 99 // any filters for this element. Otherwise fall back to its parent element.
100 else 100 else
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 overlay.style.zIndex = 0x7FFFFFFE; 158 overlay.style.zIndex = 0x7FFFFFFE;
159 159
160 document.documentElement.appendChild(overlay); 160 document.documentElement.appendChild(overlay);
161 return overlay; 161 return overlay;
162 } 162 }
163 163
164 function highlightElement(element, shadowColor, backgroundColor) 164 function highlightElement(element, shadowColor, backgroundColor)
165 { 165 {
166 unhighlightElement(element); 166 unhighlightElement(element);
167 167
168 let highlightWithOverlay = function() 168 let highlightWithOverlay = () =>
169 { 169 {
170 let overlay = addElementOverlay(element); 170 let overlay = addElementOverlay(element);
171 171
172 // If the element isn't displayed no overlay will be added. 172 // If the element isn't displayed no overlay will be added.
173 // Moreover, we don't need to highlight anything then. 173 // Moreover, we don't need to highlight anything then.
174 if (!overlay) 174 if (!overlay)
175 return; 175 return;
176 176
177 highlightElement(overlay, shadowColor, backgroundColor); 177 highlightElement(overlay, shadowColor, backgroundColor);
178 overlay.style.pointerEvents = "none"; 178 overlay.style.pointerEvents = "none";
179 179
180 element._unhighlight = () => 180 element._unhighlight = () =>
181 { 181 {
182 overlay.parentNode.removeChild(overlay); 182 overlay.parentNode.removeChild(overlay);
183 }; 183 };
184 }; 184 };
185 185
186 let highlightWithStyleAttribute = function() 186 let highlightWithStyleAttribute = () =>
187 { 187 {
188 let originalBoxShadow = element.style.getPropertyValue("box-shadow"); 188 let originalBoxShadow = element.style.getPropertyValue("box-shadow");
189 let originalBoxShadowPriority = 189 let originalBoxShadowPriority =
190 element.style.getPropertyPriority("box-shadow"); 190 element.style.getPropertyPriority("box-shadow");
191 let originalBackgroundColor = 191 let originalBackgroundColor =
192 element.style.getPropertyValue("background-color"); 192 element.style.getPropertyValue("background-color");
193 let originalBackgroundColorPriority = 193 let originalBackgroundColorPriority =
194 element.style.getPropertyPriority("background-color"); 194 element.style.getPropertyPriority("background-color");
195 195
196 element.style.setProperty("box-shadow", "inset 0px 0px 5px " + shadowColor, 196 element.style.setProperty("box-shadow", "inset 0px 0px 5px " + shadowColor,
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 } 581 }
582 }); 582 });
583 } 583 }
584 break; 584 break;
585 } 585 }
586 }); 586 });
587 587
588 if (window == window.top) 588 if (window == window.top)
589 ext.backgroundPage.sendMessage({type: "composer.ready"}); 589 ext.backgroundPage.sendMessage({type: "composer.ready"});
590 } 590 }
OLDNEW

Powered by Google App Engine
This is Rietveld