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

Side by Side Diff: include.postload.js

Issue 6463903206735872: Issue 1606 - Don't create overlays for hidden elements (Closed)
Patch Set: Use offsetParent Created Nov. 25, 2014, 5:15 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 <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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // Adds an overlay to an element, which is probably a Flash object 193 // Adds an overlay to an element, which is probably a Flash object
194 function addElementOverlay(elt) { 194 function addElementOverlay(elt) {
195 // If this element is enclosed in an object tag, we prefer to block that inste ad 195 // If this element is enclosed in an object tag, we prefer to block that inste ad
196 if(!elt) 196 if(!elt)
197 return null; 197 return null;
198 198
199 // If element doesn't have at least one of class name, ID or URL, give up 199 // If element doesn't have at least one of class name, ID or URL, give up
200 // because we don't know how to construct a filter rule for it 200 // because we don't know how to construct a filter rule for it
201 if(!hasFilters(elt)) 201 if(!hasFilters(elt))
202 return; 202 return;
203
204 // If the element isn't rendered (since its or one of its ancestor's
205 // "diplay" property is "none"), the overlay wouldn't match the element.
Wladimir Palant 2014/11/26 13:10:18 Nit: "display"
206 if (!elt.offsetParent)
Wladimir Palant 2014/11/26 13:10:18 What about elements that use visibility:hidden or
Sebastian Noack 2014/11/26 13:15:07 We don't have to bother about those. In that case
207 return;
208
203 var thisStyle = getComputedStyle(elt, null); 209 var thisStyle = getComputedStyle(elt, null);
204 var overlay = document.createElement('div'); 210 var overlay = document.createElement('div');
205 overlay.prisoner = elt; 211 overlay.prisoner = elt;
206 overlay.className = "__adblockplus__overlay"; 212 overlay.className = "__adblockplus__overlay";
207 overlay.setAttribute('style', 'opacity:0.4; background-color:#ffffff; display: inline-box; ' + 'width:' + thisStyle.width + '; height:' + thisStyle.height + '; position:absolute; overflow:hidden; -webkit-box-sizing:border-box; z-index: 999 99'); 213 overlay.setAttribute('style', 'opacity:0.4; background-color:#ffffff; display: inline-box; ' + 'width:' + thisStyle.width + '; height:' + thisStyle.height + '; position:absolute; overflow:hidden; -webkit-box-sizing:border-box; z-index: 999 99');
208 var pos = getAbsolutePosition(elt); 214 var pos = getAbsolutePosition(elt);
209 overlay.style.left = pos[0] + "px"; 215 overlay.style.left = pos[0] + "px";
210 overlay.style.top = pos[1] + "px"; 216 overlay.style.top = pos[1] + "px";
211 // elt.parentNode.appendChild(overlay, elt); 217 // elt.parentNode.appendChild(overlay, elt);
212 document.body.appendChild(overlay); 218 document.body.appendChild(overlay);
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 break; 752 break;
747 default: 753 default:
748 sendResponse({}); 754 sendResponse({});
749 break; 755 break;
750 } 756 }
751 }); 757 });
752 758
753 if (window == window.top) 759 if (window == window.top)
754 ext.backgroundPage.sendMessage({type: "report-html-page"}); 760 ext.backgroundPage.sendMessage({type: "report-html-page"});
755 } 761 }
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