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