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 671aae9aac94b806cbf22f93d6253c6a150f9abd..6f073e9837106799d60164e5f8a8810fa4acaf51 100644 |
--- a/Source/bindings/scripts/code_generator_v8.pm |
+++ b/Source/bindings/scripts/code_generator_v8.pm |
@@ -1508,7 +1508,7 @@ END |
$code .= " Element* imp = V8Element::toNative(info.Holder());\n"; |
if ($attribute->extendedAttributes->{"ReflectOnly"}) { |
$code .= " String resultValue = ${getterExpression};\n"; |
- $code .= GenerateReflectOnlyCheck($attribute->extendedAttributes->{"ReflectOnly"}, " "); |
+ $code .= GenerateReflectOnlyCheck($attribute->extendedAttributes, " "); |
$getterExpression = "resultValue"; |
} |
$code .= " v8SetReturnValueString(info, ${getterExpression}, info.GetIsolate());\n"; |
@@ -5704,7 +5704,7 @@ sub NativeToJSValue |
if ($type eq "DOMString" && $extendedAttributes->{"ReflectOnly"}) { |
my $code = "${indent}String resultValue = ${nativeValue};\n"; |
- $code .= GenerateReflectOnlyCheck($extendedAttributes->{"ReflectOnly"}, ${indent}); |
+ $code .= GenerateReflectOnlyCheck($extendedAttributes, ${indent}); |
return "${code}${indent}v8SetReturnValueString(${getCallbackInfo}, resultValue, $getIsolate);" if $isReturnValue; |
return "${code}$indent$receiver resultValue"; |
} |
@@ -6258,11 +6258,32 @@ sub GenerateCompileTimeCheckForEnumsIfNeeded |
sub GenerateReflectOnlyCheck |
{ |
- my $knownValueString = shift; |
+ my $extendedAttributes = shift; |
my $indent = shift; |
+ my $knownValueString = $extendedAttributes->{"ReflectOnly"}; |
my @knownValues = split(quotemeta("|"), $knownValueString); |
+ my $missingValueDefault = $extendedAttributes->{"ReflectMissing"}; |
+ if ($missingValueDefault) { |
+ if (!grep { $_ eq $missingValueDefault } @knownValues) { |
+ die "Missing attribute value is not a known value " . $missingValueDefault; |
+ } |
+ $missingValueDefault = "resultValue = \"${missingValueDefault}\""; |
+ } else { |
+ $missingValueDefault = ""; |
+ } |
+ |
+ my $invalidValueDefault = $extendedAttributes->{"ReflectInvalid"}; |
+ if ($invalidValueDefault) { |
+ if (!grep { $_ eq $invalidValueDefault } @knownValues) { |
+ die "Invalid attribute value is not a known value " . $invalidValueDefault; |
+ } |
+ $invalidValueDefault = "\"${invalidValueDefault}\""; |
+ } else { |
+ $invalidValueDefault = "\"\""; |
+ } |
+ |
# Attribute is limited to only known values: check that the attribute |
# value is one of those..and if not, set it to the empty string. |
# ( http://www.whatwg.org/specs/web-apps/current-work/#limited-to-only-known-values ) |
@@ -6276,10 +6297,10 @@ sub GenerateReflectOnlyCheck |
my $normalizeAttributeValue = join("\n", @normalizeAttributeCode); |
$code .= <<END; |
${indent}if (resultValue.isEmpty()) { |
-${indent} ; |
+${indent} $missingValueDefault; |
${normalizeAttributeValue} |
${indent}} else { |
-${indent} resultValue = ""; |
+${indent} resultValue = $invalidValueDefault; |
${indent}} |
END |
return "${code}"; |