LibWeb: Make Navigable::active_document() const

This commit is contained in:
Jelle Raaijmakers 2025-09-04 15:10:57 +02:00 committed by Tim Flynn
commit 26b5fa348c
Notes: github-actions[bot] 2025-09-12 19:35:36 +00:00
2 changed files with 4 additions and 4 deletions

View file

@ -297,7 +297,7 @@ void Navigable::activate_history_entry(GC::Ptr<SessionHistoryEntry> entry)
} }
// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-document // https://html.spec.whatwg.org/multipage/document-sequences.html#nav-document
GC::Ptr<DOM::Document> Navigable::active_document() GC::Ptr<DOM::Document> Navigable::active_document() const
{ {
// A navigable's active document is its active session history entry's document. // A navigable's active document is its active session history entry's document.
return m_active_session_history_entry->document(); return m_active_session_history_entry->document();
@ -2549,10 +2549,10 @@ static String visible_text_in_range(DOM::Range const& range)
String Navigable::selected_text() const String Navigable::selected_text() const
{ {
auto document = const_cast<Navigable*>(this)->active_document(); auto document = active_document();
if (!document) if (!document)
return String {}; return String {};
auto selection = const_cast<DOM::Document&>(*document).get_selection(); auto selection = document->get_selection();
auto range = selection->range(); auto range = selection->range();
if (!range) if (!range)
return String {}; return String {};

View file

@ -93,7 +93,7 @@ public:
void activate_history_entry(GC::Ptr<SessionHistoryEntry>); void activate_history_entry(GC::Ptr<SessionHistoryEntry>);
GC::Ptr<DOM::Document> active_document(); GC::Ptr<DOM::Document> active_document() const;
GC::Ptr<BrowsingContext> active_browsing_context(); GC::Ptr<BrowsingContext> active_browsing_context();
GC::Ptr<WindowProxy> active_window_proxy(); GC::Ptr<WindowProxy> active_window_proxy();
GC::Ptr<Window> active_window(); GC::Ptr<Window> active_window();