Skip to content

Commit

Permalink
Give toDataURL() and toBlob() default parameter values
Browse files Browse the repository at this point in the history
Fixes #3430.
  • Loading branch information
Donovan Glover authored and domenic committed Jan 30, 2019
1 parent f75a7b2 commit b799322
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -59562,8 +59562,8 @@ interface <dfn>HTMLCanvasElement</dfn> : <span>HTMLElement</span> {

<span>RenderingContext</span>? <span data-x="dom-canvas-getContext">getContext</span>(DOMString contextId, optional any options = null);

USVString <span data-x="dom-canvas-toDataURL">toDataURL</span>(optional DOMString type, optional any quality);
void <span data-x="dom-canvas-toBlob">toBlob</span>(<span>BlobCallback</span> _callback, optional DOMString type, optional any quality);
USVString <span data-x="dom-canvas-toDataURL">toDataURL</span>(optional DOMString type = "image/png", optional any quality);
void <span data-x="dom-canvas-toBlob">toBlob</span>(<span>BlobCallback</span> _callback, optional DOMString type = "image/png", optional any quality);
<span>OffscreenCanvas</span> <span data-x="dom-canvas-transferControlToOffscreen">transferControlToOffscreen</span>();
};

Expand Down Expand Up @@ -59961,7 +59961,7 @@ callback <dfn>BlobCallback</dfn> = void (<span>Blob</span>? blob);</code></pre>

<li><p>Let <var>file</var> be <span data-x="a serialization of the bitmap as a file">a
serialization of this <code>canvas</code> element's bitmap as a file</span>, passing
<var>type</var> and <var>quality</var> if they were given.</p></li>
<var>type</var> and <var>quality</var> if given.</p></li>

<li><p>If <var>file</var> is null then return "<code data-x="">data:,</code>".</p></li>

Expand Down Expand Up @@ -59992,8 +59992,8 @@ callback <dfn>BlobCallback</dfn> = void (<span>Blob</span>? blob);</code></pre>

<ol>
<li><p>If <var>result</var> is non-null, then set <var>result</var> to <span data-x="a
serialization of the bitmap as a file">a serialization of <var>result</var> as a file</span>,
with <var>type</var> and <var>quality</var> if they were given.</p></li>
serialization of the bitmap as a file">a serialization of <var>result</var> as a file</span>
with <var>type</var> and <var>quality</var> if given.</p></li>

<li>
<p><span>Queue a task</span> to run these steps:</p>
Expand Down Expand Up @@ -65294,7 +65294,7 @@ dictionary <dfn>ImageBitmapRenderingContextSettings</dfn> {

dictionary <dfn>ImageEncodeOptions</dfn> {
DOMString <span data-x="image-encode-options-type">type</span> = "image/png";
unrestricted double <span data-x="image-encode-options-quality">quality</span> = 1.0;
unrestricted double <span data-x="image-encode-options-quality">quality</span>;
};

enum <dfn>OffscreenRenderingContextId</dfn> { "<span data-x="offscreen-context-type-2d">2d</span>", "<span data-x="offscreen-context-type-webgl">webgl</span>", "<span data-x="offscreen-context-type-webgl2">webgl2</span>" };
Expand Down Expand Up @@ -65612,7 +65612,7 @@ interface <dfn>OffscreenCanvas</dfn> : <span>EventTarget</span> {
<li><p>Let <var>file</var> be <span data-x="a serialization of the bitmap as a file">a
serialization of <var>bitmap</var> as a file</span>, with <var>options</var>'s <dfn><code
data-x="image-encode-options-type">type</code></dfn> and <dfn><code
data-x="image-encode-options-quality">quality</code></dfn>.</p></li>
data-x="image-encode-options-quality">quality</code></dfn> if present.</p></li>

<li>
<p><span>Queue a task</span> to run these steps:</p>
Expand Down Expand Up @@ -65892,11 +65892,10 @@ interface <dfn>OffscreenCanvasRenderingContext2D</dfn> {
<div w-nodev>

<p>When a user agent is to create <!--en-GB--><dfn id="a-serialisation-of-the-bitmap-as-a-file">a
serialization of the bitmap as a file</dfn>, given an optional <var>type</var> and
<var>quality</var>, it must create an image file in the format given by <var>type</var>, or if
<var>type</var> 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.
<ref spec=PNG></p>
serialization of the bitmap as a file</dfn>, given a <var>type</var> and an optional
<var>quality</var>, it must create an image file in the format given by <var>type</var>. 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. <ref spec=PNG></p>

<p>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
Expand All @@ -65923,16 +65922,20 @@ interface <dfn>OffscreenCanvasRenderingContext2D</dfn> {
image composited onto an <span>opaque black</span> background using the source-over operator.</p>

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

<p class="note">The use of type-testing here, instead of simply declaring <var>quality</var> as
a Web IDL <code data-x="">double</code>, is a historical artifact.</p>

<p class="note">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.</p>

</div>


Expand Down

0 comments on commit b799322

Please sign in to comment.