Chromium Code Reviews| Index: Source/bindings/core/v8/V8Binding.cpp |
| diff --git a/Source/bindings/core/v8/V8Binding.cpp b/Source/bindings/core/v8/V8Binding.cpp |
| index 866ef4f527700fb9958e424ac46f1d93eff70408..712c6454a3202caab6b5123db75a49d3c3f85b2b 100644 |
| --- a/Source/bindings/core/v8/V8Binding.cpp |
| +++ b/Source/bindings/core/v8/V8Binding.cpp |
| @@ -519,6 +519,18 @@ float toFloat(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
| return static_cast<float>(toDouble(value, exceptionState)); |
| } |
| +float toRestrictedFloat(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
| +{ |
| + float numberValue = toFloat(value, exceptionState); |
| + if (exceptionState.hadException()) |
| + return 0; |
| + if (!std::isfinite(numberValue)) { |
| + exceptionState.throwTypeError("The provided float value is non-finite."); |
|
a.suchit2
2015/02/20 15:03:12
Why are we not throwing NotSupportedError from her
Jens Widell
2015/02/20 15:16:46
We're throwing TypeError here because that's what
a.suchit2
2015/02/21 09:35:26
Thanks Jens
|
| + return 0; |
| + } |
| + return numberValue; |
| +} |
| + |
| double toDouble(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
| { |
| if (value->IsNumber()) |
| @@ -534,6 +546,18 @@ double toDouble(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
| return numberObject->NumberValue(); |
| } |
| +double toRestrictedDouble(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
| +{ |
| + double numberValue = toDouble(value, exceptionState); |
| + if (exceptionState.hadException()) |
| + return 0; |
| + if (!std::isfinite(numberValue)) { |
| + exceptionState.throwTypeError("The provided double value is non-finite."); |
|
a.suchit2
2015/02/20 15:03:12
same as above.
|
| + return 0; |
| + } |
| + return numberValue; |
| +} |
| + |
| String toByteString(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
| { |
| // Handle null default value. |