Chromium Code Reviews| 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..214043c62cf148492464ab90667f66acb2eab098 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,33 @@ 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) /*-{ |
| + // Standard (includes IE9) |
|
cjhopman
2014/05/13 16:20:53
We don't care about IE.
In everything that we car
kuan
2014/05/13 16:55:43
Done.
|
| + if (document.defaultView && document.defaultView.getComputedStyle) { |
| + return document.defaultView.getComputedStyle(el, null); |
| + } |
| + |
| + // Older IE |
| + if (el.currentStyle) return el.currentStyle; |
| + |
| + // Inline style |
| + return el.style; |
| + }-*/; |
| } |