<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[204043] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/204043">204043</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-08-02 14:44:27 -0700 (Tue, 02 Aug 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WebIDL] Extend new overload resolution algorithm support to constructors
https://bugs.webkit.org/show_bug.cgi?id=160455

Reviewed by Ryosuke Niwa.

Source/WebCore:

Extend new overload resolution algorithm support (added in <a href="http://trac.webkit.org/projects/webkit/changeset/204028">r204028</a>) to
constructors as well. It was only used for operations. Remove code that
is now dead from the bindings generator.

We now share the same code of generating the overload resolution code
for operations and constructors.

No new tests, rebaselined existing tests.

* bindings/scripts/CodeGenerator.pm:
(LinkOverloadedFunctions):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateOverloadedFunctionOrConstructor):
(GenerateImplementation):
(GenerateConstructorDefinitions):
(GenerateConstructorDefinition):
(GetFunctionLength): Deleted.
(LengthOfLongestFunctionParameterList): Deleted.
(GetNativeTypeForConversions): Deleted.
(GetGnuVTableNameForInterface): Deleted.
(GetGnuMangledNameForInterface): Deleted.
(GetGnuVTableOffsetForType): Deleted.
(GenerateConstructorHelperMethods): Deleted.
* bindings/scripts/IDLParser.pm:
(applyExtendedAttributeList): Deleted.
* bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
(WebCore::JSTestOverloadedConstructorsConstructor::construct):
* bindings/scripts/test/TestOverloadedConstructors.idl:

LayoutTests:

Update / rebaseline existing test as we now provide slightly different
exception messages when given bad overloaded constructor parameters.

* fast/canvas/canvas-imageData-expected.txt:
* fast/canvas/script-tests/canvas-imageData.js:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastcanvascanvasimageDataexpectedtxt">trunk/LayoutTests/fast/canvas/canvas-imageData-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcanvasscripttestscanvasimageDatajs">trunk/LayoutTests/fast/canvas/script-tests/canvas-imageData.js</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorpm">trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsIDLParserpm">trunk/Source/WebCore/bindings/scripts/IDLParser.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestOverloadedConstructorscpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestTestOverloadedConstructorsidl">trunk/Source/WebCore/bindings/scripts/test/TestOverloadedConstructors.idl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (204042 => 204043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-08-02 21:33:36 UTC (rev 204042)
+++ trunk/LayoutTests/ChangeLog        2016-08-02 21:44:27 UTC (rev 204043)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-08-02  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        [WebIDL] Extend new overload resolution algorithm support to constructors
+        https://bugs.webkit.org/show_bug.cgi?id=160455
+
+        Reviewed by Ryosuke Niwa.
+
+        Update / rebaseline existing test as we now provide slightly different
+        exception messages when given bad overloaded constructor parameters.
+
+        * fast/canvas/canvas-imageData-expected.txt:
+        * fast/canvas/script-tests/canvas-imageData.js:
+
</ins><span class="cx"> 2016-08-02  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Marking two media tests as flaky crashes on ios-simulator-wk2
</span></span></pre></div>
<a id="trunkLayoutTestsfastcanvascanvasimageDataexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/canvas/canvas-imageData-expected.txt (204042 => 204043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/canvas/canvas-imageData-expected.txt        2016-08-02 21:33:36 UTC (rev 204042)
+++ trunk/LayoutTests/fast/canvas/canvas-imageData-expected.txt        2016-08-02 21:44:27 UTC (rev 204043)
</span><span class="lines">@@ -14,20 +14,20 @@
</span><span class="cx"> PASS new ImageData(20, -20) threw exception TypeError: Type error.
</span><span class="cx"> PASS new ImageData(null, 20) threw exception IndexSizeError (DOM Exception 1): The index is not in the allowed range..
</span><span class="cx"> PASS new ImageData(32768, 32768) threw exception TypeError: Type error.
</span><del>-PASS new ImageData(null, 20, 20) threw exception TypeError: Type error.
-PASS new ImageData(imageData, 20, 20) threw exception TypeError: Type error.
</del><ins>+PASS new ImageData(null, 20, 20) threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
+PASS new ImageData(imageData, 20, 20) threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
</ins><span class="cx"> PASS new ImageData(imageData, 0) threw exception IndexSizeError (DOM Exception 1): The index is not in the allowed range..
</span><del>-PASS new ImageData(imageData, 20, 0) threw exception TypeError: Type error.
-PASS new ImageData(imageData, 0, 20) threw exception TypeError: Type error.
-PASS new ImageData(imageData, 10, 5) threw exception TypeError: Type error.
</del><ins>+PASS new ImageData(imageData, 20, 0) threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
+PASS new ImageData(imageData, 0, 20) threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
+PASS new ImageData(imageData, 10, 5) threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
</ins><span class="cx"> PASS new ImageData(imageData.data, 10, 5) threw exception IndexSizeError (DOM Exception 1): The index is not in the allowed range..
</span><span class="cx"> PASS new ImageData(imageData.data, -10, 5) threw exception InvalidStateError (DOM Exception 11): The object is in an invalid state..
</span><span class="cx"> PASS new ImageData(imageData.data, 10, -10) threw exception IndexSizeError (DOM Exception 1): The index is not in the allowed range..
</span><span class="cx"> PASS new ImageData(new Uint8ClampedArray([1,2,3,4,5,6,7,8]),536870913,2); threw exception InvalidStateError (DOM Exception 11): The object is in an invalid state..
</span><del>-PASS new ImageData({},2,2); threw exception TypeError: Type error.
-PASS new ImageData(undefined,2,2); threw exception TypeError: Type error.
-PASS new ImageData(&quot;none&quot;,2,2); threw exception TypeError: Type error.
-PASS new ImageData(0,2,2); threw exception TypeError: Type error.
</del><ins>+PASS new ImageData({},2,2); threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
+PASS new ImageData(undefined,2,2); threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
+PASS new ImageData(&quot;none&quot;,2,2); threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
+PASS new ImageData(0,2,2); threw exception TypeError: Argument 1 ('data') to the ImageData constructor must be an instance of Uint8ClampedArray.
</ins><span class="cx"> PASS new ImageData(imageData.data, 32768, 32768) threw exception InvalidStateError (DOM Exception 11): The object is in an invalid state..
</span><span class="cx"> PASS new ImageData(imageData.data, Infinity, Infinity) threw exception IndexSizeError (DOM Exception 1): The index is not in the allowed range..
</span><span class="cx"> PASS new ImageData(imageData.data, NaN, NaN) threw exception IndexSizeError (DOM Exception 1): The index is not in the allowed range..
</span></span></pre></div>
<a id="trunkLayoutTestsfastcanvasscripttestscanvasimageDatajs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/canvas/script-tests/canvas-imageData.js (204042 => 204043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/canvas/script-tests/canvas-imageData.js        2016-08-02 21:33:36 UTC (rev 204042)
+++ trunk/LayoutTests/fast/canvas/script-tests/canvas-imageData.js        2016-08-02 21:44:27 UTC (rev 204043)
</span><span class="lines">@@ -6,33 +6,33 @@
</span><span class="cx"> var imageData = ctx.getImageData(0,0,10,10);
</span><span class="cx"> 
</span><span class="cx"> debug('Test invalid ImageData constructor arguments.')
</span><del>-shouldThrow('new ImageData()', '&quot;TypeError: Not enough arguments&quot;');
-shouldThrow('new ImageData(1)', '&quot;TypeError: Not enough arguments&quot;');
-shouldThrow('new ImageData(new Uint8ClampedArray([1,2,3,4]));', '&quot;TypeError: Not enough arguments&quot;');
-shouldThrow('new ImageData(0, 0)', '&quot;IndexSizeError (DOM Exception 1): The index is not in the allowed range.&quot;');
-shouldThrow('new ImageData(20, 0)', '&quot;IndexSizeError (DOM Exception 1): The index is not in the allowed range.&quot;');
-shouldThrow('new ImageData(0, 20)', '&quot;IndexSizeError (DOM Exception 1): The index is not in the allowed range.&quot;');
-shouldThrow('new ImageData(-20, 20)', '&quot;TypeError: Type error&quot;');
-shouldThrow('new ImageData(20, -20)', '&quot;TypeError: Type error&quot;');
-shouldThrow('new ImageData(null, 20)', '&quot;IndexSizeError (DOM Exception 1): The index is not in the allowed range.&quot;');
-shouldThrow('new ImageData(32768, 32768)', '&quot;TypeError: Type error&quot;');
-shouldThrow('new ImageData(null, 20, 20)', '&quot;TypeError: Type error&quot;');
-shouldThrow('new ImageData(imageData, 20, 20)', '&quot;TypeError: Type error&quot;');
-shouldThrow('new ImageData(imageData, 0)', '&quot;IndexSizeError (DOM Exception 1): The index is not in the allowed range.&quot;');
-shouldThrow('new ImageData(imageData, 20, 0)', '&quot;TypeError: Type error&quot;');
-shouldThrow('new ImageData(imageData, 0, 20)', '&quot;TypeError: Type error&quot;');
-shouldThrow('new ImageData(imageData, 10, 5)', '&quot;TypeError: Type error&quot;');
-shouldThrow('new ImageData(imageData.data, 10, 5)', '&quot;IndexSizeError (DOM Exception 1): The index is not in the allowed range.&quot;');
-shouldThrow('new ImageData(imageData.data, -10, 5)', '&quot;InvalidStateError (DOM Exception 11): The object is in an invalid state.&quot;');
-shouldThrow('new ImageData(imageData.data, 10, -10)', '&quot;IndexSizeError (DOM Exception 1): The index is not in the allowed range.&quot;');
-shouldThrow('new ImageData(new Uint8ClampedArray([1,2,3,4,5,6,7,8]),536870913,2);', '&quot;InvalidStateError (DOM Exception 11): The object is in an invalid state.&quot;');
-shouldThrow('new ImageData({},2,2);', '&quot;TypeError: Type error&quot;');
-shouldThrow('new ImageData(undefined,2,2);', '&quot;TypeError: Type error&quot;');
-shouldThrow('new ImageData(&quot;none&quot;,2,2);', '&quot;TypeError: Type error&quot;');
-shouldThrow('new ImageData(0,2,2);', '&quot;TypeError: Type error&quot;');
-shouldThrow('new ImageData(imageData.data, 32768, 32768)', '&quot;InvalidStateError (DOM Exception 11): The object is in an invalid state.&quot;');
-shouldThrow('new ImageData(imageData.data, Infinity, Infinity)', '&quot;IndexSizeError (DOM Exception 1): The index is not in the allowed range.&quot;');
-shouldThrow('new ImageData(imageData.data, NaN, NaN)', '&quot;IndexSizeError (DOM Exception 1): The index is not in the allowed range.&quot;');
</del><ins>+shouldThrowErrorName('new ImageData()', 'TypeError');
+shouldThrowErrorName('new ImageData(1)', 'TypeError');
+shouldThrowErrorName('new ImageData(new Uint8ClampedArray([1,2,3,4]));', 'TypeError');
+shouldThrowErrorName('new ImageData(0, 0)', 'IndexSizeError');
+shouldThrowErrorName('new ImageData(20, 0)', 'IndexSizeError');
+shouldThrowErrorName('new ImageData(0, 20)', 'IndexSizeError');
+shouldThrowErrorName('new ImageData(-20, 20)', 'TypeError');
+shouldThrowErrorName('new ImageData(20, -20)', 'TypeError');
+shouldThrowErrorName('new ImageData(null, 20)', 'IndexSizeError');
+shouldThrowErrorName('new ImageData(32768, 32768)', 'TypeError');
+shouldThrowErrorName('new ImageData(null, 20, 20)', 'TypeError');
+shouldThrowErrorName('new ImageData(imageData, 20, 20)', 'TypeError');
+shouldThrowErrorName('new ImageData(imageData, 0)', 'IndexSizeError');
+shouldThrowErrorName('new ImageData(imageData, 20, 0)', 'TypeError');
+shouldThrowErrorName('new ImageData(imageData, 0, 20)', 'TypeError');
+shouldThrowErrorName('new ImageData(imageData, 10, 5)', 'TypeError');
+shouldThrowErrorName('new ImageData(imageData.data, 10, 5)', 'IndexSizeError');
+shouldThrowErrorName('new ImageData(imageData.data, -10, 5)', 'InvalidStateError');
+shouldThrowErrorName('new ImageData(imageData.data, 10, -10)', 'IndexSizeError');
+shouldThrowErrorName('new ImageData(new Uint8ClampedArray([1,2,3,4,5,6,7,8]),536870913,2);', 'InvalidStateError');
+shouldThrowErrorName('new ImageData({},2,2);', 'TypeError');
+shouldThrowErrorName('new ImageData(undefined,2,2);', 'TypeError');
+shouldThrowErrorName('new ImageData(&quot;none&quot;,2,2);', 'TypeError');
+shouldThrowErrorName('new ImageData(0,2,2);', 'TypeError');
+shouldThrowErrorName('new ImageData(imageData.data, 32768, 32768)', 'InvalidStateError');
+shouldThrowErrorName('new ImageData(imageData.data, Infinity, Infinity)', 'IndexSizeError');
+shouldThrowErrorName('new ImageData(imageData.data, NaN, NaN)', 'IndexSizeError');
</ins><span class="cx"> debug('');
</span><span class="cx"> 
</span><span class="cx"> debug('Test valid ImageData constructors.')
</span><span class="lines">@@ -61,4 +61,4 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> var imageData2 = new ImageData(100,100);
</span><del>-shouldBeTrue('testTransparentBlack(imageData2.data)');
</del><span class="cx">\ No newline at end of file
</span><ins>+shouldBeTrue('testTransparentBlack(imageData2.data)');
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (204042 => 204043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-08-02 21:33:36 UTC (rev 204042)
+++ trunk/Source/WebCore/ChangeLog        2016-08-02 21:44:27 UTC (rev 204043)
</span><span class="lines">@@ -1,3 +1,39 @@
</span><ins>+2016-08-02  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        [WebIDL] Extend new overload resolution algorithm support to constructors
+        https://bugs.webkit.org/show_bug.cgi?id=160455
+
+        Reviewed by Ryosuke Niwa.
+
+        Extend new overload resolution algorithm support (added in r204028) to
+        constructors as well. It was only used for operations. Remove code that
+        is now dead from the bindings generator.
+
+        We now share the same code of generating the overload resolution code
+        for operations and constructors.
+
+        No new tests, rebaselined existing tests.
+
+        * bindings/scripts/CodeGenerator.pm:
+        (LinkOverloadedFunctions):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateOverloadedFunctionOrConstructor):
+        (GenerateImplementation):
+        (GenerateConstructorDefinitions):
+        (GenerateConstructorDefinition):
+        (GetFunctionLength): Deleted.
+        (LengthOfLongestFunctionParameterList): Deleted.
+        (GetNativeTypeForConversions): Deleted.
+        (GetGnuVTableNameForInterface): Deleted.
+        (GetGnuMangledNameForInterface): Deleted.
+        (GetGnuVTableOffsetForType): Deleted.
+        (GenerateConstructorHelperMethods): Deleted.
+        * bindings/scripts/IDLParser.pm:
+        (applyExtendedAttributeList): Deleted.
+        * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
+        (WebCore::JSTestOverloadedConstructorsConstructor::construct):
+        * bindings/scripts/test/TestOverloadedConstructors.idl:
+
</ins><span class="cx"> 2016-08-02  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Removing IndexedDB WebsiteData can fail for some users.
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (204042 => 204043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm        2016-08-02 21:33:36 UTC (rev 204042)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm        2016-08-02 21:44:27 UTC (rev 204043)
</span><span class="lines">@@ -614,6 +614,13 @@
</span><span class="cx">         $function-&gt;{overloads} = $nameToFunctionsMap{$name};
</span><span class="cx">         $function-&gt;{overloadIndex} = @{$nameToFunctionsMap{$name}};
</span><span class="cx">     }
</span><ins>+
+    my $index = 1;
+    foreach my $constructor (@{$interface-&gt;constructors}) {
+        $constructor-&gt;{overloads} = $interface-&gt;constructors;
+        $constructor-&gt;{overloadIndex} = $index;
+        $index++;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> sub AttributeNameForGetterAndSetter
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (204042 => 204043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-08-02 21:33:36 UTC (rev 204042)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-08-02 21:44:27 UTC (rev 204043)
</span><span class="lines">@@ -1782,14 +1782,20 @@
</span><span class="cx"> 
</span><span class="cx"> # Implements the overload resolution algorithm, as defined in the Web IDL specification:
</span><span class="cx"> # http://heycam.github.io/webidl/#es-overloads
</span><del>-sub GenerateOverloadedFunction
</del><ins>+sub GenerateOverloadedFunctionOrConstructor
</ins><span class="cx"> {
</span><del>-    my ($function, $interface) = @_;
</del><ins>+    my ($function, $interface, $isConstructor) = @_;
</ins><span class="cx">     my %allSets = ComputeEffectiveOverloadSet($function-&gt;{overloads});
</span><span class="cx"> 
</span><del>-    my $kind = $function-&gt;isStatic ? &quot;Constructor&quot; : (OperationShouldBeOnInstance($interface, $function) ? &quot;Instance&quot; : &quot;Prototype&quot;);
</del><span class="cx">     my $interfaceName = $interface-&gt;name;
</span><del>-    my $functionName = &quot;js${interfaceName}${kind}Function&quot; . $codeGenerator-&gt;WK_ucfirst($function-&gt;signature-&gt;name);
</del><ins>+    my $className = &quot;JS$interfaceName&quot;;
+    my $functionName;
+    if ($isConstructor) {
+        $functionName = &quot;construct${className}&quot;;
+    } else {
+        my $kind = $function-&gt;isStatic ? &quot;Constructor&quot; : (OperationShouldBeOnInstance($interface, $function) ? &quot;Instance&quot; : &quot;Prototype&quot;);
+        $functionName = &quot;js${interfaceName}${kind}Function&quot; . $codeGenerator-&gt;WK_ucfirst($function-&gt;signature-&gt;name);
+    }
</ins><span class="cx"> 
</span><span class="cx">     my $generateOverloadCallIfNecessary = sub {
</span><span class="cx">         my ($overload, $condition) = @_;
</span><span class="lines">@@ -1859,8 +1865,12 @@
</span><span class="cx"> 
</span><span class="cx">     my $maxArgCount = LengthOfLongestFunctionParameterList($function-&gt;{overloads});
</span><span class="cx"> 
</span><ins>+    if ($isConstructor) {
+        push(@implContent, &quot;template&lt;&gt; EncodedJSValue JSC_HOST_CALL ${className}Constructor::construct(ExecState* state)\n&quot;);
+    } else {
+        push(@implContent, &quot;EncodedJSValue JSC_HOST_CALL ${functionName}(ExecState* state)\n&quot;);
+    }
</ins><span class="cx">     push(@implContent, &lt;&lt;END);    
</span><del>-EncodedJSValue JSC_HOST_CALL ${functionName}(ExecState* state)
</del><span class="cx"> {
</span><span class="cx">     size_t argsCount = std::min&lt;size_t&gt;($maxArgCount, state-&gt;argumentCount());
</span><span class="cx"> END
</span><span class="lines">@@ -1942,56 +1952,6 @@
</span><span class="cx">     push(@implContent, &quot;}\n\n&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-sub GenerateParametersCheckExpression
-{
-    my $numParameters = shift;
-    my $function = shift;
-
-    my @andExpression = ();
-    push(@andExpression, &quot;argsCount == $numParameters&quot;);
-    my $parameterIndex = 0;
-    my %usedArguments = ();
-    foreach my $parameter (@{$function-&gt;parameters}) {
-        last if $parameterIndex &gt;= $numParameters;
-        my $value = &quot;arg$parameterIndex&quot;;
-        my $type = $parameter-&gt;type;
-
-        if ($codeGenerator-&gt;IsCallbackInterface($parameter-&gt;type)) {
-            # For Callbacks only checks if the value is null or object.
-            if ($codeGenerator-&gt;IsFunctionOnlyCallbackInterface($parameter-&gt;type)) {
-                push(@andExpression, &quot;(${value}.isNull() || ${value}.isFunction())&quot;);
-            } else {
-                push(@andExpression, &quot;(${value}.isNull() || ${value}.isObject())&quot;);
-            }
-            $usedArguments{$parameterIndex} = 1;
-        } elsif ($codeGenerator-&gt;IsDictionaryType($parameter-&gt;type)) {
-            push(@andExpression, &quot;(${value}.isUndefinedOrNull() || ${value}.isObject())&quot;);
-            $usedArguments{$parameterIndex} = 1;
-        } elsif (($codeGenerator-&gt;GetArrayOrSequenceType($type) || $codeGenerator-&gt;IsTypedArrayType($type) || $codeGenerator-&gt;IsWrapperType($type)) &amp;&amp; $type ne &quot;EventListener&quot;) {
-            my $condition = &quot;&quot;;
-
-            if ($parameter-&gt;isNullable) {
-                $condition .= &quot;${value}.isUndefinedOrNull() || &quot;;
-            } elsif ($parameter-&gt;isOptional) {
-                $condition .= &quot;${value}.isUndefined() || &quot;;
-            }
-
-            if ($codeGenerator-&gt;GetArrayOrSequenceType($type)) {
-                # FIXME: Add proper support for T[], T[]?, sequence&lt;T&gt;.
-                $condition .= &quot;(${value}.isObject() &amp;&amp; isJSArray(${value}))&quot;;
-            } else {
-                $condition .= &quot;(${value}.isObject() &amp;&amp; asObject(${value})-&gt;inherits(JS${type}::info()))&quot;;
-            }
-            push(@andExpression, &quot;(&quot; . $condition . &quot;)&quot;);
-            $usedArguments{$parameterIndex} = 1;
-        }
-        $parameterIndex++;
-    }
-    my $res = join(&quot; &amp;&amp; &quot;, @andExpression);
-    $res = &quot;($res)&quot; if @andExpression &gt; 1;
-    return ($res, sort {$a &lt;=&gt; $b} (keys %usedArguments));
-}
-
</del><span class="cx"> # As per Web IDL specification, the length of a function Object is its number of mandatory parameters.
</span><span class="cx"> sub GetFunctionLength
</span><span class="cx"> {
</span><span class="lines">@@ -2016,37 +1976,6 @@
</span><span class="cx">     return $length;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-sub GenerateFunctionParametersCheck
-{
-    my $function = shift;
-
-    my @orExpression = ();
-    my $numParameters = 0;
-    my @neededArguments = ();
-    my $hasVariadic = 0;
-    my $numMandatoryParams = @{$function-&gt;parameters};
-
-    foreach my $parameter (@{$function-&gt;parameters}) {
-        if ($parameter-&gt;isOptional) {
-            my ($expression, @usedArguments) = GenerateParametersCheckExpression($numParameters, $function);
-            push(@orExpression, $expression);
-            push(@neededArguments, @usedArguments);
-            $numMandatoryParams--;
-        }
-        if ($parameter-&gt;isVariadic) {
-            $hasVariadic = 1;
-            last;
-        }
-        $numParameters++;
-    }
-    if (!$hasVariadic) {
-        my ($expression, @usedArguments) = GenerateParametersCheckExpression($numParameters, $function);
-        push(@orExpression, $expression);
-        push(@neededArguments, @usedArguments);
-    }
-    return ($numMandatoryParams, join(&quot; || &quot;, @orExpression), @neededArguments);
-}
-
</del><span class="cx"> sub LengthOfLongestFunctionParameterList
</span><span class="cx"> {
</span><span class="cx">     my ($overloads) = @_;
</span><span class="lines">@@ -3448,7 +3377,7 @@
</span><span class="cx">             push(@implContent, &quot;#endif\n\n&quot;) if $conditional;
</span><span class="cx"> 
</span><span class="cx">             # Generate a function dispatching call to the rest of the overloads.
</span><del>-            GenerateOverloadedFunction($function, $interface) if !$isCustom &amp;&amp; $isOverloaded &amp;&amp; $function-&gt;{overloadIndex} == @{$function-&gt;{overloads}};
</del><ins>+            GenerateOverloadedFunctionOrConstructor($function, $interface, 0) if !$isCustom &amp;&amp; $isOverloaded &amp;&amp; $function-&gt;{overloadIndex} == @{$function-&gt;{overloads}};
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         push(@implContent, $endAppleCopyright) if $inAppleCopyright;
</span><span class="lines">@@ -5185,7 +5114,7 @@
</span><span class="cx">             foreach my $constructor (@constructors) {
</span><span class="cx">                 GenerateConstructorDefinition($outputArray, $className, $protoClassName, $visibleInterfaceName, $interface, $generatingNamedConstructor, $constructor);
</span><span class="cx">             }
</span><del>-            GenerateOverloadedConstructorDefinition($outputArray, $className, $interface);
</del><ins>+            GenerateOverloadedFunctionOrConstructor(@{$interface-&gt;constructors}[0], $interface, 1);
</ins><span class="cx">         } elsif (@constructors == 1) {
</span><span class="cx">             GenerateConstructorDefinition($outputArray, $className, $protoClassName, $visibleInterfaceName, $interface, $generatingNamedConstructor, $constructors[0]);
</span><span class="cx">         } else {
</span><span class="lines">@@ -5196,51 +5125,6 @@
</span><span class="cx">     GenerateConstructorHelperMethods($outputArray, $className, $protoClassName, $visibleInterfaceName, $interface, $generatingNamedConstructor);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-sub GenerateOverloadedConstructorDefinition
-{
-    my $outputArray = shift;
-    my $className = shift;
-    my $interface = shift;
-
-    # FIXME: Implement support for overloaded constructors with variadic arguments.
-    my $lengthOfLongestOverloadedConstructorParameterList = LengthOfLongestFunctionParameterList($interface-&gt;constructors);
-
-    push(@$outputArray, &lt;&lt;END);
-template&lt;&gt; EncodedJSValue JSC_HOST_CALL ${className}Constructor::construct(ExecState* state)
-{
-    size_t argsCount = std::min&lt;size_t&gt;($lengthOfLongestOverloadedConstructorParameterList, state-&gt;argumentCount());
-END
-
-    my %fetchedArguments = ();
-    my $leastNumMandatoryParams = 255;
-
-    my @constructors = @{$interface-&gt;constructors};
-    foreach my $overload (@constructors) {
-        my $functionName = &quot;construct${className}&quot;;
-        my ($numMandatoryParams, $parametersCheck, @neededArguments) = GenerateFunctionParametersCheck($overload);
-        $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams &lt; $leastNumMandatoryParams);
-
-        foreach my $parameterIndex (@neededArguments) {
-            next if exists $fetchedArguments{$parameterIndex};
-            push(@$outputArray, &quot;    JSValue arg$parameterIndex(state-&gt;argument($parameterIndex));\n&quot;);
-            $fetchedArguments{$parameterIndex} = 1;
-        }
-
-        push(@$outputArray, &quot;    if ($parametersCheck)\n&quot;);
-        push(@$outputArray, &quot;        return ${functionName}$overload-&gt;{overloadedIndex}(state);\n&quot;);
-    }
-
-    if ($leastNumMandatoryParams &gt;= 1) {
-        push(@$outputArray, &quot;    if (UNLIKELY(argsCount &lt; $leastNumMandatoryParams))\n&quot;);
-        push(@$outputArray, &quot;        return throwVMError(state, createNotEnoughArgumentsError(state));\n&quot;);
-    }
-    push(@$outputArray, &lt;&lt;END);
-    return throwVMTypeError(state);
-}
-
-END
-}
-
</del><span class="cx"> sub GenerateConstructorDefinition
</span><span class="cx"> {
</span><span class="cx">     my ($outputArray, $className, $protoClassName, $visibleInterfaceName, $interface, $generatingNamedConstructor, $function) = @_;
</span><span class="lines">@@ -5333,10 +5217,10 @@
</span><span class="cx">             push(@$outputArray, &quot;    return construct${className}(*exec);\n&quot;);
</span><span class="cx">             push(@$outputArray, &quot;}\n\n&quot;);
</span><span class="cx">          } elsif (!HasCustomConstructor($interface) &amp;&amp; (!$interface-&gt;extendedAttributes-&gt;{&quot;NamedConstructor&quot;} || $generatingNamedConstructor)) {
</span><del>-            if ($function-&gt;{overloadedIndex} &amp;&amp; $function-&gt;{overloadedIndex} &gt; 0) {
-                push(@$outputArray, &quot;static inline EncodedJSValue construct${className}$function-&gt;{overloadedIndex}(ExecState* state)\n&quot;);
-            }
-            else {
</del><ins>+            my $isOverloaded = $function-&gt;{overloads} &amp;&amp; @{$function-&gt;{overloads}} &gt; 1;
+            if ($isOverloaded) {
+                push(@$outputArray, &quot;static inline EncodedJSValue construct${className}$function-&gt;{overloadIndex}(ExecState* state)\n&quot;);
+            } else {
</ins><span class="cx">                 push(@$outputArray, &quot;template&lt;&gt; EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct(ExecState* state)\n&quot;);
</span><span class="cx">             }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsIDLParserpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/IDLParser.pm (204042 => 204043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/IDLParser.pm        2016-08-02 21:33:36 UTC (rev 204042)
+++ trunk/Source/WebCore/bindings/scripts/IDLParser.pm        2016-08-02 21:44:27 UTC (rev 204043)
</span><span class="lines">@@ -2306,7 +2306,6 @@
</span><span class="cx">             $constructor-&gt;signature-&gt;name(&quot;Constructor&quot;);
</span><span class="cx">             $constructor-&gt;signature-&gt;extendedAttributes($extendedAttributeList);
</span><span class="cx">             $constructor-&gt;parameters($param);
</span><del>-            $constructor-&gt;{overloadedIndex} = $index++;
</del><span class="cx">             push(@{$interface-&gt;constructors}, $constructor);
</span><span class="cx">         }
</span><span class="cx">         delete $extendedAttributeList-&gt;{&quot;Constructors&quot;};
</span><span class="lines">@@ -2332,7 +2331,6 @@
</span><span class="cx">             $customConstructor-&gt;signature-&gt;name(&quot;CustomConstructor&quot;);
</span><span class="cx">             $customConstructor-&gt;signature-&gt;extendedAttributes($extendedAttributeList);
</span><span class="cx">             $customConstructor-&gt;parameters($param);
</span><del>-            $customConstructor-&gt;{overloadedIndex} = $index++;
</del><span class="cx">             push(@{$interface-&gt;customConstructors}, $customConstructor);
</span><span class="cx">         }
</span><span class="cx">         delete $extendedAttributeList-&gt;{&quot;CustomConstructors&quot;};
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestOverloadedConstructorscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp (204042 => 204043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp        2016-08-02 21:33:36 UTC (rev 204042)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp        2016-08-02 21:44:27 UTC (rev 204043)
</span><span class="lines">@@ -130,19 +130,21 @@
</span><span class="cx"> template&lt;&gt; EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::construct(ExecState* state)
</span><span class="cx"> {
</span><span class="cx">     size_t argsCount = std::min&lt;size_t&gt;(1, state-&gt;argumentCount());
</span><del>-    JSValue arg0(state-&gt;argument(0));
-    if ((argsCount == 1 &amp;&amp; ((arg0.isObject() &amp;&amp; asObject(arg0)-&gt;inherits(JSArrayBuffer::info())))))
-        return constructJSTestOverloadedConstructors1(state);
-    if ((argsCount == 1 &amp;&amp; ((arg0.isObject() &amp;&amp; asObject(arg0)-&gt;inherits(JSArrayBufferView::info())))))
-        return constructJSTestOverloadedConstructors2(state);
-    if ((argsCount == 1 &amp;&amp; ((arg0.isObject() &amp;&amp; asObject(arg0)-&gt;inherits(JSBlob::info())))))
-        return constructJSTestOverloadedConstructors3(state);
-    if (argsCount == 1)
</del><ins>+    if (argsCount == 0) {
+        return constructJSTestOverloadedConstructors5(state);
+    }
+    if (argsCount == 1) {
+        JSValue distinguishingArg = state-&gt;uncheckedArgument(0);
+        if (distinguishingArg.isObject() &amp;&amp; asObject(distinguishingArg)-&gt;inherits(JSArrayBuffer::info()))
+            return constructJSTestOverloadedConstructors1(state);
+        if (distinguishingArg.isObject() &amp;&amp; asObject(distinguishingArg)-&gt;inherits(JSArrayBufferView::info()))
+            return constructJSTestOverloadedConstructors2(state);
+        if (distinguishingArg.isObject() &amp;&amp; asObject(distinguishingArg)-&gt;inherits(JSBlob::info()))
+            return constructJSTestOverloadedConstructors3(state);
+        if (distinguishingArg.isNumber())
+            return constructJSTestOverloadedConstructors5(state);
</ins><span class="cx">         return constructJSTestOverloadedConstructors4(state);
</span><del>-    if ()
-        return constructJSTestOverloadedConstructors5(state);
-    if (UNLIKELY(argsCount &lt; 1))
-        return throwVMError(state, createNotEnoughArgumentsError(state));
</del><ins>+    }
</ins><span class="cx">     return throwVMTypeError(state);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestTestOverloadedConstructorsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/TestOverloadedConstructors.idl (204042 => 204043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/TestOverloadedConstructors.idl        2016-08-02 21:33:36 UTC (rev 204042)
+++ trunk/Source/WebCore/bindings/scripts/test/TestOverloadedConstructors.idl        2016-08-02 21:44:27 UTC (rev 204043)
</span><span class="lines">@@ -30,6 +30,6 @@
</span><span class="cx">     Constructor(ArrayBufferView arrayBufferView),
</span><span class="cx">     Constructor(Blob blob),
</span><span class="cx">     Constructor(DOMString string),
</span><del>-    Constructor(long... longArgs) // FIXME: Implement support for overloaded constructors with variadic arguments.
</del><ins>+    Constructor(long... longArgs)
</ins><span class="cx"> ] interface TestOverloadedConstructors {
</span><span class="cx"> };
</span></span></pre>
</div>
</div>

</body>
</html>