Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Issue 860353002: IDL: Add toRestricted{Float,Double}() helpers to V8Binding.h (Closed)

Created:
5 years, 11 months ago by Jens Widell
Modified:
5 years, 10 months ago
Reviewers:
haraken, a.suchit2, fs, bashi
CC:
blink-reviews, blink-reviews-bindings_chromium.org, arv+blink
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Target Ref:
refs/heads/master
Project:
blink
Visibility:
Public.

Description

IDL: Add toRestricted{Float,Double}() helpers to V8Binding.h These implement conversion from V8 value to a float/double C++ that throws a TypeError if the numeric value is NaN or infinite. This is how the IDL types 'float' and 'double' should behave according to WebIDL, but in Blink they currently only do if an interface/method/attribute has the extended attribute [TypeChecking=Unrestricted]. This CL changes two observable things: 1) The error message changes from being specific to the method argument being converted ("double parameter N is non-finite"), to being generic ("The provided double value is non-finite"). 2) 'float'/'double' members in union types go from being always unrestricted to always being restricted, which is correct per specification. Since [TypeChecking=Unrestricted] wasn't supported either for dictionary members or union type members, it was previously impossible to get the correct behavior for these type conversions. An unrestricted conversion for a union member can be achieved by declaring the member as 'unrestricted float' or 'unrestricted double', also per specification. A restricted conversion for a dictionary member can now be achieved by adding [TypeChecking=Unrestricted] on the dictionary as a whole or on the member. BUG=354298, 450252 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=188797

Patch Set 1 #

Total comments: 8

Patch Set 2 : adjust handling of dictionary members #

Total comments: 2

Patch Set 3 : add FIXME comment #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+359 lines, -187 lines) Patch
M LayoutTests/fast/canvas/canvas-2d-imageData-create-nonfinite-expected.txt View 1 chunk +7 lines, -7 lines 0 comments Download
M LayoutTests/fast/canvas/canvas-getImageData-invalid-expected.txt View 1 chunk +12 lines, -12 lines 0 comments Download
M LayoutTests/fast/canvas/canvas-putImageData-expected.txt View 1 chunk +18 lines, -18 lines 0 comments Download
M LayoutTests/fast/canvas/gradient-addColorStop-with-invalid-offset-expected.txt View 1 chunk +3 lines, -3 lines 0 comments Download
M LayoutTests/fast/canvas/linearGradient-infinite-values-expected.txt View 1 chunk +12 lines, -12 lines 0 comments Download
M LayoutTests/fast/canvas/radialGradient-infinite-values-expected.txt View 1 chunk +18 lines, -18 lines 0 comments Download
M Source/bindings/core/v8/V8Binding.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/core/v8/V8Binding.cpp View 2 chunks +24 lines, -0 lines 4 comments Download
M Source/bindings/scripts/v8_attributes.py View 4 chunks +5 lines, -8 lines 0 comments Download
M Source/bindings/scripts/v8_dictionary.py View 1 4 chunks +8 lines, -3 lines 0 comments Download
M Source/bindings/scripts/v8_interface.py View 4 chunks +8 lines, -4 lines 0 comments Download
M Source/bindings/scripts/v8_methods.py View 5 chunks +8 lines, -7 lines 0 comments Download
M Source/bindings/scripts/v8_types.py View 1 2 5 chunks +10 lines, -5 lines 0 comments Download
M Source/bindings/scripts/v8_union.py View 1 chunk +1 line, -1 line 0 comments Download
M Source/bindings/templates/attributes.cpp View 1 chunk +1 line, -10 lines 0 comments Download
M Source/bindings/templates/methods.cpp View 1 chunk +1 line, -10 lines 0 comments Download
M Source/bindings/tests/idls/core/TestDictionary.idl View 1 1 chunk +2 lines, -0 lines 0 comments Download
M Source/bindings/tests/idls/core/TestObject.idl View 1 chunk +1 line, -0 lines 0 comments Download
M Source/bindings/tests/results/core/TestDictionary.h View 1 4 chunks +10 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/core/TestDictionary.cpp View 1 1 chunk +2 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/core/UnionTypesCore.h View 1 chunk +46 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/core/UnionTypesCore.cpp View 4 chunks +75 lines, -3 lines 0 comments Download
M Source/bindings/tests/results/core/V8TestDictionary.cpp View 1 4 chunks +36 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/core/V8TestInterface.cpp View 4 chunks +5 lines, -30 lines 0 comments Download
M Source/bindings/tests/results/core/V8TestObject.cpp View 3 chunks +36 lines, -12 lines 0 comments Download
M Source/bindings/tests/results/modules/V8TestInterface5.cpp View 3 chunks +4 lines, -24 lines 0 comments Download

Messages

Total messages: 12 (3 generated)
Jens Widell
haraken, bashi: PTAL fs: FYI Slightly bigger patch than I had intended initially, but I ...
5 years, 11 months ago (2015-01-21 13:35:10 UTC) #2
bashi
I like this approach. LGTM. https://codereview.chromium.org/860353002/diff/1/Source/bindings/core/v8/V8Binding.h File Source/bindings/core/v8/V8Binding.h (right): https://codereview.chromium.org/860353002/diff/1/Source/bindings/core/v8/V8Binding.h#newcode472 Source/bindings/core/v8/V8Binding.h:472: float toRestrictedFloat(v8::Handle<v8::Value>, ExceptionState&); On ...
5 years, 11 months ago (2015-01-22 02:11:15 UTC) #3
haraken
LGTM https://codereview.chromium.org/860353002/diff/1/Source/bindings/core/v8/V8Binding.h File Source/bindings/core/v8/V8Binding.h (right): https://codereview.chromium.org/860353002/diff/1/Source/bindings/core/v8/V8Binding.h#newcode472 Source/bindings/core/v8/V8Binding.h:472: float toRestrictedFloat(v8::Handle<v8::Value>, ExceptionState&); On 2015/01/22 02:11:14, bashi1 wrote: ...
5 years, 11 months ago (2015-01-22 02:43:06 UTC) #4
Jens Widell
Thanks for reviews! https://codereview.chromium.org/860353002/diff/20001/Source/bindings/scripts/v8_types.py File Source/bindings/scripts/v8_types.py (right): https://codereview.chromium.org/860353002/diff/20001/Source/bindings/scripts/v8_types.py#newcode557 Source/bindings/scripts/v8_types.py:557: if base_idl_type in ('float', 'double') and ...
5 years, 11 months ago (2015-01-22 06:59:10 UTC) #5
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/860353002/40001
5 years, 11 months ago (2015-01-22 06:59:46 UTC) #7
commit-bot: I haz the power
Committed patchset #3 (id:40001) as https://src.chromium.org/viewvc/blink?view=rev&revision=188797
5 years, 11 months ago (2015-01-22 08:17:50 UTC) #8
a.suchit2
https://codereview.chromium.org/860353002/diff/40001/Source/bindings/core/v8/V8Binding.cpp File Source/bindings/core/v8/V8Binding.cpp (right): https://codereview.chromium.org/860353002/diff/40001/Source/bindings/core/v8/V8Binding.cpp#newcode528 Source/bindings/core/v8/V8Binding.cpp:528: exceptionState.throwTypeError("The provided float value is non-finite."); Why are we ...
5 years, 10 months ago (2015-02-20 15:03:12 UTC) #10
Jens Widell
https://codereview.chromium.org/860353002/diff/40001/Source/bindings/core/v8/V8Binding.cpp File Source/bindings/core/v8/V8Binding.cpp (right): https://codereview.chromium.org/860353002/diff/40001/Source/bindings/core/v8/V8Binding.cpp#newcode528 Source/bindings/core/v8/V8Binding.cpp:528: exceptionState.throwTypeError("The provided float value is non-finite."); On 2015/02/20 15:03:12, ...
5 years, 10 months ago (2015-02-20 15:16:47 UTC) #11
a.suchit2
5 years, 10 months ago (2015-02-21 09:35:26 UTC) #12
Message was sent while issue was closed.
https://codereview.chromium.org/860353002/diff/40001/Source/bindings/core/v8/...
File Source/bindings/core/v8/V8Binding.cpp (right):

https://codereview.chromium.org/860353002/diff/40001/Source/bindings/core/v8/...
Source/bindings/core/v8/V8Binding.cpp:528: exceptionState.throwTypeError("The
provided float value is non-finite.");
On 2015/02/20 15:16:46, Jens Widell wrote:
> On 2015/02/20 15:03:12, a.suchit2 wrote:
> > Why are we not throwing NotSupportedError from here based on specification
> > http://www.w3.org/TR/2dcontext/
> > 
> > Many of the canvas API should throw NotSupportedError in the case of
> > infinite/Nan. Because control never goes to our code for throwing these
> > exceptions based on specifications.
> 
> We're throwing TypeError here because that's what WebIDL says to do, and
WebIDL
> is the specification this code primarily implements.
> 
> The specification you link to is probably simply wrong. (And also probably
> obsolete: don't read /TR/ specifications!) The description of the API in
> http://html.spec.whatwg.org/ does not say to throw NotSupportedError (except
in
> a non-normative section, which in turn is probably simply a bug). The
> specification you link also says
> 
>   "Interfaces are defined in terms of Web IDL."
> 
> which is incompatible with requiring that a different type of exception should
> be throw in error conditions also covered by Web IDL.

Thanks Jens

Powered by Google App Engine
This is Rietveld 408576698