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

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

Issue 19457002: Make 'any'-typed attributes of events available in isolated worlds (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Properly refactored Created 7 years, 5 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
Index: Source/bindings/scripts/deprecated_code_generator_v8.pm
diff --git a/Source/bindings/scripts/deprecated_code_generator_v8.pm b/Source/bindings/scripts/deprecated_code_generator_v8.pm
index ba06614be71ae0c6d679f3dd411a8aeb3f48eee1..85ea305637d4d7164ab674c977f007c4d250af29 100644
--- a/Source/bindings/scripts/deprecated_code_generator_v8.pm
+++ b/Source/bindings/scripts/deprecated_code_generator_v8.pm
@@ -2650,6 +2650,13 @@ sub GenerateEventConstructor
my $implClassName = GetImplName($interface);
my $v8ClassName = GetV8ClassName($interface);
+ my @anyAttributeNames;
+ foreach my $attribute (@{$interface->attributes}) {
+ if ($attribute->type eq "any") {
+ push(@anyAttributeNames, $attribute->name);
+ }
+ }
+
AddToImplIncludes("bindings/v8/Dictionary.h");
$implementation{nameSpaceInternal}->add(<<END);
static void constructor(const v8::FunctionCallbackInfo<v8::Value>& args)
@@ -2660,29 +2667,47 @@ static void constructor(const v8::FunctionCallbackInfo<v8::Value>& args)
}
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, args[0]);
+END
+
+ foreach my $attrName (@anyAttributeNames) {
+ $implementation{nameSpaceInternal}->add(" v8::Local<v8::Value> ${attrName};\n");
+ }
+
+ $implementation{nameSpaceInternal}->add(<<END);
${implClassName}Init eventInit;
if (args.Length() >= 2) {
V8TRYCATCH_VOID(Dictionary, options, Dictionary(args[1], args.GetIsolate()));
if (!fill${implClassName}Init(eventInit, options))
return;
END
- for (my $index = 0; $index < @{$interface->attributes}; $index++) {
- my $attribute = @{$interface->attributes}[$index];
- if ($attribute->type eq "any") {
- my $attributeName = $attribute->name;
- $implementation{nameSpaceInternal}->add(<<END);
- v8::Local<v8::Value> ${attributeName};
- options.get("${attributeName}", ${attributeName});
- if (!${attributeName}.IsEmpty())
- args.Holder()->SetHiddenValue(V8HiddenPropertyName::${attributeName}(), ${attributeName});
-END
- }
- }
+
+ foreach my $attrName (@anyAttributeNames) {
$implementation{nameSpaceInternal}->add(<<END);
+ options.get("${attrName}", ${attrName});
+ if (!${attrName}.IsEmpty())
+ args.Holder()->SetHiddenValue(V8HiddenPropertyName::${attrName}(), ${attrName});
+END
+ }
+
+ $implementation{nameSpaceInternal}->add(<<END);
}
RefPtr<${implClassName}> event = ${implClassName}::create(type, eventInit);
+END
+
+ if (@anyAttributeNames) {
+ $implementation{nameSpaceInternal}->add(" if (isolatedWorldForIsolate(args.GetIsolate())) {\n");
+ foreach my $attrName (@anyAttributeNames) {
+ my $setter = "setSerialized" . FirstLetterToUpperCase($attrName);
+ $implementation{nameSpaceInternal}->add(<<END);
+ if (!${attrName}.IsEmpty())
+ event->${setter}(SerializedScriptValue::createSwallowExceptions(${attrName}, args.GetIsolate()));
abarth-chromium 2013/07/17 23:06:44 createSwallowExceptions -> createAndSwallowExcepti
adamk 2013/07/17 23:45:10 Done.
+END
+ }
+ $implementation{nameSpaceInternal}->add(" }\n\n");
+ }
+ $implementation{nameSpaceInternal}->add(<<END);
v8::Handle<v8::Object> wrapper = args.Holder();
V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(event.release(), &${v8ClassName}::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent);
v8SetReturnValue(args, wrapper);
@@ -2704,12 +2729,10 @@ END
END
}
- for (my $index = 0; $index < @{$interface->attributes}; $index++) {
- my $attribute = @{$interface->attributes}[$index];
+ foreach my $attribute (@{$interface->attributes}) {
if ($attribute->extendedAttributes->{"InitializedByEventConstructor"}) {
- my $attributeName = $attribute->name;
- my $attributeType = $attribute->type;
- if (not ($attribute->type eq "any")) {
+ if ($attribute->type ne "any") {
+ my $attributeName = $attribute->name;
$code .= " options.get(\"$attributeName\", eventInit.$attributeName);\n";
}
}

Powered by Google App Engine
This is Rietveld 408576698