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

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: 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 | no next file » | no next file with comments »
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 a0db395f7a486008d6ec09599360ebeb4fdf4743..b5e5a902a4f68871187bf3313a6d8d1e0b71116d 100644
--- a/Source/bindings/scripts/code_generator_v8.pm
+++ b/Source/bindings/scripts/code_generator_v8.pm
@@ -1635,8 +1635,16 @@ END
} elsif ($attribute->type eq "EventHandler") {
AddToImplIncludes("bindings/v8/V8AbstractEventListener.h");
my $getterFunc = ToMethodName($attribute->name);
+ my $getterString;
# FIXME: Pass the main world ID for main-world-only getters.
- $code .= " EventListener* jsValue = imp->${getterFunc}(isolatedWorldForIsolate(info.GetIsolate()));\n";
+ my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"};
+ if ($implementedBy) {
+ my $implementedByImplName = GetImplNameFromImplementedBy($implementedBy);
+ $getterString = "${implementedByImplName}::${getterFunc}(imp, isolatedWorldForIsolate(info.GetIsolate()))";
+ } else {
+ $getterString = "imp->${getterFunc}(isolatedWorldForIsolate(info.GetIsolate()))";
+ }
+ $code .= " EventListener* jsValue = ${getterString};\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");
@@ -1955,15 +1963,30 @@ END
if ($attribute->type eq "EventHandler") {
my $implSetterFunctionName = FirstLetterToUpperCase($attrName);
- if (!InheritsInterface($interface, "Node")) {
- my $attrImplName = GetImplName($attribute);
- $code .= " transferHiddenDependency(info.Holder(), imp->${attrImplName}(isolatedWorldForIsolate(info.GetIsolate())), jsValue, ${v8ClassName}::eventListenerCacheIndex, info.GetIsolate());\n";
- }
- 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";
+ my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"};
+ if ($implementedBy) {
+ my $implementedByImplName = GetImplNameFromImplementedBy($implementedBy);
+ if (!InheritsInterface($interface, "Node")) {
+ my $attrImplName = GetImplName($attribute);
+ $code .= " transferHiddenDependency(info.Holder(), ${implementedByImplName}::${attrImplName}(imp, isolatedWorldForIsolate(info.GetIsolate())), jsValue, ${v8ClassName}::eventListenerCacheIndex, info.GetIsolate());\n";
+ }
+ if (($interfaceName eq "Window" or $interfaceName eq "WorkerGlobalScope") and $attribute->name eq "onerror") {
+ AddToImplIncludes("bindings/v8/V8ErrorHandler.h");
+ $code .= " ${implementedByImplName}::set$implSetterFunctionName(imp, V8EventListenerList::findOrCreateWrapper<V8ErrorHandler>(jsValue, true, info.GetIsolate()), isolatedWorldForIsolate(info.GetIsolate()));\n";
+ } else {
+ $code .= " ${implementedByImplName}::set$implSetterFunctionName(imp, V8EventListenerList::getEventListener(jsValue, true, ListenerFindOrCreate), isolatedWorldForIsolate(info.GetIsolate()));\n";
+ }
} else {
Nils Barth (inactive) 2013/10/24 02:41:39 You might be able to avoid having multiple branche
- $code .= " imp->set$implSetterFunctionName(V8EventListenerList::getEventListener(jsValue, true, ListenerFindOrCreate), isolatedWorldForIsolate(info.GetIsolate()));\n";
+ if (!InheritsInterface($interface, "Node")) {
Nils Barth (inactive) 2013/10/24 02:41:39 I think you can make this section simpler by havin
+ my $attrImplName = GetImplName($attribute);
+ $code .= " transferHiddenDependency(info.Holder(), imp->${attrImplName}(isolatedWorldForIsolate(info.GetIsolate())), jsValue, ${v8ClassName}::eventListenerCacheIndex, info.GetIsolate());\n";
+ }
+ 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";
+ } else {
+ $code .= " imp->set$implSetterFunctionName(V8EventListenerList::getEventListener(jsValue, true, ListenerFindOrCreate), isolatedWorldForIsolate(info.GetIsolate()));\n";
+ }
}
} else {
my ($functionName, @arguments) = SetterExpression($interfaceName, $attribute);
« 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