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..da40ec73988557319e703b5314bb7f72d2e7cede 100644 |
--- a/java/org/chromium/distiller/DomUtil.java |
+++ b/java/org/chromium/distiller/DomUtil.java |
@@ -181,6 +181,18 @@ public class DomUtil { |
} |
/** |
+ * Get the nearest common ancestor of nodes. |
+ */ |
+ public static Node getNearestCommonAncestor(final List<Element> ns) { |
+ if (ns.size() == 0) return null; |
+ Node parent = ns.get(0); |
+ for (int i = 1; i < ns.size(); i++) { |
+ parent = getNearestCommonAncestor(parent, ns.get(i)); |
+ } |
+ return parent; |
+ } |
+ |
+ /** |
* Get all text from a tree/sub-tree. |
* @param node The root of the tree. |
* @return The text contained in this tree. |