Chromium Code Reviews| Index: webkit/glue/cpp_bound_class.cc |
| =================================================================== |
| --- webkit/glue/cpp_bound_class.cc (revision 2868) |
| +++ webkit/glue/cpp_bound_class.cc (working copy) |
| @@ -154,7 +154,7 @@ |
| } |
| bool CppBoundClass::HasMethod(NPIdentifier ident) { |
| - return (methods_.find(ident) != methods_.end()); |
| + return (methods_.find(ident) != methods_.end() || fallback_callback_.get()); |
|
Evan Martin
2008/10/07 18:26:42
I spoke with Feng. This is the only line we have
|
| } |
| bool CppBoundClass::HasProperty(NPIdentifier ident) { |
| @@ -167,9 +167,11 @@ |
| NPVariant* result) { |
| MethodList::const_iterator method = methods_.find(ident); |
| Callback* callback; |
| + bool inject_method_name = false; |
| if (method == methods_.end()) { |
| if (fallback_callback_.get()) { |
| callback = fallback_callback_.get(); |
| + inject_method_name = true; |
| } else { |
| VOID_TO_NPVARIANT(*result); |
| return false; |
| @@ -179,10 +181,19 @@ |
| } |
| // Build a CppArgumentList argument vector from the NPVariants coming in. |
| - CppArgumentList cpp_args(arg_count); |
| - for (size_t i = 0; i < arg_count; i++) |
| - cpp_args[i].Set(args[i]); |
| + size_t arg_offset = (inject_method_name ? 1 : 0); |
| + CppArgumentList cpp_args(arg_count + arg_offset); |
| + for (size_t i = arg_offset; i < arg_count + arg_offset; i++) |
| + cpp_args[i].Set(args[i - arg_offset]); |
| + // If the fallback is being called pass the JavaScript method name as the |
| + // first argument. |
| + if (inject_method_name) { |
| + NPUTF8* name = NPN_UTF8FromIdentifier(ident); |
| + cpp_args[0].Set(name); |
| + free(name); |
| + } |
| + |
| CppVariant cpp_result; |
| callback->Run(cpp_args, &cpp_result); |