Commit eeb77d68 authored by fqian@google.com's avatar fqian@google.com

Second part of fix of issue http://code.google.com/p/chromium/issues/detail?id=3285.

A NPObject can be called as a construct if it implements NPN_Construct, and NOT implements
NPN_InvokeDefault. Otherwise, NPN_InvokeDefault is called even when the object is called
as a constructor.

Review URL: http://codereview.chromium.org/56167

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15029 0039d316-1c4b-4281-b951-d872f2087c98
parent c4eac73e
...@@ -104,6 +104,13 @@ static v8::Handle<v8::Value> NPObjectInvokeImpl(const v8::Arguments& args, Invok ...@@ -104,6 +104,13 @@ static v8::Handle<v8::Value> NPObjectInvokeImpl(const v8::Arguments& args, Invok
case INVOKE_DEFAULT: case INVOKE_DEFAULT:
if (npobject->_class->invokeDefault) if (npobject->_class->invokeDefault)
npobject->_class->invokeDefault(npobject, npArgs, argc, &result); npobject->_class->invokeDefault(npobject, npArgs, argc, &result);
// The call might be a construct call on an NPObject.
// See http://code.google.com/p/chromium/issues/detail?id=3285
//
// TODO: when V8 passes in the correct flag args.is_construct_call_,
// make a separate NPN_Construct case.
else if (npobject->_class->construct)
npobject->_class->construct(npobject, npArgs, argc, &result);
break; break;
default: default:
break; break;
...@@ -174,7 +181,11 @@ static v8::Handle<v8::Value> NPObjectGetProperty(v8::Local<v8::Object> self, ...@@ -174,7 +181,11 @@ static v8::Handle<v8::Value> NPObjectGetProperty(v8::Local<v8::Object> self,
v8::Handle<v8::Value> rv = convertNPVariantToV8Object(&result, npobject); v8::Handle<v8::Value> rv = convertNPVariantToV8Object(&result, npobject);
NPN_ReleaseVariantValue(&result); NPN_ReleaseVariantValue(&result);
return rv; return rv;
} else if (key->IsString() && npobject->_class->hasMethod && npobject->_class->hasMethod(npobject, ident)) {
} else if (key->IsString() &&
npobject->_class->hasMethod &&
npobject->_class->hasMethod(npobject, ident)) {
PrivateIdentifier* id = static_cast<PrivateIdentifier*>(ident); PrivateIdentifier* id = static_cast<PrivateIdentifier*>(ident);
v8::Persistent<v8::FunctionTemplate> desc = static_template_map.get(id); v8::Persistent<v8::FunctionTemplate> desc = static_template_map.get(id);
// Cache templates using identifier as the key. // Cache templates using identifier as the key.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment