1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:07:34 +00:00

LibWeb: Implement window.length

This commit is contained in:
networkException 2022-09-06 19:56:29 +02:00 committed by Linus Groh
parent b70e4e9909
commit e377e28fd2
4 changed files with 53 additions and 0 deletions

View file

@ -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
{