mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-27 03:37:53 +00:00
LibWeb: Make HTML::SharedImageRequest GC allocated
This allows to partially solve the problem of cyclic dependency between HTMLImageElement and SharedImageRequest that prevents all image elements from being deallocated.
This commit is contained in:
committed by
Andreas Kling
parent
bbfedf2e5a
commit
934afcb9d5
@@ -24,11 +24,11 @@ static HashMap<AK::URL, SharedImageRequest*>& shared_image_requests()
|
||||
return requests;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<SharedImageRequest>> SharedImageRequest::get_or_create(Page& page, AK::URL const& url)
|
||||
JS::NonnullGCPtr<SharedImageRequest> SharedImageRequest::get_or_create(JS::Realm& realm, Page& page, AK::URL const& url)
|
||||
{
|
||||
if (auto it = shared_image_requests().find(url); it != shared_image_requests().end())
|
||||
return *it->value;
|
||||
auto request = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) SharedImageRequest(page, url)));
|
||||
auto request = realm.heap().allocate<SharedImageRequest>(realm, page, url);
|
||||
shared_image_requests().set(url, request);
|
||||
return request;
|
||||
}
|
||||
@@ -44,6 +44,12 @@ SharedImageRequest::~SharedImageRequest()
|
||||
shared_image_requests().remove(m_url);
|
||||
}
|
||||
|
||||
void SharedImageRequest::visit_edges(JS::Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_fetch_controller);
|
||||
}
|
||||
|
||||
RefPtr<DecodedImageData const> SharedImageRequest::image_data() const
|
||||
{
|
||||
return m_image_data;
|
||||
|
||||
Reference in New Issue
Block a user