|
@@ -68,4 +68,20 @@ NonnullRefPtr<Range> Range::normalized() const
|
|
return inverted();
|
|
return inverted();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// https://dom.spec.whatwg.org/#dom-range-commonancestorcontainer
|
|
|
|
+NonnullRefPtr<Node> Range::common_ancestor_container() const
|
|
|
|
+{
|
|
|
|
+ // 1. Let container be start node.
|
|
|
|
+ auto container = m_start_container;
|
|
|
|
+
|
|
|
|
+ // 2. While container is not an inclusive ancestor of end node, let container be container’s parent.
|
|
|
|
+ while (!container->is_inclusive_ancestor_of(m_end_container)) {
|
|
|
|
+ VERIFY(container->parent());
|
|
|
|
+ container = *container->parent();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 3. Return container.
|
|
|
|
+ return container;
|
|
|
|
+}
|
|
|
|
+
|
|
}
|
|
}
|