mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 17:52:26 -05:00
LibWeb: Improve step 3 of "focus chain" from the HTML spec
This function was unnecessarily nested, which created a scenario where we could get stuck in an infinite loop without advancing the current_object pointer up the browsing context container chain.
This commit is contained in:
parent
086eb1ad7b
commit
1ea2467a7a
Notes:
sideshowbarker
2024-07-17 19:41:18 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/1ea2467a7a9
1 changed files with 4 additions and 4 deletions
|
@ -302,12 +302,12 @@ static Vector<DOM::Node&> focus_chain(DOM::Node* subject)
|
|||
if (!is<DOM::Document>(*current_object)) {
|
||||
// 3. If currentObject is a focusable area, then set currentObject to currentObject's DOM anchor's node document.
|
||||
current_object = ¤t_object->document();
|
||||
} else if (is<DOM::Document>(*current_object)) {
|
||||
} else if (is<DOM::Document>(*current_object)
|
||||
&& static_cast<DOM::Document&>(*current_object).browsing_context()
|
||||
&& !static_cast<DOM::Document&>(*current_object).browsing_context()->is_top_level()) {
|
||||
// Otherwise, if currentObject is a Document whose browsing context is a child browsing context,
|
||||
// then set currentObject to currentObject's browsing context's container.
|
||||
auto& document = static_cast<DOM::Document&>(*current_object);
|
||||
if (document.browsing_context() && !document.browsing_context()->is_top_level())
|
||||
current_object = document.browsing_context()->container();
|
||||
current_object = static_cast<DOM::Document&>(*current_object).browsing_context()->container();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue