mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
LibWeb: Make BrowsingContext GC-allocated
(And BrowsingContextGroup had to come along for the ride as well.) This solves a number of nasty reference cycles between browsing contexts, history items, and their documents.
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 05:17:17 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/83c5ff57d8 Pull-request: https://github.com/SerenityOS/serenity/pull/15672
@@ -8,14 +8,16 @@
|
||||
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
class BrowsingContextGroup : public RefCounted<BrowsingContextGroup> {
|
||||
class BrowsingContextGroup final : public JS::Cell {
|
||||
JS_CELL(BrowsingContextGroup, JS::Cell);
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<BrowsingContextGroup> create_a_new_browsing_context_group(Page&);
|
||||
static JS::NonnullGCPtr<BrowsingContextGroup> create_a_new_browsing_context_group(Page&);
|
||||
~BrowsingContextGroup();
|
||||
|
||||
Page* page() { return m_page; }
|
||||
@@ -30,8 +32,10 @@ public:
|
||||
private:
|
||||
explicit BrowsingContextGroup(Web::Page&);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/browsers.html#browsing-context-group-set
|
||||
OrderedHashTable<NonnullRefPtr<BrowsingContext>> m_browsing_context_set;
|
||||
OrderedHashTable<BrowsingContext*> m_browsing_context_set;
|
||||
|
||||
WeakPtr<Page> m_page;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user