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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 { | 397 { |
398 npObjectPropertyEnumerator(info, false); | 398 npObjectPropertyEnumerator(info, false); |
399 } | 399 } |
400 | 400 |
401 static DOMWrapperMap<NPObject>& staticNPObjectMap() | 401 static DOMWrapperMap<NPObject>& staticNPObjectMap() |
402 { | 402 { |
403 DEFINE_STATIC_LOCAL(DOMWrapperMap<NPObject>, npObjectMap, (v8::Isolate::GetC
urrent())); | 403 DEFINE_STATIC_LOCAL(DOMWrapperMap<NPObject>, npObjectMap, (v8::Isolate::GetC
urrent())); |
404 return npObjectMap; | 404 return npObjectMap; |
405 } | 405 } |
406 | 406 |
407 template<> | 407 void DOMWrapperMapDisposeHelper(NPObject* npObject) |
408 inline void DOMWrapperMap<NPObject>::setWeakCallback(const v8::WeakCallbackData<
v8::Object, DOMWrapperMap<NPObject> >& data) | |
409 { | 408 { |
410 NPObject* npObject = static_cast<NPObject*>(toNative(data.GetValue())); | |
411 | |
412 ASSERT(npObject); | |
413 ASSERT(staticNPObjectMap().containsKeyAndValue(npObject, data.GetValue())); | |
414 | |
415 // Must remove from our map before calling _NPN_ReleaseObject(). _NPN_Releas
eObject can | |
416 // call forgetV8ObjectForNPObject, which uses the table as well. | |
417 staticNPObjectMap().removeAndDispose(npObject); | |
418 | |
419 if (_NPN_IsAlive(npObject)) | 409 if (_NPN_IsAlive(npObject)) |
420 _NPN_ReleaseObject(npObject); | 410 _NPN_ReleaseObject(npObject); |
421 } | 411 } |
422 | 412 |
423 v8::Local<v8::Object> createV8ObjectForNPObject(NPObject* object, NPObject* root
, v8::Isolate* isolate) | 413 v8::Local<v8::Object> createV8ObjectForNPObject(NPObject* object, NPObject* root
, v8::Isolate* isolate) |
424 { | 414 { |
425 static v8::Eternal<v8::FunctionTemplate> npObjectDesc; | 415 static v8::Eternal<v8::FunctionTemplate> npObjectDesc; |
426 | 416 |
427 ASSERT(isolate->InContext()); | 417 ASSERT(isolate->InContext()); |
428 | 418 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 v8::HandleScope scope(isolate); | 465 v8::HandleScope scope(isolate); |
476 v8::Handle<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolat
e); | 466 v8::Handle<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolat
e); |
477 if (!wrapper.IsEmpty()) { | 467 if (!wrapper.IsEmpty()) { |
478 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo()); | 468 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo()); |
479 staticNPObjectMap().removeAndDispose(object); | 469 staticNPObjectMap().removeAndDispose(object); |
480 _NPN_ReleaseObject(object); | 470 _NPN_ReleaseObject(object); |
481 } | 471 } |
482 } | 472 } |
483 | 473 |
484 } // namespace WebCore | 474 } // namespace WebCore |
OLD | NEW |