1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:14:58 +00:00

LibWeb: Make TraversableNavigable store Page member as NonnullGCPtr

This commit is contained in:
Shannon Booth 2023-12-03 16:56:04 +13:00 committed by Andreas Kling
parent bf4c8f4a09
commit fd7be22653
4 changed files with 14 additions and 13 deletions

View file

@ -20,7 +20,7 @@ static HashTable<JS::NonnullGCPtr<BrowsingContextGroup>>& user_agent_browsing_co
return set;
}
BrowsingContextGroup::BrowsingContextGroup(Web::Page& page)
BrowsingContextGroup::BrowsingContextGroup(JS::NonnullGCPtr<Web::Page> page)
: m_page(page)
{
user_agent_browsing_context_group_set().set(*this);
@ -40,7 +40,7 @@ void BrowsingContextGroup::visit_edges(Cell::Visitor& visitor)
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-browsing-context-group-and-document
auto BrowsingContextGroup::create_a_new_browsing_context_group_and_document(Page& page) -> WebIDL::ExceptionOr<BrowsingContextGroupAndDocument>
auto BrowsingContextGroup::create_a_new_browsing_context_group_and_document(JS::NonnullGCPtr<Page> page) -> WebIDL::ExceptionOr<BrowsingContextGroupAndDocument>
{
// 1. Let group be a new browsing context group.
// 2. Append group to the user agent's browsing context group set.

View file

@ -23,7 +23,7 @@ public:
JS::NonnullGCPtr<HTML::BrowsingContextGroup> browsing_context;
JS::NonnullGCPtr<DOM::Document> document;
};
static WebIDL::ExceptionOr<BrowsingContextGroupAndDocument> create_a_new_browsing_context_group_and_document(Page&);
static WebIDL::ExceptionOr<BrowsingContextGroupAndDocument> create_a_new_browsing_context_group_and_document(JS::NonnullGCPtr<Page>);
~BrowsingContextGroup();
@ -36,7 +36,7 @@ public:
void append(BrowsingContext&);
private:
explicit BrowsingContextGroup(Web::Page&);
explicit BrowsingContextGroup(JS::NonnullGCPtr<Web::Page>);
virtual void visit_edges(Cell::Visitor&) override;

View file

@ -20,7 +20,7 @@ namespace Web::HTML {
JS_DEFINE_ALLOCATOR(TraversableNavigable);
TraversableNavigable::TraversableNavigable(Page& page)
TraversableNavigable::TraversableNavigable(JS::NonnullGCPtr<Page> page)
: m_page(page)
{
}
@ -30,6 +30,7 @@ TraversableNavigable::~TraversableNavigable() = default;
void TraversableNavigable::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_page);
for (auto& entry : m_session_history_entries)
visitor.visit(entry);
}
@ -41,7 +42,7 @@ static OrderedHashTable<TraversableNavigable*>& user_agent_top_level_traversable
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-top-level-browsing-context
WebIDL::ExceptionOr<BrowsingContextAndDocument> create_a_new_top_level_browsing_context_and_document(Page& page)
WebIDL::ExceptionOr<BrowsingContextAndDocument> create_a_new_top_level_browsing_context_and_document(JS::NonnullGCPtr<Page> page)
{
// 1. Let group and document be the result of creating a new browsing context group and document.
auto [group, document] = TRY(BrowsingContextGroup::create_a_new_browsing_context_group_and_document(page));
@ -51,7 +52,7 @@ WebIDL::ExceptionOr<BrowsingContextAndDocument> create_a_new_top_level_browsing_
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-top-level-traversable
WebIDL::ExceptionOr<JS::NonnullGCPtr<TraversableNavigable>> TraversableNavigable::create_a_new_top_level_traversable(Page& page, JS::GCPtr<HTML::BrowsingContext> opener, String target_name)
WebIDL::ExceptionOr<JS::NonnullGCPtr<TraversableNavigable>> TraversableNavigable::create_a_new_top_level_traversable(JS::NonnullGCPtr<Page> page, JS::GCPtr<HTML::BrowsingContext> opener, String target_name)
{
auto& vm = Bindings::main_thread_vm();
@ -112,7 +113,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<TraversableNavigable>> TraversableNavigable
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#create-a-fresh-top-level-traversable
WebIDL::ExceptionOr<JS::NonnullGCPtr<TraversableNavigable>> TraversableNavigable::create_a_fresh_top_level_traversable(Page& page, AK::URL const& initial_navigation_url, Variant<Empty, String, POSTResource> initial_navigation_post_resource)
WebIDL::ExceptionOr<JS::NonnullGCPtr<TraversableNavigable>> TraversableNavigable::create_a_fresh_top_level_traversable(JS::NonnullGCPtr<Page> page, AK::URL const& initial_navigation_url, Variant<Empty, String, POSTResource> initial_navigation_post_resource)
{
// 1. Let traversable be the result of creating a new top-level traversable given null and the empty string.
auto traversable = TRY(create_a_new_top_level_traversable(page, nullptr, {}));

View file

@ -19,8 +19,8 @@ class TraversableNavigable final : public Navigable {
JS_DECLARE_ALLOCATOR(TraversableNavigable);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<TraversableNavigable>> create_a_new_top_level_traversable(Page&, JS::GCPtr<BrowsingContext> opener, String target_name);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<TraversableNavigable>> create_a_fresh_top_level_traversable(Page&, AK::URL const& initial_navigation_url, Variant<Empty, String, POSTResource> = Empty {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<TraversableNavigable>> create_a_new_top_level_traversable(JS::NonnullGCPtr<Page>, JS::GCPtr<BrowsingContext> opener, String target_name);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<TraversableNavigable>> create_a_fresh_top_level_traversable(JS::NonnullGCPtr<Page>, AK::URL const& initial_navigation_url, Variant<Empty, String, POSTResource> = Empty {});
virtual ~TraversableNavigable() override;
@ -67,7 +67,7 @@ public:
Page const* page() const { return m_page; }
private:
TraversableNavigable(Page&);
TraversableNavigable(JS::NonnullGCPtr<Page>);
virtual void visit_edges(Cell::Visitor&) override;
@ -89,7 +89,7 @@ private:
SessionHistoryTraversalQueue m_session_history_traversal_queue;
WeakPtr<Page> m_page;
JS::NonnullGCPtr<Page> m_page;
};
struct BrowsingContextAndDocument {
@ -97,7 +97,7 @@ struct BrowsingContextAndDocument {
JS::NonnullGCPtr<DOM::Document> document;
};
WebIDL::ExceptionOr<BrowsingContextAndDocument> create_a_new_top_level_browsing_context_and_document(Page& page);
WebIDL::ExceptionOr<BrowsingContextAndDocument> create_a_new_top_level_browsing_context_and_document(JS::NonnullGCPtr<Page> page);
void finalize_a_same_document_navigation(JS::NonnullGCPtr<TraversableNavigable> traversable, JS::NonnullGCPtr<Navigable> target_navigable, JS::NonnullGCPtr<SessionHistoryEntry> target_entry, JS::GCPtr<SessionHistoryEntry> entry_to_replace);
}