| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 { | 234 { |
| 235 v8SetReturnValue(callbackInfo, toV8((WorkerOrWorkletGlobalScope*) impl, call
backInfo.Holder(), callbackInfo.GetIsolate())); | 235 v8SetReturnValue(callbackInfo, toV8((WorkerOrWorkletGlobalScope*) impl, call
backInfo.Holder(), callbackInfo.GetIsolate())); |
| 236 } | 236 } |
| 237 | 237 |
| 238 template<typename CallbackInfo, typename T> | 238 template<typename CallbackInfo, typename T> |
| 239 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, PassRefPtr<T> imp
l) | 239 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, PassRefPtr<T> imp
l) |
| 240 { | 240 { |
| 241 v8SetReturnValue(callbackInfo, impl.get()); | 241 v8SetReturnValue(callbackInfo, impl.get()); |
| 242 } | 242 } |
| 243 | 243 |
| 244 template<typename CallbackInfo, typename T> | |
| 245 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, RawPtr<T> impl) | |
| 246 { | |
| 247 v8SetReturnValue(callbackInfo, impl.get()); | |
| 248 } | |
| 249 | |
| 250 template<typename CallbackInfo> | 244 template<typename CallbackInfo> |
| 251 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, Scrip
tWrappable* impl) | 245 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, Scrip
tWrappable* impl) |
| 252 { | 246 { |
| 253 ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld()); | 247 ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld()); |
| 254 if (UNLIKELY(!impl)) { | 248 if (UNLIKELY(!impl)) { |
| 255 v8SetReturnValueNull(callbackInfo); | 249 v8SetReturnValueNull(callbackInfo); |
| 256 return; | 250 return; |
| 257 } | 251 } |
| 258 if (DOMDataStore::setReturnValueForMainWorld(callbackInfo.GetReturnValue(),
impl)) | 252 if (DOMDataStore::setReturnValueForMainWorld(callbackInfo.GetReturnValue(),
impl)) |
| 259 return; | 253 return; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 { | 298 { |
| 305 v8SetReturnValue(callbackInfo, toV8((WorkerOrWorkletGlobalScope*) impl, call
backInfo.Holder(), callbackInfo.GetIsolate())); | 299 v8SetReturnValue(callbackInfo, toV8((WorkerOrWorkletGlobalScope*) impl, call
backInfo.Holder(), callbackInfo.GetIsolate())); |
| 306 } | 300 } |
| 307 | 301 |
| 308 template<typename CallbackInfo, typename T> | 302 template<typename CallbackInfo, typename T> |
| 309 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, PassR
efPtr<T> impl) | 303 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, PassR
efPtr<T> impl) |
| 310 { | 304 { |
| 311 v8SetReturnValueForMainWorld(callbackInfo, impl.get()); | 305 v8SetReturnValueForMainWorld(callbackInfo, impl.get()); |
| 312 } | 306 } |
| 313 | 307 |
| 314 template<typename CallbackInfo, typename T> | |
| 315 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, RawPt
r<T> impl) | |
| 316 { | |
| 317 v8SetReturnValueForMainWorld(callbackInfo, impl.get()); | |
| 318 } | |
| 319 | |
| 320 template<typename CallbackInfo> | 308 template<typename CallbackInfo> |
| 321 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, ScriptWrappab
le* impl, const ScriptWrappable* wrappable) | 309 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, ScriptWrappab
le* impl, const ScriptWrappable* wrappable) |
| 322 { | 310 { |
| 323 if (UNLIKELY(!impl)) { | 311 if (UNLIKELY(!impl)) { |
| 324 v8SetReturnValueNull(callbackInfo); | 312 v8SetReturnValueNull(callbackInfo); |
| 325 return; | 313 return; |
| 326 } | 314 } |
| 327 if (DOMDataStore::setReturnValueFast(callbackInfo.GetReturnValue(), impl, ca
llbackInfo.Holder(), wrappable)) | 315 if (DOMDataStore::setReturnValueFast(callbackInfo.GetReturnValue(), impl, ca
llbackInfo.Holder(), wrappable)) |
| 328 return; | 316 return; |
| 329 v8::Local<v8::Object> wrapper = impl->wrap(callbackInfo.GetIsolate(), callba
ckInfo.Holder()); | 317 v8::Local<v8::Object> wrapper = impl->wrap(callbackInfo.GetIsolate(), callba
ckInfo.Holder()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 { | 350 { |
| 363 v8SetReturnValue(callbackInfo, toV8((WorkerOrWorkletGlobalScope*) impl, call
backInfo.Holder(), callbackInfo.GetIsolate())); | 351 v8SetReturnValue(callbackInfo, toV8((WorkerOrWorkletGlobalScope*) impl, call
backInfo.Holder(), callbackInfo.GetIsolate())); |
| 364 } | 352 } |
| 365 | 353 |
| 366 template<typename CallbackInfo, typename T, typename Wrappable> | 354 template<typename CallbackInfo, typename T, typename Wrappable> |
| 367 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr<T>
impl, const Wrappable* wrappable) | 355 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr<T>
impl, const Wrappable* wrappable) |
| 368 { | 356 { |
| 369 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); | 357 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); |
| 370 } | 358 } |
| 371 | 359 |
| 372 template<typename CallbackInfo, typename T, typename Wrappable> | |
| 373 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, RawPtr<T> imp
l, const Wrappable* wrappable) | |
| 374 { | |
| 375 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); | |
| 376 } | |
| 377 | |
| 378 // Convert v8::String to a WTF::String. If the V8 string is not already | 360 // Convert v8::String to a WTF::String. If the V8 string is not already |
| 379 // an external string then it is transformed into an external string at this | 361 // an external string then it is transformed into an external string at this |
| 380 // point to avoid repeated conversions. | 362 // point to avoid repeated conversions. |
| 381 inline String toCoreString(v8::Local<v8::String> value) | 363 inline String toCoreString(v8::Local<v8::String> value) |
| 382 { | 364 { |
| 383 return v8StringToWebCoreString<String>(value, Externalize); | 365 return v8StringToWebCoreString<String>(value, Externalize); |
| 384 } | 366 } |
| 385 | 367 |
| 386 inline String toCoreStringWithNullCheck(v8::Local<v8::String> value) | 368 inline String toCoreStringWithNullCheck(v8::Local<v8::String> value) |
| 387 { | 369 { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 return std::numeric_limits<double>::quiet_NaN(); | 567 return std::numeric_limits<double>::quiet_NaN(); |
| 586 } | 568 } |
| 587 | 569 |
| 588 inline v8::MaybeLocal<v8::Value> v8DateOrNaN(v8::Isolate* isolate, double value) | 570 inline v8::MaybeLocal<v8::Value> v8DateOrNaN(v8::Isolate* isolate, double value) |
| 589 { | 571 { |
| 590 ASSERT(isolate); | 572 ASSERT(isolate); |
| 591 return v8::Date::New(isolate->GetCurrentContext(), std::isfinite(value) ? va
lue : std::numeric_limits<double>::quiet_NaN()); | 573 return v8::Date::New(isolate->GetCurrentContext(), std::isfinite(value) ? va
lue : std::numeric_limits<double>::quiet_NaN()); |
| 592 } | 574 } |
| 593 | 575 |
| 594 // FIXME: Remove the special casing for NodeFilter and XPathNSResolver. | 576 // FIXME: Remove the special casing for NodeFilter and XPathNSResolver. |
| 595 RawPtr<NodeFilter> toNodeFilter(v8::Local<v8::Value>, v8::Local<v8::Object>, Scr
iptState*); | 577 NodeFilter* toNodeFilter(v8::Local<v8::Value>, v8::Local<v8::Object>, ScriptStat
e*); |
| 596 XPathNSResolver* toXPathNSResolver(ScriptState*, v8::Local<v8::Value>); | 578 XPathNSResolver* toXPathNSResolver(ScriptState*, v8::Local<v8::Value>); |
| 597 | 579 |
| 598 bool toV8Sequence(v8::Local<v8::Value>, uint32_t& length, v8::Isolate*, Exceptio
nState&); | 580 bool toV8Sequence(v8::Local<v8::Value>, uint32_t& length, v8::Isolate*, Exceptio
nState&); |
| 599 | 581 |
| 600 template <typename T> | 582 template <typename T> |
| 601 HeapVector<Member<T>> toMemberNativeArray(v8::Local<v8::Value> value, int argume
ntIndex, v8::Isolate* isolate, ExceptionState& exceptionState) | 583 HeapVector<Member<T>> toMemberNativeArray(v8::Local<v8::Value> value, int argume
ntIndex, v8::Isolate* isolate, ExceptionState& exceptionState) |
| 602 { | 584 { |
| 603 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); | 585 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); |
| 604 uint32_t length = 0; | 586 uint32_t length = 0; |
| 605 if (value->IsArray()) { | 587 if (value->IsArray()) { |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 }; | 931 }; |
| 950 | 932 |
| 951 // Callback functions used by generated code. | 933 // Callback functions used by generated code. |
| 952 CORE_EXPORT void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName,
const v8::PropertyCallbackInfo<v8::Value>&); | 934 CORE_EXPORT void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName,
const v8::PropertyCallbackInfo<v8::Value>&); |
| 953 | 935 |
| 954 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso
late*); | 936 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso
late*); |
| 955 | 937 |
| 956 } // namespace blink | 938 } // namespace blink |
| 957 | 939 |
| 958 #endif // V8Binding_h | 940 #endif // V8Binding_h |
| OLD | NEW |