whatwg / whatwg/html

createImageData does not specify rounding behavior for width/height parameters

Open
#765 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

compat topic: canvas
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.