mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:38:11 +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
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue