mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-27 11:48:32 +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
@@ -33,6 +33,12 @@ ImageRequest::~ImageRequest()
|
||||
{
|
||||
}
|
||||
|
||||
void ImageRequest::visit_edges(JS::Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_shared_image_request);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/images.html#img-available
|
||||
bool ImageRequest::is_available() const
|
||||
{
|
||||
@@ -60,11 +66,11 @@ AK::URL const& ImageRequest::current_url() const
|
||||
return m_current_url;
|
||||
}
|
||||
|
||||
void ImageRequest::set_current_url(AK::URL url)
|
||||
void ImageRequest::set_current_url(JS::Realm& realm, AK::URL url)
|
||||
{
|
||||
m_current_url = move(url);
|
||||
if (m_current_url.is_valid())
|
||||
m_shared_image_request = SharedImageRequest::get_or_create(m_page, m_current_url).release_value_but_fixme_should_propagate_errors();
|
||||
m_shared_image_request = SharedImageRequest::get_or_create(realm, m_page, m_current_url);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/images.html#abort-the-image-request
|
||||
|
||||
Reference in New Issue
Block a user