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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 break; | 131 break; |
132 } | 132 } |
133 | 133 |
134 if (!retval) | 134 if (!retval) |
135 throwError("Error calling method on NPObject.", V8Proxy::GeneralError); | 135 throwError("Error calling method on NPObject.", V8Proxy::GeneralError); |
136 | 136 |
137 for (int i = 0; i < numArgs; i++) | 137 for (int i = 0; i < numArgs; i++) |
138 _NPN_ReleaseVariantValue(&npArgs[i]); | 138 _NPN_ReleaseVariantValue(&npArgs[i]); |
139 | 139 |
140 // Unwrap return values. | 140 // Unwrap return values. |
141 v8::Handle<v8::Value> returnValue = convertNPVariantToV8Object(&result, npOb
ject); | 141 v8::Handle<v8::Value> returnValue; |
| 142 if (_NPN_IsAlive(npObject)) |
| 143 returnValue = convertNPVariantToV8Object(&result, npObject); |
142 _NPN_ReleaseVariantValue(&result); | 144 _NPN_ReleaseVariantValue(&result); |
143 | 145 |
144 return returnValue; | 146 return returnValue; |
145 } | 147 } |
146 | 148 |
147 | 149 |
148 v8::Handle<v8::Value> npObjectMethodHandler(const v8::Arguments& args) | 150 v8::Handle<v8::Value> npObjectMethodHandler(const v8::Arguments& args) |
149 { | 151 { |
150 return npObjectInvokeImpl(args, InvokeMethod); | 152 return npObjectInvokeImpl(args, InvokeMethod); |
151 } | 153 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 static v8::Handle<v8::Value> npObjectGetProperty(v8::Local<v8::Object> self, NPI
dentifier identifier, v8::Local<v8::Value> key) | 185 static v8::Handle<v8::Value> npObjectGetProperty(v8::Local<v8::Object> self, NPI
dentifier identifier, v8::Local<v8::Value> key) |
184 { | 186 { |
185 NPObject* npObject = v8ObjectToNPObject(self); | 187 NPObject* npObject = v8ObjectToNPObject(self); |
186 | 188 |
187 // Verify that our wrapper wasn't using a NPObject which | 189 // Verify that our wrapper wasn't using a NPObject which |
188 // has already been deleted. | 190 // has already been deleted. |
189 if (!npObject || !_NPN_IsAlive(npObject)) | 191 if (!npObject || !_NPN_IsAlive(npObject)) |
190 return throwError("NPObject deleted", V8Proxy::ReferenceError); | 192 return throwError("NPObject deleted", V8Proxy::ReferenceError); |
191 | 193 |
192 | 194 |
193 if (npObject->_class->hasProperty && npObject->_class->hasProperty(npObject,
identifier) | 195 if (npObject->_class->hasProperty && npObject->_class->getProperty && npObje
ct->_class->hasProperty(npObject, identifier)) { |
194 && npObject->_class->getProperty) { | 196 if (!_NPN_IsAlive(npObject)) |
| 197 return throwError("NPObject deleted", V8Proxy::ReferenceError); |
195 | 198 |
196 NPVariant result; | 199 NPVariant result; |
197 VOID_TO_NPVARIANT(result); | 200 VOID_TO_NPVARIANT(result); |
198 if (!npObject->_class->getProperty(npObject, identifier, &result)) | 201 if (!npObject->_class->getProperty(npObject, identifier, &result)) |
199 return v8::Handle<v8::Value>(); | 202 return v8::Handle<v8::Value>(); |
200 | 203 |
201 v8::Handle<v8::Value> returnValue = convertNPVariantToV8Object(&result,
npObject); | 204 v8::Handle<v8::Value> returnValue; |
| 205 if (_NPN_IsAlive(npObject)) |
| 206 returnValue = convertNPVariantToV8Object(&result, npObject); |
202 _NPN_ReleaseVariantValue(&result); | 207 _NPN_ReleaseVariantValue(&result); |
203 return returnValue; | 208 return returnValue; |
204 | 209 |
205 } | 210 } |
206 | 211 |
| 212 if (!_NPN_IsAlive(npObject)) |
| 213 return throwError("NPObject deleted", V8Proxy::ReferenceError); |
| 214 |
207 if (key->IsString() && npObject->_class->hasMethod && npObject->_class->hasM
ethod(npObject, identifier)) { | 215 if (key->IsString() && npObject->_class->hasMethod && npObject->_class->hasM
ethod(npObject, identifier)) { |
| 216 if (!_NPN_IsAlive(npObject)) |
| 217 return throwError("NPObject deleted", V8Proxy::ReferenceError); |
| 218 |
208 PrivateIdentifier* id = static_cast<PrivateIdentifier*>(identifier); | 219 PrivateIdentifier* id = static_cast<PrivateIdentifier*>(identifier); |
209 v8::Persistent<v8::FunctionTemplate> functionTemplate = staticTemplateMa
p().get(id); | 220 v8::Persistent<v8::FunctionTemplate> functionTemplate = staticTemplateMa
p().get(id); |
210 // Cache templates using identifier as the key. | 221 // Cache templates using identifier as the key. |
211 if (functionTemplate.IsEmpty()) { | 222 if (functionTemplate.IsEmpty()) { |
212 // Create a new template. | 223 // Create a new template. |
213 v8::Local<v8::FunctionTemplate> temp = v8::FunctionTemplate::New(); | 224 v8::Local<v8::FunctionTemplate> temp = v8::FunctionTemplate::New(); |
214 temp->SetCallHandler(npObjectMethodHandler, key); | 225 temp->SetCallHandler(npObjectMethodHandler, key); |
215 functionTemplate = v8::Persistent<v8::FunctionTemplate>::New(temp); | 226 functionTemplate = v8::Persistent<v8::FunctionTemplate>::New(temp); |
216 staticTemplateMap().set(id, functionTemplate); | 227 staticTemplateMap().set(id, functionTemplate); |
217 } | 228 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 static v8::Handle<v8::Value> npObjectSetProperty(v8::Local<v8::Object> self, NPI
dentifier identifier, v8::Local<v8::Value> value) | 269 static v8::Handle<v8::Value> npObjectSetProperty(v8::Local<v8::Object> self, NPI
dentifier identifier, v8::Local<v8::Value> value) |
259 { | 270 { |
260 NPObject* npObject = v8ObjectToNPObject(self); | 271 NPObject* npObject = v8ObjectToNPObject(self); |
261 | 272 |
262 // Verify that our wrapper wasn't using a NPObject which has already been de
leted. | 273 // Verify that our wrapper wasn't using a NPObject which has already been de
leted. |
263 if (!npObject || !_NPN_IsAlive(npObject)) { | 274 if (!npObject || !_NPN_IsAlive(npObject)) { |
264 throwError("NPObject deleted", V8Proxy::ReferenceError); | 275 throwError("NPObject deleted", V8Proxy::ReferenceError); |
265 return value; // Intercepted, but an exception was thrown. | 276 return value; // Intercepted, but an exception was thrown. |
266 } | 277 } |
267 | 278 |
268 if (npObject->_class->hasProperty && npObject->_class->hasProperty(npObject,
identifier) | 279 if (npObject->_class->hasProperty && npObject->_class->setProperty && npObje
ct->_class->hasProperty(npObject, identifier)) { |
269 && npObject->_class->setProperty) { | 280 if (!_NPN_IsAlive(npObject)) |
| 281 return throwError("NPObject deleted", V8Proxy::ReferenceError); |
270 | 282 |
271 NPVariant npValue; | 283 NPVariant npValue; |
272 VOID_TO_NPVARIANT(npValue); | 284 VOID_TO_NPVARIANT(npValue); |
273 convertV8ObjectToNPVariant(value, npObject, &npValue); | 285 convertV8ObjectToNPVariant(value, npObject, &npValue); |
274 bool success = npObject->_class->setProperty(npObject, identifier, &npVa
lue); | 286 bool success = npObject->_class->setProperty(npObject, identifier, &npVa
lue); |
275 _NPN_ReleaseVariantValue(&npValue); | 287 _NPN_ReleaseVariantValue(&npValue); |
276 if (success) | 288 if (success) |
277 return value; // Intercept the call. | 289 return value; // Intercept the call. |
278 } | 290 } |
279 return notHandledByInterceptor(); | 291 return notHandledByInterceptor(); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 if (staticNPObjectMap().contains(object)) { | 432 if (staticNPObjectMap().contains(object)) { |
421 v8::HandleScope scope; | 433 v8::HandleScope scope; |
422 v8::Persistent<v8::Object> handle(staticNPObjectMap().get(object)); | 434 v8::Persistent<v8::Object> handle(staticNPObjectMap().get(object)); |
423 V8DOMWrapper::setDOMWrapper(handle, npObjectTypeInfo(), 0); | 435 V8DOMWrapper::setDOMWrapper(handle, npObjectTypeInfo(), 0); |
424 staticNPObjectMap().forget(object); | 436 staticNPObjectMap().forget(object); |
425 _NPN_ReleaseObject(object); | 437 _NPN_ReleaseObject(object); |
426 } | 438 } |
427 } | 439 } |
428 | 440 |
429 } // namespace WebCore | 441 } // namespace WebCore |
OLD | NEW |