| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 var t = 0; | 244 var t = 0; |
| 245 for(; elt; elt = elt.offsetParent) { | 245 for(; elt; elt = elt.offsetParent) { |
| 246 l += elt.offsetLeft; | 246 l += elt.offsetLeft; |
| 247 t += elt.offsetTop; | 247 t += elt.offsetTop; |
| 248 } | 248 } |
| 249 return [l, t]; | 249 return [l, t]; |
| 250 } | 250 } |
| 251 | 251 |
| 252 // Adds an overlay to an element, which is probably a Flash object | 252 // Adds an overlay to an element, which is probably a Flash object |
| 253 function addElementOverlay(elt) { | 253 function addElementOverlay(elt) { |
| 254 // If the element isn't rendered (since its or one of its ancestor's | 254 var zIndex = null; |
| 255 // "display" property is "none"), the overlay wouldn't match the element. | 255 var position = "absolute"; |
| 256 if (!elt.offsetParent) | |
| 257 return; | |
| 258 | 256 |
| 259 var thisStyle = getComputedStyle(elt, null); | 257 for (var e = elt; e; e = e.parentElement) |
| 258 { | |
| 259 var style = getComputedStyle(e); | |
| 260 | |
| 261 // If the element isn't rendered (since its or one of its ancestor's | |
| 262 // "display" property is "none"), the overlay wouldn't match the element. | |
| 263 if (style.display == "none") | |
| 264 return null; | |
| 265 | |
| 266 // If the element or one of its ancestors uses fixed postioning, the overlay | |
| 267 // has to use fixed postioning too. Otherwise it might not match the element . | |
| 268 if (style.position == "fixed") | |
| 269 position = "fixed"; | |
| 270 | |
| 271 // Determine the effective z-index, which is the highest z-index used | |
| 272 // by the element and its offset ancestors. When using a lower z-index | |
| 273 // the element would cover the overlay. When using a higher z-index the | |
| 274 // overlay might also cover other elements. | |
| 275 if (style.position != "static" && style.zIndex != "auto") | |
| 276 zIndex = Math.max(zIndex, parseInt(style.zIndex, 10)); | |
|
kzar
2015/01/13 11:13:13
zIndex is initially null which when passed to Math
Sebastian Noack
2015/01/13 13:20:09
I didn't realize that null is converted to 0, but
| |
| 277 } | |
| 278 | |
| 260 var overlay = document.createElement('div'); | 279 var overlay = document.createElement('div'); |
| 261 overlay.prisoner = elt; | 280 overlay.prisoner = elt; |
| 262 overlay.className = "__adblockplus__overlay"; | 281 overlay.className = "__adblockplus__overlay"; |
| 263 overlay.setAttribute('style', 'opacity:0.4; display:inline-box; position:absol ute; overflow:hidden; box-sizing:border-box;'); | 282 overlay.setAttribute('style', 'opacity:0.4; display:inline-box; overflow:hidde n; box-sizing:border-box;'); |
| 264 var pos = getAbsolutePosition(elt); | 283 var pos = getAbsolutePosition(elt); |
| 265 overlay.style.width = elt.offsetWidth + "px"; | 284 overlay.style.width = elt.offsetWidth + "px"; |
| 266 overlay.style.height = elt.offsetHeight + "px"; | 285 overlay.style.height = elt.offsetHeight + "px"; |
| 267 overlay.style.left = pos[0] + "px"; | 286 overlay.style.left = pos[0] + "px"; |
| 268 overlay.style.top = pos[1] + "px"; | 287 overlay.style.top = pos[1] + "px"; |
| 269 | 288 overlay.style.position = position; |
| 270 if (thisStyle.position != "static") | 289 overlay.style.zIndex = zIndex || "auto"; |
|
kzar
2015/01/13 11:13:13
Should possibly check that zIndex is null here ins
Sebastian Noack
2015/01/13 13:20:09
I use "auto" as default value above now.
| |
| 271 overlay.style.zIndex = thisStyle.zIndex; | |
| 272 else | |
| 273 overlay.style.zIndex = getComputedStyle(elt.offsetParent).zIndex; | |
| 274 | 290 |
| 275 // elt.parentNode.appendChild(overlay, elt); | 291 // elt.parentNode.appendChild(overlay, elt); |
| 276 document.body.appendChild(overlay); | 292 document.body.appendChild(overlay); |
| 277 return overlay; | 293 return overlay; |
| 278 } | 294 } |
| 279 | 295 |
| 280 // Show dialog asking user whether she wants to add the proposed filters derived | 296 // Show dialog asking user whether she wants to add the proposed filters derived |
| 281 // from selected page element | 297 // from selected page element |
| 282 function clickHide_showDialog(left, top, filters) | 298 function clickHide_showDialog(left, top, filters) |
| 283 { | 299 { |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 663 case "clickhide-close": | 679 case "clickhide-close": |
| 664 if (clickHideFiltersDialog && msg.remove) | 680 if (clickHideFiltersDialog && msg.remove) |
| 665 { | 681 { |
| 666 // Explicitly get rid of currentElement | 682 // Explicitly get rid of currentElement |
| 667 var element = currentElement.prisoner || currentElement; | 683 var element = currentElement.prisoner || currentElement; |
| 668 if (element && element.parentNode) | 684 if (element && element.parentNode) |
| 669 element.parentNode.removeChild(element); | 685 element.parentNode.removeChild(element); |
| 670 } | 686 } |
| 671 clickHide_deactivate(); | 687 clickHide_deactivate(); |
| 672 break; | 688 break; |
| 673 default: | 689 default: |
|
kzar
2015/01/13 13:24:50
Did you remove these lines on purpose?
Sebastian Noack
2015/01/13 13:28:20
I had to rebase. And those lines don't exist anymo
| |
| 674 sendResponse({}); | 690 sendResponse({}); |
| 675 break; | 691 break; |
| 676 } | 692 } |
| 677 }); | 693 }); |
| 678 | 694 |
| 679 if (window == window.top) | 695 if (window == window.top) |
| 680 ext.backgroundPage.sendMessage({type: "report-html-page"}); | 696 ext.backgroundPage.sendMessage({type: "report-html-page"}); |
| 681 } | 697 } |
| OLD | NEW |