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

Side by Side Diff: webkit/port/bindings/v8/V8NPObject.cpp

Issue 56167: Second part of fix of issue http://code.google.com/p/chromium/issues/detail?i... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008, Google Inc. 1 // Copyright (c) 2008, Google Inc.
2 // All rights reserved. 2 // 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 case INVOKE_METHOD: 97 case INVOKE_METHOD:
98 if (npobject->_class->invoke) { 98 if (npobject->_class->invoke) {
99 v8::Handle<v8::String> function_name(v8::String::Cast(*args.Data())) ; 99 v8::Handle<v8::String> function_name(v8::String::Cast(*args.Data())) ;
100 NPIdentifier ident = getStringIdentifier(function_name); 100 NPIdentifier ident = getStringIdentifier(function_name);
101 npobject->_class->invoke(npobject, ident, npArgs, argc, &result); 101 npobject->_class->invoke(npobject, ident, npArgs, argc, &result);
102 } 102 }
103 break; 103 break;
104 case INVOKE_DEFAULT: 104 case INVOKE_DEFAULT:
105 if (npobject->_class->invokeDefault) 105 if (npobject->_class->invokeDefault)
106 npobject->_class->invokeDefault(npobject, npArgs, argc, &result); 106 npobject->_class->invokeDefault(npobject, npArgs, argc, &result);
107 // The call might be a construct call on an NPObject.
108 // See http://code.google.com/p/chromium/issues/detail?id=3285
109 //
110 // TODO: when V8 passes in the correct flag args.is_construct_call_,
111 // make a separate NPN_Construct case.
112 else if (npobject->_class->construct)
113 npobject->_class->construct(npobject, npArgs, argc, &result);
107 break; 114 break;
108 default: 115 default:
109 break; 116 break;
110 } 117 }
111 118
112 for (int i=0; i < argc; i++) 119 for (int i=0; i < argc; i++)
113 NPN_ReleaseVariantValue(&npArgs[i]); 120 NPN_ReleaseVariantValue(&npArgs[i]);
114 delete[] npArgs; 121 delete[] npArgs;
115 122
116 // unwrap return values 123 // unwrap return values
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 npobject->_class->getProperty) { 174 npobject->_class->getProperty) {
168 175
169 NPVariant result; 176 NPVariant result;
170 VOID_TO_NPVARIANT(result); 177 VOID_TO_NPVARIANT(result);
171 if (!npobject->_class->getProperty(npobject, ident, &result)) 178 if (!npobject->_class->getProperty(npobject, ident, &result))
172 return v8::Handle<v8::Value>(); 179 return v8::Handle<v8::Value>();
173 180
174 v8::Handle<v8::Value> rv = convertNPVariantToV8Object(&result, npobject) ; 181 v8::Handle<v8::Value> rv = convertNPVariantToV8Object(&result, npobject) ;
175 NPN_ReleaseVariantValue(&result); 182 NPN_ReleaseVariantValue(&result);
176 return rv; 183 return rv;
177 } else if (key->IsString() && npobject->_class->hasMethod && npobject->_clas s->hasMethod(npobject, ident)) { 184
185 } else if (key->IsString() &&
186 npobject->_class->hasMethod &&
187 npobject->_class->hasMethod(npobject, ident)) {
188
178 PrivateIdentifier* id = static_cast<PrivateIdentifier*>(ident); 189 PrivateIdentifier* id = static_cast<PrivateIdentifier*>(ident);
179 v8::Persistent<v8::FunctionTemplate> desc = static_template_map.get(id); 190 v8::Persistent<v8::FunctionTemplate> desc = static_template_map.get(id);
180 // Cache templates using identifier as the key. 191 // Cache templates using identifier as the key.
181 if (desc.IsEmpty()) { 192 if (desc.IsEmpty()) {
182 // Create a new template 193 // Create a new template
183 v8::Local<v8::FunctionTemplate> temp = v8::FunctionTemplate::New(); 194 v8::Local<v8::FunctionTemplate> temp = v8::FunctionTemplate::New();
184 temp->SetCallHandler(NPObjectMethodHandler, key); 195 temp->SetCallHandler(NPObjectMethodHandler, key);
185 desc = v8::Persistent<v8::FunctionTemplate>::New(temp); 196 desc = v8::Persistent<v8::FunctionTemplate>::New(temp);
186 static_template_map.set(id, desc); 197 static_template_map.set(id, desc);
187 } 198 }
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 void ForgetV8ObjectForNPObject(NPObject* object) 371 void ForgetV8ObjectForNPObject(NPObject* object)
361 { 372 {
362 if (staticNpobjectMap.contains(object)) { 373 if (staticNpobjectMap.contains(object)) {
363 v8::HandleScope scope; 374 v8::HandleScope scope;
364 v8::Persistent<v8::Object> handle(staticNpobjectMap.get(object)); 375 v8::Persistent<v8::Object> handle(staticNpobjectMap.get(object));
365 WebCore::V8Proxy::SetDOMWrapper(handle, WebCore::V8ClassIndex::NPOBJECT, NULL); 376 WebCore::V8Proxy::SetDOMWrapper(handle, WebCore::V8ClassIndex::NPOBJECT, NULL);
366 staticNpobjectMap.forget(object); 377 staticNpobjectMap.forget(object);
367 NPN_ReleaseObject(object); 378 NPN_ReleaseObject(object);
368 } 379 }
369 } 380 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698