Closed Bug 1500768 Opened Last year Closed Last year

Implement SVG image support for createImageBitmap

Categories

(Core :: DOM: Core & HTML, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla65
Tracking Status
firefox65 --- fixed

People

(Reporter: baku, Assigned: baku)

Details

(Keywords: dev-doc-complete)

Attachments

(2 files)

CanvasImageSource should compose, together with Blob and ImageData, the ImageBitmapSource typedef:

https://html.spec.whatwg.org/multipage/canvas.html#canvasimagesource
https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#imagebitmapsource

But we don't support SVGImageElement as input for CreateImageBitmap yet.
Priority: -- → P3
Attached patch svg.patchSplinter Review
Assignee: nobody → amarchesini
Attachment #9019952 - Flags: review?(jwatt)
Attached patch svg2.patchSplinter Review
Attachment #9019958 - Flags: review?(jwatt)
Comment on attachment 9019952 [details] [diff] [review]
svg.patch

Review of attachment 9019952 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/canvas/ImageBitmap.cpp
@@ +500,2 @@
>  static bool
> +HasRasterImage(ElementType& aImageEl)

As noted on IRC, this should go away.

@@ +892,5 @@
>    return ret.forget();
>  }
>  
>  /* static */ already_AddRefed<ImageBitmap>
> +ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, SVGImageElement& aImageEl,

It would be nice to share some of this code, but I guess it's likely to diverge as you fix more of the web-platform-tests.
Attachment #9019952 - Flags: review?(jwatt) → review+
Comment on attachment 9019958 [details] [diff] [review]
svg2.patch

Review of attachment 9019958 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/canvas/ImageBitmap.cpp
@@ -497,5 @@
> - * raster image.
> - */
> -template<class ElementType>
> -static bool
> -HasRasterImage(ElementType& aImageEl)

Ah, good. :)
Attachment #9019958 - Flags: review?(jwatt) → review+
I'm guessing that there aren't WPT tests for the steps under 'SVG image' in items 6 at:

https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#dom-createimagebitmap

Could you look into that, and perhaps add them? I expect we have some failures there.
Yes we have tests. And "SVG image" section is shared with "img" aka HTMLImageElement.
The reason why I moved the origin check is because it should be executed after 1, 2 and 3.
Pushed by amarchesini@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/e81ad7034716
Implement SVGImageElement support for createImageBitmap, r=jwatt
https://hg.mozilla.org/integration/mozilla-inbound/rev/2e9cdd9ff7b6
Support SVG images in HTMLImageElements, r=jwatt
Keywords: dev-doc-needed
https://hg.mozilla.org/mozilla-central/rev/e81ad7034716
https://hg.mozilla.org/mozilla-central/rev/2e9cdd9ff7b6
Status: NEW → RESOLVED
Closed: Last year
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
I've added a note to the Fx65 rel notes:
https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/65#APIs

Apart from that, I just needed to update the compat data. I've submitted a PR to do that:
https://github.com/mdn/browser-compat-data/pull/3230

Let me know if this all looks ok!
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.