Skip to content

Fix missing optional parameter of createImageBitmap #571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 25, 2020
37 changes: 22 additions & 15 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,15 @@ interface IIRFilterOptions extends AudioNodeOptions {
feedforward: number[];
}

interface ImageBitmapOptions {
colorSpaceConversion?: ColorSpaceConversion;
imageOrientation?: ImageOrientation;
premultiplyAlpha?: PremultiplyAlpha;
resizeHeight?: number;
resizeQuality?: ResizeQuality;
resizeWidth?: number;
}

interface IntersectionObserverEntryInit {
boundingClientRect: DOMRectInit;
intersectionRect: DOMRectInit;
Expand Down Expand Up @@ -9082,15 +9091,6 @@ declare var ImageBitmap: {
new(): ImageBitmap;
};

interface ImageBitmapOptions {
colorSpaceConversion?: "none" | "default";
imageOrientation?: "none" | "flipY";
premultiplyAlpha?: "none" | "premultiply" | "default";
resizeHeight?: number;
resizeQuality?: "pixelated" | "low" | "medium" | "high";
resizeWidth?: number;
}

interface ImageBitmapRenderingContext {
/**
* Returns the canvas element that the context is bound to.
Expand All @@ -9109,6 +9109,11 @@ declare var ImageBitmapRenderingContext: {
new(): ImageBitmapRenderingContext;
};

interface ImageBitmapWindow {
createImageBitmap(image: ImageBitmapSourceWindow, options?: ImageBitmapOptions): Promise<ImageBitmap>;
createImageBitmap(image: ImageBitmapSourceWindow, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
}

interface ImageData {
/**
* Returns the one-dimensional array containing the data in RGBA order, as integers in the
Expand Down Expand Up @@ -16293,7 +16298,7 @@ interface WindowEventMap extends GlobalEventHandlersEventMap, WindowEventHandler
"waiting": Event;
}

interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch, WindowOrWorkerGlobalScope, WindowEventHandlers {
interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch, WindowOrWorkerGlobalScope, ImageBitmapWindow, WindowEventHandlers {
Blob: typeof Blob;
URL: typeof URL;
URLSearchParams: typeof URLSearchParams;
Expand Down Expand Up @@ -16494,8 +16499,6 @@ interface WindowOrWorkerGlobalScope {
btoa(data: string): string;
clearInterval(handle?: number): void;
clearTimeout(handle?: number): void;
createImageBitmap(image: ImageBitmapSource): Promise<ImageBitmap>;
createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number): Promise<ImageBitmap>;
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
queueMicrotask(callback: Function): void;
setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
Expand Down Expand Up @@ -17550,12 +17553,12 @@ declare function atob(data: string): string;
declare function btoa(data: string): string;
declare function clearInterval(handle?: number): void;
declare function clearTimeout(handle?: number): void;
declare function createImageBitmap(image: ImageBitmapSource): Promise<ImageBitmap>;
declare function createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number): Promise<ImageBitmap>;
declare function fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
declare function queueMicrotask(callback: Function): void;
declare function setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
declare function setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
declare function createImageBitmap(image: ImageBitmapSourceWindow, options?: ImageBitmapOptions): Promise<ImageBitmap>;
declare function createImageBitmap(image: ImageBitmapSourceWindow, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
declare var sessionStorage: Storage;
declare var localStorage: Storage;
declare var onafterprint: ((this: Window, ev: Event) => any) | null;
Expand Down Expand Up @@ -17588,7 +17591,7 @@ type HTMLOrSVGImageElement = HTMLImageElement | SVGImageElement;
type CanvasImageSource = HTMLOrSVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap;
type MessageEventSource = WindowProxy | MessagePort | ServiceWorker;
type HTMLOrSVGScriptElement = HTMLScriptElement | SVGScriptElement;
type ImageBitmapSource = CanvasImageSource | Blob | ImageData;
type ImageBitmapSourceWindow = CanvasImageSource | Blob | ImageData;
type OnErrorEventHandler = OnErrorEventHandlerNonNull | null;
type OnBeforeUnloadEventHandler = OnBeforeUnloadEventHandlerNonNull | null;
type TimerHandler = string | Function;
Expand Down Expand Up @@ -17647,6 +17650,7 @@ type CanvasTextBaseline = "top" | "hanging" | "middle" | "alphabetic" | "ideogra
type ChannelCountMode = "max" | "clamped-max" | "explicit";
type ChannelInterpretation = "speakers" | "discrete";
type ClientTypes = "window" | "worker" | "sharedworker" | "all";
type ColorSpaceConversion = "none" | "default";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small global aliases are annoying because of alias interning: everybody with a type none | default will now see the name ColorSpaceConversion for it.

Not sure the best workaround for this. I’ll think about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for reviewing, I will find time to come back and reconsider about this PR soon. :)

type CompositeOperation = "replace" | "add" | "accumulate";
type DirectionSetting = "" | "rl" | "lr";
type DisplayCaptureSurfaceType = "monitor" | "window" | "application" | "browser";
Expand All @@ -17661,6 +17665,7 @@ type GamepadMappingType = "" | "standard";
type IDBCursorDirection = "next" | "nextunique" | "prev" | "prevunique";
type IDBRequestReadyState = "pending" | "done";
type IDBTransactionMode = "readonly" | "readwrite" | "versionchange";
type ImageOrientation = "none" | "flipY";
type ImageSmoothingQuality = "low" | "medium" | "high";
type IterationCompositeOperation = "replace" | "accumulate";
type KeyFormat = "raw" | "spki" | "pkcs8" | "jwk";
Expand Down Expand Up @@ -17691,6 +17696,7 @@ type PaymentComplete = "success" | "fail" | "unknown";
type PaymentShippingType = "shipping" | "delivery" | "pickup";
type PlaybackDirection = "normal" | "reverse" | "alternate" | "alternate-reverse";
type PositionAlignSetting = "line-left" | "center" | "line-right" | "auto";
type PremultiplyAlpha = "none" | "premultiply" | "default";
type PushEncryptionKeyName = "p256dh" | "auth";
type PushPermissionState = "denied" | "granted" | "prompt";
type RTCBundlePolicy = "balanced" | "max-compat" | "max-bundle";
Expand Down Expand Up @@ -17729,6 +17735,7 @@ type RequestCredentials = "omit" | "same-origin" | "include";
type RequestDestination = "" | "audio" | "audioworklet" | "document" | "embed" | "font" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt";
type RequestMode = "navigate" | "same-origin" | "no-cors" | "cors";
type RequestRedirect = "follow" | "error" | "manual";
type ResizeQuality = "pixelated" | "low" | "medium" | "high";
type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect";
type ScopedCredentialType = "ScopedCred";
type ScrollBehavior = "auto" | "instant" | "smooth";
Expand Down
34 changes: 20 additions & 14 deletions baselines/webworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ interface IDBVersionChangeEventInit extends EventInit {
oldVersion?: number;
}

interface ImageBitmapOptions {
colorSpaceConversion?: ColorSpaceConversion;
imageOrientation?: ImageOrientation;
premultiplyAlpha?: PremultiplyAlpha;
resizeHeight?: number;
resizeQuality?: ResizeQuality;
resizeWidth?: number;
}

interface JsonWebKey {
alg?: string;
crv?: string;
Expand Down Expand Up @@ -1776,13 +1785,9 @@ declare var ImageBitmap: {
new(): ImageBitmap;
};

interface ImageBitmapOptions {
colorSpaceConversion?: "none" | "default";
imageOrientation?: "none" | "flipY";
premultiplyAlpha?: "none" | "premultiply" | "default";
resizeHeight?: number;
resizeQuality?: "pixelated" | "low" | "medium" | "high";
resizeWidth?: number;
interface ImageBitmapWorker {
createImageBitmap(image: ImageBitmapSourceWorker, options?: ImageBitmapOptions): Promise<ImageBitmap>;
createImageBitmap(image: ImageBitmapSourceWorker, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
}

interface ImageData {
Expand Down Expand Up @@ -2652,8 +2657,6 @@ interface WindowOrWorkerGlobalScope {
btoa(data: string): string;
clearInterval(handle?: number): void;
clearTimeout(handle?: number): void;
createImageBitmap(image: ImageBitmapSource): Promise<ImageBitmap>;
createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number): Promise<ImageBitmap>;
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
queueMicrotask(callback: Function): void;
setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
Expand Down Expand Up @@ -2683,7 +2686,7 @@ interface WorkerGlobalScopeEventMap {
"error": ErrorEvent;
}

interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, GlobalFetch, WindowOrWorkerGlobalScope {
interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, GlobalFetch, WindowOrWorkerGlobalScope, ImageBitmapWorker {
readonly caches: CacheStorage;
readonly isSecureContext: boolean;
readonly location: WorkerLocation;
Expand Down Expand Up @@ -2934,12 +2937,12 @@ declare function atob(data: string): string;
declare function btoa(data: string): string;
declare function clearInterval(handle?: number): void;
declare function clearTimeout(handle?: number): void;
declare function createImageBitmap(image: ImageBitmapSource): Promise<ImageBitmap>;
declare function createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number): Promise<ImageBitmap>;
declare function fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
declare function queueMicrotask(callback: Function): void;
declare function setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
declare function setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
declare function createImageBitmap(image: ImageBitmapSourceWorker, options?: ImageBitmapOptions): Promise<ImageBitmap>;
declare function createImageBitmap(image: ImageBitmapSourceWorker, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
declare function addEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
declare function removeEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
Expand All @@ -2949,9 +2952,8 @@ type HeadersInit = Headers | string[][] | Record<string, string>;
type BodyInit = Blob | BufferSource | FormData | URLSearchParams | ReadableStream | string;
type RequestInfo = Request | string;
type DOMHighResTimeStamp = number;
type CanvasImageSource = ImageBitmap;
type MessageEventSource = MessagePort | ServiceWorker;
type ImageBitmapSource = CanvasImageSource | Blob | ImageData;
type ImageBitmapSourceWorker = ImageBitmap | Blob | ImageData;
type TimerHandler = string | Function;
type PerformanceEntryList = PerformanceEntry[];
type PushMessageDataInit = BufferSource | string;
Expand All @@ -2967,14 +2969,17 @@ type IDBValidKey = number | string | Date | BufferSource | IDBArrayKey;
type Transferable = ArrayBuffer | MessagePort | ImageBitmap;
type BinaryType = "blob" | "arraybuffer";
type ClientTypes = "window" | "worker" | "sharedworker" | "all";
type ColorSpaceConversion = "none" | "default";
type IDBCursorDirection = "next" | "nextunique" | "prev" | "prevunique";
type IDBRequestReadyState = "pending" | "done";
type IDBTransactionMode = "readonly" | "readwrite" | "versionchange";
type ImageOrientation = "none" | "flipY";
type KeyFormat = "raw" | "spki" | "pkcs8" | "jwk";
type KeyType = "public" | "private" | "secret";
type KeyUsage = "encrypt" | "decrypt" | "sign" | "verify" | "deriveKey" | "deriveBits" | "wrapKey" | "unwrapKey";
type NotificationDirection = "auto" | "ltr" | "rtl";
type NotificationPermission = "default" | "denied" | "granted";
type PremultiplyAlpha = "none" | "premultiply" | "default";
type PushEncryptionKeyName = "p256dh" | "auth";
type PushPermissionState = "denied" | "granted" | "prompt";
type ReferrerPolicy = "" | "no-referrer" | "no-referrer-when-downgrade" | "origin-only" | "origin-when-cross-origin" | "unsafe-url";
Expand All @@ -2983,6 +2988,7 @@ type RequestCredentials = "omit" | "same-origin" | "include";
type RequestDestination = "" | "audio" | "audioworklet" | "document" | "embed" | "font" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt";
type RequestMode = "navigate" | "same-origin" | "no-cors" | "cors";
type RequestRedirect = "follow" | "error" | "manual";
type ResizeQuality = "pixelated" | "low" | "medium" | "high";
type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect";
type ServiceWorkerState = "installing" | "installed" | "activating" | "activated" | "redundant";
type ServiceWorkerUpdateViaCache = "imports" | "all" | "none";
Expand Down
39 changes: 0 additions & 39 deletions inputfiles/addedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -396,45 +396,6 @@
}
}
},
"ImageBitmapOptions": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What replaces this entry? Whatever it is, it results in a whole bunch of unwanted type aliases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The already existing dictionary ImageBitmapOptions in HTML - ImageBitmap and animations.widl replaces this entry. This was a conflict if I remember right.

"flavor": "All",
"name": "ImageBitmapOptions",
"properties": {
"property": {
"imageOrientation": {
"name": "imageOrientation",
"override-type": "\"none\" | \"flipY\"",
"required": 0
},
"premultiplyAlpha": {
"name": "premultiplyAlpha",
"override-type": "\"none\" | \"premultiply\" | \"default\"",
"required": 0
},
"colorSpaceConversion": {
"name": "colorSpaceConversion",
"override-type": "\"none\" | \"default\"",
"required": 0
},
"resizeWidth": {
"name": "resizeWidth",
"override-type": "number",
"required": 0
},
"resizeHeight": {
"name": "resizeHeight",
"override-type": "number",
"required": 0
},
"resizeQuality": {
"name": "resizeQuality",
"override-type": "\"pixelated\" | \"low\" | \"medium\" | \"high\"",
"required": 0
}
}
},
"no-interface-object": "1"
},
"Window": {
"name": "Window",
"properties": {
Expand Down
6 changes: 5 additions & 1 deletion inputfiles/idl/HTML - ImageBitmap and animations.widl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ interface ImageBitmap {

typedef (CanvasImageSource or
Blob or
ImageData) ImageBitmapSource;
ImageData) ImageBitmapSourceWindow;

typedef (ImageBitmap or
Blob or
ImageData) ImageBitmapSourceWorker;

enum ImageOrientation { "none", "flipY" };
enum PremultiplyAlpha { "none", "premultiply", "default" };
Expand Down
15 changes: 12 additions & 3 deletions inputfiles/idl/HTML - Web application APIs.widl
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,19 @@ interface mixin WindowOrWorkerGlobalScope {

// microtask queuing
void queueMicrotask(Function callback);
};

// ImageBitmap
Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image, optional ImageBitmapOptions options);
Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image, long sx, long sy, long sw, long sh, optional ImageBitmapOptions options);
// ImageBitmap
interface mixin ImageBitmapWindow {
Promise<ImageBitmap> createImageBitmap(ImageBitmapSourceWindow image, optional ImageBitmapOptions options);
Promise<ImageBitmap> createImageBitmap(ImageBitmapSourceWindow image, long sx, long sy, long sw, long sh, optional ImageBitmapOptions options);
};
interface mixin ImageBitmapWorker {
Promise<ImageBitmap> createImageBitmap(ImageBitmapSourceWorker image, optional ImageBitmapOptions options);
Promise<ImageBitmap> createImageBitmap(ImageBitmapSourceWorker image, long sx, long sy, long sw, long sh, optional ImageBitmapOptions options);
};

Window includes WindowOrWorkerGlobalScope;
Window includes ImageBitmapWindow;
WorkerGlobalScope includes WindowOrWorkerGlobalScope;
WorkerGlobalScope includes ImageBitmapWorker;