| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 for (int i = 0; i < numArgs; i++) | 111 for (int i = 0; i < numArgs; i++) |
| 112 convertV8ObjectToNPVariant(isolate, info[i], npObject, &npArgs[i]); | 112 convertV8ObjectToNPVariant(isolate, info[i], npObject, &npArgs[i]); |
| 113 | 113 |
| 114 NPVariant result; | 114 NPVariant result; |
| 115 VOID_TO_NPVARIANT(result); | 115 VOID_TO_NPVARIANT(result); |
| 116 | 116 |
| 117 bool retval = true; | 117 bool retval = true; |
| 118 switch (functionId) { | 118 switch (functionId) { |
| 119 case InvokeMethod: | 119 case InvokeMethod: |
| 120 if (npObject->_class->invoke) { | 120 if (npObject->_class->invoke) { |
| 121 v8::Handle<v8::String> functionName = v8::Handle<v8::String>::Cast(i
nfo.Data()); | 121 v8::Local<v8::String> functionName = v8::Local<v8::String>::Cast(inf
o.Data()); |
| 122 NPIdentifier identifier = getStringIdentifier(functionName); | 122 NPIdentifier identifier = getStringIdentifier(functionName); |
| 123 retval = npObject->_class->invoke(npObject, identifier, npArgs.get()
, numArgs, &result); | 123 retval = npObject->_class->invoke(npObject, identifier, npArgs.get()
, numArgs, &result); |
| 124 } | 124 } |
| 125 break; | 125 break; |
| 126 case InvokeConstruct: | 126 case InvokeConstruct: |
| 127 if (npObject->_class->construct) | 127 if (npObject->_class->construct) |
| 128 retval = npObject->_class->construct(npObject, npArgs.get(), numArgs
, &result); | 128 retval = npObject->_class->construct(npObject, npArgs.get(), numArgs
, &result); |
| 129 break; | 129 break; |
| 130 case InvokeDefault: | 130 case InvokeDefault: |
| 131 if (npObject->_class->invokeDefault) | 131 if (npObject->_class->invokeDefault) |
| 132 retval = npObject->_class->invokeDefault(npObject, npArgs.get(), num
Args, &result); | 132 retval = npObject->_class->invokeDefault(npObject, npArgs.get(), num
Args, &result); |
| 133 break; | 133 break; |
| 134 default: | 134 default: |
| 135 break; | 135 break; |
| 136 } | 136 } |
| 137 | 137 |
| 138 if (!retval) | 138 if (!retval) |
| 139 V8ThrowException::throwGeneralError(isolate, "Error calling method on NP
Object."); | 139 V8ThrowException::throwGeneralError(isolate, "Error calling method on NP
Object."); |
| 140 | 140 |
| 141 for (int i = 0; i < numArgs; i++) | 141 for (int i = 0; i < numArgs; i++) |
| 142 _NPN_ReleaseVariantValue(&npArgs[i]); | 142 _NPN_ReleaseVariantValue(&npArgs[i]); |
| 143 | 143 |
| 144 // Unwrap return values. | 144 // Unwrap return values. |
| 145 v8::Handle<v8::Value> returnValue; | 145 v8::Local<v8::Value> returnValue; |
| 146 if (_NPN_IsAlive(npObject)) | 146 if (_NPN_IsAlive(npObject)) |
| 147 returnValue = convertNPVariantToV8Object(isolate, &result, npObject); | 147 returnValue = convertNPVariantToV8Object(isolate, &result, npObject); |
| 148 _NPN_ReleaseVariantValue(&result); | 148 _NPN_ReleaseVariantValue(&result); |
| 149 | 149 |
| 150 v8SetReturnValue(info, returnValue); | 150 v8SetReturnValue(info, returnValue); |
| 151 } | 151 } |
| 152 | 152 |
| 153 | 153 |
| 154 void npObjectMethodHandler(const v8::FunctionCallbackInfo<v8::Value>& info) | 154 void npObjectMethodHandler(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 155 { | 155 { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 class V8NPTemplateMap { | 196 class V8NPTemplateMap { |
| 197 public: | 197 public: |
| 198 // NPIdentifier is PrivateIdentifier*. | 198 // NPIdentifier is PrivateIdentifier*. |
| 199 typedef v8::PersistentValueMap<PrivateIdentifier*, v8::FunctionTemplate, V8T
emplateMapTraits> MapType; | 199 typedef v8::PersistentValueMap<PrivateIdentifier*, v8::FunctionTemplate, V8T
emplateMapTraits> MapType; |
| 200 | 200 |
| 201 v8::Local<v8::FunctionTemplate> get(PrivateIdentifier* key) | 201 v8::Local<v8::FunctionTemplate> get(PrivateIdentifier* key) |
| 202 { | 202 { |
| 203 return m_map.Get(key); | 203 return m_map.Get(key); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void set(PrivateIdentifier* key, v8::Handle<v8::FunctionTemplate> handle) | 206 void set(PrivateIdentifier* key, v8::Local<v8::FunctionTemplate> handle) |
| 207 { | 207 { |
| 208 ASSERT(!m_map.Contains(key)); | 208 ASSERT(!m_map.Contains(key)); |
| 209 m_map.Set(key, handle); | 209 m_map.Set(key, handle); |
| 210 } | 210 } |
| 211 | 211 |
| 212 static V8NPTemplateMap& sharedInstance(v8::Isolate* isolate) | 212 static V8NPTemplateMap& sharedInstance(v8::Isolate* isolate) |
| 213 { | 213 { |
| 214 DEFINE_STATIC_LOCAL(V8NPTemplateMap, map, (isolate)); | 214 DEFINE_STATIC_LOCAL(V8NPTemplateMap, map, (isolate)); |
| 215 ASSERT(isolate == map.m_map.GetIsolate()); | 215 ASSERT(isolate == map.m_map.GetIsolate()); |
| 216 return map; | 216 return map; |
| 217 } | 217 } |
| 218 | 218 |
| 219 friend class V8TemplateMapTraits; | 219 friend class V8TemplateMapTraits; |
| 220 | 220 |
| 221 private: | 221 private: |
| 222 explicit V8NPTemplateMap(v8::Isolate* isolate) | 222 explicit V8NPTemplateMap(v8::Isolate* isolate) |
| 223 : m_map(isolate) | 223 : m_map(isolate) |
| 224 { | 224 { |
| 225 } | 225 } |
| 226 | 226 |
| 227 MapType m_map; | 227 MapType m_map; |
| 228 }; | 228 }; |
| 229 | 229 |
| 230 V8TemplateMapTraits::MapType* V8TemplateMapTraits::MapFromWeakCallbackData(const
v8::WeakCallbackData<v8::FunctionTemplate, WeakCallbackDataType>& data) | 230 V8TemplateMapTraits::MapType* V8TemplateMapTraits::MapFromWeakCallbackData(const
v8::WeakCallbackData<v8::FunctionTemplate, WeakCallbackDataType>& data) |
| 231 { | 231 { |
| 232 return &V8NPTemplateMap::sharedInstance(data.GetIsolate()).m_map; | 232 return &V8NPTemplateMap::sharedInstance(data.GetIsolate()).m_map; |
| 233 } | 233 } |
| 234 | 234 |
| 235 | 235 |
| 236 static v8::Handle<v8::Value> npObjectGetProperty(v8::Local<v8::Object> self, NPI
dentifier identifier, v8::Local<v8::Value> key, v8::Isolate* isolate) | 236 static v8::Local<v8::Value> npObjectGetProperty(v8::Local<v8::Object> self, NPId
entifier identifier, v8::Local<v8::Value> key, v8::Isolate* isolate) |
| 237 { | 237 { |
| 238 NPObject* npObject = v8ObjectToNPObject(self); | 238 NPObject* npObject = v8ObjectToNPObject(self); |
| 239 | 239 |
| 240 // Verify that our wrapper wasn't using a NPObject which | 240 // Verify that our wrapper wasn't using a NPObject which |
| 241 // has already been deleted. | 241 // has already been deleted. |
| 242 if (!npObject || !_NPN_IsAlive(npObject)) | 242 if (!npObject || !_NPN_IsAlive(npObject)) |
| 243 return V8ThrowException::throwReferenceError(isolate, "NPObject deleted"
); | 243 return V8ThrowException::throwReferenceError(isolate, "NPObject deleted"
); |
| 244 | 244 |
| 245 | 245 |
| 246 if (npObject->_class->hasProperty && npObject->_class->getProperty && npObje
ct->_class->hasProperty(npObject, identifier)) { | 246 if (npObject->_class->hasProperty && npObject->_class->getProperty && npObje
ct->_class->hasProperty(npObject, identifier)) { |
| 247 if (!_NPN_IsAlive(npObject)) | 247 if (!_NPN_IsAlive(npObject)) |
| 248 return V8ThrowException::throwReferenceError(isolate, "NPObject dele
ted"); | 248 return V8ThrowException::throwReferenceError(isolate, "NPObject dele
ted"); |
| 249 | 249 |
| 250 NPVariant result; | 250 NPVariant result; |
| 251 VOID_TO_NPVARIANT(result); | 251 VOID_TO_NPVARIANT(result); |
| 252 if (!npObject->_class->getProperty(npObject, identifier, &result)) | 252 if (!npObject->_class->getProperty(npObject, identifier, &result)) |
| 253 return v8Undefined(); | 253 return v8Undefined(); |
| 254 | 254 |
| 255 v8::Handle<v8::Value> returnValue; | 255 v8::Local<v8::Value> returnValue; |
| 256 if (_NPN_IsAlive(npObject)) | 256 if (_NPN_IsAlive(npObject)) |
| 257 returnValue = convertNPVariantToV8Object(isolate, &result, npObject)
; | 257 returnValue = convertNPVariantToV8Object(isolate, &result, npObject)
; |
| 258 _NPN_ReleaseVariantValue(&result); | 258 _NPN_ReleaseVariantValue(&result); |
| 259 return returnValue; | 259 return returnValue; |
| 260 | 260 |
| 261 } | 261 } |
| 262 | 262 |
| 263 if (!_NPN_IsAlive(npObject)) | 263 if (!_NPN_IsAlive(npObject)) |
| 264 return V8ThrowException::throwReferenceError(isolate, "NPObject deleted"
); | 264 return V8ThrowException::throwReferenceError(isolate, "NPObject deleted"
); |
| 265 | 265 |
| 266 if (key->IsString() && npObject->_class->hasMethod && npObject->_class->hasM
ethod(npObject, identifier)) { | 266 if (key->IsString() && npObject->_class->hasMethod && npObject->_class->hasM
ethod(npObject, identifier)) { |
| 267 if (!_NPN_IsAlive(npObject)) | 267 if (!_NPN_IsAlive(npObject)) |
| 268 return V8ThrowException::throwReferenceError(isolate, "NPObject dele
ted"); | 268 return V8ThrowException::throwReferenceError(isolate, "NPObject dele
ted"); |
| 269 | 269 |
| 270 PrivateIdentifier* id = static_cast<PrivateIdentifier*>(identifier); | 270 PrivateIdentifier* id = static_cast<PrivateIdentifier*>(identifier); |
| 271 v8::Local<v8::FunctionTemplate> functionTemplate = V8NPTemplateMap::shar
edInstance(isolate).get(id); | 271 v8::Local<v8::FunctionTemplate> functionTemplate = V8NPTemplateMap::shar
edInstance(isolate).get(id); |
| 272 // Cache templates using identifier as the key. | 272 // Cache templates using identifier as the key. |
| 273 if (functionTemplate.IsEmpty()) { | 273 if (functionTemplate.IsEmpty()) { |
| 274 // Create a new template. | 274 // Create a new template. |
| 275 functionTemplate = v8::FunctionTemplate::New(isolate); | 275 functionTemplate = v8::FunctionTemplate::New(isolate); |
| 276 functionTemplate->SetCallHandler(npObjectMethodHandler, key); | 276 functionTemplate->SetCallHandler(npObjectMethodHandler, key); |
| 277 V8NPTemplateMap::sharedInstance(isolate).set(id, functionTemplate); | 277 V8NPTemplateMap::sharedInstance(isolate).set(id, functionTemplate); |
| 278 } | 278 } |
| 279 v8::Local<v8::Function> v8Function = functionTemplate->GetFunction(); | 279 v8::Local<v8::Function> v8Function = functionTemplate->GetFunction(); |
| 280 v8Function->SetName(v8::Handle<v8::String>::Cast(key)); | 280 v8Function->SetName(v8::Local<v8::String>::Cast(key)); |
| 281 return v8Function; | 281 return v8Function; |
| 282 } | 282 } |
| 283 | 283 |
| 284 return v8Undefined(); | 284 return v8Undefined(); |
| 285 } | 285 } |
| 286 | 286 |
| 287 void npObjectNamedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyC
allbackInfo<v8::Value>& info) | 287 void npObjectNamedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyC
allbackInfo<v8::Value>& info) |
| 288 { | 288 { |
| 289 NPIdentifier identifier = getStringIdentifier(name); | 289 NPIdentifier identifier = getStringIdentifier(name); |
| 290 v8SetReturnValue(info, npObjectGetProperty(info.Holder(), identifier, name,
info.GetIsolate())); | 290 v8SetReturnValue(info, npObjectGetProperty(info.Holder(), identifier, name,
info.GetIsolate())); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 309 } | 309 } |
| 310 | 310 |
| 311 void npObjectQueryProperty(v8::Local<v8::String> name, const v8::PropertyCallbac
kInfo<v8::Integer>& info) | 311 void npObjectQueryProperty(v8::Local<v8::String> name, const v8::PropertyCallbac
kInfo<v8::Integer>& info) |
| 312 { | 312 { |
| 313 NPIdentifier identifier = getStringIdentifier(name); | 313 NPIdentifier identifier = getStringIdentifier(name); |
| 314 if (npObjectGetProperty(info.Holder(), identifier, name, info.GetIsolate()).
IsEmpty()) | 314 if (npObjectGetProperty(info.Holder(), identifier, name, info.GetIsolate()).
IsEmpty()) |
| 315 return; | 315 return; |
| 316 v8SetReturnValueInt(info, 0); | 316 v8SetReturnValueInt(info, 0); |
| 317 } | 317 } |
| 318 | 318 |
| 319 static v8::Handle<v8::Value> npObjectSetProperty(v8::Local<v8::Object> self, NPI
dentifier identifier, v8::Local<v8::Value> value, v8::Isolate* isolate) | 319 static v8::Local<v8::Value> npObjectSetProperty(v8::Local<v8::Object> self, NPId
entifier identifier, v8::Local<v8::Value> value, v8::Isolate* isolate) |
| 320 { | 320 { |
| 321 NPObject* npObject = v8ObjectToNPObject(self); | 321 NPObject* npObject = v8ObjectToNPObject(self); |
| 322 | 322 |
| 323 // Verify that our wrapper wasn't using a NPObject which has already been de
leted. | 323 // Verify that our wrapper wasn't using a NPObject which has already been de
leted. |
| 324 if (!npObject || !_NPN_IsAlive(npObject)) { | 324 if (!npObject || !_NPN_IsAlive(npObject)) { |
| 325 V8ThrowException::throwReferenceError(isolate, "NPObject deleted"); | 325 V8ThrowException::throwReferenceError(isolate, "NPObject deleted"); |
| 326 return value; // Intercepted, but an exception was thrown. | 326 return value; // Intercepted, but an exception was thrown. |
| 327 } | 327 } |
| 328 | 328 |
| 329 if (npObject->_class->hasProperty && npObject->_class->setProperty && npObje
ct->_class->hasProperty(npObject, identifier)) { | 329 if (npObject->_class->hasProperty && npObject->_class->setProperty && npObje
ct->_class->hasProperty(npObject, identifier)) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 if (NP_CLASS_STRUCT_VERSION_HAS_ENUM(npObject->_class) && npObject->_class->
enumerate) { | 381 if (NP_CLASS_STRUCT_VERSION_HAS_ENUM(npObject->_class) && npObject->_class->
enumerate) { |
| 382 uint32_t count; | 382 uint32_t count; |
| 383 NPIdentifier* identifiers; | 383 NPIdentifier* identifiers; |
| 384 if (npObject->_class->enumerate(npObject, &identifiers, &count)) { | 384 if (npObject->_class->enumerate(npObject, &identifiers, &count)) { |
| 385 uint32_t propertiesCount = 0; | 385 uint32_t propertiesCount = 0; |
| 386 for (uint32_t i = 0; i < count; ++i) { | 386 for (uint32_t i = 0; i < count; ++i) { |
| 387 IdentifierRep* identifier = static_cast<IdentifierRep*>(identifi
ers[i]); | 387 IdentifierRep* identifier = static_cast<IdentifierRep*>(identifi
ers[i]); |
| 388 if (namedProperty == identifier->m_isString) | 388 if (namedProperty == identifier->m_isString) |
| 389 ++propertiesCount; | 389 ++propertiesCount; |
| 390 } | 390 } |
| 391 v8::Handle<v8::Array> properties = v8::Array::New(info.GetIsolate(),
propertiesCount); | 391 v8::Local<v8::Array> properties = v8::Array::New(info.GetIsolate(),
propertiesCount); |
| 392 for (uint32_t i = 0, propertyIndex = 0; i < count; ++i) { | 392 for (uint32_t i = 0, propertyIndex = 0; i < count; ++i) { |
| 393 IdentifierRep* identifier = static_cast<IdentifierRep*>(identifi
ers[i]); | 393 IdentifierRep* identifier = static_cast<IdentifierRep*>(identifi
ers[i]); |
| 394 if (namedProperty == identifier->m_isString) { | 394 if (namedProperty == identifier->m_isString) { |
| 395 ASSERT(propertyIndex < propertiesCount); | 395 ASSERT(propertyIndex < propertiesCount); |
| 396 if (namedProperty) | 396 if (namedProperty) |
| 397 properties->Set(v8::Integer::New(info.GetIsolate(), prop
ertyIndex++), v8AtomicString(info.GetIsolate(), identifier->string())); | 397 properties->Set(v8::Integer::New(info.GetIsolate(), prop
ertyIndex++), v8AtomicString(info.GetIsolate(), identifier->string())); |
| 398 else | 398 else |
| 399 properties->Set(v8::Integer::New(info.GetIsolate(), prop
ertyIndex++), v8::Integer::New(info.GetIsolate(), identifier->number())); | 399 properties->Set(v8::Integer::New(info.GetIsolate(), prop
ertyIndex++), v8::Integer::New(info.GetIsolate(), identifier->number())); |
| 400 } | 400 } |
| 401 } | 401 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 static v8::Eternal<v8::FunctionTemplate> npObjectDesc; | 438 static v8::Eternal<v8::FunctionTemplate> npObjectDesc; |
| 439 | 439 |
| 440 ASSERT(isolate->InContext()); | 440 ASSERT(isolate->InContext()); |
| 441 | 441 |
| 442 // If this is a v8 object, just return it. | 442 // If this is a v8 object, just return it. |
| 443 V8NPObject* v8NPObject = npObjectToV8NPObject(object); | 443 V8NPObject* v8NPObject = npObjectToV8NPObject(object); |
| 444 if (v8NPObject) | 444 if (v8NPObject) |
| 445 return v8::Local<v8::Object>::New(isolate, v8NPObject->v8Object); | 445 return v8::Local<v8::Object>::New(isolate, v8NPObject->v8Object); |
| 446 | 446 |
| 447 // If we've already wrapped this object, just return it. | 447 // If we've already wrapped this object, just return it. |
| 448 v8::Handle<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolat
e); | 448 v8::Local<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolate
); |
| 449 if (!wrapper.IsEmpty()) | 449 if (!wrapper.IsEmpty()) |
| 450 return wrapper; | 450 return wrapper; |
| 451 | 451 |
| 452 // FIXME: we should create a Wrapper type as a subclass of JSObject. It has
two internal fields, field 0 is the wrapped | 452 // FIXME: we should create a Wrapper type as a subclass of JSObject. It has
two internal fields, field 0 is the wrapped |
| 453 // pointer, and field 1 is the type. There should be an api function that re
turns unused type id. The same Wrapper type | 453 // pointer, and field 1 is the type. There should be an api function that re
turns unused type id. The same Wrapper type |
| 454 // can be used by DOM bindings. | 454 // can be used by DOM bindings. |
| 455 if (npObjectDesc.IsEmpty()) { | 455 if (npObjectDesc.IsEmpty()) { |
| 456 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolat
e); | 456 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolat
e); |
| 457 templ->InstanceTemplate()->SetInternalFieldCount(npObjectInternalFieldCo
unt); | 457 templ->InstanceTemplate()->SetInternalFieldCount(npObjectInternalFieldCo
unt); |
| 458 templ->InstanceTemplate()->SetNamedPropertyHandler(npObjectNamedProperty
Getter, npObjectNamedPropertySetter, npObjectQueryProperty, 0, npObjectNamedProp
ertyEnumerator); | 458 templ->InstanceTemplate()->SetNamedPropertyHandler(npObjectNamedProperty
Getter, npObjectNamedPropertySetter, npObjectQueryProperty, 0, npObjectNamedProp
ertyEnumerator); |
| 459 templ->InstanceTemplate()->SetIndexedPropertyHandler(npObjectIndexedProp
ertyGetter, npObjectIndexedPropertySetter, 0, 0, npObjectIndexedPropertyEnumerat
or); | 459 templ->InstanceTemplate()->SetIndexedPropertyHandler(npObjectIndexedProp
ertyGetter, npObjectIndexedPropertySetter, 0, 0, npObjectIndexedPropertyEnumerat
or); |
| 460 templ->InstanceTemplate()->SetCallAsFunctionHandler(npObjectInvokeDefaul
tHandler); | 460 templ->InstanceTemplate()->SetCallAsFunctionHandler(npObjectInvokeDefaul
tHandler); |
| 461 npObjectDesc.Set(isolate, templ); | 461 npObjectDesc.Set(isolate, templ); |
| 462 } | 462 } |
| 463 | 463 |
| 464 // FIXME: Move staticNPObjectMap() to DOMDataStore. | 464 // FIXME: Move staticNPObjectMap() to DOMDataStore. |
| 465 // Use V8DOMWrapper::createWrapper() and | 465 // Use V8DOMWrapper::createWrapper() and |
| 466 // V8DOMWrapper::associateObjectWithWrapper() | 466 // V8DOMWrapper::associateObjectWithWrapper() |
| 467 // to create a wrapper object. | 467 // to create a wrapper object. |
| 468 v8::Handle<v8::Function> v8Function = npObjectDesc.Get(isolate)->GetFunction
(); | 468 v8::Local<v8::Function> v8Function = npObjectDesc.Get(isolate)->GetFunction(
); |
| 469 v8::Local<v8::Object> value = V8ObjectConstructor::newInstance(isolate, v8Fu
nction); | 469 v8::Local<v8::Object> value = V8ObjectConstructor::newInstance(isolate, v8Fu
nction); |
| 470 if (value.IsEmpty()) | 470 if (value.IsEmpty()) |
| 471 return value; | 471 return value; |
| 472 | 472 |
| 473 V8DOMWrapper::setNativeInfo(value, npObjectTypeInfo(), npObjectToScriptWrapp
able(object)); | 473 V8DOMWrapper::setNativeInfo(value, npObjectTypeInfo(), npObjectToScriptWrapp
able(object)); |
| 474 | 474 |
| 475 // KJS retains the object as part of its wrapper (see Bindings::CInstance). | 475 // KJS retains the object as part of its wrapper (see Bindings::CInstance). |
| 476 _NPN_RetainObject(object); | 476 _NPN_RetainObject(object); |
| 477 _NPN_RegisterObject(object, root); | 477 _NPN_RegisterObject(object, root); |
| 478 | 478 |
| 479 staticNPObjectMap().set(object, value, npObjectTypeInfo()); | 479 staticNPObjectMap().set(object, value, npObjectTypeInfo()); |
| 480 ASSERT(V8DOMWrapper::hasInternalFieldsSet(value)); | 480 ASSERT(V8DOMWrapper::hasInternalFieldsSet(value)); |
| 481 return value; | 481 return value; |
| 482 } | 482 } |
| 483 | 483 |
| 484 void forgetV8ObjectForNPObject(NPObject* object) | 484 void forgetV8ObjectForNPObject(NPObject* object) |
| 485 { | 485 { |
| 486 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 486 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 487 v8::HandleScope scope(isolate); | 487 v8::HandleScope scope(isolate); |
| 488 v8::Handle<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolat
e); | 488 v8::Local<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolate
); |
| 489 if (!wrapper.IsEmpty()) { | 489 if (!wrapper.IsEmpty()) { |
| 490 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo()); | 490 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo()); |
| 491 staticNPObjectMap().removeAndDispose(object); | 491 staticNPObjectMap().removeAndDispose(object); |
| 492 _NPN_ReleaseObject(object); | 492 _NPN_ReleaseObject(object); |
| 493 } | 493 } |
| 494 } | 494 } |
| 495 | 495 |
| 496 } // namespace blink | 496 } // namespace blink |
| OLD | NEW |