Bug 149331

Summary: [WebIDL] Specify default parameter values where it is useful
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: DOMAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, commit-queue, darin, m.goleb+bugzilla, rniwa, webkit-bug-importer
Priority: P2 Keywords: InRadar, WebExposed
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=148582
Bug Depends on: 149263    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch none

Chris Dumez
Reported 2015-09-17 20:16:45 PDT
Specify default parameter values where it is useful, that is to say where undefined would be converted to something else than the default value otherwise.
Attachments
Patch (33.67 KB, patch)
2015-09-17 22:15 PDT, Chris Dumez
no flags
Patch (33.57 KB, patch)
2015-09-19 16:55 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2015-09-17 20:17:08 PDT
Chris Dumez
Comment 2 2015-09-17 22:15:29 PDT
Darin Adler
Comment 3 2015-09-18 09:39:06 PDT
Comment on attachment 261489 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=261489&action=review > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3387 > + push(@$outputArray, " $name = String(ASCIILiteral(" . $parameter->default . "));\n"); Why is the String() needed here? > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3389 > + push(@$outputArray, " $name = exec->uncheckedArgument($argsIndex).toString(exec)->value(exec);\n"); Why did you remove the early return when toString had an exception before calling value that the old code had? > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3396 > + push(@$outputArray, " auto* ${name}String = ${argValue}.toString(exec);\n"); > + push(@$outputArray, " auto& $name = ${name}String->value(exec);\n"); Same question here.
Chris Dumez
Comment 4 2015-09-18 10:41:46 PDT
Comment on attachment 261489 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=261489&action=review >> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3387 >> + push(@$outputArray, " $name = String(ASCIILiteral(" . $parameter->default . "));\n"); > > Why is the String() needed here? iirc, the compiler did not let me have different types (literal vs String) on both sides on the ternary but I can try without again. >> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3389 >> + push(@$outputArray, " $name = exec->uncheckedArgument($argsIndex).toString(exec)->value(exec);\n"); > > Why did you remove the early return when toString had an exception before calling value that the old code had? I believe this was a bug. This is inconsistent with how we usually convert String in the bindings. In regular cases, we do .toString(exec)->value(exec) then do the exception check. However, we were doing it differently in the string enumeration case only which does not make much sense to me. If JSString::value() throws an exception, I think it makes sense to do the exception check after the call the value() as well. At the very least, it is consistent with how we usually convert strings.
Chris Dumez
Comment 5 2015-09-18 10:58:01 PDT
Comment on attachment 261489 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=261489&action=review >>> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3389 >>> + push(@$outputArray, " $name = exec->uncheckedArgument($argsIndex).toString(exec)->value(exec);\n"); >> >> Why did you remove the early return when toString had an exception before calling value that the old code had? > > I believe this was a bug. This is inconsistent with how we usually convert String in the bindings. In regular cases, we do .toString(exec)->value(exec) then do the exception check. However, we were doing it differently in the string enumeration case only which does not make much sense to me. If JSString::value() throws an exception, I think it makes sense to do the exception check after the call the value() as well. At the very least, it is consistent with how we usually convert strings. I have just talked to Geoff about this: 1. Calling toString(exec)->value(exec) is safe because toString() will return an empty string (not null) in case of exception. 2. We should do an exception check after the call to value(exec) because it can throw in case it runs out of memory.
Darin Adler
Comment 6 2015-09-19 15:43:41 PDT
Comment on attachment 261489 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=261489&action=review >>> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3387 >>> + push(@$outputArray, " $name = String(ASCIILiteral(" . $parameter->default . "));\n"); >> >> Why is the String() needed here? > > iirc, the compiler did not let me have different types (literal vs String) on both sides on the ternary but I can try without again. I don’t see a ternary. Maybe you had that in an earlier version.
Chris Dumez
Comment 7 2015-09-19 16:20:38 PDT
Comment on attachment 261489 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=261489&action=review >>>> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3387 >>>> + push(@$outputArray, " $name = String(ASCIILiteral(" . $parameter->default . "));\n"); >>> >>> Why is the String() needed here? >> >> iirc, the compiler did not let me have different types (literal vs String) on both sides on the ternary but I can try without again. > > I don’t see a ternary. Maybe you had that in an earlier version. Oh right, this iteration no longer has a ternary, sorry. I'll fix before landing.
Chris Dumez
Comment 8 2015-09-19 16:55:32 PDT
WebKit Commit Bot
Comment 9 2015-09-19 17:45:44 PDT
Comment on attachment 261591 [details] Patch Clearing flags on attachment: 261591 Committed r190021: <http://trac.webkit.org/changeset/190021>
WebKit Commit Bot
Comment 10 2015-09-19 17:45:49 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.