| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Ericsson AB. All rights reserved. | 3 * Copyright (C) 2012 Ericsson AB. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 CORE_EXPORT String toByteString(v8::Isolate*, v8::Local<v8::Value>, ExceptionSta
te&); | 555 CORE_EXPORT String toByteString(v8::Isolate*, v8::Local<v8::Value>, ExceptionSta
te&); |
| 556 | 556 |
| 557 // Converts a value to a String, replacing unmatched UTF-16 surrogates with repl
acement characters. | 557 // Converts a value to a String, replacing unmatched UTF-16 surrogates with repl
acement characters. |
| 558 CORE_EXPORT String toUSVString(v8::Isolate*, v8::Local<v8::Value>, ExceptionStat
e&); | 558 CORE_EXPORT String toUSVString(v8::Isolate*, v8::Local<v8::Value>, ExceptionStat
e&); |
| 559 | 559 |
| 560 inline v8::Local<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate) | 560 inline v8::Local<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate) |
| 561 { | 561 { |
| 562 return value ? v8::True(isolate) : v8::False(isolate); | 562 return value ? v8::True(isolate) : v8::False(isolate); |
| 563 } | 563 } |
| 564 | 564 |
| 565 inline double toCoreDate(v8::Isolate* isolate, v8::Local<v8::Value> object) | 565 inline double toCoreDate(v8::Isolate* isolate, v8::Local<v8::Value> object, Exce
ptionState& exceptionState) |
| 566 { | 566 { |
| 567 if (object->IsDate()) | 567 if (object->IsNull()) |
| 568 return object.As<v8::Date>()->ValueOf(); | 568 return std::numeric_limits<double>::quiet_NaN(); |
| 569 if (object->IsNumber()) | 569 if (!object->IsDate()) { |
| 570 return object.As<v8::Number>()->Value(); | 570 exceptionState.throwTypeError("The provided value is not a Date."); |
| 571 return std::numeric_limits<double>::quiet_NaN(); | 571 return 0; |
| 572 } |
| 573 return object.As<v8::Date>()->ValueOf(); |
| 572 } | 574 } |
| 573 | 575 |
| 574 inline v8::MaybeLocal<v8::Value> v8DateOrNaN(v8::Isolate* isolate, double value) | 576 inline v8::MaybeLocal<v8::Value> v8DateOrNaN(v8::Isolate* isolate, double value) |
| 575 { | 577 { |
| 576 ASSERT(isolate); | 578 ASSERT(isolate); |
| 577 return v8::Date::New(isolate->GetCurrentContext(), std::isfinite(value) ? va
lue : std::numeric_limits<double>::quiet_NaN()); | 579 return v8::Date::New(isolate->GetCurrentContext(), std::isfinite(value) ? va
lue : std::numeric_limits<double>::quiet_NaN()); |
| 578 } | 580 } |
| 579 | 581 |
| 580 // FIXME: Remove the special casing for NodeFilter and XPathNSResolver. | 582 // FIXME: Remove the special casing for NodeFilter and XPathNSResolver. |
| 581 NodeFilter* toNodeFilter(v8::Local<v8::Value>, v8::Local<v8::Object>, ScriptStat
e*); | 583 NodeFilter* toNodeFilter(v8::Local<v8::Value>, v8::Local<v8::Object>, ScriptStat
e*); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 typedef void (*InstallTemplateFunction)(v8::Isolate*, const DOMWrapperWorld&, v8
::Local<v8::FunctionTemplate> interfaceTemplate); | 959 typedef void (*InstallTemplateFunction)(v8::Isolate*, const DOMWrapperWorld&, v8
::Local<v8::FunctionTemplate> interfaceTemplate); |
| 958 | 960 |
| 959 // Freeze a V8 object. The type of the first parameter and the return value is | 961 // Freeze a V8 object. The type of the first parameter and the return value is |
| 960 // intentionally v8::Value so that this function can wrap toV8(). | 962 // intentionally v8::Value so that this function can wrap toV8(). |
| 961 // If the argument isn't an object, this will crash. | 963 // If the argument isn't an object, this will crash. |
| 962 CORE_EXPORT v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value>, v8::Isolat
e*); | 964 CORE_EXPORT v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value>, v8::Isolat
e*); |
| 963 | 965 |
| 964 } // namespace blink | 966 } // namespace blink |
| 965 | 967 |
| 966 #endif // V8Binding_h | 968 #endif // V8Binding_h |
| OLD | NEW |