| 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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 static v8::Eternal<v8::FunctionTemplate> npObjectDesc; | 449 static v8::Eternal<v8::FunctionTemplate> npObjectDesc; |
| 450 | 450 |
| 451 ASSERT(isolate->InContext()); | 451 ASSERT(isolate->InContext()); |
| 452 | 452 |
| 453 // If this is a v8 object, just return it. | 453 // If this is a v8 object, just return it. |
| 454 V8NPObject* v8NPObject = npObjectToV8NPObject(object); | 454 V8NPObject* v8NPObject = npObjectToV8NPObject(object); |
| 455 if (v8NPObject) | 455 if (v8NPObject) |
| 456 return v8::Local<v8::Object>::New(isolate, v8NPObject->v8Object); | 456 return v8::Local<v8::Object>::New(isolate, v8NPObject->v8Object); |
| 457 | 457 |
| 458 // If we've already wrapped this object, just return it. | 458 // If we've already wrapped this object, just return it. |
| 459 v8::Local<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolate
); | 459 v8::Local<v8::Object> wrapper = staticNPObjectMap().newLocal(isolate, object
); |
| 460 if (!wrapper.IsEmpty()) | 460 if (!wrapper.IsEmpty()) |
| 461 return wrapper; | 461 return wrapper; |
| 462 | 462 |
| 463 // FIXME: we should create a Wrapper type as a subclass of JSObject. It has
two internal fields, field 0 is the wrapped | 463 // FIXME: we should create a Wrapper type as a subclass of JSObject. It has
two internal fields, field 0 is the wrapped |
| 464 // pointer, and field 1 is the type. There should be an api function that re
turns unused type id. The same Wrapper type | 464 // pointer, and field 1 is the type. There should be an api function that re
turns unused type id. The same Wrapper type |
| 465 // can be used by DOM bindings. | 465 // can be used by DOM bindings. |
| 466 if (npObjectDesc.IsEmpty()) { | 466 if (npObjectDesc.IsEmpty()) { |
| 467 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolat
e); | 467 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolat
e); |
| 468 templ->InstanceTemplate()->SetInternalFieldCount(npObjectInternalFieldCo
unt); | 468 templ->InstanceTemplate()->SetInternalFieldCount(npObjectInternalFieldCo
unt); |
| 469 templ->InstanceTemplate()->SetNamedPropertyHandler(npObjectNamedProperty
Getter, npObjectNamedPropertySetter, npObjectQueryProperty, 0, npObjectNamedProp
ertyEnumerator); | 469 templ->InstanceTemplate()->SetNamedPropertyHandler(npObjectNamedProperty
Getter, npObjectNamedPropertySetter, npObjectQueryProperty, 0, npObjectNamedProp
ertyEnumerator); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 491 | 491 |
| 492 staticNPObjectMap().set(object, value, npObjectTypeInfo()); | 492 staticNPObjectMap().set(object, value, npObjectTypeInfo()); |
| 493 ASSERT(V8DOMWrapper::hasInternalFieldsSet(value)); | 493 ASSERT(V8DOMWrapper::hasInternalFieldsSet(value)); |
| 494 return value; | 494 return value; |
| 495 } | 495 } |
| 496 | 496 |
| 497 void forgetV8ObjectForNPObject(NPObject* object) | 497 void forgetV8ObjectForNPObject(NPObject* object) |
| 498 { | 498 { |
| 499 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 499 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 500 v8::HandleScope scope(isolate); | 500 v8::HandleScope scope(isolate); |
| 501 v8::Local<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolate
); | 501 v8::Local<v8::Object> wrapper = staticNPObjectMap().newLocal(isolate, object
); |
| 502 if (!wrapper.IsEmpty()) { | 502 if (!wrapper.IsEmpty()) { |
| 503 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo()); | 503 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo()); |
| 504 staticNPObjectMap().removeAndDispose(object); | 504 staticNPObjectMap().removeAndDispose(object); |
| 505 _NPN_ReleaseObject(object); | 505 _NPN_ReleaseObject(object); |
| 506 } | 506 } |
| 507 } | 507 } |
| 508 | 508 |
| 509 } // namespace blink | 509 } // namespace blink |
| OLD | NEW |