From d6b7b706e26f6962cf96f405c3807b679e23e30d Mon Sep 17 00:00:00 2001 From: Bentaimia Haddadi Date: Mon, 10 Jun 2024 23:01:52 +0200 Subject: [PATCH] Drain promises vec and run update_the_image_data when element is created Signed-off-by: Bentaimia Haddadi --- components/script/dom/htmlimageelement.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 9404b20a3c1..22bdc942083 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -1190,6 +1190,7 @@ impl HTMLImageElement { for promise in self.image_decode_promises.borrow().iter() { promise.resolve_native(&()); } + self.image_decode_promises.borrow_mut().clear(); } fn reject_image_decode_promises(&self) { @@ -1200,6 +1201,7 @@ impl HTMLImageElement { DOMErrorName::EncodingError, )); } + self.image_decode_promises.borrow_mut().clear(); } /// Step 15 for @@ -1333,6 +1335,10 @@ impl HTMLImageElement { 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) } pub fn areas(&self) -> Option>> {