mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 07:24:58 +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
|
@ -39,6 +39,12 @@ void HTMLObjectElement::initialize(JS::Realm& realm)
|
|||
set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLObjectElementPrototype>(realm, "HTMLObjectElement"));
|
||||
}
|
||||
|
||||
void HTMLObjectElement::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_image_request);
|
||||
}
|
||||
|
||||
void HTMLObjectElement::attribute_changed(DeprecatedFlyString const& name, DeprecatedString const& value)
|
||||
{
|
||||
NavigableContainer::attribute_changed(name, value);
|
||||
|
@ -316,7 +322,7 @@ void HTMLObjectElement::load_image()
|
|||
// NOTE: This currently reloads the image instead of reusing the resource we've already downloaded.
|
||||
auto data = attribute(HTML::AttributeNames::data);
|
||||
auto url = document().parse_url(data);
|
||||
m_image_request = HTML::SharedImageRequest::get_or_create(*document().page(), url).release_value_but_fixme_should_propagate_errors();
|
||||
m_image_request = HTML::SharedImageRequest::get_or_create(realm(), *document().page(), url);
|
||||
m_image_request->add_callbacks(
|
||||
[this] {
|
||||
run_object_representation_completed_steps(Representation::Image);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue