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

Side by Side Diff: include.postload.js

Issue 5859059588661248: Issue 2077 - Inject overlays with highest possible z-index (Closed)
Patch Set: Created April 8, 2015, 1:28 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 | « 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 <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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 case "audio": 215 case "audio":
216 case "picture": 216 case "picture":
217 return getURLsFromMediaElement(element); 217 return getURLsFromMediaElement(element);
218 } 218 }
219 219
220 return getURLsFromAttributes(element); 220 return getURLsFromAttributes(element);
221 } 221 }
222 222
223 // Adds an overlay to an element, which is probably a Flash object 223 // Adds an overlay to an element, which is probably a Flash object
224 function addElementOverlay(elt) { 224 function addElementOverlay(elt) {
225 var zIndex = "auto";
226 var position = "absolute"; 225 var position = "absolute";
227
228 var offsetX = window.scrollX; 226 var offsetX = window.scrollX;
229 var offsetY = window.scrollY; 227 var offsetY = window.scrollY;
230 228
231 for (var e = elt; e; e = e.parentElement) 229 for (var e = elt; e; e = e.parentElement)
232 { 230 {
233 var style = getComputedStyle(e); 231 var style = getComputedStyle(e);
234 232
235 // If the element isn't rendered (since its or one of its ancestor's 233 // If the element isn't rendered (since its or one of its ancestor's
236 // "display" property is "none"), the overlay wouldn't match the element. 234 // "display" property is "none"), the overlay wouldn't match the element.
237 if (style.display == "none") 235 if (style.display == "none")
238 return null; 236 return null;
239 237
240 // If the element or one of its ancestors uses fixed postioning, the overlay 238 // If the element or one of its ancestors uses fixed postioning, the overlay
241 // has to use fixed postioning too. Otherwise it might not match the element . 239 // has to use fixed postioning too. Otherwise it might not match the element .
242 if (style.position == "fixed") 240 if (style.position == "fixed")
243 { 241 {
244 position = "fixed"; 242 position = "fixed";
245 offsetX = offsetY = 0; 243 offsetX = offsetY = 0;
246 } 244 }
247
248 // Determine the effective z-index, which is the highest z-index used
249 // by the element and its offset ancestors, and increase it by one.
250 // When using a lower z-index the element would cover the overlay.
251 // When using a higher z-index the overlay might also cover other elements.
252 if (style.position != "static" && style.zIndex != "auto")
253 {
254 var curZIndex = parseInt(style.zIndex, 10) + 1;
255
256 if (zIndex == "auto" || curZIndex > zIndex)
257 zIndex = curZIndex;
258 }
259 } 245 }
260 246
261 var overlay = document.createElement('div'); 247 var overlay = document.createElement('div');
262 overlay.prisoner = elt; 248 overlay.prisoner = elt;
263 overlay.className = "__adblockplus__overlay"; 249 overlay.className = "__adblockplus__overlay";
264 overlay.setAttribute('style', 'opacity:0.4; display:inline-box; overflow:hidde n; box-sizing:border-box;'); 250 overlay.setAttribute('style', 'opacity:0.4; display:inline-box; overflow:hidde n; box-sizing:border-box;');
265 var rect = elt.getBoundingClientRect(); 251 var rect = elt.getBoundingClientRect();
266 overlay.style.width = rect.width + "px"; 252 overlay.style.width = rect.width + "px";
267 overlay.style.height = rect.height + "px"; 253 overlay.style.height = rect.height + "px";
268 overlay.style.left = (rect.left + offsetX) + "px"; 254 overlay.style.left = (rect.left + offsetX) + "px";
269 overlay.style.top = (rect.top + offsetY) + "px"; 255 overlay.style.top = (rect.top + offsetY) + "px";
270 overlay.style.position = position; 256 overlay.style.position = position;
271 overlay.style.zIndex = zIndex; 257 overlay.style.zIndex = 0x7FFFFFFE;
kzar 2015/04/08 14:12:22 Hang on, shouldn't that be 0x7FFFFFFF?
Sebastian Noack 2015/04/08 14:32:45 No, 0x7FFFFFFF is the z-index of the dialog which
kzar 2015/04/08 14:33:40 Gotya.
272 258
273 // elt.parentNode.appendChild(overlay, elt); 259 // elt.parentNode.appendChild(overlay, elt);
274 document.documentElement.appendChild(overlay); 260 document.documentElement.appendChild(overlay);
275 return overlay; 261 return overlay;
276 } 262 }
277 263
278 // Show dialog asking user whether she wants to add the proposed filters derived 264 // Show dialog asking user whether she wants to add the proposed filters derived
279 // from selected page element 265 // from selected page element
280 function clickHide_showDialog(filters) 266 function clickHide_showDialog(filters)
281 { 267 {
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 lastRightClickEventValid = false; 750 lastRightClickEventValid = false;
765 else 751 else
766 lastRightClickEvent = null; 752 lastRightClickEvent = null;
767 break; 753 break;
768 } 754 }
769 }); 755 });
770 756
771 if (window == window.top) 757 if (window == window.top)
772 ext.backgroundPage.sendMessage({type: "report-html-page"}); 758 ext.backgroundPage.sendMessage({type: "report-html-page"});
773 } 759 }
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