mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 20:17:42 +00:00
LibWeb: Update WindowProxy::internal_get_own_property
for navigables
This commit is contained in:
parent
d45f2a4952
commit
dd9eca254e
1 changed files with 9 additions and 10 deletions
|
@ -72,20 +72,19 @@ JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> WindowProxy::internal_ge
|
||||||
// 1. Let index be ! ToUint32(P).
|
// 1. Let index be ! ToUint32(P).
|
||||||
auto index = property_key.as_number();
|
auto index = property_key.as_number();
|
||||||
|
|
||||||
// 2. Let maxProperties be the number of document-tree child browsing contexts of W.
|
// 2. Let children be the document-tree child navigables of W's associated Document.
|
||||||
auto max_properties = m_window->document_tree_child_browsing_context_count();
|
auto children = m_window->associated_document().document_tree_child_navigables();
|
||||||
|
|
||||||
// 3. Let value be undefined.
|
// 3. Let value be undefined.
|
||||||
Optional<JS::Value> value;
|
Optional<JS::Value> value;
|
||||||
|
|
||||||
// 4. If maxProperties is greater than 0 and index is less than maxProperties, then set value to the WindowProxy object of the indexth document-tree child browsing context of W's browsing context, sorted in the order that their browsing context container elements were most recently inserted into W's associated Document, the WindowProxy object of the most recently inserted browsing context container's nested browsing context being last.
|
// 4. If index is less than children's size, then:
|
||||||
if (max_properties > 0 && index < max_properties) {
|
if (index < children.size()) {
|
||||||
JS::MarkedVector<BrowsingContext*> browsing_contexts { vm.heap() };
|
// 1. Sort children in ascending order, with navigableA being less than navigableB if navigableA's container was inserted into W's associated Document earlier than navigableB's container was.
|
||||||
m_window->browsing_context()->for_each_child([&](BrowsingContext& child) {
|
// NOTE: children are coming sorted in required order from document_tree_child_navigables()
|
||||||
if (child.container() && child.container()->in_a_document_tree())
|
|
||||||
browsing_contexts.append(&child);
|
// 2. Set value to children[index]'s active WindowProxy.
|
||||||
});
|
value = children[index]->active_window_proxy();
|
||||||
value = JS::Value(browsing_contexts[index]->window_proxy());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. If value is undefined, then:
|
// 5. If value is undefined, then:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue