mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-20 23:19:44 +00:00
LibWeb+WebContent: Rename Document::focused_element to ::focused_area
And make it a DOM::Node, not DOM::Element. This makes everything flow much better, such as spec texts that explicitly mention "focused area" as the fact that we don't necessarily need to traverse a tree of elements, since a Node can be focusable as well. Eventually this will need to be a struct with a separate "focused area" and "DOM anchor", but this change will make it easier to achieve that.
This commit is contained in:
parent
90f1c8724b
commit
518c048eb4
Notes:
github-actions[bot]
2025-08-26 08:27:18 +00:00
Author: https://github.com/gmta
Commit: 518c048eb4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5952
11 changed files with 92 additions and 91 deletions
|
@ -1369,17 +1369,17 @@ GC::Ptr<DOM::Node> TraversableNavigable::currently_focused_area()
|
|||
|
||||
// 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();
|
||||
while (candidate->focused_area()
|
||||
&& is<NavigableContainer>(candidate->focused_area().ptr())
|
||||
&& as<NavigableContainer>(*candidate->focused_area()).content_navigable()) {
|
||||
candidate = as<NavigableContainer>(*candidate->focused_area()).content_navigable()->active_document();
|
||||
}
|
||||
|
||||
// 4. If candidate's focused area is non-null, set candidate to candidate's focused area.
|
||||
if (candidate->focused_element()) {
|
||||
if (candidate->focused_area()) {
|
||||
// NOTE: We return right away here instead of assigning to candidate,
|
||||
// since that would require compromising type safety.
|
||||
return candidate->focused_element();
|
||||
return candidate->focused_area();
|
||||
}
|
||||
|
||||
// 5. Return candidate.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue