Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Side by Side Diff: Source/bindings/v8/V8Binding.h

Issue 238723009: Implement V8ValueTraits<T>::toV8Value conversion functions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/bindings/v8/ScriptPromiseResolverWithContext.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32 #ifndef V8Binding_h 32 #ifndef V8Binding_h
33 #define V8Binding_h 33 #define V8Binding_h
34 34
35 #include "bindings/v8/DOMWrapperWorld.h" 35 #include "bindings/v8/DOMWrapperWorld.h"
36 #include "bindings/v8/ExceptionMessages.h" 36 #include "bindings/v8/ExceptionMessages.h"
37 #include "bindings/v8/ScriptValue.h"
37 #include "bindings/v8/V8BindingMacros.h" 38 #include "bindings/v8/V8BindingMacros.h"
38 #include "bindings/v8/V8PerIsolateData.h" 39 #include "bindings/v8/V8PerIsolateData.h"
39 #include "bindings/v8/V8StringResource.h" 40 #include "bindings/v8/V8StringResource.h"
40 #include "bindings/v8/V8ThrowException.h" 41 #include "bindings/v8/V8ThrowException.h"
41 #include "bindings/v8/V8ValueCache.h" 42 #include "bindings/v8/V8ValueCache.h"
42 #include "platform/heap/Heap.h" 43 #include "platform/heap/Heap.h"
43 #include "wtf/MathExtras.h" 44 #include "wtf/MathExtras.h"
44 #include "wtf/text/AtomicString.h" 45 #include "wtf/text/AtomicString.h"
45 #include <v8.h> 46 #include <v8.h>
46 47
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 { 210 {
210 ASSERT(isolate); 211 ASSERT(isolate);
211 return v8::String::NewFromUtf8(isolate, str, v8::String::kInternalizedString , length); 212 return v8::String::NewFromUtf8(isolate, str, v8::String::kInternalizedString , length);
212 } 213 }
213 214
214 inline v8::Handle<v8::Value> v8Undefined() 215 inline v8::Handle<v8::Value> v8Undefined()
215 { 216 {
216 return v8::Handle<v8::Value>(); 217 return v8::Handle<v8::Value>();
217 } 218 }
218 219
220 v8::Isolate* toIsolate(ExecutionContext*);
221 v8::Isolate* toIsolate(LocalFrame*);
222
223 DOMWindow* toDOMWindow(v8::Handle<v8::Value>, v8::Isolate*);
224 DOMWindow* toDOMWindow(v8::Handle<v8::Context>);
225 DOMWindow* enteredDOMWindow(v8::Isolate*);
226 DOMWindow* currentDOMWindow(v8::Isolate*);
227 DOMWindow* callingDOMWindow(v8::Isolate*);
228 ExecutionContext* toExecutionContext(v8::Handle<v8::Context>);
229 ExecutionContext* currentExecutionContext(v8::Isolate*);
230 ExecutionContext* callingExecutionContext(v8::Isolate*);
231
232 // Returns a V8 context associated with a ExecutionContext and a DOMWrapperWorld .
233 // This method returns an empty context if there is no frame or the frame is alr eady detached.
234 v8::Local<v8::Context> toV8Context(ExecutionContext*, DOMWrapperWorld&);
235 // Returns a V8 context associated with a LocalFrame and a DOMWrapperWorld.
236 // This method returns an empty context if the frame is already detached.
237 v8::Local<v8::Context> toV8Context(v8::Isolate*, LocalFrame*, DOMWrapperWorld&);
238
239 // Returns the frame object of the window object associated with
240 // a context, if the window is currently being displayed in the LocalFrame.
241 LocalFrame* toFrameIfNotDetached(v8::Handle<v8::Context>);
242
243 // Converts a DOM object to a v8 value.
244 // This is a no-inline version of toV8(). If you want to call toV8()
245 // without creating #include cycles, you can use this function instead.
246 // Each specialized implementation will be generated.
247 template<typename T>
248 v8::Handle<v8::Value> toV8NoInline(T* impl, v8::Handle<v8::Object> creationConte xt, v8::Isolate*);
249 template<typename T>
250 v8::Handle<v8::Value> toV8NoInline(T* impl, ExecutionContext* context)
251 {
252 v8::Isolate* isolate = toIsolate(context);
253 v8::Handle<v8::Context> v8Context = toV8Context(context, DOMWrapperWorld::cu rrent(isolate));
254 return toV8NoInline(impl, v8Context->Global(), isolate);
255 }
256
257 // Every ValueTraits has the following methods and properties.
258 // - arrayV8Value: A conversion function that is used to construct an array.
259 // This function may use toV8 and including the associated
260 // generated header is needed to call this function.
261 //
262 // - toV8: A general conversion function. This function uses toV8NoInline,
263 // This function doesn't use toV8, so this can be called without
264 // including a generated header.
265 // Some V8ValueTraitses have toV8Value whose type is
266 // Handle<Value> toV8Value(const T&, Handle<Object>, Isolate*);
267 // and the other have toV8Value whose type is
268 // Handle<Value> toV8Value(const T&, Isolate*);
269 // .
270 // - toV8ValueNeedsCreationContext: set true if the class provides toV8 which
271 // requires a creationContext as a parameter.
272 // set false otherwise.
haraken 2014/04/17 12:42:27 I'm not sure if we need the toV8ValueNeedsCreation
yhirano 2014/04/18 01:09:42 Do you mean that V8ValueTraits are for the types t
219 template <class T> 273 template <class T>
220 struct V8ValueTraits { 274 struct V8ValueTraits {
221 static inline v8::Handle<v8::Value> arrayV8Value(const T& value, v8::Isolate * isolate) 275 static inline v8::Handle<v8::Value> arrayV8Value(const T& value, v8::Isolate * isolate)
222 { 276 {
223 return toV8(WTF::getPtr(value), v8::Handle<v8::Object>(), isolate); 277 return toV8(WTF::getPtr(value), v8::Handle<v8::Object>(), isolate);
224 } 278 }
279 static inline v8::Handle<v8::Value> toV8Value(const T& value, v8::Handle<v8: :Object> creationContext, v8::Isolate* isolate)
280 {
281 return toV8NoInline(WTF::getPtr(value), creationContext, isolate);
282 }
283 static const bool toV8ValueNeedsCreationContext = true;
284 };
285
286 template <typename T>
287 struct V8ValueTraits<T*> {
288 static inline v8::Handle<v8::Value> arrayV8Value(T* const& value, v8::Isolat e* isolate)
289 {
290 return toV8(value, v8::Handle<v8::Object>(), isolate);
291 }
292 static inline v8::Handle<v8::Value> toV8Value(T* const& value, v8::Handle<v8 ::Object> creationContext, v8::Isolate* isolate)
293 {
294 return toV8NoInline(value, creationContext, isolate);
295 }
296 static const bool toV8ValueNeedsCreationContext = true;
225 }; 297 };
226 298
227 template<> 299 template<>
228 struct V8ValueTraits<String> { 300 struct V8ValueTraits<String> {
229 static inline v8::Handle<v8::Value> arrayV8Value(const String& value, v8::Is olate* isolate) 301 static inline v8::Handle<v8::Value> arrayV8Value(const String& value, v8::Is olate* isolate)
230 { 302 {
231 return v8String(isolate, value); 303 return v8String(isolate, value);
232 } 304 }
305 static inline v8::Handle<v8::Value> toV8Value(const String& value, v8::Isola te* isolate)
306 {
307 return v8String(isolate, value);
308 }
309 static const bool toV8ValueNeedsCreationContext = false;
233 }; 310 };
234 311
235 template<> 312 template<>
236 struct V8ValueTraits<AtomicString> { 313 struct V8ValueTraits<AtomicString> {
237 static inline v8::Handle<v8::Value> arrayV8Value(const AtomicString& value, v8::Isolate* isolate) 314 static inline v8::Handle<v8::Value> arrayV8Value(const AtomicString& value, v8::Isolate* isolate)
238 { 315 {
239 return v8String(isolate, value); 316 return v8String(isolate, value);
240 } 317 }
318 static inline v8::Handle<v8::Value> toV8Value(const AtomicString& value, v8: :Isolate* isolate)
319 {
320 return v8String(isolate, value);
321 }
322 static const bool toV8ValueNeedsCreationContext = false;
241 }; 323 };
242 324
243 template<> 325 template<>
326 struct V8ValueTraits<const char*> {
327 static inline v8::Handle<v8::Value> arrayV8Value(const char* const& value, v 8::Isolate* isolate)
328 {
329 return v8String(isolate, value);
330 }
331 static inline v8::Handle<v8::Value> toV8Value(const char* const& value, v8:: Isolate* isolate)
332 {
333 return v8String(isolate, value);
334 }
335 static const bool toV8ValueNeedsCreationContext = false;
336 };
337
338 template<>
339 struct V8ValueTraits<int> {
340 static inline v8::Handle<v8::Value> arrayV8Value(const int& value, v8::Isola te* isolate)
341 {
342 return v8::Integer::New(isolate, value);
343 }
344 static inline v8::Handle<v8::Value> toV8Value(const int& value, v8::Isolate* isolate)
345 {
346 return v8::Integer::New(isolate, value);
347 }
348 static const bool toV8ValueNeedsCreationContext = false;
349 };
350
351 template<>
352 struct V8ValueTraits<long> {
353 static inline v8::Handle<v8::Value> arrayV8Value(const long& value, v8::Isol ate* isolate)
354 {
355 return v8::Integer::New(isolate, value);
356 }
357 static inline v8::Handle<v8::Value> toV8Value(const long& value, v8::Isolate * isolate)
358 {
359 return v8::Integer::New(isolate, value);
360 }
361 static const bool toV8ValueNeedsCreationContext = false;
362 };
363
364 template<>
244 struct V8ValueTraits<unsigned> { 365 struct V8ValueTraits<unsigned> {
245 static inline v8::Handle<v8::Value> arrayV8Value(const unsigned& value, v8:: Isolate* isolate) 366 static inline v8::Handle<v8::Value> arrayV8Value(const unsigned& value, v8:: Isolate* isolate)
246 { 367 {
247 return v8::Integer::NewFromUnsigned(isolate, value); 368 return v8::Integer::NewFromUnsigned(isolate, value);
248 } 369 }
370 static inline v8::Handle<v8::Value> toV8Value(const unsigned& value, v8::Iso late* isolate)
371 {
372 return v8::Integer::NewFromUnsigned(isolate, value);
373 }
374 static const bool toV8ValueNeedsCreationContext = false;
249 }; 375 };
250 376
251 template<> 377 template<>
252 struct V8ValueTraits<unsigned long> { 378 struct V8ValueTraits<unsigned long> {
253 static inline v8::Handle<v8::Value> arrayV8Value(const unsigned long& value, v8::Isolate* isolate) 379 static inline v8::Handle<v8::Value> arrayV8Value(const unsigned long& value, v8::Isolate* isolate)
254 { 380 {
255 return v8::Integer::NewFromUnsigned(isolate, value); 381 return v8::Integer::NewFromUnsigned(isolate, value);
256 } 382 }
383 static inline v8::Handle<v8::Value> toV8Value(const unsigned long& value, v8 ::Isolate* isolate)
384 {
385 return v8::Integer::NewFromUnsigned(isolate, value);
386 }
387 static const bool toV8ValueNeedsCreationContext = false;
257 }; 388 };
258 389
259 template<> 390 template<>
260 struct V8ValueTraits<float> { 391 struct V8ValueTraits<float> {
261 static inline v8::Handle<v8::Value> arrayV8Value(const float& value, v8::Iso late* isolate) 392 static inline v8::Handle<v8::Value> arrayV8Value(const float& value, v8::Iso late* isolate)
262 { 393 {
263 return v8::Number::New(isolate, value); 394 return v8::Number::New(isolate, value);
264 } 395 }
396 static inline v8::Handle<v8::Value> toV8Value(const float& value, v8::Isolat e* isolate)
397 {
398 return v8::Number::New(isolate, value);
399 }
400 static const bool toV8ValueNeedsCreationContext = false;
265 }; 401 };
266 402
267 template<> 403 template<>
268 struct V8ValueTraits<double> { 404 struct V8ValueTraits<double> {
269 static inline v8::Handle<v8::Value> arrayV8Value(const double& value, v8::Is olate* isolate) 405 static inline v8::Handle<v8::Value> arrayV8Value(const double& value, v8::Is olate* isolate)
270 { 406 {
271 return v8::Number::New(isolate, value); 407 return v8::Number::New(isolate, value);
272 } 408 }
409 static inline v8::Handle<v8::Value> toV8Value(const double& value, v8::Isola te* isolate)
410 {
411 return v8::Number::New(isolate, value);
412 }
413 static const bool toV8ValueNeedsCreationContext = false;
414 };
415
416 template<>
417 struct V8ValueTraits<bool> {
418 static inline v8::Handle<v8::Value> arrayV8Value(const bool& value, v8::Isol ate* isolate)
419 {
420 return v8::Boolean::New(isolate, value);
421 }
422 static inline v8::Handle<v8::Value> toV8Value(const bool& value, v8::Isolate * isolate)
423 {
424 return v8::Boolean::New(isolate, value);
425 }
426 static const bool toV8ValueNeedsCreationContext = false;
427 };
428
429 // V8NullType and V8UndefinedType are used only for the value conversion.
430 class V8NullType { };
431 class V8UndefinedType { };
432
433 template<>
434 struct V8ValueTraits<V8NullType> {
435 static inline v8::Handle<v8::Value> arrayV8Value(const V8NullType&, v8::Isol ate* isolate)
436 {
437 return v8::Null(isolate);
438 }
439 static inline v8::Handle<v8::Value> toV8Value(const V8NullType&, v8::Isolate * isolate)
440 {
441 return v8::Null(isolate);
442 }
443 static const bool toV8ValueNeedsCreationContext = false;
444 };
445
446 template<>
447 struct V8ValueTraits<V8UndefinedType> {
448 static inline v8::Handle<v8::Value> arrayV8Value(const V8UndefinedType&, v8: :Isolate* isolate)
449 {
450 return v8::Undefined(isolate);
451 }
452 static inline v8::Handle<v8::Value> toV8Value(const V8UndefinedType&, v8::Is olate* isolate)
453 {
454 return v8::Undefined(isolate);
455 }
456 static const bool toV8ValueNeedsCreationContext = false;
457 };
458
459 template<>
460 struct V8ValueTraits<ScriptValue> {
461 static inline v8::Handle<v8::Value> arrayV8Value(const ScriptValue& value, v 8::Isolate*)
462 {
463 return value.v8Value();
464 }
465 static inline v8::Handle<v8::Value> toV8Value(const ScriptValue& value, v8:: Isolate*)
466 {
467 return value.v8Value();
468 }
469 static const bool toV8ValueNeedsCreationContext = false;
470 };
471
472 template<>
473 struct V8ValueTraits<v8::Handle<v8::Value> > {
474 static inline v8::Handle<v8::Value> arrayV8Value(const v8::Handle<v8::Value> & value, v8::Isolate*)
475 {
476 return value;
477 }
478 static inline v8::Handle<v8::Value> toV8Value(const v8::Handle<v8::Value>& v alue, v8::Isolate*)
479 {
480 return value;
481 }
482 static const bool toV8ValueNeedsCreationContext = false;
483 };
484
485 template<>
486 struct V8ValueTraits<v8::Local<v8::Value> > {
487 static inline v8::Handle<v8::Value> arrayV8Value(const v8::Local<v8::Value>& value, v8::Isolate*)
488 {
489 return value;
490 }
491 static inline v8::Handle<v8::Value> toV8Value(const v8::Local<v8::Value>& va lue, v8::Isolate*)
492 {
493 return value;
494 }
495 static const bool toV8ValueNeedsCreationContext = false;
273 }; 496 };
274 497
275 template<typename T, size_t inlineCapacity> 498 template<typename T, size_t inlineCapacity>
276 v8::Handle<v8::Value> v8Array(const Vector<T, inlineCapacity>& iterator, v8::Iso late* isolate) 499 v8::Handle<v8::Value> v8Array(const Vector<T, inlineCapacity>& iterator, v8::Iso late* isolate)
277 { 500 {
278 v8::Local<v8::Array> result = v8::Array::New(isolate, iterator.size()); 501 v8::Local<v8::Array> result = v8::Array::New(isolate, iterator.size());
279 int index = 0; 502 int index = 0;
280 typename Vector<T, inlineCapacity>::const_iterator end = iterator.end(); 503 typename Vector<T, inlineCapacity>::const_iterator end = iterator.end();
281 typedef V8ValueTraits<T> TraitsType; 504 typedef V8ValueTraits<T> TraitsType;
282 for (typename Vector<T, inlineCapacity>::const_iterator iter = iterator.begi n(); iter != end; ++iter) 505 for (typename Vector<T, inlineCapacity>::const_iterator iter = iterator.begi n(); iter != end; ++iter)
(...skipping 17 matching lines...) Expand all
300 v8::Handle<v8::Value> v8ArrayNoInline(const Vector<T, inlineCapacity>& iterator, v8::Isolate* isolate) 523 v8::Handle<v8::Value> v8ArrayNoInline(const Vector<T, inlineCapacity>& iterator, v8::Isolate* isolate)
301 { 524 {
302 v8::Local<v8::Array> result = v8::Array::New(isolate, iterator.size()); 525 v8::Local<v8::Array> result = v8::Array::New(isolate, iterator.size());
303 int index = 0; 526 int index = 0;
304 typename Vector<T, inlineCapacity>::const_iterator end = iterator.end(); 527 typename Vector<T, inlineCapacity>::const_iterator end = iterator.end();
305 for (typename Vector<T, inlineCapacity>::const_iterator iter = iterator.begi n(); iter != end; ++iter) 528 for (typename Vector<T, inlineCapacity>::const_iterator iter = iterator.begi n(); iter != end; ++iter)
306 result->Set(v8::Integer::New(isolate, index++), toV8NoInline(WTF::getPtr (*iter), v8::Handle<v8::Object>(), isolate)); 529 result->Set(v8::Integer::New(isolate, index++), toV8NoInline(WTF::getPtr (*iter), v8::Handle<v8::Object>(), isolate));
307 return result; 530 return result;
308 } 531 }
309 532
533 template<typename T, size_t inlinCapacity>
534 struct V8ValueTraits<Vector<T, inlinCapacity> > {
535 static inline v8::Handle<v8::Value> arrayV8Value(const Vector<T, inlinCapaci ty>& value, v8::Isolate* isolate)
536 {
537 return v8Array(value, isolate);
538 }
539 static inline v8::Handle<v8::Value> toV8Value(const Vector<T, inlinCapacity> & value, v8::Isolate* isolate)
540 {
541 return v8ArrayNoInline(value, isolate);
542 }
543 static const bool toV8ValueNeedsCreationContext = false;
544 };
545
310 // Conversion flags, used in toIntXX/toUIntXX. 546 // Conversion flags, used in toIntXX/toUIntXX.
311 enum IntegerConversionConfiguration { 547 enum IntegerConversionConfiguration {
312 NormalConversion, 548 NormalConversion,
313 EnforceRange, 549 EnforceRange,
314 Clamp 550 Clamp
315 }; 551 };
316 552
317 // Convert a value to a 8-bit signed integer. The conversion fails if the 553 // Convert a value to a 8-bit signed integer. The conversion fails if the
318 // value cannot be converted to a number or the range violated per WebIDL: 554 // value cannot be converted to a number or the range violated per WebIDL:
319 // http://www.w3.org/TR/WebIDL/#es-byte 555 // http://www.w3.org/TR/WebIDL/#es-byte
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 if (lengthValue->IsUndefined() || lengthValue->IsNull()) { 879 if (lengthValue->IsUndefined() || lengthValue->IsNull()) {
644 // The caller is responsible for reporting a TypeError. 880 // The caller is responsible for reporting a TypeError.
645 return v8Undefined(); 881 return v8Undefined();
646 } 882 }
647 883
648 TONATIVE_EXCEPTION(uint32_t, sequenceLength, lengthValue->Int32Value()); 884 TONATIVE_EXCEPTION(uint32_t, sequenceLength, lengthValue->Int32Value());
649 length = sequenceLength; 885 length = sequenceLength;
650 return v8Value; 886 return v8Value;
651 } 887 }
652 888
653 v8::Isolate* toIsolate(ExecutionContext*);
654 v8::Isolate* toIsolate(LocalFrame*);
655
656 DOMWindow* toDOMWindow(v8::Handle<v8::Value>, v8::Isolate*);
657 DOMWindow* toDOMWindow(v8::Handle<v8::Context>);
658 DOMWindow* enteredDOMWindow(v8::Isolate*);
659 DOMWindow* currentDOMWindow(v8::Isolate*);
660 DOMWindow* callingDOMWindow(v8::Isolate*);
661 ExecutionContext* toExecutionContext(v8::Handle<v8::Context>);
662 ExecutionContext* currentExecutionContext(v8::Isolate*);
663 ExecutionContext* callingExecutionContext(v8::Isolate*);
664
665 // Returns a V8 context associated with a ExecutionContext and a DOMWrapperWorld .
666 // This method returns an empty context if there is no frame or the frame is alr eady detached.
667 v8::Local<v8::Context> toV8Context(ExecutionContext*, DOMWrapperWorld&);
668 // Returns a V8 context associated with a LocalFrame and a DOMWrapperWorld.
669 // This method returns an empty context if the frame is already detached.
670 v8::Local<v8::Context> toV8Context(v8::Isolate*, LocalFrame*, DOMWrapperWorld&);
671
672 // Returns the frame object of the window object associated with
673 // a context, if the window is currently being displayed in the LocalFrame.
674 LocalFrame* toFrameIfNotDetached(v8::Handle<v8::Context>);
675
676 // If the current context causes out of memory, JavaScript setting 889 // If the current context causes out of memory, JavaScript setting
677 // is disabled and it returns true. 890 // is disabled and it returns true.
678 bool handleOutOfMemory(); 891 bool handleOutOfMemory();
679 v8::Local<v8::Value> handleMaxRecursionDepthExceeded(v8::Isolate*); 892 v8::Local<v8::Value> handleMaxRecursionDepthExceeded(v8::Isolate*);
680 void crashIfV8IsDead(); 893 void crashIfV8IsDead();
681 894
682 inline bool isUndefinedOrNull(v8::Handle<v8::Value> value) 895 inline bool isUndefinedOrNull(v8::Handle<v8::Value> value)
683 { 896 {
684 return value->IsNull() || value->IsUndefined(); 897 return value->IsNull() || value->IsUndefined();
685 } 898 }
(...skipping 17 matching lines...) Expand all
703 properties->Set(integer, integer); 916 properties->Set(integer, integer);
704 } 917 }
705 v8SetReturnValue(info, properties); 918 v8SetReturnValue(info, properties);
706 } 919 }
707 920
708 // These methods store hidden values into an array that is stored in the interna l field of a DOM wrapper. 921 // These methods store hidden values into an array that is stored in the interna l field of a DOM wrapper.
709 void addHiddenValueToArray(v8::Handle<v8::Object>, v8::Local<v8::Value>, int cac heIndex, v8::Isolate*); 922 void addHiddenValueToArray(v8::Handle<v8::Object>, v8::Local<v8::Value>, int cac heIndex, v8::Isolate*);
710 void removeHiddenValueFromArray(v8::Handle<v8::Object>, v8::Local<v8::Value>, in t cacheIndex, v8::Isolate*); 923 void removeHiddenValueFromArray(v8::Handle<v8::Object>, v8::Local<v8::Value>, in t cacheIndex, v8::Isolate*);
711 void moveEventListenerToNewWrapper(v8::Handle<v8::Object>, EventListener* oldVal ue, v8::Local<v8::Value> newValue, int cacheIndex, v8::Isolate*); 924 void moveEventListenerToNewWrapper(v8::Handle<v8::Object>, EventListener* oldVal ue, v8::Local<v8::Value> newValue, int cacheIndex, v8::Isolate*);
712 925
713 // Converts a DOM object to a v8 value.
714 // This is a no-inline version of toV8(). If you want to call toV8()
715 // without creating #include cycles, you can use this function instead.
716 // Each specialized implementation will be generated.
717 template<typename T>
718 v8::Handle<v8::Value> toV8NoInline(T* impl, v8::Handle<v8::Object> creationConte xt, v8::Isolate*);
719 template<typename T>
720 v8::Handle<v8::Value> toV8NoInline(T* impl, ExecutionContext* context)
721 {
722 v8::Isolate* isolate = toIsolate(context);
723 v8::Handle<v8::Context> v8Context = toV8Context(context, DOMWrapperWorld::cu rrent(isolate));
724 return toV8NoInline(impl, v8Context->Global(), isolate);
725 }
726
727 // Result values for platform object 'deleter' methods, 926 // Result values for platform object 'deleter' methods,
728 // http://www.w3.org/TR/WebIDL/#delete 927 // http://www.w3.org/TR/WebIDL/#delete
729 enum DeleteResult { 928 enum DeleteResult {
730 DeleteSuccess, 929 DeleteSuccess,
731 DeleteReject, 930 DeleteReject,
732 DeleteUnknownProperty 931 DeleteUnknownProperty
733 }; 932 };
734 933
735 class V8IsolateInterruptor : public ThreadState::Interruptor { 934 class V8IsolateInterruptor : public ThreadState::Interruptor {
736 public: 935 public:
(...skipping 25 matching lines...) Expand all
762 961
763 private: 962 private:
764 v8::HandleScope m_handleScope; 963 v8::HandleScope m_handleScope;
765 v8::Context::Scope m_contextScope; 964 v8::Context::Scope m_contextScope;
766 RefPtr<NewScriptState> m_scriptState; 965 RefPtr<NewScriptState> m_scriptState;
767 }; 966 };
768 967
769 } // namespace WebCore 968 } // namespace WebCore
770 969
771 #endif // V8Binding_h 970 #endif // V8Binding_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/ScriptPromiseResolverWithContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698