summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
diff options
context:
space:
mode:
authornetworkException <git@nwex.de>2022-09-06 19:56:29 +0200
committerLinus Groh <mail@linusgroh.de>2022-09-09 17:42:30 +0100
commite377e28fd29081f809f934c9107a2d742dae7718 (patch)
tree910c59133c7e7c840c413f971b541fb614c1c339 /Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
parentb70e4e9909acdb3e6da19b9a749b2cb805280126 (diff)
downloadserenity-e377e28fd29081f809f934c9107a2d742dae7718.zip
LibWeb: Implement window.length
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp')
-rw-r--r--Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
index 28fdb48a01..a68ce1c19a 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
@@ -742,6 +742,28 @@ BrowsingContext* BrowsingContext::choose_a_browsing_context(StringView name, boo
return chosen;
}
+// https://html.spec.whatwg.org/multipage/browsers.html#document-tree-child-browsing-context
+size_t BrowsingContext::document_tree_child_browsing_context_count() const
+{
+ size_t count = 0;
+
+ // A browsing context child is a document-tree child browsing context of parent if child is a child browsing context and child's container is in a document tree.
+ for_each_child([this, &count](BrowsingContext const& child) {
+ if (child.is_child_of(*this) && child.container()->in_a_document_tree())
+ ++count;
+ });
+
+ return count;
+}
+
+// https://html.spec.whatwg.org/multipage/browsers.html#child-browsing-context
+bool BrowsingContext::is_child_of(BrowsingContext const& parent) const
+{
+ // A browsing context child is said to be a child browsing context of another browsing context parent,
+ // if child's container document is non-null and child's container document's browsing context is parent.
+ return container_document() && container_document()->browsing_context() == &parent;
+}
+
// https://html.spec.whatwg.org/multipage/dom.html#still-on-its-initial-about:blank-document
bool BrowsingContext::still_on_its_initial_about_blank_document() const
{