| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 template <typename CallbackInfo, typename T> | 213 template <typename CallbackInfo, typename T> |
| 214 inline void V8SetReturnValue(const CallbackInfo& callback_info, | 214 inline void V8SetReturnValue(const CallbackInfo& callback_info, |
| 215 PassRefPtr<T> impl) { | 215 PassRefPtr<T> impl) { |
| 216 V8SetReturnValue(callback_info, impl.Get()); | 216 V8SetReturnValue(callback_info, impl.Get()); |
| 217 } | 217 } |
| 218 | 218 |
| 219 template <typename CallbackInfo> | 219 template <typename CallbackInfo> |
| 220 inline void V8SetReturnValueForMainWorld(const CallbackInfo& callback_info, | 220 inline void V8SetReturnValueForMainWorld(const CallbackInfo& callback_info, |
| 221 ScriptWrappable* impl) { | 221 ScriptWrappable* impl) { |
| 222 ASSERT(DOMWrapperWorld::Current(callback_info.GetIsolate()).IsMainWorld()); | 222 DCHECK(DOMWrapperWorld::Current(callback_info.GetIsolate()).IsMainWorld()); |
| 223 if (UNLIKELY(!impl)) { | 223 if (UNLIKELY(!impl)) { |
| 224 V8SetReturnValueNull(callback_info); | 224 V8SetReturnValueNull(callback_info); |
| 225 return; | 225 return; |
| 226 } | 226 } |
| 227 if (DOMDataStore::SetReturnValueForMainWorld(callback_info.GetReturnValue(), | 227 if (DOMDataStore::SetReturnValueForMainWorld(callback_info.GetReturnValue(), |
| 228 impl)) | 228 impl)) |
| 229 return; | 229 return; |
| 230 v8::Local<v8::Object> wrapper = | 230 v8::Local<v8::Object> wrapper = |
| 231 impl->Wrap(callback_info.GetIsolate(), callback_info.Holder()); | 231 impl->Wrap(callback_info.GetIsolate(), callback_info.Holder()); |
| 232 V8SetReturnValue(callback_info, wrapper); | 232 V8SetReturnValue(callback_info, wrapper); |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 CORE_EXPORT int64_t ToInt64Slow(v8::Isolate*, | 549 CORE_EXPORT int64_t ToInt64Slow(v8::Isolate*, |
| 550 v8::Local<v8::Value>, | 550 v8::Local<v8::Value>, |
| 551 IntegerConversionConfiguration, | 551 IntegerConversionConfiguration, |
| 552 ExceptionState&); | 552 ExceptionState&); |
| 553 inline int64_t ToInt64(v8::Isolate* isolate, | 553 inline int64_t ToInt64(v8::Isolate* isolate, |
| 554 v8::Local<v8::Value> value, | 554 v8::Local<v8::Value> value, |
| 555 IntegerConversionConfiguration configuration, | 555 IntegerConversionConfiguration configuration, |
| 556 ExceptionState& exception_state) { | 556 ExceptionState& exception_state) { |
| 557 // Clamping not supported for int64_t/long long int. See | 557 // Clamping not supported for int64_t/long long int. See |
| 558 // Source/wtf/MathExtras.h. | 558 // Source/wtf/MathExtras.h. |
| 559 ASSERT(configuration != kClamp); | 559 DCHECK_NE(configuration, kClamp); |
| 560 | 560 |
| 561 // Fast case. The value is a 32-bit integer. | 561 // Fast case. The value is a 32-bit integer. |
| 562 if (LIKELY(value->IsInt32())) | 562 if (LIKELY(value->IsInt32())) |
| 563 return value.As<v8::Int32>()->Value(); | 563 return value.As<v8::Int32>()->Value(); |
| 564 | 564 |
| 565 return ToInt64Slow(isolate, value, configuration, exception_state); | 565 return ToInt64Slow(isolate, value, configuration, exception_state); |
| 566 } | 566 } |
| 567 | 567 |
| 568 // Convert a value to a 64-bit unsigned integer. The conversion fails if the | 568 // Convert a value to a 64-bit unsigned integer. The conversion fails if the |
| 569 // value cannot be converted to a number or the range violated per WebIDL: | 569 // value cannot be converted to a number or the range violated per WebIDL: |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 return std::numeric_limits<double>::quiet_NaN(); | 637 return std::numeric_limits<double>::quiet_NaN(); |
| 638 if (!object->IsDate()) { | 638 if (!object->IsDate()) { |
| 639 exception_state.ThrowTypeError("The provided value is not a Date."); | 639 exception_state.ThrowTypeError("The provided value is not a Date."); |
| 640 return 0; | 640 return 0; |
| 641 } | 641 } |
| 642 return object.As<v8::Date>()->ValueOf(); | 642 return object.As<v8::Date>()->ValueOf(); |
| 643 } | 643 } |
| 644 | 644 |
| 645 inline v8::MaybeLocal<v8::Value> V8DateOrNaN(v8::Isolate* isolate, | 645 inline v8::MaybeLocal<v8::Value> V8DateOrNaN(v8::Isolate* isolate, |
| 646 double value) { | 646 double value) { |
| 647 ASSERT(isolate); | 647 DCHECK(isolate); |
| 648 return v8::Date::New(isolate->GetCurrentContext(), value); | 648 return v8::Date::New(isolate->GetCurrentContext(), value); |
| 649 } | 649 } |
| 650 | 650 |
| 651 // FIXME: Remove the special casing for NodeFilter and XPathNSResolver. | 651 // FIXME: Remove the special casing for NodeFilter and XPathNSResolver. |
| 652 NodeFilter* ToNodeFilter(v8::Local<v8::Value>, | 652 NodeFilter* ToNodeFilter(v8::Local<v8::Value>, |
| 653 v8::Local<v8::Object>, | 653 v8::Local<v8::Object>, |
| 654 ScriptState*); | 654 ScriptState*); |
| 655 XPathNSResolver* ToXPathNSResolver(ScriptState*, v8::Local<v8::Value>); | 655 XPathNSResolver* ToXPathNSResolver(ScriptState*, v8::Local<v8::Value>); |
| 656 | 656 |
| 657 bool ToV8Sequence(v8::Local<v8::Value>, | 657 bool ToV8Sequence(v8::Local<v8::Value>, |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 | 845 |
| 846 // Validates that the passed object is a sequence type per WebIDL spec | 846 // Validates that the passed object is a sequence type per WebIDL spec |
| 847 // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-sequence | 847 // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-sequence |
| 848 inline bool ToV8Sequence(v8::Local<v8::Value> value, | 848 inline bool ToV8Sequence(v8::Local<v8::Value> value, |
| 849 uint32_t& length, | 849 uint32_t& length, |
| 850 v8::Isolate* isolate, | 850 v8::Isolate* isolate, |
| 851 ExceptionState& exception_state) { | 851 ExceptionState& exception_state) { |
| 852 // Attempt converting to a sequence if the value is not already an array but | 852 // Attempt converting to a sequence if the value is not already an array but |
| 853 // is any kind of object except for a native Date object or a native RegExp | 853 // is any kind of object except for a native Date object or a native RegExp |
| 854 // object. | 854 // object. |
| 855 ASSERT(!value->IsArray()); | 855 DCHECK(!value->IsArray()); |
| 856 // FIXME: Do we really need to special case Date and RegExp object? | 856 // FIXME: Do we really need to special case Date and RegExp object? |
| 857 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=22806 | 857 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=22806 |
| 858 if (!value->IsObject() || value->IsDate() || value->IsRegExp()) { | 858 if (!value->IsObject() || value->IsDate() || value->IsRegExp()) { |
| 859 // The caller is responsible for reporting a TypeError. | 859 // The caller is responsible for reporting a TypeError. |
| 860 return false; | 860 return false; |
| 861 } | 861 } |
| 862 | 862 |
| 863 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); | 863 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); |
| 864 v8::Local<v8::String> length_symbol = V8AtomicString(isolate, "length"); | 864 v8::Local<v8::String> length_symbol = V8AtomicString(isolate, "length"); |
| 865 | 865 |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 // If the argument isn't an object, this will crash. | 1159 // If the argument isn't an object, this will crash. |
| 1160 CORE_EXPORT v8::Local<v8::Value> FreezeV8Object(v8::Local<v8::Value>, | 1160 CORE_EXPORT v8::Local<v8::Value> FreezeV8Object(v8::Local<v8::Value>, |
| 1161 v8::Isolate*); | 1161 v8::Isolate*); |
| 1162 | 1162 |
| 1163 CORE_EXPORT v8::Local<v8::Value> FromJSONString(v8::Isolate*, | 1163 CORE_EXPORT v8::Local<v8::Value> FromJSONString(v8::Isolate*, |
| 1164 const String& stringified_json, | 1164 const String& stringified_json, |
| 1165 ExceptionState&); | 1165 ExceptionState&); |
| 1166 } // namespace blink | 1166 } // namespace blink |
| 1167 | 1167 |
| 1168 #endif // V8Binding_h | 1168 #endif // V8Binding_h |
| OLD | NEW |