| 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 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 class Node; | 43 class Node; |
| 44 struct WrapperTypeInfo; | 44 struct WrapperTypeInfo; |
| 45 | 45 |
| 46 class V8DOMWrapper { | 46 class V8DOMWrapper { |
| 47 public: | 47 public: |
| 48 static v8::Local<v8::Object> createWrapper(v8::Isolate*, v8::Handle<v8::Obje
ct> creationContext, const WrapperTypeInfo*, ScriptWrappableBase*); | 48 static v8::Local<v8::Object> createWrapper(v8::Isolate*, v8::Handle<v8::Obje
ct> creationContext, const WrapperTypeInfo*, ScriptWrappableBase*); |
| 49 | 49 |
| 50 static v8::Handle<v8::Object> associateObjectWithWrapper(v8::Isolate*, Scrip
tWrappableBase*, const WrapperTypeInfo*, v8::Handle<v8::Object> wrapper); | |
| 51 static v8::Handle<v8::Object> associateObjectWithWrapper(v8::Isolate*, Scrip
tWrappable*, const WrapperTypeInfo*, v8::Handle<v8::Object>); | 50 static v8::Handle<v8::Object> associateObjectWithWrapper(v8::Isolate*, Scrip
tWrappable*, const WrapperTypeInfo*, v8::Handle<v8::Object>); |
| 52 static v8::Handle<v8::Object> associateObjectWithWrapper(v8::Isolate*, Node*
, const WrapperTypeInfo*, v8::Handle<v8::Object>); | 51 static v8::Handle<v8::Object> associateObjectWithWrapper(v8::Isolate*, Node*
, const WrapperTypeInfo*, v8::Handle<v8::Object>); |
| 53 static void setNativeInfo(v8::Handle<v8::Object>, const WrapperTypeInfo*, Sc
riptWrappableBase*); | 52 static void setNativeInfo(v8::Handle<v8::Object>, const WrapperTypeInfo*, Sc
riptWrappableBase*); |
| 54 static void clearNativeInfo(v8::Handle<v8::Object>, const WrapperTypeInfo*); | 53 static void clearNativeInfo(v8::Handle<v8::Object>, const WrapperTypeInfo*); |
| 55 | 54 |
| 56 static bool isDOMWrapper(v8::Handle<v8::Value>); | 55 static bool isDOMWrapper(v8::Handle<v8::Value>); |
| 57 }; | 56 }; |
| 58 | 57 |
| 59 inline void V8DOMWrapper::setNativeInfo(v8::Handle<v8::Object> wrapper, const Wr
apperTypeInfo* wrapperTypeInfo, ScriptWrappableBase* scriptWrappableBase) | 58 inline void V8DOMWrapper::setNativeInfo(v8::Handle<v8::Object> wrapper, const Wr
apperTypeInfo* wrapperTypeInfo, ScriptWrappableBase* scriptWrappableBase) |
| 60 { | 59 { |
| 61 ASSERT(wrapper->InternalFieldCount() >= 2); | 60 ASSERT(wrapper->InternalFieldCount() >= 2); |
| 62 ASSERT(scriptWrappableBase); | 61 ASSERT(scriptWrappableBase); |
| 63 ASSERT(wrapperTypeInfo); | 62 ASSERT(wrapperTypeInfo); |
| 64 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, scriptWra
ppableBase); | 63 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, scriptWra
ppableBase); |
| 65 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_cast<
WrapperTypeInfo*>(wrapperTypeInfo)); | 64 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_cast<
WrapperTypeInfo*>(wrapperTypeInfo)); |
| 66 } | 65 } |
| 67 | 66 |
| 68 inline void V8DOMWrapper::clearNativeInfo(v8::Handle<v8::Object> wrapper, const
WrapperTypeInfo* wrapperTypeInfo) | 67 inline void V8DOMWrapper::clearNativeInfo(v8::Handle<v8::Object> wrapper, const
WrapperTypeInfo* wrapperTypeInfo) |
| 69 { | 68 { |
| 70 ASSERT(wrapper->InternalFieldCount() >= 2); | 69 ASSERT(wrapper->InternalFieldCount() >= 2); |
| 71 ASSERT(wrapperTypeInfo); | 70 ASSERT(wrapperTypeInfo); |
| 72 // clearNativeInfo() is used only by NP objects, which are not garbage colle
cted. | 71 // clearNativeInfo() is used only by NP objects, which are not garbage colle
cted. |
| 73 ASSERT(wrapperTypeInfo->gcType == WrapperTypeInfo::RefCountedObject); | 72 ASSERT(wrapperTypeInfo->gcType == WrapperTypeInfo::RefCountedObject); |
| 74 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_cast<
WrapperTypeInfo*>(wrapperTypeInfo)); | 73 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_cast<
WrapperTypeInfo*>(wrapperTypeInfo)); |
| 75 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, 0); | 74 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, 0); |
| 76 } | 75 } |
| 77 | 76 |
| 78 inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapper(v8::Isola
te* isolate, ScriptWrappableBase* impl, const WrapperTypeInfo* wrapperTypeInfo,
v8::Handle<v8::Object> wrapper) | |
| 79 { | |
| 80 wrapperTypeInfo->refObject(impl); | |
| 81 setNativeInfo(wrapper, wrapperTypeInfo, impl); | |
| 82 ASSERT(isDOMWrapper(wrapper)); | |
| 83 DOMDataStore::setWrapper(impl, wrapper, isolate, wrapperTypeInfo); | |
| 84 return wrapper; | |
| 85 } | |
| 86 | |
| 87 inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapper(v8::Isola
te* isolate, ScriptWrappable* impl, const WrapperTypeInfo* wrapperTypeInfo, v8::
Handle<v8::Object> wrapper) | 77 inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapper(v8::Isola
te* isolate, ScriptWrappable* impl, const WrapperTypeInfo* wrapperTypeInfo, v8::
Handle<v8::Object> wrapper) |
| 88 { | 78 { |
| 89 wrapperTypeInfo->refObject(impl->toScriptWrappableBase()); | 79 wrapperTypeInfo->refObject(impl->toScriptWrappableBase()); |
| 90 setNativeInfo(wrapper, wrapperTypeInfo, impl->toScriptWrappableBase()); | 80 setNativeInfo(wrapper, wrapperTypeInfo, impl->toScriptWrappableBase()); |
| 91 ASSERT(isDOMWrapper(wrapper)); | 81 ASSERT(isDOMWrapper(wrapper)); |
| 92 DOMDataStore::setWrapper(impl, wrapper, isolate, wrapperTypeInfo); | 82 DOMDataStore::setWrapper(impl, wrapper, isolate, wrapperTypeInfo); |
| 93 return wrapper; | 83 return wrapper; |
| 94 } | 84 } |
| 95 | 85 |
| 96 inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapper(v8::Isola
te* isolate, Node* node, const WrapperTypeInfo* wrapperTypeInfo, v8::Handle<v8::
Object> wrapper) | 86 inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapper(v8::Isola
te* isolate, Node* node, const WrapperTypeInfo* wrapperTypeInfo, v8::Handle<v8::
Object> wrapper) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 v8::Handle<v8::Context> context() const { return m_context; } | 122 v8::Handle<v8::Context> context() const { return m_context; } |
| 133 | 123 |
| 134 private: | 124 private: |
| 135 bool m_didEnterContext; | 125 bool m_didEnterContext; |
| 136 v8::Handle<v8::Context> m_context; | 126 v8::Handle<v8::Context> m_context; |
| 137 }; | 127 }; |
| 138 | 128 |
| 139 } // namespace blink | 129 } // namespace blink |
| 140 | 130 |
| 141 #endif // V8DOMWrapper_h | 131 #endif // V8DOMWrapper_h |
| OLD | NEW |