Index: java/org/chromium/distiller/DomUtil.java |
diff --git a/java/org/chromium/distiller/DomUtil.java b/java/org/chromium/distiller/DomUtil.java |
index d0bcb1bfd7330c1cc8c56be59fdbc6320918284f..4fc01d015d0fcf2e05b771f0695ddbb8b8fada2c 100644 |
--- a/java/org/chromium/distiller/DomUtil.java |
+++ b/java/org/chromium/distiller/DomUtil.java |
@@ -95,6 +95,15 @@ public class DomUtil { |
}-*/; |
public static boolean isVisible(Element e) { |
+ // Detect whether any of the ancestors has "display: none". |
+ // Using offsetParent alone wouldn't work because it's also null when position is fixed. |
+ return !(e.getOffsetParent() == null && e.getOffsetHeight() == 0 && e.getOffsetWidth() == 0); |
mdjones
2015/12/08 00:04:33
why not:
return e.getOffsetParent() != null || ...
wychen
2015/12/08 00:41:46
Done.
|
+ } |
+ |
+ // Currently not used by anyone. |
mdjones
2015/12/08 00:04:33
I think it's okay if we remove this if not used.
wychen
2015/12/08 00:41:46
Done.
|
+ public static boolean isVisibleAccurate(Element e) { |
+ if (!isVisible(e)) |
+ return false; |
Style style = getComputedStyle(e); |
double opacity = JavaScript.parseFloat(style.getOpacity()); |
return !(style.getDisplay().equals("none") || |