createImageData does not specify rounding behavior for width/height parameters
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 9.4k
- Forks
- 3.2k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 38
Description
The IDL for CanvasRenderingContext2D.createImageBitmap specifies that the size parameters are "double", and the functions's algorithm says to take the absolute magnitudes of sw and sh. The behavior for fractional values of sw and sh is unspecified. I looked at open-source implementations of createImageBitmap and it looks like browsers are not compatible.
Blink and webkit:
effective width = ceil(abs(sw))
Mozilla: effective width = abs(toInt32(sw)), which simplifies to floor(abs(sw))
Sources:
https://trac.webkit.org/browser/trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp#L2017
https://dxr.mozilla.org/mozilla-central/source/dom/canvas/CanvasRenderingContext2D.cpp#5559
https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp&sq=package:chromium&type=cs&l=1148
Would be nice to agree on what the interoperable behavior should be, then spec it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the createImageBitmap IDL and algorithm alongside the Blink, WebKit, and Mozilla implementation sources linked in the issue. Compare their fractional sw and sh handling, then establish and specify interoperable rounding behavior once the standards discussion reaches agreement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- html
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100