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

Delta Between Two Patch Sets: include.postload.js

Issue 5474511327592448: Issue 703 - Make sure that z-index of the "Block Element" dialog is the highest in the document (Closed)
Left Patch Set: Created June 24, 2014, 9:05 a.m.
Right Patch Set: Hard-code 0x7FFFFFFF as z-index Created June 24, 2014, 1:07 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 clickHide_deactivate(); 111 clickHide_deactivate();
112 currentElement = savedElement; 112 currentElement = savedElement;
113 } 113 }
114 114
115 clickHide_filters = filters; 115 clickHide_filters = filters;
116 116
117 clickHideFiltersDialog = document.createElement("iframe"); 117 clickHideFiltersDialog = document.createElement("iframe");
118 clickHideFiltersDialog.src = ext.getURL("block.html"); 118 clickHideFiltersDialog.src = ext.getURL("block.html");
119 clickHideFiltersDialog.setAttribute("style", "position: fixed !important; visi bility: hidden; display: block !important; border: 0px !important;"); 119 clickHideFiltersDialog.setAttribute("style", "position: fixed !important; visi bility: hidden; display: block !important; border: 0px !important;");
120 clickHideFiltersDialog.style.WebkitBoxShadow = "5px 5px 20px rgba(0,0,0,0.5)"; 120 clickHideFiltersDialog.style.WebkitBoxShadow = "5px 5px 20px rgba(0,0,0,0.5)";
121 121 clickHideFiltersDialog.style.zIndex = 0x7FFFFFFF;
122 // make sure that the dialog is above everything else, by setting
123 // the z-index to the highest z-index used in the document plus 1
124 clickHideFiltersDialog.style.zIndex = Math.max.apply(null, Array.prototype.map .call(
125 document.all, function(el)
126 {
127 return parseInt(getComputedStyle(el).zIndex) || 0;
128 }
129 )) + 1;
Wladimir Palant 2014/06/24 10:31:39 Please just use the maximum possible value for zIn
Sebastian Noack 2014/06/24 13:07:52 Done.
130 122
131 // Position in upper-left all the time 123 // Position in upper-left all the time
132 clickHideFiltersDialog.style.left = "50px"; 124 clickHideFiltersDialog.style.left = "50px";
133 clickHideFiltersDialog.style.top = "50px"; 125 clickHideFiltersDialog.style.top = "50px";
134 126
135 // Make dialog partly transparent when mouse isn't over it so user has a bette r 127 // Make dialog partly transparent when mouse isn't over it so user has a bette r
136 // view of what's going to be blocked 128 // view of what's going to be blocked
137 clickHideFiltersDialog.onmouseout = function() 129 clickHideFiltersDialog.onmouseout = function()
138 { 130 {
139 if (clickHideFiltersDialog) 131 if (clickHideFiltersDialog)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 clickHide_mouseClick(ev); 212 clickHide_mouseClick(ev);
221 } 213 }
222 214
223 // Hovering over an element so highlight it 215 // Hovering over an element so highlight it
224 function clickHide_mouseOver(e) 216 function clickHide_mouseOver(e)
225 { 217 {
226 if (clickHide_activated == false) 218 if (clickHide_activated == false)
227 return; 219 return;
228 220
229 var target = e.target; 221 var target = e.target;
230 while (target.parentNode && target.attributes.length == 0) 222 while (target.parentNode && !(target.id || target.className || target.src || / :.+:/.test(target.getAttribute("style"))))
231 target = target.parentNode; 223 target = target.parentNode;
232 if (target == document.documentElement || target == document.body) 224 if (target == document.documentElement || target == document.body)
233 target = null; 225 target = null;
234 226
235 if (target && target instanceof HTMLElement) 227 if (target && target instanceof HTMLElement)
236 { 228 {
237 currentElement = target; 229 currentElement = target;
238 currentElement_boxShadow = target.style.getPropertyValue("-webkit-box-shadow "); 230 currentElement_boxShadow = target.style.getPropertyValue("-webkit-box-shadow ");
239 currentElement_backgroundColor = target.style.backgroundColor; 231 currentElement_backgroundColor = target.style.backgroundColor;
240 target.style.setProperty("-webkit-box-shadow", "inset 0px 0px 5px #d6d84b"); 232 target.style.setProperty("-webkit-box-shadow", "inset 0px 0px 5px #d6d84b");
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 { 318 {
327 clickHideFilters.push(relativeToAbsoluteUrl(url)); 319 clickHideFilters.push(relativeToAbsoluteUrl(url));
328 selectorList.push(elt.localName + '[src="' + url + '"]'); 320 selectorList.push(elt.localName + '[src="' + url + '"]');
329 } 321 }
330 322
331 // restore the original style, before generating the fallback filter that 323 // restore the original style, before generating the fallback filter that
332 // will include the style, and to prevent highlightElements from saving those 324 // will include the style, and to prevent highlightElements from saving those
333 currentElement.style.setProperty("-webkit-box-shadow", currentElement_boxShado w); 325 currentElement.style.setProperty("-webkit-box-shadow", currentElement_boxShado w);
334 currentElement.style.backgroundColor = currentElement_backgroundColor; 326 currentElement.style.backgroundColor = currentElement_backgroundColor;
335 327
336 // as last resort, create a filter based on tag's name 328 // as last resort, create a filter based on inline styles
337 // and all of its attributes, if everything else fails 329 if (clickHideFilters.length == 0 && elt.hasAttribute("style"))
338 if (clickHideFilters.length == 0) 330 addSelector(elt.localName + '[style="' + elt.getAttribute("style") + '"]');
339 {
340 var selector = elt.localName;
341
342 for (var i = 0; i < elt.attributes.length; i++)
343 selector += "[" + elt.attributes[i].name + '="' + elt.attributes[i].value. replace('"', '\\"') + '"]';
344
345 addSelector(selector);
346 }
347 331
348 // Show popup 332 // Show popup
349 clickHide_showDialog(e.clientX, e.clientY, clickHideFilters); 333 clickHide_showDialog(e.clientX, e.clientY, clickHideFilters);
350 334
351 // Highlight the elements specified by selector in yellow 335 // Highlight the elements specified by selector in yellow
352 highlightElements(selectorList.join(",")); 336 highlightElements(selectorList.join(","));
353 // Now, actually highlight the element the user clicked on in red 337 // Now, actually highlight the element the user clicked on in red
354 currentElement.style.setProperty("-webkit-box-shadow", "inset 0px 0px 5px #fd1 708"); 338 currentElement.style.setProperty("-webkit-box-shadow", "inset 0px 0px 5px #fd1 708");
355 currentElement.style.backgroundColor = "#f6a1b5"; 339 currentElement.style.backgroundColor = "#f6a1b5";
356 340
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 569
586 clickHide_deactivate(); 570 clickHide_deactivate();
587 } 571 }
588 break; 572 break;
589 default: 573 default:
590 sendResponse({}); 574 sendResponse({});
591 break; 575 break;
592 } 576 }
593 }); 577 });
594 } 578 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld