From b799322188cf33c7caef336bb27fe9223d995b24 Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Wed, 30 Jan 2019 15:57:14 -0500 Subject: [PATCH] Give toDataURL() and toBlob() default parameter values Fixes #3430. --- source | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/source b/source index 9842cf1c926..12ae6fe4cde 100644 --- a/source +++ b/source @@ -59562,8 +59562,8 @@ interface HTMLCanvasElement : HTMLElement { RenderingContext? getContext(DOMString contextId, optional any options = null); - USVString toDataURL(optional DOMString type, optional any quality); - void toBlob(BlobCallback _callback, optional DOMString type, optional any quality); + USVString toDataURL(optional DOMString type = "image/png", optional any quality); + void toBlob(BlobCallback _callback, optional DOMString type = "image/png", optional any quality); OffscreenCanvas transferControlToOffscreen(); }; @@ -59961,7 +59961,7 @@ callback BlobCallback = void (Blob? blob);
  • Let file be a serialization of this canvas element's bitmap as a file, passing - type and quality if they were given.

  • + type and quality if given.

  • If file is null then return "data:,".

  • @@ -59992,8 +59992,8 @@ callback BlobCallback = void (Blob? blob);
    1. If result is non-null, then set result to a serialization of result as a file, - with type and quality if they were given.

    2. + serialization of the bitmap as a file">a serialization of result as a file + with type and quality if given.

    3. Queue a task to run these steps:

      @@ -65294,7 +65294,7 @@ dictionary ImageBitmapRenderingContextSettings { dictionary ImageEncodeOptions { DOMString type = "image/png"; - unrestricted double quality = 1.0; + unrestricted double quality; }; enum OffscreenRenderingContextId { "2d", "webgl", "webgl2" }; @@ -65612,7 +65612,7 @@ interface OffscreenCanvas : EventTarget {
    4. Let file be a serialization of bitmap as a file, with options's type and quality.

    5. + data-x="image-encode-options-quality">quality if present.

    6. Queue a task to run these steps:

      @@ -65892,11 +65892,10 @@ interface OffscreenCanvasRenderingContext2D {

      When a user agent is to create a - serialization of the bitmap as a file, given an optional type and - quality, it must create an image file in the format given by type, or if - type was not supplied, in the PNG format. If an error occurs during the creation of - the image file (e.g. an internal encoder error), then the result of the serialization is null. -

      + serialization of the bitmap as a file, given a type and an optional + quality, it must create an image file in the format given by type. If an + error occurs during the creation of the image file (e.g. an internal encoder error), then the + result of the serialization is null.

      The image file's pixel data must be the bitmap's pixel data scaled to one image pixel per coordinate space unit, and if the file format used supports encoding resolution metadata, the @@ -65923,16 +65922,20 @@ interface OffscreenCanvasRenderingContext2D { image composited onto an opaque black background using the source-over operator.

      If type is an image format that supports variable quality (such as - "image/jpeg") and quality is given, then, if Type(quality) is Number, and quality is in the range - 0.0 to 1.0 inclusive, the user agent must treat quality as the desired quality level. - If Type(quality) is not Number, or if quality - is outside that range, the user agent must use its default quality value, as if the - quality argument had not been given.

      + "image/jpeg"), quality is given, and type is not + "image/png", then, if Type(quality) is + Number, and quality is in the range 0.0 to 1.0 inclusive, the user agent must treat + quality as the desired quality level. Otherwise, the user agent must use its default + quality value, as if the quality argument had not been given.

      The use of type-testing here, instead of simply declaring quality as a Web IDL double, is a historical artifact.

      +

      Different implementations can have slightly different interpretations of + "quality". When the quality is not specified, an implementation-specific default is used that + represents a reasonable compromise between compression ratio, image quality, and encoding + time.

      +