Skip to content

Commit

Permalink
Make createImageBitmap support SVG, but not RenderingContexts
Browse files Browse the repository at this point in the history
This change fixes issue #923 by allowing ImageBitmap objects to
be created from SVG source images, as long as the image has an
intrinsic size. If the image does not have an intrinsic size,
we still reject the promise with an InvalidStateError, as before.

This change also removes CanvasRenderingContext2D from
ImageBtimapSource, which was an oversight in PR #790. Since there
is no longer a concept of a standalone context, this is no longer
needed.
  • Loading branch information
junov authored and annevk committed Apr 1, 2016
1 parent fc53707 commit 43ad288
Showing 1 changed file with 12 additions and 47 deletions.
59 changes: 12 additions & 47 deletions source
Expand Up @@ -90231,7 +90231,6 @@ typedef (<span>HTMLOrSVGImageElement</span> or
<span>HTMLCanvasElement</span> or
<span>Blob</span> or
<span>ImageData</span> or
<span>CanvasRenderingContext2D</span> or
<span>ImageBitmap</span>) <dfn>ImageBitmapSource</dfn>;

enum <dfn>ImageOrientation</dfn> { "<span data-x="dom-ImageOrientation-none">none</span>", "<span data-x="dom-ImageOrientation-flipY">flipY</span>" };
Expand Down Expand Up @@ -90267,9 +90266,9 @@ interface <dfn>ImageBitmapFactories</dfn> {

<dd>

<p>Takes <var>image</var>, which can be an <code>img</code> element,
<code>video</code>, or <code>canvas</code> element, a <code>Blob</code> object, an
<code>ImageData</code> object, a <code>CanvasRenderingContext2D</code> object, or another
<p>Takes <var>image</var>, which can be an <code>img</code> element, an <span>SVG
<code>image</code></span> element, a <code>video</code> element, a <code>canvas</code>
element, a <code>Blob</code> object, an <code>ImageData</code> object, or another
<code>ImageBitmap</code> object, and returns a promise that is resolved when a new
<code>ImageBitmap</code> is created.</p>

Expand Down Expand Up @@ -90395,9 +90394,9 @@ interface <dfn>ImageBitmapFactories</dfn> {
return a promise rejected with an <code>InvalidStateError</code> exception and abort these
steps.</p></li>

<li><p>If <var>image</var>'s media data is not a bitmap (e.g. it's a vector graphic), then
return a promise rejected with an <code>InvalidStateError</code> exception and abort these
steps.</p></li>
<li><p>If <var>image</var>'s media data has no intrinsic dimensions (e.g. it's a vector
graphic with no specified content size), then return a promise rejected with an
<code>InvalidStateError</code> exception and abort these steps.</p></li>

<li><p>Create a new <code>ImageBitmap</code> object.</p></li>

Expand Down Expand Up @@ -90524,13 +90523,13 @@ interface <dfn>ImageBitmapFactories</dfn> {

<li><p>Apply the <span data-x="Content-Type sniffing: image">image sniffing rules</span> to
determine the file format of the image data, with MIME type of the <code>Blob</code> (as given
by the <code>Blob</code> object's <code data-x="dom-Blob-type">type</code> attribute) giving the
official type.</p></li>
by the <code>Blob</code> object's <code data-x="dom-Blob-type">type</code> attribute) giving
the official type.</p></li>

<li><p>If the image data is not in a supported bitmap image file format (e.g. it's a vector
graphic or it's not an image at all), or if the image data is corrupted in some fatal way such
that the image dimensions cannot be obtained, then reject the promise with an
<code>InvalidStateError</code> exception, and abort these steps.</p></li>
<li><p>If the image data is not in a supported image file format (e.g. it's not an image at
all), or if the image data is corrupted in some fatal way such that the image dimensions
cannot be obtained (e.g. a vector graphic with no intrinsic size), then reject the promise
with an <code>InvalidStateError</code> exception, and abort these steps.</p></li>

<li><p>Create a new <code>ImageBitmap</code> object.</p></li>

Expand Down Expand Up @@ -90578,40 +90577,6 @@ interface <dfn>ImageBitmapFactories</dfn> {

</dd>

<dt>If <var>image</var> is a <code>CanvasRenderingContext2D</code> object

<dd>

<ol>

<li><p>If either the <var>sw</var> or <var>sh</var> arguments are specified
but zero, return a promise rejected with an <code>IndexSizeError</code> exception and abort these steps.</p></li>

<li><p>If the <code>CanvasRenderingContext2D</code> object's <span>output bitmap</span> has
either a horizontal dimension or a vertical dimension equal to zero, then return a promise
rejected with an <code>InvalidStateError</code> exception and abort these steps.</p></li>

<li><p>Create a new <code>ImageBitmap</code> object.</p></li>

<li><p>Let the <code>ImageBitmap</code> object's <span
data-x="concept-ImageBitmap-bitmap-data">bitmap data</span> be a copy of the
<code>CanvasRenderingContext2D</code> object's <span>output bitmap</span>, <span>cropped to
the source rectangle with formatting</span>.</p></li>

<li><p>Set the <span data-x="concept-canvas-origin-clean">origin-clean</span> flag of the
<code>ImageBitmap</code> object's bitmap to the same value as the <span
data-x="concept-canvas-origin-clean">origin-clean</span> flag of the
<code>CanvasRenderingContext2D</code> object.</p></li>

<li><p>Return a new promise, but continue running these steps
<span>in parallel</span>.</p></li>

<li><p>Resolve the promise with the new <code>ImageBitmap</code> object as the value.</p></li>

</ol>

</dd>


<dt>If <var>image</var> is an <code>ImageBitmap</code> object

Expand Down

0 comments on commit 43ad288

Please sign in to comment.