diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
index d11b5a3dc6..d872f45de5 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
@@ -79,7 +79,7 @@ HTML::Origin determine_the_origin(AK::URL const& url, SandboxingFlagSet sandbox_
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-auxiliary-browsing-context
-WebIDL::ExceptionOr BrowsingContext::create_a_new_auxiliary_browsing_context_and_document(Page& page, JS::NonnullGCPtr opener)
+WebIDL::ExceptionOr BrowsingContext::create_a_new_auxiliary_browsing_context_and_document(JS::NonnullGCPtr page, JS::NonnullGCPtr opener)
{
// 1. Let openerTopLevelBrowsingContext be opener's top-level traversable's active browsing context.
auto opener_top_level_browsing_context = opener->top_level_traversable()->active_browsing_context();
@@ -110,7 +110,7 @@ WebIDL::ExceptionOr BrowsingContext
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-browsing-context
-WebIDL::ExceptionOr BrowsingContext::create_a_new_browsing_context_and_document(Page& page, JS::GCPtr creator, JS::GCPtr embedder, JS::NonnullGCPtr group)
+WebIDL::ExceptionOr BrowsingContext::create_a_new_browsing_context_and_document(JS::NonnullGCPtr page, JS::GCPtr creator, JS::GCPtr embedder, JS::NonnullGCPtr group)
{
auto& vm = group->vm();
@@ -263,7 +263,7 @@ WebIDL::ExceptionOr BrowsingContext
return BrowsingContext::BrowsingContextAndDocument { browsing_context, document };
}
-BrowsingContext::BrowsingContext(Page& page, HTML::NavigableContainer* container)
+BrowsingContext::BrowsingContext(JS::NonnullGCPtr page, HTML::NavigableContainer* container)
: m_page(page)
, m_event_handler({}, *this)
, m_container(container)
@@ -284,6 +284,7 @@ void BrowsingContext::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
+ visitor.visit(m_page);
for (auto& entry : m_session_history)
visitor.visit(entry);
visitor.visit(m_container);
@@ -335,7 +336,7 @@ bool BrowsingContext::is_top_level() const
bool BrowsingContext::is_focused_context() const
{
- return m_page && &m_page->focused_context() == this;
+ return &m_page->focused_context() == this;
}
void BrowsingContext::scroll_to(CSSPixelPoint position)
@@ -347,7 +348,7 @@ void BrowsingContext::scroll_to(CSSPixelPoint position)
active_document()->update_layout();
}
- if (m_page && this == &m_page->top_level_browsing_context())
+ if (this == &m_page->top_level_browsing_context())
m_page->client().page_did_request_scroll_to(position);
}
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h
index b731625399..3d76021621 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h
@@ -43,8 +43,8 @@ public:
JS::NonnullGCPtr document;
};
- static WebIDL::ExceptionOr create_a_new_browsing_context_and_document(Page& page, JS::GCPtr creator, JS::GCPtr embedder, JS::NonnullGCPtr group);
- static WebIDL::ExceptionOr create_a_new_auxiliary_browsing_context_and_document(Page& page, JS::NonnullGCPtr opener);
+ static WebIDL::ExceptionOr create_a_new_browsing_context_and_document(JS::NonnullGCPtr page, JS::GCPtr creator, JS::GCPtr embedder, JS::NonnullGCPtr group);
+ static WebIDL::ExceptionOr create_a_new_auxiliary_browsing_context_and_document(JS::NonnullGCPtr page, JS::NonnullGCPtr opener);
virtual ~BrowsingContext() override;
@@ -183,13 +183,13 @@ public:
virtual void set_window_handle(String handle) override { m_window_handle = move(handle); }
private:
- explicit BrowsingContext(Page&, HTML::NavigableContainer*);
+ explicit BrowsingContext(JS::NonnullGCPtr, HTML::NavigableContainer*);
virtual void visit_edges(Cell::Visitor&) override;
void reset_cursor_blink_cycle();
- WeakPtr m_page;
+ JS::NonnullGCPtr m_page;
Web::EventHandler m_event_handler;