Drain promises vec and run update_the_image_data when element is created

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
This commit is contained in:
Bentaimia Haddadi 2024-06-10 23:01:52 +02:00
parent 3bf6a5bbf8
commit d6b7b706e2

View file

@ -1190,6 +1190,7 @@ impl HTMLImageElement {
for promise in self.image_decode_promises.borrow().iter() { for promise in self.image_decode_promises.borrow().iter() {
promise.resolve_native(&()); promise.resolve_native(&());
} }
self.image_decode_promises.borrow_mut().clear();
} }
fn reject_image_decode_promises(&self) { fn reject_image_decode_promises(&self) {
@ -1200,6 +1201,7 @@ impl HTMLImageElement {
DOMErrorName::EncodingError, DOMErrorName::EncodingError,
)); ));
} }
self.image_decode_promises.borrow_mut().clear();
} }
/// Step 15 for <https://html.spec.whatwg.org/multipage/#img-environment-changes> /// Step 15 for <https://html.spec.whatwg.org/multipage/#img-environment-changes>
@ -1333,6 +1335,10 @@ impl HTMLImageElement {
image.SetHeight(h); image.SetHeight(h);
} }
// run update_the_image_data when the element is created.
// https://html.spec.whatwg.org/multipage/#when-to-obtain-images
image.update_the_image_data();
Ok(image) Ok(image)
} }
pub fn areas(&self) -> Option<Vec<DomRoot<HTMLAreaElement>>> { pub fn areas(&self) -> Option<Vec<DomRoot<HTMLAreaElement>>> {