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

Unified Diff: Source/bindings/core/v8/V8Binding.cpp

Issue 860353002: IDL: Add toRestricted{Float,Double}() helpers to V8Binding.h (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add FIXME comment Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/core/v8/V8Binding.h ('k') | Source/bindings/scripts/v8_attributes.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « Source/bindings/core/v8/V8Binding.h ('k') | Source/bindings/scripts/v8_attributes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698