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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
5 # Copyright (C) 2006 Apple Computer, Inc. 5 # Copyright (C) 2006 Apple Computer, Inc.
6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc.
7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved.
9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 # Copyright (C) 2012 Ericsson AB. All rights reserved. 10 # Copyright (C) 2012 Ericsson AB. All rights reserved.
(...skipping 6257 matching lines...) Expand 10 before | Expand all | Expand 10 after
6268 } 6268 }
6269 } 6269 }
6270 return @checks; 6270 return @checks;
6271 } 6271 }
6272 6272
6273 sub GenerateReflectOnlyCheck 6273 sub GenerateReflectOnlyCheck
6274 { 6274 {
6275 my $extendedAttributes = shift; 6275 my $extendedAttributes = shift;
6276 my $indent = shift; 6276 my $indent = shift;
6277 6277
6278 my $knownValueString = $extendedAttributes->{"ReflectOnly"}; 6278 my @knownValues = split(quotemeta("|"), $extendedAttributes->{"ReflectOnly"} );
6279 my @knownValues = split(quotemeta("|"), $knownValueString);
6280 6279
6281 my $missingValueDefault = $extendedAttributes->{"ReflectMissing"}; 6280 my $missingValueDefault = $extendedAttributes->{"ReflectMissing"};
6282 if ($missingValueDefault) { 6281 if ($missingValueDefault) {
6283 if (!grep { $_ eq $missingValueDefault } @knownValues) { 6282 if (!grep { $_ eq $missingValueDefault } @knownValues) {
6284 die "Missing attribute value is not a known value " . $missingValueD efault; 6283 die "Missing attribute value is not a known value " . $missingValueD efault;
6285 } 6284 }
6286 $missingValueDefault = "resultValue = \"${missingValueDefault}\""; 6285 $missingValueDefault = "resultValue = \"${missingValueDefault}\"";
6287 } else { 6286 } else {
6288 $missingValueDefault = ""; 6287 $missingValueDefault = "";
6289 } 6288 }
6290 6289
6291 my $invalidValueDefault = $extendedAttributes->{"ReflectInvalid"}; 6290 my $invalidValueDefault = $extendedAttributes->{"ReflectInvalid"};
6292 if ($invalidValueDefault) { 6291 if ($invalidValueDefault) {
6293 if (!grep { $_ eq $invalidValueDefault } @knownValues) { 6292 if (!grep { $_ eq $invalidValueDefault } @knownValues) {
6294 die "Invalid attribute value is not a known value " . $invalidValueD efault; 6293 die "Invalid attribute value is not a known value " . $invalidValueD efault;
6295 } 6294 }
6296 $invalidValueDefault = "\"${invalidValueDefault}\""; 6295 $invalidValueDefault = "resultValue = \"${invalidValueDefault}\"";
6297 } else { 6296 } else {
6298 $invalidValueDefault = "\"\""; 6297 $invalidValueDefault = "resultValue = \"\"";
6298 }
6299
6300 my @normalizeAttributeCode = ();
6301
6302 # Attributes without a value (div empty-attribute>) can be
6303 # separately reflected to some value.
6304
6305 my $isAttributeValueMissing = "resultValue.isEmpty()";
6306 my $emptyValueDefault = $extendedAttributes->{"ReflectEmpty"};
6307 if ($emptyValueDefault) {
6308 $isAttributeValueMissing = "resultValue.isNull()";
6309 push(@normalizeAttributeCode, "${indent}} else if (resultValue.isEmpty() ) {");
6310 push(@normalizeAttributeCode, "${indent} resultValue = \"$emptyValueD efault\";");
6299 } 6311 }
6300 6312
6301 # Attribute is limited to only known values: check that the attribute 6313 # Attribute is limited to only known values: check that the attribute
6302 # value is one of those..and if not, set it to the empty string. 6314 # value is one of those..and if not, set it to the empty string.
6303 # ( http://www.whatwg.org/specs/web-apps/current-work/#limited-to-only-known -values ) 6315 # ( http://www.whatwg.org/specs/web-apps/current-work/#limited-to-only-known -values )
6304 # 6316 #
6305 my @normalizeAttributeCode = ();
6306 my $code = "";
6307 foreach my $knownValue (@knownValues) { 6317 foreach my $knownValue (@knownValues) {
6308 push(@normalizeAttributeCode, "${indent}} else if (equalIgnoringCase(res ultValue, \"$knownValue\")) {"); 6318 push(@normalizeAttributeCode, "${indent}} else if (equalIgnoringCase(res ultValue, \"$knownValue\")) {");
6309 push(@normalizeAttributeCode, "${indent} resultValue = \"$knownValue\ ";"); 6319 push(@normalizeAttributeCode, "${indent} resultValue = \"$knownValue\ ";");
6310 } 6320 }
6311 my $normalizeAttributeValue = join("\n", @normalizeAttributeCode); 6321 my $normalizeAttributeValue = join("\n", @normalizeAttributeCode);
6312 $code .= <<END; 6322 my $code .= <<END;
6313 ${indent}if (resultValue.isEmpty()) { 6323 ${indent}if ($isAttributeValueMissing) {
6314 ${indent} $missingValueDefault; 6324 ${indent} $missingValueDefault;
6315 ${normalizeAttributeValue} 6325 ${normalizeAttributeValue}
6316 ${indent}} else { 6326 ${indent}} else {
6317 ${indent} resultValue = $invalidValueDefault; 6327 ${indent} $invalidValueDefault;
6318 ${indent}} 6328 ${indent}}
6319 END 6329 END
6320 return "${code}"; 6330 return "${code}";
6321 } 6331 }
6322 6332
6323 sub ExtendedAttributeContains 6333 sub ExtendedAttributeContains
6324 { 6334 {
6325 my $extendedAttributeValue = shift; 6335 my $extendedAttributeValue = shift;
6326 return 0 unless $extendedAttributeValue; 6336 return 0 unless $extendedAttributeValue;
6327 my $keyword = shift; 6337 my $keyword = shift;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
6386 if ($parameter->type eq "SerializedScriptValue") { 6396 if ($parameter->type eq "SerializedScriptValue") {
6387 return 1; 6397 return 1;
6388 } elsif (IsIntegerType($parameter->type)) { 6398 } elsif (IsIntegerType($parameter->type)) {
6389 return 1; 6399 return 1;
6390 } 6400 }
6391 } 6401 }
6392 return 0; 6402 return 0;
6393 } 6403 }
6394 6404
6395 1; 6405 1;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698