| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 static const int v8DefaultWrapperInternalFieldCount = static_cast<int>(gin::kNum
berOfInternalFields); | 47 static const int v8DefaultWrapperInternalFieldCount = static_cast<int>(gin::kNum
berOfInternalFields); |
| 48 static const int v8PrototypeTypeIndex = 0; | 48 static const int v8PrototypeTypeIndex = 0; |
| 49 static const int v8PrototypeInternalFieldcount = 1; | 49 static const int v8PrototypeInternalFieldcount = 1; |
| 50 | 50 |
| 51 typedef v8::Handle<v8::FunctionTemplate> (*DomTemplateFunction)(v8::Isolate*); | 51 typedef v8::Handle<v8::FunctionTemplate> (*DomTemplateFunction)(v8::Isolate*); |
| 52 typedef void (*RefObjectFunction)(ScriptWrappableBase*); | 52 typedef void (*RefObjectFunction)(ScriptWrappableBase*); |
| 53 typedef void (*DerefObjectFunction)(ScriptWrappableBase*); | 53 typedef void (*DerefObjectFunction)(ScriptWrappableBase*); |
| 54 typedef void (*TraceFunction)(Visitor*, ScriptWrappableBase*); | 54 typedef void (*TraceFunction)(Visitor*, ScriptWrappableBase*); |
| 55 typedef ActiveDOMObject* (*ToActiveDOMObjectFunction)(v8::Handle<v8::Object>); | 55 typedef ActiveDOMObject* (*ToActiveDOMObjectFunction)(v8::Handle<v8::Object>); |
| 56 typedef EventTarget* (*ToEventTargetFunction)(v8::Handle<v8::Object>); | 56 typedef EventTarget* (*ToEventTargetFunction)(v8::Handle<v8::Object>); |
| 57 typedef void (*ResolveWrapperReachabilityFunction)(ScriptWrappableBase*, const v
8::Persistent<v8::Object>&, v8::Isolate*); | 57 typedef void (*ResolveWrapperReachabilityFunction)(v8::Isolate*, ScriptWrappable
Base*, const v8::Persistent<v8::Object>&); |
| 58 typedef void (*InstallConditionallyEnabledMethodsFunction)(v8::Handle<v8::Object
>, v8::Isolate*); | 58 typedef void (*InstallConditionallyEnabledMethodsFunction)(v8::Handle<v8::Object
>, v8::Isolate*); |
| 59 typedef void (*InstallConditionallyEnabledPropertiesFunction)(v8::Handle<v8::Obj
ect>, v8::Isolate*); | 59 typedef void (*InstallConditionallyEnabledPropertiesFunction)(v8::Handle<v8::Obj
ect>, v8::Isolate*); |
| 60 | 60 |
| 61 inline void setObjectGroup(ScriptWrappableBase* scriptWrappableBase, const v8::P
ersistent<v8::Object>& wrapper, v8::Isolate* isolate) | 61 inline void setObjectGroup(v8::Isolate* isolate, ScriptWrappableBase* scriptWrap
pableBase, const v8::Persistent<v8::Object>& wrapper) |
| 62 { | 62 { |
| 63 isolate->SetObjectGroupId(wrapper, v8::UniqueId(reinterpret_cast<intptr_t>(s
criptWrappableBase))); | 63 isolate->SetObjectGroupId(wrapper, v8::UniqueId(reinterpret_cast<intptr_t>(s
criptWrappableBase))); |
| 64 } | 64 } |
| 65 | 65 |
| 66 // This struct provides a way to store a bunch of information that is helpful wh
en unwrapping | 66 // This struct provides a way to store a bunch of information that is helpful wh
en unwrapping |
| 67 // v8 objects. Each v8 bindings class has exactly one static WrapperTypeInfo mem
ber, so | 67 // v8 objects. Each v8 bindings class has exactly one static WrapperTypeInfo mem
ber, so |
| 68 // comparing pointers is a safe way to determine if types match. | 68 // comparing pointers is a safe way to determine if types match. |
| 69 struct WrapperTypeInfo { | 69 struct WrapperTypeInfo { |
| 70 enum WrapperTypePrototype { | 70 enum WrapperTypePrototype { |
| 71 WrapperTypeObjectPrototype, | 71 WrapperTypeObjectPrototype, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 return toActiveDOMObjectFunction(object); | 158 return toActiveDOMObjectFunction(object); |
| 159 } | 159 } |
| 160 | 160 |
| 161 EventTarget* toEventTarget(v8::Handle<v8::Object> object) const | 161 EventTarget* toEventTarget(v8::Handle<v8::Object> object) const |
| 162 { | 162 { |
| 163 if (!toEventTargetFunction) | 163 if (!toEventTargetFunction) |
| 164 return 0; | 164 return 0; |
| 165 return toEventTargetFunction(object); | 165 return toEventTargetFunction(object); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void visitDOMWrapper(ScriptWrappableBase* scriptWrappableBase, const v8::Per
sistent<v8::Object>& wrapper, v8::Isolate* isolate) const | 168 void visitDOMWrapper(v8::Isolate* isolate, ScriptWrappableBase* scriptWrappa
bleBase, const v8::Persistent<v8::Object>& wrapper) const |
| 169 { | 169 { |
| 170 if (!visitDOMWrapperFunction) | 170 if (!visitDOMWrapperFunction) |
| 171 setObjectGroup(scriptWrappableBase, wrapper, isolate); | 171 setObjectGroup(isolate, scriptWrappableBase, wrapper); |
| 172 else | 172 else |
| 173 visitDOMWrapperFunction(scriptWrappableBase, wrapper, isolate); | 173 visitDOMWrapperFunction(isolate, scriptWrappableBase, wrapper); |
| 174 } | 174 } |
| 175 | 175 |
| 176 // This field must be the first member of the struct WrapperTypeInfo. This i
s also checked by a COMPILE_ASSERT() below. | 176 // This field must be the first member of the struct WrapperTypeInfo. This i
s also checked by a COMPILE_ASSERT() below. |
| 177 const gin::GinEmbedder ginEmbedder; | 177 const gin::GinEmbedder ginEmbedder; |
| 178 | 178 |
| 179 DomTemplateFunction domTemplateFunction; | 179 DomTemplateFunction domTemplateFunction; |
| 180 const RefObjectFunction refObjectFunction; | 180 const RefObjectFunction refObjectFunction; |
| 181 const DerefObjectFunction derefObjectFunction; | 181 const DerefObjectFunction derefObjectFunction; |
| 182 const TraceFunction traceFunction; | 182 const TraceFunction traceFunction; |
| 183 const ToActiveDOMObjectFunction toActiveDOMObjectFunction; | 183 const ToActiveDOMObjectFunction toActiveDOMObjectFunction; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 229 } |
| 230 | 230 |
| 231 inline void releaseObject(v8::Handle<v8::Object> wrapper) | 231 inline void releaseObject(v8::Handle<v8::Object> wrapper) |
| 232 { | 232 { |
| 233 toWrapperTypeInfo(wrapper)->derefObject(toScriptWrappableBase(wrapper)); | 233 toWrapperTypeInfo(wrapper)->derefObject(toScriptWrappableBase(wrapper)); |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace blink | 236 } // namespace blink |
| 237 | 237 |
| 238 #endif // WrapperTypeInfo_h | 238 #endif // WrapperTypeInfo_h |
| OLD | NEW |