Re: [whatwg] Why CanvasRenderingContext2D uses WebIDL unrestricted float type?

2015-03-25 Thread Tetsuharu OHZEKI
 I understand the reason.
Thank you!

Tetsuharu OHZEKI
2015/03/25 午前5:37 Boris Zbarsky bzbar...@mit.edu:

 On 3/24/15 4:06 PM, Tetsuharu OHZEKI wrote:

 But I think that, why don't  CanvasRenderingContext2D use restricted
 float type defined in WebIDL if these methods ignore the value when
 its is not finite?


 Because they want to ignore the value.

  By the current WebIDL spec
 (http://heycam.github.io/webidl/#es-double), restricted values,
 'float'  'double', will raise TypeError in conversion phase under
 ECMAScript environment if the passed value is a NaN or +-Infinity.


 Exactly.  That's not the same thing as ignoring the value.

  For the purpose to ignore non-restricted values, I feel that it's more
 better to restrict by IDL type.


 Not if you want to actually _ignore_ the value (as opposed to throwing an
 exception).

 -Boris



Re: [whatwg] Why CanvasRenderingContext2D uses WebIDL unrestricted float type?

2015-03-24 Thread Rik Cabanier
On Tue, Mar 24, 2015 at 1:06 PM, Tetsuharu OHZEKI saneyuki.s...@gmail.com
wrote:

 Hi everybody.

 I have a question about the definition of CanvasRenderingContext2D's
 behavior.

 The current spec about CanvasRenderingContext2D says the following:

  Except where otherwise specified, for the 2D context interface,
  any method call with a numeric argument whose value is infinite
  or a NaN value must be ignored.

 https://html.spec.whatwg.org/multipage/scripting.html#canvasrenderingcontext2d

 But I think that, why don't  CanvasRenderingContext2D use restricted
 float type defined in WebIDL if these methods ignore the value when
 its is not finite?

 By the current WebIDL spec
 (http://heycam.github.io/webidl/#es-double), restricted values,
 'float'  'double', will raise TypeError in conversion phase under
 ECMAScript environment if the passed value is a NaN or +-Infinity.

 For the purpose to ignore non-restricted values, I feel that it's more
 better to restrict by IDL type. So the definitions by the current spec
 is for backward compatibility, or simply a spec issue?


We had a long discussion on this about a year ago.
In short, we want web APIs to be robust so that if a developer makes a
mistakes and passes a NaN or other strange value, the application will
attempt to keep on running.
Worst case, the app will crash later on anyway and best case, it will show
up as a short flicker or not at all.


Re: [whatwg] Why CanvasRenderingContext2D uses WebIDL unrestricted float type?

2015-03-24 Thread Boris Zbarsky

On 3/24/15 4:06 PM, Tetsuharu OHZEKI wrote:

But I think that, why don't  CanvasRenderingContext2D use restricted
float type defined in WebIDL if these methods ignore the value when
its is not finite?


Because they want to ignore the value.


By the current WebIDL spec
(http://heycam.github.io/webidl/#es-double), restricted values,
'float'  'double', will raise TypeError in conversion phase under
ECMAScript environment if the passed value is a NaN or +-Infinity.


Exactly.  That's not the same thing as ignoring the value.


For the purpose to ignore non-restricted values, I feel that it's more
better to restrict by IDL type.


Not if you want to actually _ignore_ the value (as opposed to throwing 
an exception).


-Boris