mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Make ImageData more spec compliant (#37620)
I updated webidl, and all changes that bring, currently we still not support float16array (there is no support in FF either). Most notable change is refactored new_*/Constructors methods, that should now handle HeapBufferSource more properly (with less unsafe). Testing: Existing WPT tests try run: https://github.com/sagudev/servo/actions/runs/15806083404 Fixes: #37618 (although not tested) --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
59b99de90a
commit
6f53d422b0
14 changed files with 206 additions and 156 deletions
|
@ -18,6 +18,9 @@ pub(crate) mod base {
|
|||
pub(crate) use js::panic::maybe_resume_unwind;
|
||||
pub(crate) use js::rust::wrappers::Call;
|
||||
pub(crate) use js::rust::{HandleObject, HandleValue, MutableHandleObject, MutableHandleValue};
|
||||
pub(crate) use js::typedarray::{
|
||||
ArrayBuffer, ArrayBufferView, Float32Array, Float64Array, Uint8Array, Uint8ClampedArray,
|
||||
};
|
||||
|
||||
pub(crate) use crate::callback::{
|
||||
CallSetup, CallbackContainer, CallbackFunction, CallbackInterface, CallbackObject,
|
||||
|
@ -84,9 +87,6 @@ pub(crate) mod module {
|
|||
CustomAutoRooterGuard, GCMethods, Handle, MutableHandle, get_context_realm,
|
||||
get_object_class, get_object_realm,
|
||||
};
|
||||
pub(crate) use js::typedarray::{
|
||||
ArrayBuffer, ArrayBufferView, Float32Array, Float64Array, Uint8Array, Uint8ClampedArray,
|
||||
};
|
||||
pub(crate) use js::{
|
||||
JS_CALLEE, JSCLASS_GLOBAL_SLOT_COUNT, JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL,
|
||||
JSCLASS_RESERVED_SLOTS_MASK, typedarray,
|
||||
|
|
|
@ -16,6 +16,10 @@ typedef (HTMLOrSVGImageElement or
|
|||
/*VideoFrame or*/
|
||||
/*CSSImageValue*/ CSSStyleValue) CanvasImageSource;
|
||||
|
||||
enum PredefinedColorSpace { "srgb"/*, "display-p3"*/ };
|
||||
|
||||
enum CanvasColorType { "unorm8", "float16" };
|
||||
|
||||
enum CanvasFillRule { "nonzero", "evenodd" };
|
||||
|
||||
[Exposed=Window]
|
||||
|
@ -253,17 +257,28 @@ interface CanvasPattern {
|
|||
//undefined setTransform(optional DOMMatrix2DInit transform = {});
|
||||
};
|
||||
|
||||
// TODO: Float16Array
|
||||
typedef Uint8ClampedArray ImageDataArray;
|
||||
|
||||
enum ImageDataPixelFormat { "rgba-unorm8"/*, "rgba-float16"*/ };
|
||||
|
||||
dictionary ImageDataSettings {
|
||||
PredefinedColorSpace colorSpace;
|
||||
ImageDataPixelFormat pixelFormat = "rgba-unorm8";
|
||||
};
|
||||
|
||||
[Exposed=(Window,Worker),
|
||||
Serializable]
|
||||
interface ImageData {
|
||||
[Throws] constructor(unsigned long sw, unsigned long sh/*, optional ImageDataSettings settings = {}*/);
|
||||
[Throws] constructor(Uint8ClampedArray data, unsigned long sw, optional unsigned long sh
|
||||
/*, optional ImageDataSettings settings = {}*/);
|
||||
[Throws] constructor(unsigned long sw, unsigned long sh, optional ImageDataSettings settings = {});
|
||||
[Throws] constructor(ImageDataArray data, unsigned long sw,
|
||||
optional unsigned long sh, optional ImageDataSettings settings = {});
|
||||
|
||||
readonly attribute unsigned long width;
|
||||
readonly attribute unsigned long height;
|
||||
[Throws] readonly attribute Uint8ClampedArray data;
|
||||
//readonly attribute PredefinedColorSpace colorSpace;
|
||||
[Throws] readonly attribute ImageDataArray data;
|
||||
readonly attribute ImageDataPixelFormat pixelFormat;
|
||||
readonly attribute PredefinedColorSpace colorSpace;
|
||||
};
|
||||
|
||||
[Exposed=(Window,Worker)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue