createImageBitmap's crop-rect should be clipped to the input's dimensions
Categories
(Core :: DOM: Core & HTML, task, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox86 | --- | affected |
People
(Reporter: tristan.fraipont, Unassigned)
Details
Attachments
(1 file)
|
502 bytes,
text/html
|
Details |
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.
Ps: I opened https://github.com/whatwg/html/issues/6306
Updated•4 years ago
|
Comment 2•4 years ago
|
||
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!
Description
•