| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 static v8::Handle<v8::Object> associateObjectWithWrapper(RawPtr<T> object, c
onst WrapperTypeInfo* wrapperTypeInfo, v8::Handle<v8::Object> wrapper, v8::Isola
te* isolate) | 53 static v8::Handle<v8::Object> associateObjectWithWrapper(RawPtr<T> object, c
onst WrapperTypeInfo* wrapperTypeInfo, v8::Handle<v8::Object> wrapper, v8::Isola
te* isolate) |
| 54 { | 54 { |
| 55 return associateObjectWithWrapper<V8T, T>(object.get(), wrapperTypeInfo,
wrapper, isolate); | 55 return associateObjectWithWrapper<V8T, T>(object.get(), wrapperTypeInfo,
wrapper, isolate); |
| 56 } | 56 } |
| 57 template<typename V8T, typename T> | 57 template<typename V8T, typename T> |
| 58 static v8::Handle<v8::Object> associateObjectWithWrapper(T*, const WrapperTy
peInfo*, v8::Handle<v8::Object>, v8::Isolate*); | 58 static v8::Handle<v8::Object> associateObjectWithWrapper(T*, const WrapperTy
peInfo*, v8::Handle<v8::Object>, v8::Isolate*); |
| 59 static v8::Handle<v8::Object> associateObjectWithWrapperNonTemplate(ScriptWr
appable*, const WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*); | 59 static v8::Handle<v8::Object> associateObjectWithWrapperNonTemplate(ScriptWr
appable*, const WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*); |
| 60 static v8::Handle<v8::Object> associateObjectWithWrapperNonTemplate(Node*, c
onst WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*); | 60 static v8::Handle<v8::Object> associateObjectWithWrapperNonTemplate(Node*, c
onst WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*); |
| 61 static void setNativeInfo(v8::Handle<v8::Object>, const WrapperTypeInfo*, Sc
riptWrappableBase* internalPointer); | 61 static void setNativeInfo(v8::Handle<v8::Object>, const WrapperTypeInfo*, Sc
riptWrappableBase* internalPointer); |
| 62 static void setNativeInfoForHiddenWrapper(v8::Handle<v8::Object>, const Wrap
perTypeInfo*, ScriptWrappableBase* internalPointer); | 62 static void setNativeInfoForHiddenWrapper(v8::Handle<v8::Object>, const Wrap
perTypeInfo*, ScriptWrappableBase* internalPointer); |
| 63 static void setNativeInfoWithPersistentHandle(v8::Handle<v8::Object>, const
WrapperTypeInfo*, ScriptWrappableBase* internalPointer, PersistentNode*); | 63 static void setNativeInfoWithPersistentHandle(v8::Handle<v8::Object>, const
WrapperTypeInfo*, ScriptWrappableBase* internalPointer, WrapperPersistentNode*); |
| 64 static void clearNativeInfo(v8::Handle<v8::Object>, const WrapperTypeInfo*); | 64 static void clearNativeInfo(v8::Handle<v8::Object>, const WrapperTypeInfo*); |
| 65 | 65 |
| 66 static bool isDOMWrapper(v8::Handle<v8::Value>); | 66 static bool isDOMWrapper(v8::Handle<v8::Value>); |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 inline void V8DOMWrapper::setNativeInfo(v8::Handle<v8::Object> wrapper, const Wr
apperTypeInfo* wrapperTypeInfo, ScriptWrappableBase* internalPointer) | 69 inline void V8DOMWrapper::setNativeInfo(v8::Handle<v8::Object> wrapper, const Wr
apperTypeInfo* wrapperTypeInfo, ScriptWrappableBase* internalPointer) |
| 70 { | 70 { |
| 71 ASSERT(wrapper->InternalFieldCount() >= 2); | 71 ASSERT(wrapper->InternalFieldCount() >= 2); |
| 72 ASSERT(internalPointer); | 72 ASSERT(internalPointer); |
| 73 ASSERT(wrapperTypeInfo); | 73 ASSERT(wrapperTypeInfo); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 97 wrapper->SetAlignedPointerInInternalField(wrapper->InternalFieldCount()
- 1, 0); | 97 wrapper->SetAlignedPointerInInternalField(wrapper->InternalFieldCount()
- 1, 0); |
| 98 } else if (wrapperTypeInfo->gcType == WrapperTypeInfo::WillBeGarbageCollecte
dObject) { | 98 } else if (wrapperTypeInfo->gcType == WrapperTypeInfo::WillBeGarbageCollecte
dObject) { |
| 99 #if ENABLE(OILPAN) | 99 #if ENABLE(OILPAN) |
| 100 wrapper->SetAlignedPointerInInternalField(wrapper->InternalFieldCount()
- 1, 0); | 100 wrapper->SetAlignedPointerInInternalField(wrapper->InternalFieldCount()
- 1, 0); |
| 101 #endif | 101 #endif |
| 102 } | 102 } |
| 103 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, internalP
ointer); | 103 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, internalP
ointer); |
| 104 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_cast<
WrapperTypeInfo*>(wrapperTypeInfo)); | 104 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_cast<
WrapperTypeInfo*>(wrapperTypeInfo)); |
| 105 } | 105 } |
| 106 | 106 |
| 107 inline void V8DOMWrapper::setNativeInfoWithPersistentHandle(v8::Handle<v8::Objec
t> wrapper, const WrapperTypeInfo* wrapperTypeInfo, ScriptWrappableBase* interna
lPointer, PersistentNode* handle) | 107 inline void V8DOMWrapper::setNativeInfoWithPersistentHandle(v8::Handle<v8::Objec
t> wrapper, const WrapperTypeInfo* wrapperTypeInfo, ScriptWrappableBase* interna
lPointer, WrapperPersistentNode* handle) |
| 108 { | 108 { |
| 109 ASSERT(wrapper->InternalFieldCount() >= 3); | 109 ASSERT(wrapper->InternalFieldCount() >= 3); |
| 110 ASSERT(internalPointer); | 110 ASSERT(internalPointer); |
| 111 ASSERT(wrapperTypeInfo); | 111 ASSERT(wrapperTypeInfo); |
| 112 #if ENABLE(OILPAN) | 112 #if ENABLE(OILPAN) |
| 113 ASSERT(wrapperTypeInfo->gcType == WrapperTypeInfo::WillBeGarbageCollectedObj
ect || wrapperTypeInfo->gcType == WrapperTypeInfo::GarbageCollectedObject); | 113 ASSERT(wrapperTypeInfo->gcType == WrapperTypeInfo::WillBeGarbageCollectedObj
ect || wrapperTypeInfo->gcType == WrapperTypeInfo::GarbageCollectedObject); |
| 114 #else | 114 #else |
| 115 ASSERT(wrapperTypeInfo->gcType == WrapperTypeInfo::GarbageCollectedObject); | 115 ASSERT(wrapperTypeInfo->gcType == WrapperTypeInfo::GarbageCollectedObject); |
| 116 #endif | 116 #endif |
| 117 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, internalP
ointer); | 117 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, internalP
ointer); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 135 { | 135 { |
| 136 setNativeInfo(wrapper, wrapperTypeInfo, V8T::toScriptWrappableBase(object.ge
t())); | 136 setNativeInfo(wrapper, wrapperTypeInfo, V8T::toScriptWrappableBase(object.ge
t())); |
| 137 ASSERT(isDOMWrapper(wrapper)); | 137 ASSERT(isDOMWrapper(wrapper)); |
| 138 DOMDataStore::setWrapper<V8T>(object.leakRef(), wrapper, isolate, wrapperTyp
eInfo); | 138 DOMDataStore::setWrapper<V8T>(object.leakRef(), wrapper, isolate, wrapperTyp
eInfo); |
| 139 return wrapper; | 139 return wrapper; |
| 140 } | 140 } |
| 141 | 141 |
| 142 template<typename V8T, typename T> | 142 template<typename V8T, typename T> |
| 143 inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapper(T* object
, const WrapperTypeInfo* wrapperTypeInfo, v8::Handle<v8::Object> wrapper, v8::Is
olate* isolate) | 143 inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapper(T* object
, const WrapperTypeInfo* wrapperTypeInfo, v8::Handle<v8::Object> wrapper, v8::Is
olate* isolate) |
| 144 { | 144 { |
| 145 setNativeInfoWithPersistentHandle(wrapper, wrapperTypeInfo, V8T::toScriptWra
ppableBase(object), new Persistent<T>(object)); | 145 setNativeInfoWithPersistentHandle(wrapper, wrapperTypeInfo, V8T::toScriptWra
ppableBase(object), WrapperPersistent<T>::create(object)); |
| 146 ASSERT(isDOMWrapper(wrapper)); | 146 ASSERT(isDOMWrapper(wrapper)); |
| 147 DOMDataStore::setWrapper<V8T>(object, wrapper, isolate, wrapperTypeInfo); | 147 DOMDataStore::setWrapper<V8T>(object, wrapper, isolate, wrapperTypeInfo); |
| 148 return wrapper; | 148 return wrapper; |
| 149 } | 149 } |
| 150 | 150 |
| 151 inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapperNonTemplat
e(ScriptWrappable* impl, const WrapperTypeInfo* wrapperTypeInfo, v8::Handle<v8::
Object> wrapper, v8::Isolate* isolate) | 151 inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapperNonTemplat
e(ScriptWrappable* impl, const WrapperTypeInfo* wrapperTypeInfo, v8::Handle<v8::
Object> wrapper, v8::Isolate* isolate) |
| 152 { | 152 { |
| 153 #if ENABLE(OILPAN) | 153 #if ENABLE(OILPAN) |
| 154 if (wrapperTypeInfo->gcType == WrapperTypeInfo::RefCountedObject) | 154 if (wrapperTypeInfo->gcType == WrapperTypeInfo::RefCountedObject) |
| 155 setNativeInfo(wrapper, wrapperTypeInfo, impl->toScriptWrappableBase()); | 155 setNativeInfo(wrapper, wrapperTypeInfo, impl->toScriptWrappableBase()); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 v8::Handle<v8::Context> context() const { return m_context; } | 214 v8::Handle<v8::Context> context() const { return m_context; } |
| 215 | 215 |
| 216 private: | 216 private: |
| 217 bool m_didEnterContext; | 217 bool m_didEnterContext; |
| 218 v8::Handle<v8::Context> m_context; | 218 v8::Handle<v8::Context> m_context; |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 } // namespace blink | 221 } // namespace blink |
| 222 | 222 |
| 223 #endif // V8DOMWrapper_h | 223 #endif // V8DOMWrapper_h |
| OLD | NEW |