mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Prevent multiple notifications for image dimensions (#36600)
Added a simple check to only perform metadata extraction and listener notification when we haven't already processed the metadata for an image Testing: Existing tests should cover if we break decoding image metadata complete. Fixes: #36502 --------- Signed-off-by: Barigbue <barigbuenbira@gmail.com> Co-authored-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
46247a7621
commit
add8c51f47
1 changed files with 11 additions and 9 deletions
|
@ -608,16 +608,18 @@ impl ImageCache for ImageCacheImpl {
|
||||||
pending_load.bytes.extend_from_slice(&data);
|
pending_load.bytes.extend_from_slice(&data);
|
||||||
|
|
||||||
//jmr0 TODO: possibly move to another task?
|
//jmr0 TODO: possibly move to another task?
|
||||||
let mut reader = std::io::Cursor::new(pending_load.bytes.as_slice());
|
if pending_load.metadata.is_none() {
|
||||||
if let Ok(info) = imsz_from_reader(&mut reader) {
|
let mut reader = std::io::Cursor::new(pending_load.bytes.as_slice());
|
||||||
let img_metadata = ImageMetadata {
|
if let Ok(info) = imsz_from_reader(&mut reader) {
|
||||||
width: info.width as u32,
|
let img_metadata = ImageMetadata {
|
||||||
height: info.height as u32,
|
width: info.width as u32,
|
||||||
};
|
height: info.height as u32,
|
||||||
for listener in &pending_load.listeners {
|
};
|
||||||
listener.respond(ImageResponse::MetadataLoaded(img_metadata.clone()));
|
for listener in &pending_load.listeners {
|
||||||
|
listener.respond(ImageResponse::MetadataLoaded(img_metadata.clone()));
|
||||||
|
}
|
||||||
|
pending_load.metadata = Some(img_metadata);
|
||||||
}
|
}
|
||||||
pending_load.metadata = Some(img_metadata);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(FetchResponseMsg::ProcessResponseEOF(_, result), key) => {
|
(FetchResponseMsg::ProcessResponseEOF(_, result), key) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue