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

Unified Diff: include.postload.js

Issue 6463903206735872: Issue 1606 - Don't create overlays for hidden elements (Closed)
Patch Set: Created Nov. 25, 2014, 4:30 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include.postload.js
===================================================================
--- a/include.postload.js
+++ b/include.postload.js
@@ -190,6 +190,19 @@
return [l, t];
}
+function isDisplayed(element)
+{
+ while (element)
+ {
+ if (getComputedStyle(element).display == "none")
+ return false;
+
+ element = element.parentElement;
+ }
+
+ return true;
+}
+
// Adds an overlay to an element, which is probably a Flash object
function addElementOverlay(elt) {
// If this element is enclosed in an object tag, we prefer to block that instead
@@ -200,6 +213,12 @@
// because we don't know how to construct a filter rule for it
if(!hasFilters(elt))
return;
+
+ // If the element isn't rendered (since its or one of its ancestor's
+ // "diplay" property is "none"), the overlay wouldn't match the element.
+ if (!isDisplayed(elt))
+ return;
+
var thisStyle = getComputedStyle(elt, null);
var overlay = document.createElement('div');
overlay.prisoner = elt;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld