1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 10:47:34 +00:00

LibWeb: Make Web::Page GC-allocated

This is a first step towards removing the various Page& and Page*
we have littering the engine with "trust me bro" safety guarantees.

Co-Authored-By: Andreas Kling <kling@serenityos.org>
This commit is contained in:
Shannon Booth 2023-12-04 21:57:13 +13:00 committed by Andreas Kling
parent 6e6f3a9a8f
commit 0ae5c070c7
8 changed files with 65 additions and 30 deletions

View file

@ -8,6 +8,7 @@
#include <LibGfx/ShareableBitmap.h>
#include <LibGfx/SystemTheme.h>
#include <LibWeb/Bindings/MainThreadVM.h>
#include <LibWeb/CSS/SystemColor.h>
#include <LibWeb/Cookie/ParsedCookie.h>
#include <LibWeb/DOM/Attr.h>
@ -46,7 +47,7 @@ JS::NonnullGCPtr<PageClient> PageClient::create(JS::VM& vm, PageHost& page_host,
PageClient::PageClient(PageHost& owner, u64 id)
: m_owner(owner)
, m_page(make<Web::Page>(*this))
, m_page(Web::Page::create(Web::Bindings::main_thread_vm(), *this))
, m_id(id)
{
setup_palette();
@ -56,6 +57,12 @@ PageClient::PageClient(PageHost& owner, u64 id)
});
}
void PageClient::visit_edges(JS::Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_page);
}
ConnectionFromClient& PageClient::client() const
{
return m_owner.client();

View file

@ -61,6 +61,8 @@ public:
private:
PageClient(PageHost&, u64 id);
virtual void visit_edges(JS::Cell::Visitor&) override;
// ^PageClient
virtual bool is_connection_open() const override;
virtual Gfx::Palette palette() const override;
@ -131,7 +133,7 @@ private:
ConnectionFromClient& client() const;
PageHost& m_owner;
NonnullOwnPtr<Web::Page> m_page;
JS::NonnullGCPtr<Web::Page> m_page;
RefPtr<Gfx::PaletteImpl> m_palette_impl;
Web::DevicePixelRect m_screen_rect;
Web::DevicePixelSize m_content_size;