diff --git a/Libraries/LibWeb/HTML/Navigable.cpp b/Libraries/LibWeb/HTML/Navigable.cpp
index 966c4b804b3..d9cb76abe93 100644
--- a/Libraries/LibWeb/HTML/Navigable.cpp
+++ b/Libraries/LibWeb/HTML/Navigable.cpp
@@ -297,7 +297,7 @@ void Navigable::activate_history_entry(GC::Ptr entry)
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-document
-GC::Ptr Navigable::active_document()
+GC::Ptr Navigable::active_document() const
{
// A navigable's active document is its active session history entry's 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
{
- auto document = const_cast(this)->active_document();
+ auto document = active_document();
if (!document)
return String {};
- auto selection = const_cast(*document).get_selection();
+ auto selection = document->get_selection();
auto range = selection->range();
if (!range)
return String {};
diff --git a/Libraries/LibWeb/HTML/Navigable.h b/Libraries/LibWeb/HTML/Navigable.h
index 962c771c25b..1277a603dfa 100644
--- a/Libraries/LibWeb/HTML/Navigable.h
+++ b/Libraries/LibWeb/HTML/Navigable.h
@@ -93,7 +93,7 @@ public:
void activate_history_entry(GC::Ptr);
- GC::Ptr active_document();
+ GC::Ptr active_document() const;
GC::Ptr active_browsing_context();
GC::Ptr active_window_proxy();
GC::Ptr active_window();