New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 622017 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner:
Closed: Jun 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Passing undefined as the maxWidth argument of CRC2D.fillText does not behave correctly

Project Member Reported by junov@chromium.org, Jun 21 2016

Issue description

ctx.fillText("Hello World!", 10, 10, undefined);
behaves the same as:
ctx.fillText("Hello World!", 10, 10);

This should only be the case when using the [TreatUndefinedAs=Missing] exended attribute, which is not the case for this argument.

The correct behavior is convert to a number, which yields NaN.  The IDL for fillText says the argument is an optional unrestricted double, so the NaN should get passed down to the implementation of fillText.  

The tesxt preparation algorithm, which consume maxWidth, doe not state how to handle NaN: https://html.spec.whatwg.org/multipage/scripting.html#text-preparation-algorithm

It currently says: "If maxWidth was provided but is less than or equal to zero, return an empty array."  It should probably be modified to say: "If maxWidth was provided but is less than or equal to zero or equal to NaN, return an empty array."

We should check what other implementations are doing to be sure.
 

Comment 1 by junov@chromium.org, Jun 21 2016

Summary: Passing undefined as the maxWidth argument of CRC2D.fillText does not behave correctly (was: passing undefined that the maxWidth argument of CRC2D.fillText does not behave correctly)
The behavior of passing null, undefined, and NaN is inconsistent through different browsers.

Chrome: passing null and NaN is the same as passing 0, not showing anything. But fillText(text, x, y, undefined) == fillText(test, x, y)

Edge: passing null, undefined, NaN are always treated the same as passing 0, which means not showing anything.

Firefox: fillText(text, x, y, null) == fillText(text, x, y, undefined) == fillText(text, x, y). While passing NaN is the same as passing 0, not showing anything.
Cc: junov@chromium.org

Comment 4 by junov@chromium.org, Jun 21 2016

Could you start a thread on the whatwg issue tracker about this?  FWIW, I think edge is the browser that is doing the right thing here. The spec needs to be clarified that NaN means draw nothing. Then everything else is well defined:
ES6 spec says undefined converts to NaN, and null converts to 0.

Comment 6 by junov@chromium.org, Jun 21 2016

Components: Blink>Bindings
The fact that NaN and undefined have different behaviors in Chrome suggests that there might be a bug in the bindings.
Status: WontFix (was: Assigned)
Please refer to discussion here:
https://codereview.chromium.org/2085973005/

The behavior is following the specs, and there is no bug.

Sign in to add a comment