mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:48:14 +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:
parent
bbfedf2e5a
commit
934afcb9d5
9 changed files with 46 additions and 18 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue