OLD | NEW |
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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 197 } |
198 | 198 |
199 return getURLsFromAttributes(element); | 199 return getURLsFromAttributes(element); |
200 } | 200 } |
201 | 201 |
202 // Adds an overlay to an element, which is probably a Flash object | 202 // Adds an overlay to an element, which is probably a Flash object |
203 function addElementOverlay(elt) { | 203 function addElementOverlay(elt) { |
204 var zIndex = "auto"; | 204 var zIndex = "auto"; |
205 var position = "absolute"; | 205 var position = "absolute"; |
206 | 206 |
| 207 var offsetX = window.scrollX; |
| 208 var offsetY = window.scrollY; |
| 209 |
207 for (var e = elt; e; e = e.parentElement) | 210 for (var e = elt; e; e = e.parentElement) |
208 { | 211 { |
209 var style = getComputedStyle(e); | 212 var style = getComputedStyle(e); |
210 | 213 |
211 // If the element isn't rendered (since its or one of its ancestor's | 214 // If the element isn't rendered (since its or one of its ancestor's |
212 // "display" property is "none"), the overlay wouldn't match the element. | 215 // "display" property is "none"), the overlay wouldn't match the element. |
213 if (style.display == "none") | 216 if (style.display == "none") |
214 return null; | 217 return null; |
215 | 218 |
216 // If the element or one of its ancestors uses fixed postioning, the overlay | 219 // If the element or one of its ancestors uses fixed postioning, the overlay |
217 // has to use fixed postioning too. Otherwise it might not match the element
. | 220 // has to use fixed postioning too. Otherwise it might not match the element
. |
218 if (style.position == "fixed") | 221 if (style.position == "fixed") |
| 222 { |
219 position = "fixed"; | 223 position = "fixed"; |
| 224 offsetX = offsetY = 0; |
| 225 } |
220 | 226 |
221 // Determine the effective z-index, which is the highest z-index used | 227 // Determine the effective z-index, which is the highest z-index used |
222 // by the element and its offset ancestors, and increase it by one. | 228 // by the element and its offset ancestors, and increase it by one. |
223 // When using a lower z-index the element would cover the overlay. | 229 // When using a lower z-index the element would cover the overlay. |
224 // When using a higher z-index the overlay might also cover other elements. | 230 // When using a higher z-index the overlay might also cover other elements. |
225 if (style.position != "static" && style.zIndex != "auto") | 231 if (style.position != "static" && style.zIndex != "auto") |
226 { | 232 { |
227 var curZIndex = parseInt(style.zIndex, 10) + 1; | 233 var curZIndex = parseInt(style.zIndex, 10) + 1; |
228 | 234 |
229 if (zIndex == "auto" || curZIndex > zIndex) | 235 if (zIndex == "auto" || curZIndex > zIndex) |
230 zIndex = curZIndex; | 236 zIndex = curZIndex; |
231 } | 237 } |
232 } | 238 } |
233 | 239 |
234 var overlay = document.createElement('div'); | 240 var overlay = document.createElement('div'); |
235 overlay.prisoner = elt; | 241 overlay.prisoner = elt; |
236 overlay.className = "__adblockplus__overlay"; | 242 overlay.className = "__adblockplus__overlay"; |
237 overlay.setAttribute('style', 'opacity:0.4; display:inline-box; overflow:hidde
n; box-sizing:border-box;'); | 243 overlay.setAttribute('style', 'opacity:0.4; display:inline-box; overflow:hidde
n; box-sizing:border-box;'); |
238 var rect = elt.getBoundingClientRect(); | 244 var rect = elt.getBoundingClientRect(); |
239 overlay.style.width = rect.width + "px"; | 245 overlay.style.width = rect.width + "px"; |
240 overlay.style.height = rect.height + "px"; | 246 overlay.style.height = rect.height + "px"; |
241 overlay.style.left = (rect.left + window.scrollX) + "px"; | 247 overlay.style.left = (rect.left + offsetX) + "px"; |
242 overlay.style.top = (rect.top + window.scrollY) + "px"; | 248 overlay.style.top = (rect.top + offsetY) + "px"; |
243 overlay.style.position = position; | 249 overlay.style.position = position; |
244 overlay.style.zIndex = zIndex; | 250 overlay.style.zIndex = zIndex; |
245 | 251 |
246 // elt.parentNode.appendChild(overlay, elt); | 252 // elt.parentNode.appendChild(overlay, elt); |
247 document.documentElement.appendChild(overlay); | 253 document.documentElement.appendChild(overlay); |
248 return overlay; | 254 return overlay; |
249 } | 255 } |
250 | 256 |
251 // Show dialog asking user whether she wants to add the proposed filters derived | 257 // Show dialog asking user whether she wants to add the proposed filters derived |
252 // from selected page element | 258 // from selected page element |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 lastRightClickEventValid = false; | 742 lastRightClickEventValid = false; |
737 else | 743 else |
738 lastRightClickEvent = null; | 744 lastRightClickEvent = null; |
739 break; | 745 break; |
740 } | 746 } |
741 }); | 747 }); |
742 | 748 |
743 if (window == window.top) | 749 if (window == window.top) |
744 ext.backgroundPage.sendMessage({type: "report-html-page"}); | 750 ext.backgroundPage.sendMessage({type: "report-html-page"}); |
745 } | 751 } |
OLD | NEW |