1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 14:04:59 +00:00

LibWeb: Use JS::HeapFunction for DocumentObserver callbacks

If GC-allocated object wants to own a function it should use
HeapFunction because using SafeFunction will almost always lead to a
leak.
This commit is contained in:
Aliaksandr Kalenik 2023-09-27 17:23:48 +02:00 committed by Andreas Kling
parent 12adaac08d
commit cad2d2c85b
4 changed files with 24 additions and 6 deletions

View file

@ -57,11 +57,11 @@ void HTMLMediaElement::initialize(JS::Realm& realm)
m_document_observer = realm.heap().allocate<DOM::DocumentObserver>(realm, realm, document());
// https://html.spec.whatwg.org/multipage/media.html#playing-the-media-resource:media-element-82
m_document_observer->document_became_inactive = [this]() {
m_document_observer->set_document_became_inactive([this]() {
// If the media element's node document stops being a fully active document, then the playback will stop until
// the document is active again.
pause_element().release_value_but_fixme_should_propagate_errors();
};
});
}
// https://html.spec.whatwg.org/multipage/media.html#queue-a-media-element-task