| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. |
| 3 * Copyright (C) 2007, 2008, 2009 Google, Inc. All rights reserved. | 3 * Copyright (C) 2007, 2008, 2009 Google, Inc. All rights reserved. |
| 4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. | 4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 VOID_TO_NPVARIANT(*result); | 266 VOID_TO_NPVARIANT(*result); |
| 267 return false; | 267 return false; |
| 268 } | 268 } |
| 269 | 269 |
| 270 LocalFrame* frame = v8NpObject->rootObject->frame(); | 270 LocalFrame* frame = v8NpObject->rootObject->frame(); |
| 271 ASSERT(frame); | 271 ASSERT(frame); |
| 272 | 272 |
| 273 // Call the function object. | 273 // Call the function object. |
| 274 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(functionObj
ect); | 274 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(functionObj
ect); |
| 275 OwnPtr<v8::Local<v8::Value>[]> argv = createValueListFromVariantArgs(isolate
, arguments, argumentCount, npObject); | 275 OwnPtr<v8::Local<v8::Value>[]> argv = createValueListFromVariantArgs(isolate
, arguments, argumentCount, npObject); |
| 276 v8::Local<v8::Value> resultObject = frame->script().callFunction(function, v
8Object, argumentCount, argv.get()); | |
| 277 | |
| 278 // If we had an error, return false. The spec is a little unclear here, but
says "Returns true if the method was | 276 // If we had an error, return false. The spec is a little unclear here, but
says "Returns true if the method was |
| 279 // successfully invoked". If we get an error return value, was that success
fully invoked? | 277 // successfully invoked". If we get an error return value, was that success
fully invoked? |
| 280 if (resultObject.IsEmpty()) | 278 v8::Local<v8::Value> resultObject; |
| 279 if (!frame->script().callFunction(function, v8Object, argumentCount, argv.ge
t()).ToLocal(&resultObject)) |
| 281 return false; | 280 return false; |
| 282 | 281 |
| 283 convertV8ObjectToNPVariant(isolate, resultObject, npObject, result); | 282 convertV8ObjectToNPVariant(isolate, resultObject, npObject, result); |
| 284 return true; | 283 return true; |
| 285 } | 284 } |
| 286 | 285 |
| 287 // FIXME: Fix it same as _NPN_Invoke (HandleScope and such). | 286 // FIXME: Fix it same as _NPN_Invoke (HandleScope and such). |
| 288 bool _NPN_InvokeDefault(NPP npp, NPObject* npObject, const NPVariant* arguments,
uint32_t argumentCount, NPVariant* result) | 287 bool _NPN_InvokeDefault(NPP npp, NPObject* npObject, const NPVariant* arguments,
uint32_t argumentCount, NPVariant* result) |
| 289 { | 288 { |
| 290 if (!npObject) | 289 if (!npObject) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 308 return false; | 307 return false; |
| 309 | 308 |
| 310 ScriptState::Scope scope(scriptState); | 309 ScriptState::Scope scope(scriptState); |
| 311 ExceptionCatcher exceptionCatcher; | 310 ExceptionCatcher exceptionCatcher; |
| 312 | 311 |
| 313 // Lookup the function object and call it. | 312 // Lookup the function object and call it. |
| 314 v8::Local<v8::Object> functionObject = v8::Local<v8::Object>::New(isolate, v
8NpObject->v8Object); | 313 v8::Local<v8::Object> functionObject = v8::Local<v8::Object>::New(isolate, v
8NpObject->v8Object); |
| 315 if (!functionObject->IsFunction()) | 314 if (!functionObject->IsFunction()) |
| 316 return false; | 315 return false; |
| 317 | 316 |
| 318 v8::Local<v8::Value> resultObject; | |
| 319 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(functionObj
ect); | 317 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(functionObj
ect); |
| 320 if (!function->IsNull()) { | 318 if (function->IsNull()) |
| 321 LocalFrame* frame = v8NpObject->rootObject->frame(); | 319 return false; |
| 322 ASSERT(frame); | |
| 323 | 320 |
| 324 OwnPtr<v8::Local<v8::Value>[]> argv = createValueListFromVariantArgs(iso
late, arguments, argumentCount, npObject); | 321 LocalFrame* frame = v8NpObject->rootObject->frame(); |
| 325 resultObject = frame->script().callFunction(function, functionObject, ar
gumentCount, argv.get()); | 322 ASSERT(frame); |
| 326 } | 323 |
| 324 OwnPtr<v8::Local<v8::Value>[]> argv = createValueListFromVariantArgs(isolate
, arguments, argumentCount, npObject); |
| 327 // If we had an error, return false. The spec is a little unclear here, but
says "Returns true if the method was | 325 // If we had an error, return false. The spec is a little unclear here, but
says "Returns true if the method was |
| 328 // successfully invoked". If we get an error return value, was that success
fully invoked? | 326 // successfully invoked". If we get an error return value, was that success
fully invoked? |
| 329 if (resultObject.IsEmpty()) | 327 v8::Local<v8::Value> resultObject; |
| 328 if (!frame->script().callFunction(function, functionObject, argumentCount, a
rgv.get()).ToLocal(&resultObject)) |
| 330 return false; | 329 return false; |
| 331 | 330 |
| 332 convertV8ObjectToNPVariant(isolate, resultObject, npObject, result); | 331 convertV8ObjectToNPVariant(isolate, resultObject, npObject, result); |
| 333 return true; | 332 return true; |
| 334 } | 333 } |
| 335 | 334 |
| 336 bool _NPN_Evaluate(NPP npp, NPObject* npObject, NPString* npScript, NPVariant* r
esult) | 335 bool _NPN_Evaluate(NPP npp, NPObject* npObject, NPString* npScript, NPVariant* r
esult) |
| 337 { | 336 { |
| 338 // FIXME: Give the embedder a way to control this. | 337 // FIXME: Give the embedder a way to control this. |
| 339 bool popupsAllowed = false; | 338 bool popupsAllowed = false; |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 | 614 |
| 616 convertV8ObjectToNPVariant(scriptState->isolate(), resultObject, npObjec
t, result); | 615 convertV8ObjectToNPVariant(scriptState->isolate(), resultObject, npObjec
t, result); |
| 617 return true; | 616 return true; |
| 618 } | 617 } |
| 619 | 618 |
| 620 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npObject->_class) && npObject->_class->
construct) | 619 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npObject->_class) && npObject->_class->
construct) |
| 621 return npObject->_class->construct(npObject, arguments, argumentCount, r
esult); | 620 return npObject->_class->construct(npObject, arguments, argumentCount, r
esult); |
| 622 | 621 |
| 623 return false; | 622 return false; |
| 624 } | 623 } |
| OLD | NEW |