imagebitmap: Add missing basic functionality (#37025)

Add missing basic functionality for ImageBitmap
https://html.spec.whatwg.org/multipage/#imagebitmap
including new variant of creation bitmap with source rectangle
https://html.spec.whatwg.org/multipage/#dom-createimagebitmap
but without support of cropping bitmap data with formatting.

Add ImageBitmap to CanvasImageSource union type
https://html.spec.whatwg.org/multipage/#canvasimagesource

Add ImageBitmap to TexImageSource for WebGL
https://registry.khronos.org/webgl/specs/latest/1.0/index.html

Testing: Improvements in the following WPT tests
 - html/canvas/element/manual/imagebitmap/*
 - html/canvas/element/manual/wide-gamut-canvas/*
 - html/semantics/embedded-content/the-canvas-element/*
 - webgl/tests/conformance/textures/image_bitmap_from*
 - webmessaging/postMessage_cross_domain_image_transfer_2d.sub.htm

Fixes: https://github.com/servo/servo/issues/34112

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
This commit is contained in:
Andrei Volykhin 2025-06-09 17:28:30 +03:00 committed by GitHub
parent a3c792e5aa
commit 7f536e8092
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
79 changed files with 653 additions and 1232 deletions

View file

@ -1214,7 +1214,7 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
self.as_global_scope().queue_function_as_microtask(callback);
}
// https://html.spec.whatwg.org/multipage/#dom-createimagebitmap
/// <https://html.spec.whatwg.org/multipage/#dom-createimagebitmap>
fn CreateImageBitmap(
&self,
image: ImageBitmapSource,
@ -1223,7 +1223,30 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
) -> Rc<Promise> {
let p = self
.as_global_scope()
.create_image_bitmap(image, options, can_gc);
.create_image_bitmap(image, 0, 0, None, None, options, can_gc);
p
}
/// <https://html.spec.whatwg.org/multipage/#dom-createimagebitmap>
fn CreateImageBitmap_(
&self,
image: ImageBitmapSource,
sx: i32,
sy: i32,
sw: i32,
sh: i32,
options: &ImageBitmapOptions,
can_gc: CanGc,
) -> Rc<Promise> {
let p = self.as_global_scope().create_image_bitmap(
image,
sx,
sy,
Some(sw),
Some(sh),
options,
can_gc,
);
p
}