mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 09:39:39 +00:00
LibWeb: Move event handling & cursor from BrowsingContext to Navigable
This was a long standing FIXME since the introduction of navigables.
This commit is contained in:
parent
9cd4a65071
commit
0ebfc0a4c4
Notes:
sideshowbarker
2024-07-17 01:46:43 +09:00
Author: https://github.com/awesomekling
Commit: 0ebfc0a4c4
Pull-request: https://github.com/SerenityOS/serenity/pull/24123
26 changed files with 364 additions and 360 deletions
|
@ -1138,4 +1138,33 @@ void TraversableNavigable::set_system_visibility_state(VisibilityState visibilit
|
|||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#currently-focused-area-of-a-top-level-traversable
|
||||
JS::GCPtr<DOM::Node> TraversableNavigable::currently_focused_area()
|
||||
{
|
||||
// 1. If traversable does not have system focus, then return null.
|
||||
if (!is_focused())
|
||||
return nullptr;
|
||||
|
||||
// 2. Let candidate be traversable's active document.
|
||||
auto candidate = active_document();
|
||||
|
||||
// 3. While candidate's focused area is a navigable container with a non-null content navigable:
|
||||
// set candidate to the active document of that navigable container's content navigable.
|
||||
while (candidate->focused_element()
|
||||
&& is<HTML::NavigableContainer>(candidate->focused_element())
|
||||
&& static_cast<HTML::NavigableContainer&>(*candidate->focused_element()).content_navigable()) {
|
||||
candidate = static_cast<HTML::NavigableContainer&>(*candidate->focused_element()).content_navigable()->active_document();
|
||||
}
|
||||
|
||||
// 4. If candidate's focused area is non-null, set candidate to candidate's focused area.
|
||||
if (candidate->focused_element()) {
|
||||
// NOTE: We return right away here instead of assigning to candidate,
|
||||
// since that would require compromising type safety.
|
||||
return candidate->focused_element();
|
||||
}
|
||||
|
||||
// 5. Return candidate.
|
||||
return candidate;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue