OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 { | 512 { |
513 NonThrowableExceptionState exceptionState; | 513 NonThrowableExceptionState exceptionState; |
514 return toUInt64(value, NormalConversion, exceptionState); | 514 return toUInt64(value, NormalConversion, exceptionState); |
515 } | 515 } |
516 | 516 |
517 float toFloat(v8::Handle<v8::Value> value, ExceptionState& exceptionState) | 517 float toFloat(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
518 { | 518 { |
519 return static_cast<float>(toDouble(value, exceptionState)); | 519 return static_cast<float>(toDouble(value, exceptionState)); |
520 } | 520 } |
521 | 521 |
522 float toRestrictedFloat(v8::Handle<v8::Value> value, ExceptionState& exceptionSt ate) | |
523 { | |
524 float numberValue = toFloat(value, exceptionState); | |
525 if (exceptionState.hadException()) | |
526 return 0; | |
527 if (!std::isfinite(numberValue)) { | |
528 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
| |
529 return 0; | |
530 } | |
531 return numberValue; | |
532 } | |
533 | |
522 double toDouble(v8::Handle<v8::Value> value, ExceptionState& exceptionState) | 534 double toDouble(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
523 { | 535 { |
524 if (value->IsNumber()) | 536 if (value->IsNumber()) |
525 return value->NumberValue(); | 537 return value->NumberValue(); |
526 | 538 |
527 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 539 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
528 v8::TryCatch block(isolate); | 540 v8::TryCatch block(isolate); |
529 v8::Local<v8::Number> numberObject(value->ToNumber(isolate)); | 541 v8::Local<v8::Number> numberObject(value->ToNumber(isolate)); |
530 if (block.HasCaught()) { | 542 if (block.HasCaught()) { |
531 exceptionState.rethrowV8Exception(block.Exception()); | 543 exceptionState.rethrowV8Exception(block.Exception()); |
532 return 0; | 544 return 0; |
533 } | 545 } |
534 return numberObject->NumberValue(); | 546 return numberObject->NumberValue(); |
535 } | 547 } |
536 | 548 |
549 double toRestrictedDouble(v8::Handle<v8::Value> value, ExceptionState& exception State) | |
550 { | |
551 double numberValue = toDouble(value, exceptionState); | |
552 if (exceptionState.hadException()) | |
553 return 0; | |
554 if (!std::isfinite(numberValue)) { | |
555 exceptionState.throwTypeError("The provided double value is non-finite." ); | |
a.suchit2
2015/02/20 15:03:12
same as above.
| |
556 return 0; | |
557 } | |
558 return numberValue; | |
559 } | |
560 | |
537 String toByteString(v8::Handle<v8::Value> value, ExceptionState& exceptionState) | 561 String toByteString(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
538 { | 562 { |
539 // Handle null default value. | 563 // Handle null default value. |
540 if (value.IsEmpty()) | 564 if (value.IsEmpty()) |
541 return String(); | 565 return String(); |
542 | 566 |
543 // From the Web IDL spec: http://heycam.github.io/webidl/#es-ByteString | 567 // From the Web IDL spec: http://heycam.github.io/webidl/#es-ByteString |
544 if (value.IsEmpty()) | 568 if (value.IsEmpty()) |
545 return String(); | 569 return String(); |
546 | 570 |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1006 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(v8::Isol ate* isolate, ExecutionContext* context, v8::Handle<v8::Function> function) | 1030 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(v8::Isol ate* isolate, ExecutionContext* context, v8::Handle<v8::Function> function) |
1007 { | 1031 { |
1008 int scriptId = 0; | 1032 int scriptId = 0; |
1009 String resourceName; | 1033 String resourceName; |
1010 int lineNumber = 1; | 1034 int lineNumber = 1; |
1011 GetDevToolsFunctionInfo(function, isolate, scriptId, resourceName, lineNumbe r); | 1035 GetDevToolsFunctionInfo(function, isolate, scriptId, resourceName, lineNumbe r); |
1012 return InspectorFunctionCallEvent::data(context, scriptId, resourceName, lin eNumber); | 1036 return InspectorFunctionCallEvent::data(context, scriptId, resourceName, lin eNumber); |
1013 } | 1037 } |
1014 | 1038 |
1015 } // namespace blink | 1039 } // namespace blink |
OLD | NEW |