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:
Jelle Raaijmakers 2025-08-21 17:09:40 +02:00 committed by Jelle Raaijmakers
parent 90f1c8724b
commit 518c048eb4
Notes: github-actions[bot] 2025-08-26 08:27:18 +00:00
11 changed files with 92 additions and 91 deletions

View file

@ -35,7 +35,6 @@
#include <LibWeb/HTML/Focus.h>
#include <LibWeb/HTML/HTMLScriptElement.h>
#include <LibWeb/HTML/History.h>
#include <LibWeb/HTML/LazyLoadingElement.h>
#include <LibWeb/HTML/NavigationType.h>
#include <LibWeb/HTML/SandboxingFlagSet.h>
#include <LibWeb/HTML/Scripting/Environments.h>
@ -431,10 +430,10 @@ public:
void set_editable(bool editable) { m_editable = editable; }
Element* focused_element() { return m_focused_element.ptr(); }
Element const* focused_element() const { return m_focused_element.ptr(); }
void set_focused_element(GC::Ptr<Element>);
// // https://html.spec.whatwg.org/multipage/interaction.html#focused-area-of-the-document
GC::Ptr<Node> focused_area() { return m_focused_area; }
GC::Ptr<Node const> focused_area() const { return m_focused_area; }
void set_focused_area(GC::Ptr<Node>);
HTML::FocusTrigger last_focus_trigger() const { return m_last_focus_trigger; }
void set_last_focus_trigger(HTML::FocusTrigger trigger) { m_last_focus_trigger = trigger; }
@ -1017,7 +1016,9 @@ private:
bool m_editable { false };
GC::Ptr<Element> m_focused_element;
// https://html.spec.whatwg.org/multipage/interaction.html#focused-area-of-the-document
GC::Ptr<Node> m_focused_area;
HTML::FocusTrigger m_last_focus_trigger { HTML::FocusTrigger::Other };
GC::Ptr<Element> m_active_element;