Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1442)

Unified Diff: webkit/port/bindings/v8/NPV8Object.cpp

Issue 113823: Added support for constructor calls in the NPAPI (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/plugin/npobject_stub.cc ('k') | webkit/port/bindings/v8/V8NPObject.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/port/bindings/v8/NPV8Object.cpp
===================================================================
--- webkit/port/bindings/v8/NPV8Object.cpp (revision 16974)
+++ webkit/port/bindings/v8/NPV8Object.cpp (working copy)
@@ -482,10 +482,40 @@
if (!npobj)
return false;
- // FIXME(estade): implement this case.
if (npobj->_class == npScriptObjectClass) {
- VOID_TO_NPVARIANT(*result);
- return false;
+ V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj);
+
+ v8::HandleScope handleScope;
+ v8::Handle<v8::Context> context = getV8Context(npp, npobj);
+ if (context.IsEmpty())
+ return false;
+ v8::Context::Scope scope(context);
+
+ // Lookup the constructor function.
+ v8::Handle<v8::Object> ctorObj(object->v8Object);
+ if (!ctorObj->IsFunction())
+ return false;
+
+ // Call the constructor.
+ v8::Local<v8::Value> resultObj;
+ v8::Handle<v8::Function> ctor(v8::Function::Cast(*ctorObj));
+ if (!ctor->IsNull()) {
+ WebCore::V8Proxy* proxy = GetV8Proxy(npobj);
+ ASSERT(proxy);
+
+ // Create list of args to pass to v8.
+ v8::Handle<v8::Value>* argv = listFromVariantArgs(args, argCount, npobj);
+ resultObj = proxy->NewInstance(ctor, argCount, argv);
+ delete[] argv;
+ }
+
+ // If we had an error return false.
+ if (resultObj.IsEmpty())
+ return false;
+
+ // Convert the result back to an NPVariant.
+ convertV8ObjectToNPVariant(resultObj, npobj, result);
+ return true;
}
if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npobj->_class) && npobj->_class->construct)
« no previous file with comments | « chrome/plugin/npobject_stub.cc ('k') | webkit/port/bindings/v8/V8NPObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698