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

Unified Diff: webkit/glue/cpp_bound_class.cc

Issue 3175: Pass the invoked JavaScript method name as an argument to the fallback callback (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 2 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 | « webkit/glue/cpp_bound_class.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « webkit/glue/cpp_bound_class.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698