Closed Bug 1687216 Opened 4 years ago Closed 4 years ago

createImageBitmap's crop-rect should be clipped to the input's dimensions

Categories

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

Firefox 86
task

Tracking

()

RESOLVED INVALID
Tracking Status
firefox86 --- affected

People

(Reporter: tristan.fraipont, Unassigned)

Details

Attachments

(1 file)

Attached file test-case.html

Since this PR from 2016, the sourceRectangle used in the cropping algorithm of createImageBitmap has to be clipped to the input's dimensions.

This means that if we are to get an ImageBitmap with a crop-rect (defined by the sx, sy, sw, and sh params) that goes beyond the image's dimensions, instead of an ImageBitmap of abs(sw) per abs(sh), it should produce an ImageBitmap with a smaller size.
With numbers that gives

// input_dimensions = { w: 300, h: 300 };
createImageBitmap(input, 200, 200, 200, 200); // => ImageBitmap { w: 100, h: 100 }

The behavior when the sourceRectangle does not intersect at all with the input is apparently undefined, but Blink does return a transparent ImageBitmap the size of crop-rect.

Currently Firefox follows the previous texts and returns an ImageBitmap of the size specified by sw and sh, like anyone would expect...

I made a PR to WPT to handle this case (first assuming FF's behavior was the correct one, then changing to Chrome's + specs).

Note that I plan to start a discussion over at HTML about this case, since as a web-author I find this behavior particularly questionable.

Severity: -- → N/A
Priority: -- → P3

Per that issue we'll change the HTML Standard to align with Firefox and Chrome will have to change. Thanks for your work on this Kaiido!

Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: