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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 219 |
220 template <typename CallbackInfo, typename T> | 220 template <typename CallbackInfo, typename T> |
221 inline void V8SetReturnValue(const CallbackInfo& callbackInfo, | 221 inline void V8SetReturnValue(const CallbackInfo& callbackInfo, |
222 NotShared<T> notShared) { | 222 NotShared<T> notShared) { |
223 V8SetReturnValue(callbackInfo, notShared.View()); | 223 V8SetReturnValue(callbackInfo, notShared.View()); |
224 } | 224 } |
225 | 225 |
226 template <typename CallbackInfo> | 226 template <typename CallbackInfo> |
227 inline void V8SetReturnValueForMainWorld(const CallbackInfo& callback_info, | 227 inline void V8SetReturnValueForMainWorld(const CallbackInfo& callback_info, |
228 ScriptWrappable* impl) { | 228 ScriptWrappable* impl) { |
229 ASSERT(DOMWrapperWorld::Current(callback_info.GetIsolate()).IsMainWorld()); | 229 DCHECK(DOMWrapperWorld::Current(callback_info.GetIsolate()).IsMainWorld()); |
230 if (UNLIKELY(!impl)) { | 230 if (UNLIKELY(!impl)) { |
231 V8SetReturnValueNull(callback_info); | 231 V8SetReturnValueNull(callback_info); |
232 return; | 232 return; |
233 } | 233 } |
234 if (DOMDataStore::SetReturnValueForMainWorld(callback_info.GetReturnValue(), | 234 if (DOMDataStore::SetReturnValueForMainWorld(callback_info.GetReturnValue(), |
235 impl)) | 235 impl)) |
236 return; | 236 return; |
237 v8::Local<v8::Object> wrapper = | 237 v8::Local<v8::Object> wrapper = |
238 impl->Wrap(callback_info.GetIsolate(), callback_info.Holder()); | 238 impl->Wrap(callback_info.GetIsolate(), callback_info.Holder()); |
239 V8SetReturnValue(callback_info, wrapper); | 239 V8SetReturnValue(callback_info, wrapper); |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 CORE_EXPORT int64_t ToInt64Slow(v8::Isolate*, | 563 CORE_EXPORT int64_t ToInt64Slow(v8::Isolate*, |
564 v8::Local<v8::Value>, | 564 v8::Local<v8::Value>, |
565 IntegerConversionConfiguration, | 565 IntegerConversionConfiguration, |
566 ExceptionState&); | 566 ExceptionState&); |
567 inline int64_t ToInt64(v8::Isolate* isolate, | 567 inline int64_t ToInt64(v8::Isolate* isolate, |
568 v8::Local<v8::Value> value, | 568 v8::Local<v8::Value> value, |
569 IntegerConversionConfiguration configuration, | 569 IntegerConversionConfiguration configuration, |
570 ExceptionState& exception_state) { | 570 ExceptionState& exception_state) { |
571 // Clamping not supported for int64_t/long long int. See | 571 // Clamping not supported for int64_t/long long int. See |
572 // Source/wtf/MathExtras.h. | 572 // Source/wtf/MathExtras.h. |
573 ASSERT(configuration != kClamp); | 573 DCHECK_NE(configuration, kClamp); |
574 | 574 |
575 // Fast case. The value is a 32-bit integer. | 575 // Fast case. The value is a 32-bit integer. |
576 if (LIKELY(value->IsInt32())) | 576 if (LIKELY(value->IsInt32())) |
577 return value.As<v8::Int32>()->Value(); | 577 return value.As<v8::Int32>()->Value(); |
578 | 578 |
579 return ToInt64Slow(isolate, value, configuration, exception_state); | 579 return ToInt64Slow(isolate, value, configuration, exception_state); |
580 } | 580 } |
581 | 581 |
582 // Convert a value to a 64-bit unsigned integer. The conversion fails if the | 582 // Convert a value to a 64-bit unsigned integer. The conversion fails if the |
583 // value cannot be converted to a number or the range violated per WebIDL: | 583 // 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... |
651 return std::numeric_limits<double>::quiet_NaN(); | 651 return std::numeric_limits<double>::quiet_NaN(); |
652 if (!object->IsDate()) { | 652 if (!object->IsDate()) { |
653 exception_state.ThrowTypeError("The provided value is not a Date."); | 653 exception_state.ThrowTypeError("The provided value is not a Date."); |
654 return 0; | 654 return 0; |
655 } | 655 } |
656 return object.As<v8::Date>()->ValueOf(); | 656 return object.As<v8::Date>()->ValueOf(); |
657 } | 657 } |
658 | 658 |
659 inline v8::MaybeLocal<v8::Value> V8DateOrNaN(v8::Isolate* isolate, | 659 inline v8::MaybeLocal<v8::Value> V8DateOrNaN(v8::Isolate* isolate, |
660 double value) { | 660 double value) { |
661 ASSERT(isolate); | 661 DCHECK(isolate); |
662 return v8::Date::New(isolate->GetCurrentContext(), value); | 662 return v8::Date::New(isolate->GetCurrentContext(), value); |
663 } | 663 } |
664 | 664 |
665 // FIXME: Remove the special casing for NodeFilter and XPathNSResolver. | 665 // FIXME: Remove the special casing for NodeFilter and XPathNSResolver. |
666 NodeFilter* ToNodeFilter(v8::Local<v8::Value>, | 666 NodeFilter* ToNodeFilter(v8::Local<v8::Value>, |
667 v8::Local<v8::Object>, | 667 v8::Local<v8::Object>, |
668 ScriptState*); | 668 ScriptState*); |
669 XPathNSResolver* ToXPathNSResolver(ScriptState*, v8::Local<v8::Value>); | 669 XPathNSResolver* ToXPathNSResolver(ScriptState*, v8::Local<v8::Value>); |
670 | 670 |
671 bool ToV8Sequence(v8::Local<v8::Value>, | 671 bool ToV8Sequence(v8::Local<v8::Value>, |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 | 859 |
860 // Validates that the passed object is a sequence type per WebIDL spec | 860 // Validates that the passed object is a sequence type per WebIDL spec |
861 // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-sequence | 861 // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-sequence |
862 inline bool ToV8Sequence(v8::Local<v8::Value> value, | 862 inline bool ToV8Sequence(v8::Local<v8::Value> value, |
863 uint32_t& length, | 863 uint32_t& length, |
864 v8::Isolate* isolate, | 864 v8::Isolate* isolate, |
865 ExceptionState& exception_state) { | 865 ExceptionState& exception_state) { |
866 // Attempt converting to a sequence if the value is not already an array but | 866 // Attempt converting to a sequence if the value is not already an array but |
867 // is any kind of object except for a native Date object or a native RegExp | 867 // is any kind of object except for a native Date object or a native RegExp |
868 // object. | 868 // object. |
869 ASSERT(!value->IsArray()); | 869 DCHECK(!value->IsArray()); |
870 // FIXME: Do we really need to special case Date and RegExp object? | 870 // FIXME: Do we really need to special case Date and RegExp object? |
871 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=22806 | 871 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=22806 |
872 if (!value->IsObject() || value->IsDate() || value->IsRegExp()) { | 872 if (!value->IsObject() || value->IsDate() || value->IsRegExp()) { |
873 // The caller is responsible for reporting a TypeError. | 873 // The caller is responsible for reporting a TypeError. |
874 return false; | 874 return false; |
875 } | 875 } |
876 | 876 |
877 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); | 877 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); |
878 v8::Local<v8::String> length_symbol = V8AtomicString(isolate, "length"); | 878 v8::Local<v8::String> length_symbol = V8AtomicString(isolate, "length"); |
879 | 879 |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 exception_state.ThrowTypeError( | 1192 exception_state.ThrowTypeError( |
1193 "The provided ArrayBufferView value must not be shared."); | 1193 "The provided ArrayBufferView value must not be shared."); |
1194 return NotSharedType(); | 1194 return NotSharedType(); |
1195 } | 1195 } |
1196 return NotSharedType(dom_typed_array); | 1196 return NotSharedType(dom_typed_array); |
1197 } | 1197 } |
1198 | 1198 |
1199 } // namespace blink | 1199 } // namespace blink |
1200 | 1200 |
1201 #endif // V8Binding_h | 1201 #endif // V8Binding_h |
OLD | NEW |