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

Unified Diff: Source/bindings/scripts/code_generator_v8.pm

Issue 37263002: Unify the GlobalEventHandlers list on the C++ side (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: one list to rule the C++ side Created 7 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 | « no previous file | Source/bindings/tests/idls/TestImplements.idl » ('j') | Source/core/events/EventTarget.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/code_generator_v8.pm
diff --git a/Source/bindings/scripts/code_generator_v8.pm b/Source/bindings/scripts/code_generator_v8.pm
index 7eace567479ab7d9704a7a7bcca3073cc5bc115d..c714c34f1a180717b90315e67717164f278979f9 100644
--- a/Source/bindings/scripts/code_generator_v8.pm
+++ b/Source/bindings/scripts/code_generator_v8.pm
@@ -1635,9 +1635,18 @@ END
}
} elsif ($attribute->type eq "EventHandler") {
AddToImplIncludes("bindings/v8/V8AbstractEventListener.h");
- my $getterFunc = ToMethodName($attribute->name);
# FIXME: Pass the main world ID for main-world-only getters.
- $code .= " EventListener* jsValue = imp->${getterFunc}(isolatedWorldForIsolate(info.GetIsolate()));\n";
+ my ($functionName, @arguments) = GetterExpression($interfaceName, $attribute);
+ my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"};
+ if ($implementedBy) {
+ my $implementedByImplName = GetImplNameFromImplementedBy($implementedBy);
+ $functionName = "${implementedByImplName}::${functionName}";
+ push(@arguments, "imp");
+ } else {
+ $functionName = "imp->${functionName}";
+ }
+ push(@arguments, "isolatedWorldForIsolate(info.GetIsolate())");
+ $code .= " EventListener* jsValue = ${functionName}(" . join(", ", @arguments) . ");\n";
$code .= " v8SetReturnValue(info, jsValue ? v8::Handle<v8::Value>(V8AbstractEventListener::cast(jsValue)->getListenerObject(imp->executionContext())) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate())));\n";
} else {
my $nativeValue = NativeToJSValue($attribute->type, $attribute->extendedAttributes, $expression, " ", "", "info.Holder()", "info.GetIsolate()", "info", "imp", $forMainWorldSuffix, "return");
@@ -1956,17 +1965,38 @@ END
}
if ($attribute->type eq "EventHandler") {
- my $implSetterFunctionName = FirstLetterToUpperCase($attrName);
+ my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"};
+ my $implementedByImplName;
+ if ($implementedBy) {
+ $implementedByImplName = GetImplNameFromImplementedBy($implementedBy);
+ }
if (!InheritsInterface($interface, "Node")) {
my $attrImplName = GetImplName($attribute);
- $code .= " transferHiddenDependency(info.Holder(), imp->${attrImplName}(isolatedWorldForIsolate(info.GetIsolate())), jsValue, ${v8ClassName}::eventListenerCacheIndex, info.GetIsolate());\n";
+ my @arguments;
+ if ($implementedBy) {
+ $attrImplName = "${implementedByImplName}::${attrImplName}";
+ push(@arguments, "imp");
+ } else {
+ $attrImplName = "imp->${attrImplName}";
+ }
+ push(@arguments, "isolatedWorldForIsolate(info.GetIsolate())");
+ $code .= " transferHiddenDependency(info.Holder(), ${attrImplName}(" . join(", ", @arguments) . "), jsValue, ${v8ClassName}::eventListenerCacheIndex, info.GetIsolate());\n";
+ }
+ my ($functionName, @arguments) = SetterExpression($interfaceName, $attribute);
+ if ($implementedBy) {
+ $functionName = "${implementedByImplName}::${functionName}";
+ push(@arguments, "imp");
+ } else {
+ $functionName = "imp->${functionName}";
}
if (($interfaceName eq "Window" or $interfaceName eq "WorkerGlobalScope") and $attribute->name eq "onerror") {
AddToImplIncludes("bindings/v8/V8ErrorHandler.h");
- $code .= " imp->set$implSetterFunctionName(V8EventListenerList::findOrCreateWrapper<V8ErrorHandler>(jsValue, true, info.GetIsolate()), isolatedWorldForIsolate(info.GetIsolate()));\n";
+ push(@arguments, "V8EventListenerList::findOrCreateWrapper<V8ErrorHandler>(jsValue, true, info.GetIsolate())");
} else {
- $code .= " imp->set$implSetterFunctionName(V8EventListenerList::getEventListener(jsValue, true, ListenerFindOrCreate), isolatedWorldForIsolate(info.GetIsolate()));\n";
+ push(@arguments, "V8EventListenerList::getEventListener(jsValue, true, ListenerFindOrCreate)");
}
+ push(@arguments, "isolatedWorldForIsolate(info.GetIsolate())");
+ $code .= " ${functionName}(" . join(", ", @arguments) . ");\n";
} else {
my ($functionName, @arguments) = SetterExpression($interfaceName, $attribute);
push(@arguments, $expression);
« no previous file with comments | « no previous file | Source/bindings/tests/idls/TestImplements.idl » ('j') | Source/core/events/EventTarget.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698