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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 return 0; | 497 return 0; |
498 } | 498 } |
499 return numberValue; | 499 return numberValue; |
500 } | 500 } |
501 | 501 |
502 double toDoubleSlow(v8::Isolate* isolate, | 502 double toDoubleSlow(v8::Isolate* isolate, |
503 v8::Local<v8::Value> value, | 503 v8::Local<v8::Value> value, |
504 ExceptionState& exceptionState) { | 504 ExceptionState& exceptionState) { |
505 ASSERT(!value->IsNumber()); | 505 ASSERT(!value->IsNumber()); |
506 v8::TryCatch block(isolate); | 506 v8::TryCatch block(isolate); |
507 double doubleValue; | 507 v8::Local<v8::Number> numberValue; |
508 if (!v8Call(value->NumberValue(isolate->GetCurrentContext()), doubleValue, | 508 if (!value->ToNumber(isolate->GetCurrentContext()).ToLocal(&numberValue)) { |
509 block)) { | |
510 exceptionState.rethrowV8Exception(block.Exception()); | 509 exceptionState.rethrowV8Exception(block.Exception()); |
511 return 0; | 510 return 0; |
512 } | 511 } |
513 return doubleValue; | 512 return numberValue->Value(); |
514 } | 513 } |
515 | 514 |
516 double toRestrictedDouble(v8::Isolate* isolate, | 515 double toRestrictedDouble(v8::Isolate* isolate, |
517 v8::Local<v8::Value> value, | 516 v8::Local<v8::Value> value, |
518 ExceptionState& exceptionState) { | 517 ExceptionState& exceptionState) { |
519 double numberValue = toDouble(isolate, value, exceptionState); | 518 double numberValue = toDouble(isolate, value, exceptionState); |
520 if (exceptionState.hadException()) | 519 if (exceptionState.hadException()) |
521 return 0; | 520 return 0; |
522 if (!std::isfinite(numberValue)) { | 521 if (!std::isfinite(numberValue)) { |
523 exceptionState.throwTypeError("The provided double value is non-finite."); | 522 exceptionState.throwTypeError("The provided double value is non-finite."); |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 if (!v8Call(v8::JSON::Parse(isolate, v8String(isolate, stringifiedJSON)), | 971 if (!v8Call(v8::JSON::Parse(isolate, v8String(isolate, stringifiedJSON)), |
973 parsed, tryCatch)) { | 972 parsed, tryCatch)) { |
974 if (tryCatch.HasCaught()) | 973 if (tryCatch.HasCaught()) |
975 exceptionState.rethrowV8Exception(tryCatch.Exception()); | 974 exceptionState.rethrowV8Exception(tryCatch.Exception()); |
976 } | 975 } |
977 | 976 |
978 return parsed; | 977 return parsed; |
979 } | 978 } |
980 | 979 |
981 } // namespace blink | 980 } // namespace blink |
OLD | NEW |