| OLD | NEW |
| 1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, Google Inc. |
| 2 // All rights reserved. | 2 // 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // Params: holder could be HTMLEmbedElement or NPObject | 52 // Params: holder could be HTMLEmbedElement or NPObject |
| 53 static v8::Handle<v8::Value> NPObjectInvokeImpl( | 53 static v8::Handle<v8::Value> NPObjectInvokeImpl( |
| 54 const v8::Arguments& args, InvokeFunctionType func_id) { | 54 const v8::Arguments& args, InvokeFunctionType func_id) { |
| 55 NPObject* npobject; | 55 NPObject* npobject; |
| 56 | 56 |
| 57 // These three types are subtypes of HTMLPlugInElement. | 57 // These three types are subtypes of HTMLPlugInElement. |
| 58 if (V8HTMLAppletElement::HasInstance(args.Holder()) || | 58 if (V8HTMLAppletElement::HasInstance(args.Holder()) || |
| 59 V8HTMLEmbedElement::HasInstance(args.Holder()) || | 59 V8HTMLEmbedElement::HasInstance(args.Holder()) || |
| 60 V8HTMLObjectElement::HasInstance(args.Holder())) { | 60 V8HTMLObjectElement::HasInstance(args.Holder())) { |
| 61 // The holder object is a subtype of HTMLPlugInElement. | 61 // The holder object is a subtype of HTMLPlugInElement. |
| 62 HTMLPlugInElement* imp = V8Proxy::FastToNativeObject<HTMLPlugInElement>( | 62 HTMLPlugInElement* imp = |
| 63 V8ClassIndex::NODE, args.Holder()); | 63 V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(args.Holder()); |
| 64 v8::Handle<v8::Object> instance = imp->getInstance(); | 64 v8::Handle<v8::Object> instance = imp->getInstance(); |
| 65 npobject = V8Proxy::ToNativeObject<NPObject>( | 65 npobject = V8Proxy::ToNativeObject<NPObject>( |
| 66 V8ClassIndex::NPOBJECT, instance); | 66 V8ClassIndex::NPOBJECT, instance); |
| 67 | 67 |
| 68 } else { | 68 } else { |
| 69 // The holder object is not a subtype of HTMLPlugInElement, it | 69 // The holder object is not a subtype of HTMLPlugInElement, it |
| 70 // must be an NPObject which has three internal fields. | 70 // must be an NPObject which has three internal fields. |
| 71 ASSERT(args.Holder()->InternalFieldCount() == 3); | 71 ASSERT(args.Holder()->InternalFieldCount() == 3); |
| 72 npobject = V8Proxy::ToNativeObject<NPObject>( | 72 npobject = V8Proxy::ToNativeObject<NPObject>( |
| 73 V8ClassIndex::NPOBJECT, args.Holder()); | 73 V8ClassIndex::NPOBJECT, args.Holder()); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 216 |
| 217 v8::Handle<v8::Value> NPObjectGetIndexedProperty(v8::Local<v8::Object> self, | 217 v8::Handle<v8::Value> NPObjectGetIndexedProperty(v8::Local<v8::Object> self, |
| 218 uint32_t index) { | 218 uint32_t index) { |
| 219 NPIdentifier ident = NPN_GetIntIdentifier(index); | 219 NPIdentifier ident = NPN_GetIntIdentifier(index); |
| 220 return NPObjectGetProperty(self, ident, v8::Number::New(index)); | 220 return NPObjectGetProperty(self, ident, v8::Number::New(index)); |
| 221 } | 221 } |
| 222 | 222 |
| 223 static v8::Handle<v8::Value> NPObjectSetProperty(v8::Local<v8::Object> self, | 223 static v8::Handle<v8::Value> NPObjectSetProperty(v8::Local<v8::Object> self, |
| 224 NPIdentifier ident, | 224 NPIdentifier ident, |
| 225 v8::Local<v8::Value> value) { | 225 v8::Local<v8::Value> value) { |
| 226 NPObject* npobject = V8Proxy::ToNativeObject<NPObject>(V8ClassIndex::NPOBJECT, | 226 NPObject* npobject = |
| 227 self); | 227 V8Proxy::ToNativeObject<NPObject>(V8ClassIndex::NPOBJECT, self); |
| 228 | 228 |
| 229 // Verify that our wrapper wasn't using a NPObject which | 229 // Verify that our wrapper wasn't using a NPObject which |
| 230 // has already been deleted. | 230 // has already been deleted. |
| 231 if (!npobject || !_NPN_IsAlive(npobject)) { | 231 if (!npobject || !_NPN_IsAlive(npobject)) { |
| 232 V8Proxy::ThrowError(V8Proxy::REFERENCE_ERROR, "NPObject deleted"); | 232 V8Proxy::ThrowError(V8Proxy::REFERENCE_ERROR, "NPObject deleted"); |
| 233 return value; // intercepted, but an exception was thrown | 233 return value; // intercepted, but an exception was thrown |
| 234 } | 234 } |
| 235 | 235 |
| 236 if (npobject->_class->hasProperty && | 236 if (npobject->_class->hasProperty && |
| 237 npobject->_class->hasProperty(npobject, ident) && | 237 npobject->_class->hasProperty(npobject, ident) && |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 void ForgetV8ObjectForNPObject(NPObject* object) { | 355 void ForgetV8ObjectForNPObject(NPObject* object) { |
| 356 if (static_npobject_map.contains(object)) { | 356 if (static_npobject_map.contains(object)) { |
| 357 v8::HandleScope scope; | 357 v8::HandleScope scope; |
| 358 v8::Persistent<v8::Object> handle(static_npobject_map.get(object)); | 358 v8::Persistent<v8::Object> handle(static_npobject_map.get(object)); |
| 359 WebCore::V8Proxy::SetDOMWrapper(handle, | 359 WebCore::V8Proxy::SetDOMWrapper(handle, |
| 360 WebCore::V8ClassIndex::NPOBJECT, NULL); | 360 WebCore::V8ClassIndex::NPOBJECT, NULL); |
| 361 static_npobject_map.forget(object); | 361 static_npobject_map.forget(object); |
| 362 NPN_ReleaseObject(object); | 362 NPN_ReleaseObject(object); |
| 363 } | 363 } |
| 364 } | 364 } |
| OLD | NEW |