mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 06:47:40 +00:00
LibWeb: Implement step 7 of choose_a_browsing_context
This commit is contained in:
parent
caa491b72a
commit
266d4a3553
1 changed files with 17 additions and 9 deletions
|
@ -848,6 +848,15 @@ BrowsingContext::ChosenBrowsingContext BrowsingContext::choose_a_browsing_contex
|
||||||
{
|
{
|
||||||
// The rules for choosing a browsing context, given a browsing context name name, a browsing context current, and
|
// The rules for choosing a browsing context, given a browsing context name name, a browsing context current, and
|
||||||
// a boolean noopener are as follows:
|
// a boolean noopener are as follows:
|
||||||
|
JS::GCPtr<AbstractBrowsingContext> matching_name_in_tree = nullptr;
|
||||||
|
top_level_browsing_context().for_each_in_subtree([&](auto& context) {
|
||||||
|
if (context.name() == name) {
|
||||||
|
matching_name_in_tree = &context;
|
||||||
|
return IterationDecision::Break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
});
|
||||||
|
|
||||||
// 1. Let chosen be null.
|
// 1. Let chosen be null.
|
||||||
JS::GCPtr<AbstractBrowsingContext> chosen = nullptr;
|
JS::GCPtr<AbstractBrowsingContext> chosen = nullptr;
|
||||||
|
@ -878,15 +887,14 @@ BrowsingContext::ChosenBrowsingContext BrowsingContext::choose_a_browsing_contex
|
||||||
chosen = &top_level_browsing_context();
|
chosen = &top_level_browsing_context();
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: 7. Otherwise, if name is not an ASCII case-insensitive match for "_blank", there exists a browsing context
|
// 7. Otherwise, if name is not an ASCII case-insensitive match for "_blank", there exists a browsing context
|
||||||
// whose name is the same as name, current is familiar with that browsing context, and the user agent
|
// whose name is the same as name, current is familiar with that browsing context, and the user agent
|
||||||
// determines that the two browsing contexts are related enough that it is ok if they reach each other,
|
// determines that the two browsing contexts are related enough that it is ok if they reach each other,
|
||||||
// set chosen to that browsing context. If there are multiple matching browsing contexts, the user agent
|
// set chosen to that browsing context. If there are multiple matching browsing contexts, the user agent
|
||||||
// should set chosen to one in some arbitrary consistent manner, such as the most recently opened, most
|
// should set chosen to one in some arbitrary consistent manner, such as the most recently opened, most
|
||||||
// recently focused, or more closely related.
|
// recently focused, or more closely related.
|
||||||
else if (!Infra::is_ascii_case_insensitive_match(name, "_blank"sv)) {
|
else if (!Infra::is_ascii_case_insensitive_match(name, "_blank"sv) && matching_name_in_tree) {
|
||||||
dbgln("FIXME: Find matching browser context for name {}", name);
|
chosen = matching_name_in_tree;
|
||||||
chosen = this;
|
|
||||||
} else {
|
} else {
|
||||||
// 8. Otherwise, a new browsing context is being requested, and what happens depends on the user agent's
|
// 8. Otherwise, a new browsing context is being requested, and what happens depends on the user agent's
|
||||||
// configuration and abilities — it is determined by the rules given for the first applicable option from
|
// configuration and abilities — it is determined by the rules given for the first applicable option from
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue