1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:47:36 +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

@ -1,7 +1,8 @@
/*
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2020-2023, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
* Copyright (c) 2023, Shannon Booth <shannon@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -36,12 +37,14 @@ namespace Web {
class PageClient;
class Page : public Weakable<Page> {
AK_MAKE_NONCOPYABLE(Page);
AK_MAKE_NONMOVABLE(Page);
class Page final
: public JS::Cell
, public Weakable<Page> {
JS_CELL(Page, JS::Cell);
public:
explicit Page(PageClient&);
static JS::NonnullGCPtr<Page> create(JS::VM&, JS::NonnullGCPtr<PageClient>);
~Page();
PageClient& client() { return m_client; }
@ -152,13 +155,16 @@ public:
bool pdf_viewer_supported() const { return m_pdf_viewer_supported; }
private:
explicit Page(JS::NonnullGCPtr<PageClient>);
virtual void visit_edges(Visitor&) override;
JS::GCPtr<HTML::HTMLMediaElement> media_context_menu_element();
PageClient& m_client;
JS::NonnullGCPtr<PageClient> m_client;
WeakPtr<HTML::BrowsingContext> m_focused_context;
JS::Handle<HTML::TraversableNavigable> m_top_level_traversable;
JS::GCPtr<HTML::TraversableNavigable> m_top_level_traversable;
// FIXME: Enable this by default once CORS preflight checks are supported.
bool m_same_origin_policy_enabled { false };