1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:47:36 +00:00

LibWeb: Make History GC-allocated

This commit is contained in:
Andreas Kling 2022-09-02 13:50:24 +02:00
parent abfb73f2e7
commit 16fbb91aa1
7 changed files with 40 additions and 25 deletions

View file

@ -281,7 +281,6 @@ Document::Document(HTML::Window& window, const AK::URL& url)
, m_style_computer(make<CSS::StyleComputer>(*this))
, m_url(url)
, m_window(window)
, m_history(HTML::History::create(*this))
{
set_prototype(&window.ensure_web_prototype<Bindings::DocumentPrototype>("Document"));
@ -315,6 +314,7 @@ void Document::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_current_script.ptr());
visitor.visit(m_associated_inert_template_document.ptr());
visitor.visit(m_pending_parsing_blocking_script.ptr());
visitor.visit(m_history.ptr());
for (auto& script : m_scripts_to_execute_when_parsing_has_finished)
visitor.visit(script.ptr());
@ -1812,4 +1812,11 @@ CSS::StyleSheetList const& Document::style_sheets() const
return const_cast<Document*>(this)->style_sheets();
}
JS::NonnullGCPtr<HTML::History> Document::history()
{
if (!m_history)
m_history = HTML::History::create(window(), *this);
return *m_history;
}
}

View file

@ -298,7 +298,7 @@ public:
bool is_fully_active() const;
bool is_active() const;
NonnullRefPtr<HTML::History> history() const { return m_history; }
JS::NonnullGCPtr<HTML::History> history();
Bindings::LocationObject* location();
@ -433,7 +433,7 @@ private:
// https://html.spec.whatwg.org/multipage/semantics.html#script-blocking-style-sheet-counter
u32 m_script_blocking_style_sheet_counter { 0 };
NonnullRefPtr<HTML::History> m_history;
JS::GCPtr<HTML::History> m_history;
size_t m_number_of_things_delaying_the_load_event { 0 };