unspecified dimension of image tag is rounded to integer
Categories
(Core :: SVG, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox86 | --- | fixed |
People
(Reporter: joriki27, Assigned: longsonr)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:84.0) Gecko/20100101 Firefox/84.0
Steps to reproduce:
I specified only the width for SVG <image> tags, not the height. The coordinate system was such that the width and height were small numbers like 1 or 5.
Actual results:
The missing dimension was apparently inferred using the pixel dimensions of the image, but rounded to an integer, e.g. when the width was specified as 10 and the image was 326 x 176 pixels, the height seemed to be inferred as 5, not as 10 * 176/326 ≈ 5.4. (I didn't specify preserveAspectRatio, so it had its default value "xMidYMid meet", so the aspect ratio was preserved, but the positioning was affected by the rounding.)
Expected results:
Strictly speaking, nothing particular should have happened, since the width and height are both required attributes of the image tag so the behaviour is unspecified if one of them is missing. However, all browsers seem to infer a missing dimension using the specified dimension and the pixel dimensions of the image. Other browsers don't round the missing dimension to an integer (and it's not apparent why they should), so this leads to the image being positioned differently in Firefox than it's positioned in other browsers.
Assignee | ||
Comment 1•4 years ago
|
||
Could you attach a testcase to the bug please?
The attached test case shows an image on which the width is specified as 1.5 and the height is not specified. The height inferred from the pixel dimensions of the image, 270x310, would be 31/8 ≈ 1.7222. The green rectangle shows the expected image rectangle with width 1.5 and height 1.7222. Other browsers centre the image in this rectangle. The red rectangle shows the image rectangle in which Firefox seems to centre the image, with the inferred height rounded down to the integer 1.
(In reply to joriki27 from comment #2)
Sorry, that was supposed to be 31/18 ≈ 1.7222, not 31/8.
Assignee | ||
Comment 4•4 years ago
|
||
Updated•4 years ago
|
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 5•4 years ago
|
||
Comment 8•4 years ago
|
||
bugherder |
Description
•