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
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 30 additions & 16 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,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 @@ -1793,6 +1802,11 @@ declare var AnimationEvent: {
new(type: string, animationEventInitDict?: AnimationEventInit): AnimationEvent;
};

interface AnimationFrameProvider {
cancelAnimationFrame(handle: number): void;
requestAnimationFrame(callback: FrameRequestCallback): number;
}

interface AnimationPlaybackEvent extends Event {
readonly currentTime: number | null;
readonly timelineTime: number | null;
Expand Down Expand Up @@ -5400,6 +5414,7 @@ interface GlobalEventHandlersEventMap {
"ended": Event;
"error": ErrorEvent;
"focus": FocusEvent;
"formdata": Event;
"gotpointercapture": PointerEvent;
"input": Event;
"invalid": Event;
Expand Down Expand Up @@ -5561,6 +5576,7 @@ interface GlobalEventHandlers {
* @param ev The event.
*/
onfocus: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
onformdata: ((this: GlobalEventHandlers, ev: Event) => any) | null;
ongotpointercapture: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
oninput: ((this: GlobalEventHandlers, ev: Event) => any) | null;
oninvalid: ((this: GlobalEventHandlers, ev: Event) => any) | null;
Expand Down Expand Up @@ -9344,15 +9360,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 Down Expand Up @@ -16918,7 +16925,7 @@ interface WindowEventMap extends GlobalEventHandlersEventMap, WindowEventHandler
}

/** The Window interface represents a window containing a DOM document; the document property points to the DOM document loaded in that window. */
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, AnimationFrameProvider, WindowOrWorkerGlobalScope, WindowEventHandlers {
Blob: typeof Blob;
URL: typeof URL;
URLSearchParams: typeof URLSearchParams;
Expand Down Expand Up @@ -17120,10 +17127,10 @@ 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>;
createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise<ImageBitmap>;
createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
queueMicrotask(callback: Function): void;
queueMicrotask(callback: VoidFunction): void;
setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
}
Expand Down Expand Up @@ -18030,6 +18037,7 @@ declare var onerror: OnErrorEventHandler;
* @param ev The event.
*/
declare var onfocus: ((this: Window, ev: FocusEvent) => any) | null;
declare var onformdata: ((this: Window, ev: Event) => any) | null;
declare var ongotpointercapture: ((this: Window, ev: PointerEvent) => any) | null;
declare var oninput: ((this: Window, ev: Event) => any) | null;
declare var oninvalid: ((this: Window, ev: Event) => any) | null;
Expand Down Expand Up @@ -18199,6 +18207,8 @@ declare var indexedDB: IDBFactory;
declare function atob(encodedString: string): string;
declare function btoa(rawString: string): string;
declare function fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
declare function cancelAnimationFrame(handle: number): void;
declare function requestAnimationFrame(callback: FrameRequestCallback): number;
declare var caches: CacheStorage;
declare var crypto: Crypto;
declare var indexedDB: IDBFactory;
Expand All @@ -18208,10 +18218,10 @@ 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 createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise<ImageBitmap>;
declare function createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
declare function fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
declare function queueMicrotask(callback: Function): void;
declare function queueMicrotask(callback: VoidFunction): void;
declare function setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
declare function setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
declare var sessionStorage: Storage;
Expand Down Expand Up @@ -18306,6 +18316,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 CompositeOperationOrAuto = "replace" | "add" | "accumulate" | "auto";
type DirectionSetting = "" | "rl" | "lr";
Expand All @@ -18323,6 +18334,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 @@ -18353,6 +18365,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 @@ -18391,6 +18404,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" | "smooth";
Expand Down
51 changes: 35 additions & 16 deletions baselines/webworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,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 @@ -528,6 +537,11 @@ interface AesCmacParams extends Algorithm {
length: number;
}

interface AnimationFrameProvider {
cancelAnimationFrame(handle: number): void;
requestAnimationFrame(callback: FrameRequestCallback): number;
}

/** A Blob object represents a file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system. */
interface Blob {
readonly size: number;
Expand Down Expand Up @@ -1064,7 +1078,7 @@ interface DedicatedWorkerGlobalScopeEventMap extends WorkerGlobalScopeEventMap {
}

/** The DedicatedWorkerGlobalScope object (the Worker global scope) is accessible through the self keyword. Some additional global functions, namespaces objects, and constructors, not typically associated with the worker global scope, but available on it, are listed in the JavaScript Reference. See also: Functions available to workers. */
interface DedicatedWorkerGlobalScope extends WorkerGlobalScope {
interface DedicatedWorkerGlobalScope extends WorkerGlobalScope, AnimationFrameProvider {
onmessage: ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any) | null;
close(): void;
postMessage(message: any, transfer?: Transferable[]): void;
Expand Down Expand Up @@ -1961,15 +1975,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;
}

/** The ImageData interface represents the underlying pixel data of an area of a <canvas> element. It is created using the ImageData() constructor or creator methods on the CanvasRenderingContext2D object associated with a canvas: createImageData() and getImageData(). It can also be used to set a part of the canvas by using putImageData(). */
interface ImageData {
/**
Expand Down Expand Up @@ -3980,10 +3985,10 @@ 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>;
createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise<ImageBitmap>;
createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
queueMicrotask(callback: Function): void;
queueMicrotask(callback: VoidFunction): void;
setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
}
Expand Down Expand Up @@ -4255,6 +4260,10 @@ interface EventHandlerNonNull {
(event: Event): any;
}

interface FrameRequestCallback {
(time: number): void;
}

interface PerformanceObserverCallback {
(entries: PerformanceObserverEntryList, observer: PerformanceObserver): void;
}
Expand Down Expand Up @@ -4283,6 +4292,10 @@ interface TransformStreamDefaultControllerTransformCallback<I, O> {
(chunk: I, controller: TransformStreamDefaultController<O>): void | PromiseLike<void>;
}

interface VoidFunction {
(): void;
}

interface WritableStreamDefaultControllerCloseCallback {
(): void | PromiseLike<void>;
}
Expand Down Expand Up @@ -4336,12 +4349,14 @@ 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 createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise<ImageBitmap>;
declare function createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
declare function fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
declare function queueMicrotask(callback: Function): void;
declare function queueMicrotask(callback: VoidFunction): void;
declare function setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
declare function setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
declare function cancelAnimationFrame(handle: number): void;
declare function requestAnimationFrame(callback: FrameRequestCallback): number;
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 Down Expand Up @@ -4382,15 +4397,18 @@ 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 EndingType = "transparent" | "native";
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" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
Expand All @@ -4399,6 +4417,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 @@ -451,45 +451,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
9 changes: 9 additions & 0 deletions inputfiles/idl/HTML - ImageBitmap and animations.widl
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@ dictionary ImageBitmapOptions {
[EnforceRange] unsigned long resizeHeight;
ResizeQuality resizeQuality = "low";
};

callback FrameRequestCallback = void (DOMHighResTimeStamp time);

interface mixin AnimationFrameProvider {
unsigned long requestAnimationFrame(FrameRequestCallback callback);
void cancelAnimationFrame(unsigned long handle);
};
Window includes AnimationFrameProvider;
DedicatedWorkerGlobalScope includes AnimationFrameProvider;
3 changes: 2 additions & 1 deletion inputfiles/idl/HTML - Web application APIs.widl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ interface mixin GlobalEventHandlers {
attribute EventHandler onended;
attribute OnErrorEventHandler onerror;
attribute EventHandler onfocus;
attribute EventHandler onformdata;
attribute EventHandler oninput;
attribute EventHandler oninvalid;
attribute EventHandler onkeydown;
Expand Down Expand Up @@ -144,7 +145,7 @@ interface mixin WindowOrWorkerGlobalScope {
void clearInterval(optional long handle = 0);

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

// ImageBitmap
Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image, optional ImageBitmapOptions options);
Expand Down