Closed Bug 1684567 Opened 3 years ago Closed 3 years ago

unspecified dimension of image tag is rounded to integer

Categories

(Core :: SVG, defect)

Firefox 84
defect

Tracking

()

RESOLVED FIXED
86 Branch
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.

Could you attach a testcase to the bug please?

Flags: needinfo?(joriki27)
Attached image test case

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.

Flags: needinfo?(joriki27)

(In reply to joriki27 from comment #2)

Sorry, that was supposed to be 31/18 ≈ 1.7222, not 31/8.

Assignee: nobody → longsonr
Status: UNCONFIRMED → NEW
Ever confirmed: true
Pushed by longsonr@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/b2bde87ec64a
don't round unspecified image dimensions to integers r=emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/27024 for changes under testing/web-platform/tests
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 86 Branch
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: