imagebitmap: Make ImageBitmap serializable and transferable (#37101)

According to specification ImageBitmap objects are serializable objects
and transferable objects.

https://html.spec.whatwg.org/multipage/#the-imagebitmap-interface:imagebitmap-11

Testing:
 - html/canvas/element/manual/imagebitmap/*
 - html/infrastructure/safe-passing-of-structured-data/*
 - html/webappapis/structured-clone/*
 - workers/semantics/structured-clone/*

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
This commit is contained in:
Andrei Volykhin 2025-05-23 23:40:25 +03:00 committed by GitHub
parent cd36c35cf2
commit 1f5087d773
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 215 additions and 103 deletions

View file

@ -10,7 +10,7 @@ mod transferable;
use std::collections::HashMap;
use base::id::{BlobId, DomExceptionId, DomPointId, MessagePortId};
use base::id::{BlobId, DomExceptionId, DomPointId, ImageBitmapId, MessagePortId};
use log::warn;
use malloc_size_of_derive::MallocSizeOf;
use serde::{Deserialize, Serialize};
@ -34,6 +34,10 @@ pub struct StructuredSerializedData {
pub ports: Option<HashMap<MessagePortId, MessagePortImpl>>,
/// Transform streams transferred objects.
pub transform_streams: Option<HashMap<MessagePortId, TransformStreamData>>,
/// Serialized image bitmap objects.
pub image_bitmaps: Option<HashMap<ImageBitmapId, SerializableImageBitmap>>,
/// Transferred image bitmap objects.
pub transferred_image_bitmaps: Option<HashMap<ImageBitmapId, SerializableImageBitmap>>,
}
impl StructuredSerializedData {
@ -42,6 +46,7 @@ impl StructuredSerializedData {
field.as_ref().is_some_and(|h| h.is_empty())
}
match val {
Transferrable::ImageBitmap => is_field_empty(&self.transferred_image_bitmaps),
Transferrable::MessagePort => is_field_empty(&self.ports),
Transferrable::ReadableStream => is_field_empty(&self.ports),
Transferrable::WritableStream => is_field_empty(&self.ports),