| 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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 // Use V8DOMWrapper::createWrapper() and | 475 // Use V8DOMWrapper::createWrapper() and |
| 476 // V8DOMWrapper::associateObjectWithWrapper() | 476 // V8DOMWrapper::associateObjectWithWrapper() |
| 477 // to create a wrapper object. | 477 // to create a wrapper object. |
| 478 v8::Local<v8::Function> v8Function; | 478 v8::Local<v8::Function> v8Function; |
| 479 if (!npObjectDesc.Get(isolate)->GetFunction(isolate->GetCurrentContext()).To
Local(&v8Function)) | 479 if (!npObjectDesc.Get(isolate)->GetFunction(isolate->GetCurrentContext()).To
Local(&v8Function)) |
| 480 return v8::Local<v8::Object>(); | 480 return v8::Local<v8::Object>(); |
| 481 v8::Local<v8::Object> value; | 481 v8::Local<v8::Object> value; |
| 482 if (!V8ObjectConstructor::newInstance(isolate, v8Function).ToLocal(&value)) | 482 if (!V8ObjectConstructor::newInstance(isolate, v8Function).ToLocal(&value)) |
| 483 return v8::Local<v8::Object>(); | 483 return v8::Local<v8::Object>(); |
| 484 | 484 |
| 485 V8DOMWrapper::setNativeInfo(value, npObjectTypeInfo(), npObjectToScriptWrapp
able(object)); | 485 // NPObject is not ScriptWrappable. We must not retrieve the pointer as |
| 486 // ScriptWrappable. |
| 487 V8DOMWrapper::setNativeInfo(value, npObjectTypeInfo(), reinterpret_cast<Scri
ptWrappable*>(object)); |
| 486 | 488 |
| 487 // KJS retains the object as part of its wrapper (see Bindings::CInstance). | 489 // KJS retains the object as part of its wrapper (see Bindings::CInstance). |
| 488 _NPN_RetainObject(object); | 490 _NPN_RetainObject(object); |
| 489 _NPN_RegisterObject(object, root); | 491 _NPN_RegisterObject(object, root); |
| 490 | 492 |
| 491 bool wrapperDidNotExist = staticNPObjectMap().set(object, npObjectTypeInfo()
, value); | 493 bool wrapperDidNotExist = staticNPObjectMap().set(object, npObjectTypeInfo()
, value); |
| 492 ASSERT_UNUSED(wrapperDidNotExist, wrapperDidNotExist); | 494 ASSERT_UNUSED(wrapperDidNotExist, wrapperDidNotExist); |
| 493 ASSERT(V8DOMWrapper::hasInternalFieldsSet(value)); | 495 ASSERT(V8DOMWrapper::hasInternalFieldsSet(value)); |
| 494 return value; | 496 return value; |
| 495 } | 497 } |
| 496 | 498 |
| 497 void forgetV8ObjectForNPObject(NPObject* object) | 499 void forgetV8ObjectForNPObject(NPObject* object) |
| 498 { | 500 { |
| 499 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 501 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 500 v8::HandleScope scope(isolate); | 502 v8::HandleScope scope(isolate); |
| 501 v8::Local<v8::Object> wrapper = staticNPObjectMap().newLocal(isolate, object
); | 503 v8::Local<v8::Object> wrapper = staticNPObjectMap().newLocal(isolate, object
); |
| 502 if (!wrapper.IsEmpty()) { | 504 if (!wrapper.IsEmpty()) { |
| 503 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo()); | 505 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo()); |
| 504 staticNPObjectMap().removeAndDispose(object); | 506 staticNPObjectMap().removeAndDispose(object); |
| 505 _NPN_ReleaseObject(object); | 507 _NPN_ReleaseObject(object); |
| 506 } | 508 } |
| 507 } | 509 } |
| 508 | 510 |
| 509 } // namespace blink | 511 } // namespace blink |
| OLD | NEW |