OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "bindings/v8/V8DOMWrapper.h" | 39 #include "bindings/v8/V8DOMWrapper.h" |
40 #include "bindings/v8/WrapperTypeInfo.h" | 40 #include "bindings/v8/WrapperTypeInfo.h" |
41 #include "heap/Handle.h" | 41 #include "heap/Handle.h" |
42 | 42 |
43 namespace WebCore { | 43 namespace WebCore { |
44 | 44 |
45 class V8TestInterfaceWillBeGarbageCollected { | 45 class V8TestInterfaceWillBeGarbageCollected { |
46 public: | 46 public: |
47 static bool hasInstance(v8::Handle<v8::Value>, v8::Isolate*); | 47 static bool hasInstance(v8::Handle<v8::Value>, v8::Isolate*); |
48 static v8::Handle<v8::Object> findInstanceInPrototypeChain(v8::Handle<v8::Va
lue>, v8::Isolate*); | 48 static v8::Handle<v8::Object> findInstanceInPrototypeChain(v8::Handle<v8::Va
lue>, v8::Isolate*); |
49 static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*, WrapperWor
ldType); | 49 static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*); |
50 static TestInterfaceWillBeGarbageCollected* toNative(v8::Handle<v8::Object>
object) | 50 static TestInterfaceWillBeGarbageCollected* toNative(v8::Handle<v8::Object>
object) |
51 { | 51 { |
52 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8
DOMWrapperObjectIndex)); | 52 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8
DOMWrapperObjectIndex)); |
53 } | 53 } |
54 static TestInterfaceWillBeGarbageCollected* toNativeWithTypeCheck(v8::Isolat
e*, v8::Handle<v8::Value>); | 54 static TestInterfaceWillBeGarbageCollected* toNativeWithTypeCheck(v8::Isolat
e*, v8::Handle<v8::Value>); |
55 static const WrapperTypeInfo wrapperTypeInfo; | 55 static const WrapperTypeInfo wrapperTypeInfo; |
56 static void derefObject(void*); | 56 static void derefObject(void*); |
57 static EventTarget* toEventTarget(v8::Handle<v8::Object>); | 57 static EventTarget* toEventTarget(v8::Handle<v8::Object>); |
58 static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&); | 58 static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&); |
59 static const int eventListenerCacheIndex = v8DefaultWrapperInternalFieldCoun
t + 0; | 59 static const int eventListenerCacheIndex = v8DefaultWrapperInternalFieldCoun
t + 0; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 102 } |
103 if (DOMDataStore::setReturnValueFromWrapper<V8TestInterfaceWillBeGarbageColl
ected>(callbackInfo.GetReturnValue(), impl)) | 103 if (DOMDataStore::setReturnValueFromWrapper<V8TestInterfaceWillBeGarbageColl
ected>(callbackInfo.GetReturnValue(), impl)) |
104 return; | 104 return; |
105 v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackI
nfo.GetIsolate()); | 105 v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackI
nfo.GetIsolate()); |
106 v8SetReturnValue(callbackInfo, wrapper); | 106 v8SetReturnValue(callbackInfo, wrapper); |
107 } | 107 } |
108 | 108 |
109 template<typename CallbackInfo> | 109 template<typename CallbackInfo> |
110 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, TestI
nterfaceWillBeGarbageCollected* impl) | 110 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, TestI
nterfaceWillBeGarbageCollected* impl) |
111 { | 111 { |
112 ASSERT(worldType(callbackInfo.GetIsolate()) == MainWorld); | 112 ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate())->isMainWorld()); |
113 if (UNLIKELY(!impl)) { | 113 if (UNLIKELY(!impl)) { |
114 v8SetReturnValueNull(callbackInfo); | 114 v8SetReturnValueNull(callbackInfo); |
115 return; | 115 return; |
116 } | 116 } |
117 if (DOMDataStore::setReturnValueFromWrapperForMainWorld<V8TestInterfaceWillB
eGarbageCollected>(callbackInfo.GetReturnValue(), impl)) | 117 if (DOMDataStore::setReturnValueFromWrapperForMainWorld<V8TestInterfaceWillB
eGarbageCollected>(callbackInfo.GetReturnValue(), impl)) |
118 return; | 118 return; |
119 v8::Handle<v8::Value> wrapper = wrap(impl, callbackInfo.Holder(), callbackIn
fo.GetIsolate()); | 119 v8::Handle<v8::Value> wrapper = wrap(impl, callbackInfo.Holder(), callbackIn
fo.GetIsolate()); |
120 v8SetReturnValue(callbackInfo, wrapper); | 120 v8SetReturnValue(callbackInfo, wrapper); |
121 } | 121 } |
122 | 122 |
(...skipping 28 matching lines...) Expand all Loading... |
151 } | 151 } |
152 | 152 |
153 template<class CallbackInfo, class Wrappable> | 153 template<class CallbackInfo, class Wrappable> |
154 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtrWil
lBeRawPtr<TestInterfaceWillBeGarbageCollected> impl, Wrappable* wrappable) | 154 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtrWil
lBeRawPtr<TestInterfaceWillBeGarbageCollected> impl, Wrappable* wrappable) |
155 { | 155 { |
156 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); | 156 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); |
157 } | 157 } |
158 | 158 |
159 } | 159 } |
160 #endif // V8TestInterfaceWillBeGarbageCollected_h | 160 #endif // V8TestInterfaceWillBeGarbageCollected_h |
OLD | NEW |