Bug 206914

Summary: CanvasRenderingContext2DBase::drawImage() should use the destRect values to draw the SVG image.
Product: WebKit Reporter: zalan <zalan>
Component: SVGAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: sabouhallawa, simon.fraser, webkit-bug-importer, zimmermann
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=207160
Attachments:
Description Flags
test case
none
test case none

Description zalan 2020-01-28 16:33:48 PST
see fast/hidpi/image-srcset-relative-svg-canvas-2x.html and rdar://problem/58580461
Comment 1 Radar WebKit Bug Importer 2020-01-30 11:24:53 PST
<rdar://problem/59035239>
Comment 2 Said Abou-Hallawa 2020-01-30 14:42:29 PST
Created attachment 389291 [details]
test case

Open the attached test case in Safari, in Chrome and in FireFox. The three browsers have different layout and rendering of the test case.

This test case has an SVG image embedded inside an <img> element. The SVG does not have intrinsic size. But the css size of the <img> element is (100x50). The <img> element is then drawn to the canvas to (200x100) rectangle. This is how the three browsers behave:

1. Safari: the <img> element intrinsic size (100x50) is used for doing the SVG layout when it's drawing as an embedded element inside the <img> element and when it is drawn to the canvas through the drawImage() API.

2. Chrome: the <img> element intrinsic size (100x50) is used for doing the SVG layout when drawing it in as an embedded element inside the <img> element. But the destRect (200x100) of the canvas drawImage() API is used to do the SVG layout when it is drawn to the canvas through the drawImage() API.

3. FireFox: I am not sure how the intrinsic size of the SVG is set to (200x100). And it seems FireFox does not support drawing an SVG image to canvas.

I looked for a specification on how this should work but I could not find anything.
Comment 3 Said Abou-Hallawa 2020-01-30 14:44:57 PST
Created attachment 389292 [details]
test case
Comment 4 Said Abou-Hallawa 2020-04-01 15:24:30 PDT
Related GitHub issue: https://github.com/w3c/svgwg/issues/784