| 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 1f38d7fa439d5c5700fc55d0e031d6f1f6f6d393..71837ed49d99caeeeead0f3e0ebc8e23aeff3cfa 100644
|
| --- a/Source/bindings/scripts/code_generator_v8.pm
|
| +++ b/Source/bindings/scripts/code_generator_v8.pm
|
| @@ -169,6 +169,16 @@ my %primitiveTypeHash = ("Date" => 1,
|
| "double" => 1,
|
| );
|
|
|
| +my %integerTypeHash = ("byte" => 1,
|
| + "octet" => 1,
|
| + "short" => 1,
|
| + "long" => 1,
|
| + "long long" => 1,
|
| + "unsigned short" => 1,
|
| + "unsigned long" => 1,
|
| + "unsigned long long" => 1,
|
| + );
|
| +
|
| my %nonWrapperTypes = ("CompareHow" => 1,
|
| "Dictionary" => 1,
|
| "EventListener" => 1,
|
| @@ -1019,7 +1029,7 @@ inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr<${
|
| END
|
|
|
| if (IsConstructorTemplate($interface, "Event")) {
|
| - $header{nameSpaceWebCore}->add("bool fill${implClassName}Init(${implClassName}Init&, const Dictionary&);\n\n");
|
| + $header{nameSpaceWebCore}->add("bool fill${implClassName}Init(${implClassName}Init&, const Dictionary&, ExceptionState&);\n\n");
|
| }
|
| }
|
|
|
| @@ -2863,6 +2873,8 @@ sub GenerateEventConstructor
|
| my $implClassName = GetImplName($interface);
|
| my $v8ClassName = GetV8ClassName($interface);
|
|
|
| + my $constructorRaisesException = $interface->extendedAttributes->{"RaisesException"} && $interface->extendedAttributes->{"RaisesException"} eq "Constructor";
|
| +
|
| my @anyAttributeNames;
|
| my @serializableAnyAttributeNames;
|
| foreach my $attribute (@{$interface->attributes}) {
|
| @@ -2895,8 +2907,11 @@ END
|
| ${implClassName}Init eventInit;
|
| if (info.Length() >= 2) {
|
| V8TRYCATCH_VOID(Dictionary, options, Dictionary(info[1], info.GetIsolate()));
|
| - if (!fill${implClassName}Init(eventInit, options))
|
| + ExceptionState exceptionState(info.Holder(), info.GetIsolate());
|
| + if (!fill${implClassName}Init(eventInit, options, exceptionState)) {
|
| + exceptionState.throwIfNeeded();
|
| return;
|
| + }
|
| END
|
|
|
| # Store 'any'-typed properties on the wrapper to avoid leaking them between isolated worlds.
|
| @@ -2910,10 +2925,27 @@ END
|
|
|
| $implementation{nameSpaceInternal}->add(<<END);
|
| }
|
| +END
|
|
|
| - RefPtr<${implClassName}> event = ${implClassName}::create(type, eventInit);
|
| + my $exceptionStateArgument = "";
|
| + if ($constructorRaisesException) {
|
| + ${exceptionStateArgument} = ", exceptionState";
|
| + $implementation{nameSpaceInternal}->add(<<END);
|
| + ExceptionState exceptionState(info.Holder(), info.GetIsolate());
|
| +END
|
| + }
|
| +
|
| + $implementation{nameSpaceInternal}->add(<<END);
|
| + RefPtr<${implClassName}> event = ${implClassName}::create(type, eventInit${exceptionStateArgument});
|
| END
|
|
|
| + if ($constructorRaisesException) {
|
| + $implementation{nameSpaceInternal}->add(<<END);
|
| + if (exceptionState.throwIfNeeded())
|
| + return;
|
| +END
|
| + }
|
| +
|
| if (@serializableAnyAttributeNames) {
|
| # If we're in an isolated world, create a SerializedScriptValue and store it in the event for
|
| # later cloning if the property is accessed from another world.
|
| @@ -2939,14 +2971,14 @@ END
|
|
|
| my $code = "";
|
| $code .= <<END;
|
| -bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary& options)
|
| +bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary& options, ExceptionState& exceptionState)
|
| {
|
| END
|
|
|
| if ($interface->parent) {
|
| my $interfaceBase = $interface->parent;
|
| $code .= <<END;
|
| - if (!fill${interfaceBase}Init(eventInit, options))
|
| + if (!fill${interfaceBase}Init(eventInit, options, exceptionState))
|
| return false;
|
|
|
| END
|
| @@ -2958,12 +2990,45 @@ END
|
| my $attributeName = $attribute->name;
|
| my $attributeImplName = GetImplName($attribute);
|
| my $deprecation = $attribute->extendedAttributes->{"DeprecateAs"};
|
| - my $dictionaryGetter = "options.get(\"$attributeName\", eventInit.$attributeImplName)";
|
| +
|
| + my $typeNameArgument = "";
|
| + my $nullableArgument = "";
|
| + my $integerConversionArgument = "";
|
| +
|
| + # Construct the arguments to the corresponding Dictionary.convert() method.
|
| + if ($attribute->extendedAttributes->{"EnforceRange"}) {
|
| + $integerConversionArgument = ", EnforceRange";
|
| + } elsif ($attribute->extendedAttributes->{"Clamp"}) {
|
| + $integerConversionArgument = ", Clamp";
|
| + } elsif (IsIntegerType($attribute->type)) {
|
| + $integerConversionArgument = ", NormalConversion";
|
| + } elsif ($attribute->type eq "boolean" || $attribute->type eq "double") {
|
| + ;
|
| + } elsif ($attribute->type eq "DOMString" || IsEnumType($attribute->type) || IsCallbackFunctionType($attribute->type)) {
|
| + ;
|
| + } elsif ($attribute->isNullable) {
|
| + $nullableArgument = ", true";
|
| + $typeNameArgument = ", \"" . $attribute->type . "\"";
|
| + } else {
|
| + $nullableArgument = ", false";
|
| + $typeNameArgument = ", \"" . $attribute->type . "\"";
|
| + }
|
| + if ($typeNameArgument eq ", \"object\"") {
|
| + # Too generic, leave as empty for equally good error message.
|
| + $typeNameArgument = ", \"\"";
|
| + }
|
| +
|
| + my $dictionaryGetter = "options.convert(\"$attributeName\"${typeNameArgument}${nullableArgument}${integerConversionArgument}, eventInit.$attributeImplName, exceptionState)";
|
| if ($attribute->extendedAttributes->{"DeprecateAs"}) {
|
| - $code .= " if ($dictionaryGetter)\n";
|
| - $code .= " " . GenerateDeprecationNotification($attribute->extendedAttributes->{"DeprecateAs"});
|
| + $code .= " if ($dictionaryGetter) {\n";
|
| + $code .= " if (options.hasProperty(\"$attributeName\"))\n";
|
| + $code .= " " . GenerateDeprecationNotification($attribute->extendedAttributes->{"DeprecateAs"});
|
| + $code .= " } else {\n";
|
| + $code .= " return false;\n";
|
| + $code .= " }\n";
|
| } else {
|
| - $code .= " $dictionaryGetter;\n";
|
| + $code .= " if (!$dictionaryGetter)\n";
|
| + $code .= " return false;\n";
|
| }
|
| }
|
| }
|
| @@ -5942,6 +6007,14 @@ sub IsPrimitiveType
|
| return 0;
|
| }
|
|
|
| +sub IsIntegerType
|
| +{
|
| + my $type = shift;
|
| +
|
| + return 1 if $integerTypeHash{$type};
|
| + return 0;
|
| +}
|
| +
|
| sub IsCallbackFunctionType
|
| {
|
| my $type = shift;
|
|
|