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

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

Issue 127903002: Empty reflected attributes and string literals in extended attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: docstring formatting Created 6 years, 11 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 | « Source/bindings/IDLExtendedAttributes.txt ('k') | Source/bindings/scripts/idl_parser.pm » ('j') | 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 1e976f8246b656e81c06282074317af31902030b..766bfb829a96604d1a16b5b3cce8a5204a51725d 100644
--- a/Source/bindings/scripts/code_generator_v8.pm
+++ b/Source/bindings/scripts/code_generator_v8.pm
@@ -6275,13 +6275,13 @@ sub GenerateReflectOnlyCheck
my $extendedAttributes = shift;
my $indent = shift;
- my $knownValueString = $extendedAttributes->{"ReflectOnly"};
- my @knownValues = split(quotemeta("|"), $knownValueString);
+ my $attributeValueList = $extendedAttributes->{"ReflectOnly"};
+ my @knownValues = split(quotemeta("|"), $attributeValueList);
my $missingValueDefault = $extendedAttributes->{"ReflectMissing"};
if ($missingValueDefault) {
if (!grep { $_ eq $missingValueDefault } @knownValues) {
- die "Missing attribute value is not a known value " . $missingValueDefault;
+ die "The [ReflectMissing] attribute value '${missingValueDefault}' is not a known value ";
}
$missingValueDefault = "resultValue = \"${missingValueDefault}\"";
} else {
@@ -6291,30 +6291,44 @@ sub GenerateReflectOnlyCheck
my $invalidValueDefault = $extendedAttributes->{"ReflectInvalid"};
if ($invalidValueDefault) {
if (!grep { $_ eq $invalidValueDefault } @knownValues) {
- die "Invalid attribute value is not a known value " . $invalidValueDefault;
+ die "The [ReflectInvalid] attribute value '${invalidValueDefault}' is not a known value ";
}
- $invalidValueDefault = "\"${invalidValueDefault}\"";
+ $invalidValueDefault = "resultValue = \"${invalidValueDefault}\"";
} else {
- $invalidValueDefault = "\"\"";
+ $invalidValueDefault = "resultValue = \"\"";
+ }
+
+ my @normalizeAttributeCode = ();
+
+ # Attributes without a value (div empty-attribute>) can be
+ # separately reflected to some value.
+
+ my $isAttributeValueMissing = "resultValue.isEmpty()";
+ my $emptyValueDefault = $extendedAttributes->{"ReflectEmpty"};
+ if ($emptyValueDefault) {
+ if (!grep { $_ eq $emptyValueDefault } @knownValues) {
+ die "The [ReflectEmpty] attribute value '${emptyValueDefault}' is not a known value ";
+ }
+ $isAttributeValueMissing = "resultValue.isNull()";
+ push(@normalizeAttributeCode, "${indent}} else if (resultValue.isEmpty()) {");
+ push(@normalizeAttributeCode, "${indent} resultValue = \"$emptyValueDefault\";");
}
# 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 )
#
- my @normalizeAttributeCode = ();
- my $code = "";
foreach my $knownValue (@knownValues) {
push(@normalizeAttributeCode, "${indent}} else if (equalIgnoringCase(resultValue, \"$knownValue\")) {");
push(@normalizeAttributeCode, "${indent} resultValue = \"$knownValue\";");
}
my $normalizeAttributeValue = join("\n", @normalizeAttributeCode);
- $code .= <<END;
-${indent}if (resultValue.isEmpty()) {
+ my $code .= <<END;
+${indent}if ($isAttributeValueMissing) {
${indent} $missingValueDefault;
${normalizeAttributeValue}
${indent}} else {
-${indent} resultValue = $invalidValueDefault;
+${indent} $invalidValueDefault;
${indent}}
END
return "${code}";
« no previous file with comments | « Source/bindings/IDLExtendedAttributes.txt ('k') | Source/bindings/scripts/idl_parser.pm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698