Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: src/com/dom_distiller/client/DomUtil.java

Issue 275493007: filter out invisible elements (Closed) Base URL: https://code.google.com/p/dom-distiller/@master
Patch Set: addressed comments Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/com/dom_distiller/client/DomUtil.java
diff --git a/src/com/dom_distiller/client/DomUtil.java b/src/com/dom_distiller/client/DomUtil.java
index 1450b3b3718c139f9c722349ba12a4e3b2a84db6..6df24cf69b549af01a331f1873ec2fe817414321 100644
--- a/src/com/dom_distiller/client/DomUtil.java
+++ b/src/com/dom_distiller/client/DomUtil.java
@@ -9,6 +9,7 @@ import com.google.gwt.core.client.JsArray;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
+import com.google.gwt.dom.client.Style;
public class DomUtil {
/**
@@ -46,12 +47,24 @@ public class DomUtil {
NodeList<Element> allElems = root.getElementsByTagName("*");
for (int i = 0; i < allElems.getLength(); i++) {
Element elem = allElems.getItem(i);
- String classAttr = elem.getClassName().toLowerCase();
- // Make sure |className| is not the substring of another name in |classAttr|, so check
- // for whitespaces before and after.
- if ((" " + classAttr + " ").contains(" " + className + " ")) return elem;
+ if (hasClassName(elem, className)) return elem;
}
return null;
}
+ public static boolean hasClassName(Element elem, String className) {
+ String classAttr = elem.getClassName().toLowerCase();
+ // Make sure |className| is not the substring of another name in |classAttr|, so check
+ // for whitespaces before and after.
+ return (" " + classAttr + " ").contains(" " + className + " ");
+ }
+
+ /**
+ * @Return The CSS style of an element after applying the active stylesheets and resolving any
+ * basic computation the style's value(s) may contain.
+ * @param el - DOM element
+ */
+ public static native Style getComputedStyle(Element el) /*-{
+ return getComputedStyle(el, null);
+ }-*/;
}
« no previous file with comments | « src/com/dom_distiller/client/DomToSaxVisitor.java ('k') | src/com/dom_distiller/client/FilteringDomVisitor.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698