Changeset 204028 in webkit


Ignore:
Timestamp:
Aug 2, 2016 10:02:23 AM (8 years ago)
Author:
Chris Dumez
Message:

[WebIDL] Implement overload resolution algorithm
https://bugs.webkit.org/show_bug.cgi?id=160394

Reviewed by Darin Adler.

Source/WebCore:

Implement overload resolution algorithm:

This means that our support for operation overloading in our IDL is
now a lot more extensive than it used to be and is now compliant with
the Web IDL specification.

In particular, overloading should now work for a lot more parameter
types which means that:

  • We should be able to drop some custom bindings code in a follow-up patch.
  • We will be able to drop the [StrictTypeChecking] attribute which was a hack used to make overloading work for parameters of type DOMString.

Also, the order of the overloads in the IDL no longer impacts the
generated bindings code. It used to be that you needed to put the
overloads with the more specific parameter types first in order for the
generated bindings code to be somewhat correct.

No new tests, rebaselined bindings tests.

  • bindings/scripts/CodeGenerator.pm:

(IsStringOrEnumType):

  • bindings/scripts/CodeGeneratorJS.pm:

(IsNullableType):
(StripNullable):
(ComputeEffectiveOverloadSet):
(AreTypesDistinguishableForOverloadResolution):
(GetDistinguishingArgumentIndex):
(GetOverloadThatMatches):
(GenerateOverloadedFunction):

  • bindings/scripts/test/JS/JSTestGlobalObject.cpp:

(WebCore::jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation):

  • bindings/scripts/test/JS/JSTestObj.cpp:

(WebCore::jsTestObjPrototypeFunctionEnabledAtRuntimeOperation):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter):
(WebCore::jsTestObjConstructorFunctionOverloadedMethod1):
(WebCore::jsTestObjPrototypeFunctionTestPromiseOverloadedFunction):
(WebCore::jsTestObjConstructorFunctionOverloadedMethod12): Deleted.
(WebCore::jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2Promise): Deleted.

  • bindings/scripts/test/TestObj.idl:
  • dom/EventTarget.h:
  • dom/EventTarget.idl:
  • html/HTMLOptionsCollection.h:
  • html/HTMLOptionsCollection.idl:
  • html/HTMLSelectElement.h:

(WebCore::HTMLSelectElement::add):

  • html/HTMLSelectElement.idl:

LayoutTests:

Update / Rebaseline existing test. There is no major behavior change.
We sometimes get a different exception message than we used to.

  • fast/canvas/canvas-clip-path-expected.txt:
  • fast/canvas/canvas-fill-path-expected.txt:
  • fast/canvas/canvas-path-addPath-expected.txt:
  • fast/canvas/canvas-path-isPointInPath-expected.txt:
  • fast/canvas/canvas-path-isPointInStroke-expected.txt:
  • fast/canvas/canvas-putImageData-expected.txt:
  • fast/canvas/canvas-putImageData.js:
  • fast/canvas/canvas-stroke-path-expected.txt:
  • fast/canvas/webgl/script-tests/texImageTest.js:
  • fast/canvas/webgl/texImageTest-expected.txt:
  • fast/dom/HTMLSelectElement/add-expected.txt:
  • fast/dom/HTMLSelectElement/add.html:
  • fast/dom/HTMLSelectElement/options-collection-add-expected.txt:
  • fast/dom/HTMLSelectElement/options-collection-add.html:
  • fast/dom/incompatible-operations-expected.txt:
  • js/dom/select-options-add-expected.txt:
  • webaudio/audiobuffer-expected.txt:
  • webaudio/audiobuffer.html:
  • webgl/1.0.2/resources/webgl_test_files/conformance/textures/tex-image-with-invalid-data.html:
Location:
trunk
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r204024 r204028  
     12016-08-02  Chris Dumez  <cdumez@apple.com>
     2
     3        [WebIDL] Implement overload resolution algorithm
     4        https://bugs.webkit.org/show_bug.cgi?id=160394
     5
     6        Reviewed by Darin Adler.
     7
     8        Update / Rebaseline existing test. There is no major behavior change.
     9        We sometimes get a different exception message than we used to.
     10
     11        * fast/canvas/canvas-clip-path-expected.txt:
     12        * fast/canvas/canvas-fill-path-expected.txt:
     13        * fast/canvas/canvas-path-addPath-expected.txt:
     14        * fast/canvas/canvas-path-isPointInPath-expected.txt:
     15        * fast/canvas/canvas-path-isPointInStroke-expected.txt:
     16        * fast/canvas/canvas-putImageData-expected.txt:
     17        * fast/canvas/canvas-putImageData.js:
     18        * fast/canvas/canvas-stroke-path-expected.txt:
     19        * fast/canvas/webgl/script-tests/texImageTest.js:
     20        * fast/canvas/webgl/texImageTest-expected.txt:
     21        * fast/dom/HTMLSelectElement/add-expected.txt:
     22        * fast/dom/HTMLSelectElement/add.html:
     23        * fast/dom/HTMLSelectElement/options-collection-add-expected.txt:
     24        * fast/dom/HTMLSelectElement/options-collection-add.html:
     25        * fast/dom/incompatible-operations-expected.txt:
     26        * js/dom/select-options-add-expected.txt:
     27        * webaudio/audiobuffer-expected.txt:
     28        * webaudio/audiobuffer.html:
     29        * webgl/1.0.2/resources/webgl_test_files/conformance/textures/tex-image-with-invalid-data.html:
     30
    1312016-08-02  Per Arne Vollan  <pvollan@apple.com>
    232
  • trunk/LayoutTests/fast/canvas/canvas-clip-path-expected.txt

    r190021 r204028  
    3333PASS ctx.clip(false) threw exception TypeError: Argument 1 ('winding') to CanvasRenderingContext2D.clip must be one of: "nonzero", "evenodd".
    3434PASS ctx.clip(new Date()) threw exception TypeError: Argument 1 ('winding') to CanvasRenderingContext2D.clip must be one of: "nonzero", "evenodd".
    35 PASS ctx.clip(0, 'nonzero') threw exception TypeError: Type error.
    36 PASS ctx.clip(null, 'nonzero') threw exception TypeError: Type error.
    37 PASS ctx.clip('path2d', 'nonzero') threw exception TypeError: Type error.
    38 PASS ctx.clip(undefined, 'nonzero') threw exception TypeError: Type error.
    39 PASS ctx.clip(Number.MAX_VALUE, 'nonzero') threw exception TypeError: Type error.
    40 PASS ctx.clip(function() {}, 'nonzero') threw exception TypeError: Type error.
    41 PASS ctx.clip(false, 'nonzero') threw exception TypeError: Type error.
    42 PASS ctx.clip(new Date(), 'nonzero') threw exception TypeError: Type error.
     35PASS ctx.clip(0, 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.clip must be an instance of DOMPath.
     36PASS ctx.clip(null, 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.clip must be an instance of DOMPath.
     37PASS ctx.clip('path2d', 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.clip must be an instance of DOMPath.
     38PASS ctx.clip(undefined, 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.clip must be an instance of DOMPath.
     39PASS ctx.clip(Number.MAX_VALUE, 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.clip must be an instance of DOMPath.
     40PASS ctx.clip(function() {}, 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.clip must be an instance of DOMPath.
     41PASS ctx.clip(false, 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.clip must be an instance of DOMPath.
     42PASS ctx.clip(new Date(), 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.clip must be an instance of DOMPath.
    4343PASS successfullyParsed is true
    4444
  • trunk/LayoutTests/fast/canvas/canvas-fill-path-expected.txt

    r190021 r204028  
    3232PASS ctx.fill(false) threw exception TypeError: Argument 1 ('winding') to CanvasRenderingContext2D.fill must be one of: "nonzero", "evenodd".
    3333PASS ctx.fill(new Date()) threw exception TypeError: Argument 1 ('winding') to CanvasRenderingContext2D.fill must be one of: "nonzero", "evenodd".
    34 PASS ctx.fill(0, 'nonzero') threw exception TypeError: Type error.
    35 PASS ctx.fill(null, 'nonzero') threw exception TypeError: Type error.
    36 PASS ctx.fill('path2d', 'nonzero') threw exception TypeError: Type error.
     34PASS ctx.fill(0, 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.fill must be an instance of DOMPath.
     35PASS ctx.fill(null, 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.fill must be an instance of DOMPath.
     36PASS ctx.fill('path2d', 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.fill must be an instance of DOMPath.
    3737FAIL ctx.fill(undefined) should throw an exception. Was undefined.
    38 PASS ctx.fill(Number.MAX_VALUE, 'nonzero') threw exception TypeError: Type error.
    39 PASS ctx.fill(function() {}, 'nonzero') threw exception TypeError: Type error.
    40 PASS ctx.fill(false, 'nonzero') threw exception TypeError: Type error.
    41 PASS ctx.fill(new Date(), 'nonzero') threw exception TypeError: Type error.
     38PASS ctx.fill(Number.MAX_VALUE, 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.fill must be an instance of DOMPath.
     39PASS ctx.fill(function() {}, 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.fill must be an instance of DOMPath.
     40PASS ctx.fill(false, 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.fill must be an instance of DOMPath.
     41PASS ctx.fill(new Date(), 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.fill must be an instance of DOMPath.
    4242PASS successfullyParsed is true
    4343
  • trunk/LayoutTests/fast/canvas/canvas-path-addPath-expected.txt

    r199265 r204028  
    3232
    3333Various tests of invalid values.
    34 PASS pathA.addPath(matrix, pathB) threw exception TypeError: Type error.
    35 PASS pathA.addPath(pathB, ctx.canvas) threw exception TypeError: Type error.
    36 PASS pathA.addPath(pathB, null) threw exception TypeError: Type error.
    37 PASS pathA.addPath(pathB, undefined) threw exception TypeError: Type error.
    38 PASS pathA.addPath(pathB, 0) threw exception TypeError: Type error.
    39 PASS pathA.addPath(pathB, "0") threw exception TypeError: Type error.
     34PASS pathA.addPath(matrix, pathB) threw exception TypeError: Argument 1 ('path') to Path2D.addPath must be an instance of DOMPath.
     35PASS pathA.addPath(pathB, ctx.canvas) threw exception TypeError: Argument 2 ('transform') to Path2D.addPath must be an instance of SVGMatrix.
     36PASS pathA.addPath(pathB, null) threw exception TypeError: Argument 2 ('transform') to Path2D.addPath must be an instance of SVGMatrix.
     37PASS pathA.addPath(pathB, undefined) threw exception TypeError: Argument 2 ('transform') to Path2D.addPath must be an instance of SVGMatrix.
     38PASS pathA.addPath(pathB, 0) threw exception TypeError: Argument 2 ('transform') to Path2D.addPath must be an instance of SVGMatrix.
     39PASS pathA.addPath(pathB, "0") threw exception TypeError: Argument 2 ('transform') to Path2D.addPath must be an instance of SVGMatrix.
    4040PASS successfullyParsed is true
    4141
  • trunk/LayoutTests/fast/canvas/canvas-path-isPointInPath-expected.txt

    r165927 r204028  
    1111PASS ctx.isPointInPath(path, 50, 50, 'nonzero') is false
    1212PASS ctx.isPointInPath(null, 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: "nonzero", "evenodd".
    13 PASS ctx.isPointInPath(null, 50, 50, 'nonzero') threw exception TypeError: Type error.
    14 PASS ctx.isPointInPath(null, 50, 50, 'evenodd') threw exception TypeError: Type error.
     13PASS ctx.isPointInPath(null, 50, 50, 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.isPointInPath must be an instance of DOMPath.
     14PASS ctx.isPointInPath(null, 50, 50, 'evenodd') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.isPointInPath must be an instance of DOMPath.
    1515PASS ctx.isPointInPath([], 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: "nonzero", "evenodd".
    16 PASS ctx.isPointInPath([], 50, 50, 'nonzero') threw exception TypeError: Type error.
    17 PASS ctx.isPointInPath([], 50, 50, 'evenodd') threw exception TypeError: Type error.
     16PASS ctx.isPointInPath([], 50, 50, 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.isPointInPath must be an instance of DOMPath.
     17PASS ctx.isPointInPath([], 50, 50, 'evenodd') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.isPointInPath must be an instance of DOMPath.
    1818PASS ctx.isPointInPath({}, 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: "nonzero", "evenodd".
    19 PASS ctx.isPointInPath({}, 50, 50, 'nonzero') threw exception TypeError: Type error.
    20 PASS ctx.isPointInPath({}, 50, 50, 'evenodd') threw exception TypeError: Type error.
    21 PASS ctx.isPointInPath('path2d', 50, 50, 'evenodd') threw exception TypeError: Type error.
    22 PASS ctx.isPointInPath(undefined, 50, 50, 'evenodd') threw exception TypeError: Type error.
    23 PASS ctx.isPointInPath(Number.MAX_VALUE, 50, 50, 'evenodd') threw exception TypeError: Type error.
    24 PASS ctx.isPointInPath(function() {}, 50, 50, 'evenodd') threw exception TypeError: Type error.
    25 PASS ctx.isPointInPath(false, 50, 50, 'evenodd') threw exception TypeError: Type error.
    26 PASS ctx.isPointInPath(new Date(), 50, 50, 'evenodd') threw exception TypeError: Type error.
     19PASS ctx.isPointInPath({}, 50, 50, 'nonzero') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.isPointInPath must be an instance of DOMPath.
     20PASS ctx.isPointInPath({}, 50, 50, 'evenodd') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.isPointInPath must be an instance of DOMPath.
     21PASS ctx.isPointInPath('path2d', 50, 50, 'evenodd') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.isPointInPath must be an instance of DOMPath.
     22PASS ctx.isPointInPath(undefined, 50, 50, 'evenodd') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.isPointInPath must be an instance of DOMPath.
     23PASS ctx.isPointInPath(Number.MAX_VALUE, 50, 50, 'evenodd') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.isPointInPath must be an instance of DOMPath.
     24PASS ctx.isPointInPath(function() {}, 50, 50, 'evenodd') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.isPointInPath must be an instance of DOMPath.
     25PASS ctx.isPointInPath(false, 50, 50, 'evenodd') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.isPointInPath must be an instance of DOMPath.
     26PASS ctx.isPointInPath(new Date(), 50, 50, 'evenodd') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.isPointInPath must be an instance of DOMPath.
    2727PASS successfullyParsed is true
    2828
  • trunk/LayoutTests/fast/canvas/canvas-path-isPointInStroke-expected.txt

    r165927 r204028  
    2222PASS ctx.isPointInStroke(path,NaN,122) is false
    2323PASS ctx.isPointInStroke(path,18,NaN) is false
    24 PASS ctx.isPointInStroke(null,70,20) threw exception TypeError: Type error.
    25 PASS ctx.isPointInStroke([],20,70) threw exception TypeError: Type error.
    26 PASS ctx.isPointInStroke({},120,70) threw exception TypeError: Type error.
     24PASS ctx.isPointInStroke(null,70,20) threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.isPointInStroke must be an instance of DOMPath.
     25PASS ctx.isPointInStroke([],20,70) threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.isPointInStroke must be an instance of DOMPath.
     26PASS ctx.isPointInStroke({},120,70) threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.isPointInStroke must be an instance of DOMPath.
    2727PASS ctx.isPointInPath('path2d', 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: "nonzero", "evenodd".
    2828PASS ctx.isPointInPath(undefined, 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: "nonzero", "evenodd".
  • trunk/LayoutTests/fast/canvas/canvas-putImageData-expected.txt

    r200528 r204028  
    145145PASS getPixel(1,1) is [0,128,0,255]
    146146PASS getPixel(9,9) is [0,128,0,255]
    147 PASS context.putImageData({}, 0, 0) threw exception TypeError: Type error.
     147PASS context.putImageData({}, 0, 0) threw exception TypeError: Argument 1 ('imagedata') to CanvasRenderingContext2D.putImageData must be an instance of ImageData.
    148148PASS context.putImageData(buffer, NaN, 0, 0, 0, 0, 0) threw exception TypeError: The provided value is non-finite.
    149149PASS context.putImageData(buffer, 0, NaN, 0, 0, 0, 0) threw exception TypeError: The provided value is non-finite.
  • trunk/LayoutTests/fast/canvas/canvas-putImageData.js

    r200528 r204028  
    202202
    203203
    204 shouldThrow("context.putImageData({}, 0, 0)", "'TypeError: Type error'");
     204shouldThrowErrorName("context.putImageData({}, 0, 0)", "TypeError");
    205205shouldThrow("context.putImageData(buffer, NaN, 0, 0, 0, 0, 0)", "'TypeError: The provided value is non-finite'");
    206206shouldThrow("context.putImageData(buffer, 0, NaN, 0, 0, 0, 0)", "'TypeError: The provided value is non-finite'");
  • trunk/LayoutTests/fast/canvas/canvas-stroke-path-expected.txt

    r165976 r204028  
    1818PASS areaColor(imageData.data, {r:0,g:255,b:0,a:255}) is true
    1919
    20 PASS ctx.stroke(0) threw exception TypeError: Type error.
    21 PASS ctx.stroke(null) threw exception TypeError: Type error.
    22 PASS ctx.stroke('path2d') threw exception TypeError: Type error.
    23 PASS ctx.stroke(undefined) threw exception TypeError: Type error.
    24 PASS ctx.stroke(Number.MAX_VALUE) threw exception TypeError: Type error.
    25 PASS ctx.stroke(function() {}) threw exception TypeError: Type error.
    26 PASS ctx.stroke(false) threw exception TypeError: Type error.
    27 PASS ctx.stroke(new Date()) threw exception TypeError: Type error.
     20PASS ctx.stroke(0) threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.stroke must be an instance of DOMPath.
     21PASS ctx.stroke(null) threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.stroke must be an instance of DOMPath.
     22PASS ctx.stroke('path2d') threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.stroke must be an instance of DOMPath.
     23PASS ctx.stroke(undefined) threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.stroke must be an instance of DOMPath.
     24PASS ctx.stroke(Number.MAX_VALUE) threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.stroke must be an instance of DOMPath.
     25PASS ctx.stroke(function() {}) threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.stroke must be an instance of DOMPath.
     26PASS ctx.stroke(false) threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.stroke must be an instance of DOMPath.
     27PASS ctx.stroke(new Date()) threw exception TypeError: Argument 1 ('path') to CanvasRenderingContext2D.stroke must be an instance of DOMPath.
    2828PASS successfullyParsed is true
    2929
  • trunk/LayoutTests/fast/canvas/webgl/script-tests/texImageTest.js

    r140851 r204028  
    2626shouldThrow("context.texSubImage2D(context.TEXTURE_2D)");
    2727shouldBeUndefined("context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, 0, 0, context.RGBA, context.UNSIGNED_BYTE, null)");
    28 shouldThrow("context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, 0, 0, context.RGBA, context.UNSIGNED_BYTE, 0)");
     28shouldBeUndefined("context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, 0, 0, context.RGBA, context.UNSIGNED_BYTE, 0)"); // We do not do strict type checking on ArrayBufferView.
    2929shouldThrow("context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, 0, context.UNSIGNED_BYTE, 0)");
    3030shouldBeUndefined("context.pixelStorei(context.UNPACK_FLIP_Y_WEBGL, false)");
  • trunk/LayoutTests/fast/canvas/webgl/texImageTest-expected.txt

    r126562 r204028  
    1616PASS context.texSubImage2D(context.TEXTURE_2D) threw exception TypeError: Not enough arguments.
    1717PASS context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, 0, 0, context.RGBA, context.UNSIGNED_BYTE, null) is undefined.
    18 PASS context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, 0, 0, context.RGBA, context.UNSIGNED_BYTE, 0) threw exception TypeError: Type error.
     18PASS context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, 0, 0, context.RGBA, context.UNSIGNED_BYTE, 0) is undefined.
    1919PASS context.texSubImage2D(context.TEXTURE_2D, 0, 10, 20, 0, context.UNSIGNED_BYTE, 0) threw exception TypeError: Type error.
    2020PASS context.pixelStorei(context.UNPACK_FLIP_Y_WEBGL, false) is undefined.
  • trunk/LayoutTests/fast/dom/HTMLSelectElement/add-expected.txt

    r186275 r204028  
    1010Call HTMLSelectElement.add() with one argument:
    1111PASS testAdd(createOption("Y1")) is "0,1,2,Y1"
    12 PASS testAdd("foo") threw exception TypeError: Type error.
    13 PASS testAdd(undefined) threw exception TypeError: Type error.
    14 PASS testAdd(null) threw exception TypeError: Type error.
     12PASS testAdd("foo") threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.
     13PASS testAdd(undefined) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.
     14PASS testAdd(null) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.
    1515
    1616Call HTMLSelectElement.add() with two arguments:
     
    4141PASS testAdd(createOption("X"), mySelect.options[1]) is "0,X,1,2"
    4242PASS testAdd(createOption("X"), mySelect.options[2]) is "0,1,X,2"
    43 PASS testAdd("foo", 0) threw exception TypeError: Type error.
    44 PASS testAdd(undefined, 0) threw exception TypeError: Type error.
    45 PASS testAdd(null, 0) threw exception TypeError: Type error.
     43PASS testAdd("foo", 0) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.
     44PASS testAdd(undefined, 0) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.
     45PASS testAdd(null, 0) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.
    4646
    4747Call HTMLSelectElement.add() with three arguments (when it only takes two arguments):
  • trunk/LayoutTests/fast/dom/HTMLSelectElement/add.html

    r186275 r204028  
    22<html>
    33<head>
    4 <script src="../../../resources/js-test.js"></script>
     4<script src="../../../resources/js-test-pre.js"></script>
    55<script src="resources/html-select-and-options-collection-utilities.js"></script>
    66</head>
     
    2424debug("<br>Call HTMLSelectElement.add() with one argument:");
    2525shouldBeEqualToString('testAdd(createOption("Y1"))', "0,1,2,Y1");
    26 shouldThrow('testAdd("foo")');
    27 shouldThrow("testAdd(undefined)");
    28 shouldThrow("testAdd(null)");
     26shouldThrowErrorName('testAdd("foo")', "TypeError");
     27shouldThrowErrorName("testAdd(undefined)", "TypeError");
     28shouldThrowErrorName("testAdd(null)", "TypeError");
    2929
    3030debug("<br>Call HTMLSelectElement.add() with two arguments:");
     
    5555shouldBeEqualToString('testAdd(createOption("X"), mySelect.options[1])', "0,X,1,2");
    5656shouldBeEqualToString('testAdd(createOption("X"), mySelect.options[2])', "0,1,X,2");
    57 shouldThrow('testAdd("foo", 0)', "'TypeError: Type error'");
    58 shouldThrow('testAdd(undefined, 0)', "'TypeError: Type error'");
    59 shouldThrow('testAdd(null, 0)', "'TypeError: Type error'");
     57shouldThrowErrorName('testAdd("foo", 0)', "TypeError");
     58shouldThrowErrorName('testAdd(undefined, 0)', "TypeError");
     59shouldThrowErrorName('testAdd(null, 0)', "TypeError");
    6060
    6161debug("<br>Call HTMLSelectElement.add() with three arguments (when it only takes two arguments):");
     
    6363shouldBeEqualToString('testAdd(createOption("X"), mySelect.options[1], "unnecessary extra argument - should be ignored")', "0,X,1,2");
    6464</script>
     65<script src="../../../resources/js-test-post.js"></script>
    6566</body>
    6667</html>
  • trunk/LayoutTests/fast/dom/HTMLSelectElement/options-collection-add-expected.txt

    r203333 r204028  
    1010Call HTMLOptionsCollection.add() with only one argument:
    1111PASS testAdd(createOption("Y9")) is "0,1,2,Y9"
    12 PASS testAdd("foo") threw exception TypeError: Type error.
    13 PASS testAdd(undefined) threw exception TypeError: Type error.
    14 PASS testAdd(null) threw exception TypeError: Type error.
     12PASS testAdd("foo") threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
     13PASS testAdd(undefined) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
     14PASS testAdd(null) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    1515
    1616Call HTMLOptionsCollection.add() with two arguments:
     
    5353PASS testAdd(createOption("Y25"), 0, 1) is "Y25,0,1,2"
    5454PASS testAdd(createOption("Y25"), mySelect.options[0], 1) is "Y25,0,1,2"
    55 PASS testAdd("foo", 0) threw exception TypeError: Type error.
    56 PASS testAdd(undefined, 0) threw exception TypeError: Type error.
    57 PASS testAdd(null, 0) threw exception TypeError: Type error.
     55PASS testAdd("foo", 0) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
     56PASS testAdd(undefined, 0) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
     57PASS testAdd(null, 0) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    5858
    5959Call HTMLOptionsCollection.add() with three arguments (when it only takes two arguments):
  • trunk/LayoutTests/fast/dom/HTMLSelectElement/options-collection-add.html

    r186275 r204028  
    22<html>
    33<head>
    4 <script src="../../../resources/js-test.js"></script>
     4<script src="../../../resources/js-test-pre.js"></script>
    55<script src="resources/html-select-and-options-collection-utilities.js"></script>
    66</head>
     
    3030debug("<br>Call HTMLOptionsCollection.add() with only one argument:");
    3131shouldBeEqualToString('testAdd(createOption("Y9"))', "0,1,2,Y9");
    32 shouldThrow('testAdd("foo")');
    33 shouldThrow("testAdd(undefined)");
    34 shouldThrow("testAdd(null)");
     32shouldThrowErrorName('testAdd("foo")', "TypeError");
     33shouldThrowErrorName("testAdd(undefined)", "TypeError");
     34shouldThrowErrorName("testAdd(null)", "TypeError");
    3535
    3636debug("<br>Call HTMLOptionsCollection.add() with two arguments:");
     
    7777shouldBeEqualToString('testAdd(createOption("Y25"), 0, 1)', "Y25,0,1,2");
    7878shouldBeEqualToString('testAdd(createOption("Y25"), mySelect.options[0], 1)', "Y25,0,1,2");
    79 shouldThrow('testAdd("foo", 0)', "'TypeError: Type error'");
    80 shouldThrow('testAdd(undefined, 0)', "'TypeError: Type error'");
    81 shouldThrow('testAdd(null, 0)', "'TypeError: Type error'");
     79shouldThrowErrorName('testAdd("foo", 0)', "TypeError");
     80shouldThrowErrorName('testAdd(undefined, 0)', "TypeError");
     81shouldThrowErrorName('testAdd(null, 0)', "TypeError");
    8282
    8383debug("<br>Call HTMLOptionsCollection.add() with three arguments (when it only takes two arguments):");
     
    8686shouldBeEqualToString('testAdd(createGroup("G1", "G2"), 1, "unnecessary extra argument - should be ignored")', "0,G1,G2,1,2");
    8787</script>
     88<script src="../../../resources/js-test-post.js"></script>
    8889</body>
    8990</html>
  • trunk/LayoutTests/fast/dom/incompatible-operations-expected.txt

    r203941 r204028  
    1313PASS aNode.lookupPrefix(void 0) is null
    1414PASS aNode.cloneNode(aDOMImplementation) instanceof HTMLDivElement is true
    15 PASS aSelect.add(aDOMImplementation, aDOMImplementation) threw exception TypeError: Type error.
    16 PASS aSelect.add(aDOMImplementation, anOption) threw exception TypeError: Type error.
     15PASS aSelect.add(aDOMImplementation, aDOMImplementation) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.
     16PASS aSelect.add(aDOMImplementation, anOption) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.
    1717PASS aSelect.add(anOption, aDOMImplementation) is undefined.
    18 PASS aSelect.add(void 0, void 0) threw exception TypeError: Type error.
    19 PASS aSelect.add(void 0, anOption) threw exception TypeError: Type error.
     18PASS aSelect.add(void 0, void 0) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.
     19PASS aSelect.add(void 0, anOption) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.
    2020PASS aSelect.add(anOption, void 0) is undefined.
    2121PASS successfullyParsed is true
  • trunk/LayoutTests/js/dom/select-options-add-expected.txt

    r178097 r204028  
    3535
    36361.5 Add a non-element (string)
    37 PASS select1.options.add(option1) threw exception TypeError: Type error.
     37PASS select1.options.add(option1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    3838PASS select1.options.length is 3
    3939PASS select1.selectedIndex is 0
    4040
    41411.6 Add a non-element (number)
    42 PASS select1.options.add(option1) threw exception TypeError: Type error.
     42PASS select1.options.add(option1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    4343PASS select1.options.length is 3
    4444PASS select1.selectedIndex is 0
    4545
    46461.7 Add a non-element (boolean)
    47 PASS select1.options.add(option1) threw exception TypeError: Type error.
     47PASS select1.options.add(option1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    4848PASS select1.options.length is 3
    4949PASS select1.selectedIndex is 0
    5050
    51511.8 Add undefined
    52 PASS select1.options.add(option1) threw exception TypeError: Type error.
     52PASS select1.options.add(option1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    5353PASS select1.options.length is 3
    5454PASS select1.selectedIndex is 0
    5555
    56561.9 Add null
    57 PASS select1.options.add(option1) threw exception TypeError: Type error.
     57PASS select1.options.add(option1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    5858PASS select1.options.length is 3
    5959PASS select1.selectedIndex is 0
    6060
    61611.10 Add negative infinity
    62 PASS select1.options.add(option1) threw exception TypeError: Type error.
     62PASS select1.options.add(option1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    6363PASS select1.options.length is 3
    6464PASS select1.selectedIndex is 0
    6565
    66661.11 Add NaN
    67 PASS select1.options.add(option1) threw exception TypeError: Type error.
     67PASS select1.options.add(option1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    6868PASS select1.options.length is 3
    6969PASS select1.selectedIndex is 0
    7070
    71711.12 Add positive infinity
    72 PASS select1.options.add(option1) threw exception TypeError: Type error.
     72PASS select1.options.add(option1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    7373PASS select1.options.length is 3
    7474PASS select1.selectedIndex is 0
     
    184184
    1851852.13 Add a non-element (string)
    186 PASS select2.options.add(option2, 1) threw exception TypeError: Type error.
     186PASS select2.options.add(option2, 1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    187187PASS select2.options.length is 11
    188188PASS select2.selectedIndex is 4
    189189
    1901902.14 Add a non-element (number)
    191 PASS select2.options.add(option2, 1) threw exception TypeError: Type error.
     191PASS select2.options.add(option2, 1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    192192PASS select2.options.length is 11
    193193PASS select2.selectedIndex is 4
    194194
    1951952.15 Add a non-element (boolean)
    196 PASS select2.options.add(option2, 1) threw exception TypeError: Type error.
     196PASS select2.options.add(option2, 1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    197197PASS select2.options.length is 11
    198198PASS select2.selectedIndex is 4
    199199
    2002002.16 Add undefined
    201 PASS select2.options.add(option2, 1) threw exception TypeError: Type error.
     201PASS select2.options.add(option2, 1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    202202PASS select2.options.length is 11
    203203PASS select2.selectedIndex is 4
    204204
    2052052.17 Add null
    206 PASS select2.options.add(option2, 1) threw exception TypeError: Type error.
     206PASS select2.options.add(option2, 1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    207207PASS select2.options.length is 11
    208208PASS select2.selectedIndex is 4
    209209
    2102102.18 Add negative infinity
    211 PASS select2.options.add(option2, 1) threw exception TypeError: Type error.
     211PASS select2.options.add(option2, 1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    212212PASS select2.options.length is 11
    213213PASS select2.selectedIndex is 4
    214214
    2152152.19 Add NaN
    216 PASS select2.options.add(option2, 1) threw exception TypeError: Type error.
     216PASS select2.options.add(option2, 1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    217217PASS select2.options.length is 11
    218218PASS select2.selectedIndex is 4
    219219
    2202202.20 Add positive infinity
    221 PASS select2.options.add(option2, 1) threw exception TypeError: Type error.
     221PASS select2.options.add(option2, 1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.
    222222PASS select2.options.length is 11
    223223PASS select2.selectedIndex is 4
  • trunk/LayoutTests/webaudio/audiobuffer-expected.txt

    r199775 r204028  
    1313PASS getChannelData(3) returns a Float32Array object.
    1414PASS Exception has been thrown correctly when index is not less than numberOfChannels.
    15 PASS context.createBuffer(null, false) threw exception TypeError: Type error.
     15PASS context.createBuffer(null, false) threw exception TypeError: Argument 1 ('buffer') to webkitAudioContext.createBuffer must be an instance of ArrayBuffer.
    1616PASS successfullyParsed is true
    1717
  • trunk/LayoutTests/webaudio/audiobuffer.html

    r199775 r204028  
    5050}
    5151
    52 shouldThrow("context.createBuffer(null, false)", "'TypeError: Type error'");
     52shouldThrowErrorName("context.createBuffer(null, false)", "TypeError");
    5353
    5454</script>
  • trunk/LayoutTests/webgl/1.0.2/resources/webgl_test_files/conformance/textures/tex-image-with-invalid-data.html

    r157888 r204028  
    7272    }
    7373
    74     if (expected == gl.INVALID_OPERATION) {
     74    if (expected == gl.INVALID_OPERATION || expected == gl.INVALID_VALUE) {
    7575      glErrorShouldBe(gl, expected);
    7676    } else if (expected == "exception") {
     
    9090     gl.INVALID_OPERATION);
    9191
    92 test("Passing texImage2D parameter data of Number type should throw an exception",
     92// We do not do strict type checking for ArrayBufferView type.
     93test("Passing texImage2D parameter data of Number type should generate an INVALID_OPERATION",
    9394     function () {
    9495        gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 64, 64, 0, gl.RGBA, gl.UNSIGNED_BYTE, 42);
    9596     },
    96      "exception");
     97     gl.INVALID_OPERATION);
    9798
    98 test("Passing texImage2D parameter data of String type should throw a TypeError",
     99test("Passing texImage2D parameter data of String type should generate an INVALID_OPERATION",
    99100     function () {
    100101        gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 64, 64, 0, gl.RGBA, gl.UNSIGNED_BYTE, "not a buffer");
    101102     },
    102      "exception");
     103     gl.INVALID_OPERATION);
    103104test("Passing a buffer not large enough to texSubImage2D should generate an INVALID_OPERATION",
    104105     function () {
     
    108109     gl.INVALID_OPERATION);
    109110
    110 test("Passing texSubImage2D parameter data of Number type should throw a TypeError",
     111test("Passing texSubImage2D parameter data of Number type should generate an INVALID_VALUE",
    111112     function () {
    112113        gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 64, 64, gl.RGBA, gl.UNSIGNED_BYTE, 42);
    113114     },
    114      "exception");
     115     gl.INVALID_VALUE);
    115116
    116 test("Passing texSubImage2D parameter data of String type should throw a TypeError",
     117test("Passing texSubImage2D parameter data of String type should generate an INVALID_VALUE",
    117118     function () {
    118119        gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 64, 64, gl.RGBA, gl.UNSIGNED_BYTE, "not a buffer");
    119120     },
    120      "exception");
     121     gl.INVALID_VALUE);
    121122
    122123debug("");
  • trunk/Source/WebCore/ChangeLog

    r204027 r204028  
     12016-08-02  Chris Dumez  <cdumez@apple.com>
     2
     3        [WebIDL] Implement overload resolution algorithm
     4        https://bugs.webkit.org/show_bug.cgi?id=160394
     5
     6        Reviewed by Darin Adler.
     7
     8        Implement overload resolution algorithm:
     9        - http://heycam.github.io/webidl/#es-overloads
     10
     11        This means that our support for operation overloading in our IDL is
     12        now a lot more extensive than it used to be and is now compliant with
     13        the Web IDL specification.
     14
     15        In particular, overloading should now work for a lot more parameter
     16        types which means that:
     17        - We should be able to drop some custom bindings code in a follow-up patch.
     18        - We will be able to drop the [StrictTypeChecking] attribute which was
     19          a hack used to make overloading work for parameters of type DOMString.
     20
     21        Also, the order of the overloads in the IDL no longer impacts the
     22        generated bindings code. It used to be that you needed to put the
     23        overloads with the more specific parameter types first in order for the
     24        generated bindings code to be somewhat correct.
     25
     26        No new tests, rebaselined bindings tests.
     27
     28        * bindings/scripts/CodeGenerator.pm:
     29        (IsStringOrEnumType):
     30        * bindings/scripts/CodeGeneratorJS.pm:
     31        (IsNullableType):
     32        (StripNullable):
     33        (ComputeEffectiveOverloadSet):
     34        (AreTypesDistinguishableForOverloadResolution):
     35        (GetDistinguishingArgumentIndex):
     36        (GetOverloadThatMatches):
     37        (GenerateOverloadedFunction):
     38        * bindings/scripts/test/JS/JSTestGlobalObject.cpp:
     39        (WebCore::jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation):
     40        * bindings/scripts/test/JS/JSTestObj.cpp:
     41        (WebCore::jsTestObjPrototypeFunctionEnabledAtRuntimeOperation):
     42        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod):
     43        (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1):
     44        (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter):
     45        (WebCore::jsTestObjConstructorFunctionOverloadedMethod1):
     46        (WebCore::jsTestObjPrototypeFunctionTestPromiseOverloadedFunction):
     47        (WebCore::jsTestObjConstructorFunctionOverloadedMethod12): Deleted.
     48        (WebCore::jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2Promise): Deleted.
     49        * bindings/scripts/test/TestObj.idl:
     50        * dom/EventTarget.h:
     51        * dom/EventTarget.idl:
     52        * html/HTMLOptionsCollection.h:
     53        * html/HTMLOptionsCollection.idl:
     54        * html/HTMLSelectElement.h:
     55        (WebCore::HTMLSelectElement::add):
     56        * html/HTMLSelectElement.idl:
     57
    1582016-08-02  Myles C. Maxfield  <mmaxfield@apple.com>
    259
  • trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm

    r203675 r204028  
    359359}
    360360
     361sub IsStringOrEnumType
     362{
     363    my ($object, $type) = @_;
     364   
     365    return 1 if $type eq "DOMString";
     366    return 1 if $object->IsEnumType($type);
     367    return 0;
     368}
     369
    361370sub IsIntegerType
    362371{
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r203949 r204028  
    16441644}
    16451645
     1646sub IsNullableType
     1647{
     1648    my $type = shift;
     1649
     1650    return substr($type, -1) eq "?";
     1651}
     1652
     1653sub StripNullable
     1654{
     1655    my $type = shift;
     1656
     1657    chop($type) if IsNullableType($type);
     1658    return $type;
     1659}
     1660
     1661# This computes an effective overload set for a given operation / constructor,
     1662# which represents the allowable invocations.This set is used as input for
     1663# the Web IDL overload resolution algorithm.
     1664# http://heycam.github.io/webidl/#dfn-effective-overload-set
     1665sub ComputeEffectiveOverloadSet
     1666{
     1667    my ($overloads) = @_;
     1668
     1669    my %allSets;
     1670    my $addTuple = sub {
     1671        my $tuple = shift;
     1672        # The Web IDL specification uses a flat set of tuples but we use a hash where the key is the
     1673        # number of parameters and the value is the set of tuples for the given number of parameters.
     1674        my $length = scalar(@{@$tuple[1]});
     1675        if (!exists($allSets{$length})) {
     1676            $allSets{$length} = [ $tuple ];
     1677        } else {
     1678            push(@{$allSets{$length}}, $tuple);
     1679        }
     1680    };
     1681
     1682    my $m = LengthOfLongestFunctionParameterList($overloads);
     1683    foreach my $overload (@{$overloads}) {
     1684        my $n = @{$overload->parameters};
     1685        my @t;
     1686        my @o;
     1687        my $isVariadic = 0;
     1688        foreach my $parameter (@{$overload->parameters}) {
     1689            push(@t, $parameter->isNullable ? $parameter->type . "?" : $parameter->type);
     1690            if ($parameter->isOptional) {
     1691                push(@o, "optional");
     1692            } elsif ($parameter->isVariadic) {
     1693                push(@o, "variadic");
     1694                $isVariadic = 1;
     1695            } else {
     1696                push(@o, "required");
     1697            }
     1698        }
     1699        &$addTuple([$overload, [@t], [@o]]);
     1700        if ($isVariadic) {
     1701            my @newT = @t;
     1702            my @newO = @o;
     1703            for (my $i = $n; $i < $m; $i++) {
     1704                push(@newT, $t[-1]);
     1705                push(@newO, "variadic");
     1706                &$addTuple([$overload, [@newT], [@newO]]);
     1707            }
     1708        }
     1709        for (my $i = $n - 1; $i >= 0; $i--) {
     1710            my $parameter = @{$overload->parameters}[$i];
     1711            last unless ($parameter->isOptional || $parameter->isVariadic);
     1712            pop(@t);
     1713            pop(@o);
     1714            &$addTuple([$overload, [@t], [@o]]);
     1715        }
     1716    }
     1717    return %allSets;
     1718}
     1719
     1720# Determines if two types are distinguishable in the context of overload resolution,
     1721# according to the Web IDL specification:
     1722# http://heycam.github.io/webidl/#dfn-distinguishable
     1723sub AreTypesDistinguishableForOverloadResolution
     1724{
     1725    my ($typeA, $typeB) = @_;
     1726
     1727    my $isDictionary = sub {
     1728        my $type = shift;
     1729        return $type eq "Dictionary" || $codeGenerator->IsDictionaryType($type);
     1730    };
     1731    my $isCallbackFunctionOrDictionary = sub {
     1732        my $type = shift;
     1733        return $codeGenerator->IsFunctionOnlyCallbackInterface($type) || &$isDictionary($type);
     1734    };
     1735
     1736    # FIXME: The WebIDL mandates this but this currently does not work because some of our IDL is wrong.
     1737    # return 0 if IsNullableType($typeA) && IsNullableType($typeB);
     1738
     1739    $typeA = StripNullable($typeA);
     1740    $typeB = StripNullable($typeB);
     1741
     1742    return 0 if $typeA eq $typeB;
     1743    return 0 if $typeA eq "object" or $typeB eq "object";
     1744    return 0 if $codeGenerator->IsNumericType($typeA) && $codeGenerator->IsNumericType($typeB);
     1745    return 0 if $codeGenerator->IsStringOrEnumType($typeA) && $codeGenerator->IsStringOrEnumType($typeB);
     1746    return 0 if &$isDictionary($typeA) && &$isDictionary($typeB);
     1747    return 0 if $codeGenerator->IsCallbackInterface($typeA) && $codeGenerator->IsCallbackInterface($typeB);
     1748    return 0 if &$isCallbackFunctionOrDictionary($typeA) && &$isCallbackFunctionOrDictionary($typeB);
     1749    return 0 if $codeGenerator->GetArrayOrSequenceType($typeA) && $codeGenerator->GetArrayOrSequenceType($typeB);
     1750    # FIXME: return 0 if typeA and typeB are both exception types.
     1751    return 1;
     1752}
     1753
     1754# If there is more than one entry in an effective overload set that has a given type list length,
     1755# then for those entries there must be an index i such that for each pair of entries the types
     1756# at index i are distinguishable. The lowest such index is termed the distinguishing argument index.
     1757# http://heycam.github.io/webidl/#dfn-distinguishing-argument-index
     1758sub GetDistinguishingArgumentIndex
     1759{
     1760    my ($function, $S) = @_;
     1761
     1762    # FIXME: Consider all the tuples, not just the 2 first ones?
     1763    my $firstTupleTypes = @{@{$S}[0]}[1];
     1764    my $secondTupleTypes = @{@{$S}[1]}[1];
     1765    for (my $index = 0; $index < scalar(@$firstTupleTypes); $index++) {
     1766        return $index if AreTypesDistinguishableForOverloadResolution(@{$firstTupleTypes}[$index], @{$secondTupleTypes}[$index]);
     1767    }
     1768    die "Undistinguishable overloads for operation " . $function->signature->name . " with length: " . scalar(@$firstTupleTypes);
     1769}
     1770
     1771sub GetOverloadThatMatches
     1772{
     1773    my ($S, $parameterIndex, $matches) = @_;
     1774
     1775    for my $tuple (@{$S}) {
     1776        my $type = @{@{$tuple}[1]}[$parameterIndex];
     1777        my $optionality = @{@{$tuple}[2]}[$parameterIndex];
     1778        my $isNullable = IsNullableType($type);
     1779        return @{$tuple}[0] if $matches->(StripNullable($type), $optionality, $isNullable);
     1780    }
     1781}
     1782
     1783# Implements the overload resolution algorithm, as defined in the Web IDL specification:
     1784# http://heycam.github.io/webidl/#es-overloads
     1785sub GenerateOverloadedFunction
     1786{
     1787    my ($function, $interface) = @_;
     1788    my %allSets = ComputeEffectiveOverloadSet($function->{overloads});
     1789
     1790    my $kind = $function->isStatic ? "Constructor" : (OperationShouldBeOnInstance($interface, $function) ? "Instance" : "Prototype");
     1791    my $interfaceName = $interface->name;
     1792    my $functionName = "js${interfaceName}${kind}Function" . $codeGenerator->WK_ucfirst($function->signature->name);
     1793
     1794    my $generateOverloadCallIfNecessary = sub {
     1795        my ($overload, $condition) = @_;
     1796        return unless $overload;
     1797        my $conditionalString = $codeGenerator->GenerateConditionalString($overload->signature);
     1798        push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
     1799        push(@implContent, "        if ($condition)\n    ") if $condition;
     1800        push(@implContent, "        return ${functionName}$overload->{overloadIndex}(state);\n");
     1801        push(@implContent, "#endif\n") if $conditionalString;
     1802    };
     1803    my $isOptionalParameter = sub {
     1804        my ($type, $optionality, $isNullable) = @_;
     1805        return $optionality eq "optional";
     1806    };
     1807    my $isDictionaryParameter = sub {
     1808        my ($type, $optionality, $isNullable) = @_;
     1809        return $type eq "Dictionary" || $codeGenerator->IsDictionaryType($type);
     1810    };
     1811    my $isNullableOrDictionaryParameter = sub {
     1812        my ($type, $optionality, $isNullable) = @_;
     1813        return $isNullable || &$isDictionaryParameter($type, $optionality, $isNullable);
     1814    };
     1815    my $isRegExpOrObjectParameter = sub {
     1816        my ($type, $optionality, $isNullable) = @_;
     1817        return $type eq "RegExp" || $type eq "object";
     1818    };
     1819    my $isObjectOrErrorParameter = sub {
     1820        my ($type, $optionality, $isNullable) = @_;
     1821        return $type eq "object" || $type eq "Error";
     1822    };
     1823    my $isObjectOrErrorOrDOMExceptionParameter = sub {
     1824        my ($type, $optionality, $isNullable) = @_;
     1825        return 1 if &$isObjectOrErrorParameter($type, $optionality, $isNullable);
     1826        return $type eq "DOMException";
     1827    };
     1828    my $isObjectOrCallbackFunctionParameter = sub {
     1829        my ($type, $optionality, $isNullable) = @_;
     1830        return $type eq "object" || $codeGenerator->IsFunctionOnlyCallbackInterface($type);
     1831    };
     1832    my $isArrayOrSequenceParameter = sub {
     1833        my ($type, $optionality, $isNullable) = @_;
     1834        return $codeGenerator->GetArrayOrSequenceType($type);
     1835    };
     1836    my $isDictionaryOrObjectOrCallbackInterfaceParameter = sub {
     1837        my ($type, $optionality, $isNullable) = @_;
     1838        return 1 if &$isDictionaryParameter($type, $optionality, $isNullable);
     1839        return 1 if $type eq "object";
     1840        return 1 if $codeGenerator->IsCallbackInterface($type) && !$codeGenerator->IsFunctionOnlyCallbackInterface($type);
     1841        return 0;
     1842    };
     1843    my $isBooleanParameter = sub {
     1844        my ($type, $optionality, $isNullable) = @_;
     1845        return $type eq "boolean";
     1846    };
     1847    my $isNumericParameter = sub {
     1848        my ($type, $optionality, $isNullable) = @_;
     1849        return $codeGenerator->IsNumericType($type);
     1850    };
     1851    my $isStringOrEnumParameter = sub {
     1852        my ($type, $optionality, $isNullable) = @_;
     1853        return $codeGenerator->IsStringOrEnumType($type);
     1854    };
     1855    my $isAnyParameter = sub {
     1856        my ($type, $optionality, $isNullable) = @_;
     1857        return $type eq "any";
     1858    };
     1859
     1860    my $maxArgCount = LengthOfLongestFunctionParameterList($function->{overloads});
     1861
     1862    push(@implContent, <<END);   
     1863EncodedJSValue JSC_HOST_CALL ${functionName}(ExecState* state)
     1864{
     1865    size_t argsCount = std::min<size_t>($maxArgCount, state->argumentCount());
     1866END
     1867
     1868    for my $length ( sort keys %allSets ) {
     1869        push(@implContent, <<END);
     1870    if (argsCount == $length) {
     1871END
     1872        my $S = $allSets{$length};
     1873        if (scalar(@$S) > 1) {
     1874            my $d = GetDistinguishingArgumentIndex($function, $S);
     1875            push(@implContent, "        JSValue distinguishingArg = state->uncheckedArgument($d);\n");
     1876
     1877            my $overload = GetOverloadThatMatches($S, $d, \&$isOptionalParameter);
     1878            &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isUndefined()");
     1879
     1880            $overload = GetOverloadThatMatches($S, $d, \&$isNullableOrDictionaryParameter);
     1881            &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isUndefinedOrNull()");
     1882
     1883            for my $tuple (@{$S}) {
     1884                my $overload = @{$tuple}[0];
     1885                my $type = StripNullable(@{@{$tuple}[1]}[$d]);
     1886                if ($codeGenerator->IsWrapperType($type) || $codeGenerator->IsTypedArrayType($type)) {
     1887                    &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JS${type}::info())");
     1888                }
     1889            }
     1890
     1891            $overload = GetOverloadThatMatches($S, $d, \&$isRegExpOrObjectParameter);
     1892            &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isObject() && asObject(distinguishingArg)->type() == RegExpObjectType");
     1893
     1894            $overload = GetOverloadThatMatches($S, $d, \&$isObjectOrErrorOrDOMExceptionParameter);
     1895            &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSDOMCoreException::info())");
     1896
     1897            $overload = GetOverloadThatMatches($S, $d, \&$isObjectOrErrorParameter);
     1898            &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isObject() && asObject(distinguishingArg)->type() == ErrorInstanceType");
     1899
     1900            $overload = GetOverloadThatMatches($S, $d, \&$isObjectOrCallbackFunctionParameter);
     1901            &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isFunction()");
     1902
     1903            $overload = GetOverloadThatMatches($S, $d, \&$isArrayOrSequenceParameter);
     1904            &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isObject() && isJSArray(distinguishingArg)");
     1905
     1906            $overload = GetOverloadThatMatches($S, $d, \&$isDictionaryOrObjectOrCallbackInterfaceParameter);
     1907            &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isObject() && asObject(distinguishingArg)->type() != RegExpObjectType");
     1908
     1909            my $booleanOverload = GetOverloadThatMatches($S, $d, \&$isBooleanParameter);
     1910            &$generateOverloadCallIfNecessary($booleanOverload, "distinguishingArg.isBoolean()");
     1911
     1912            my $numericOverload = GetOverloadThatMatches($S, $d, \&$isNumericParameter);
     1913            &$generateOverloadCallIfNecessary($numericOverload, "distinguishingArg.isNumber()");
     1914
     1915            # Fallbacks.
     1916            $overload = GetOverloadThatMatches($S, $d, \&$isStringOrEnumParameter);
     1917            if ($overload) {
     1918                &$generateOverloadCallIfNecessary($overload);
     1919            } elsif ($numericOverload) {
     1920                &$generateOverloadCallIfNecessary($numericOverload);
     1921            } elsif ($booleanOverload) {
     1922                &$generateOverloadCallIfNecessary($booleanOverload);
     1923            } else {
     1924                $overload = GetOverloadThatMatches($S, $d, \&$isAnyParameter);
     1925                &$generateOverloadCallIfNecessary($overload);
     1926            }
     1927        } else {
     1928            # Only 1 overload with this number of parameters.
     1929            my $overload = @{@{$S}[0]}[0];
     1930            &$generateOverloadCallIfNecessary($overload);
     1931        }
     1932        push(@implContent, <<END);
     1933    }
     1934END
     1935    }
     1936    my $minArgCount = GetFunctionLength($function);
     1937    if ($minArgCount > 0) {
     1938        push(@implContent, "    return argsCount < $minArgCount ? throwVMError(state, createNotEnoughArgumentsError(state)) : throwVMTypeError(state);\n")
     1939    } else {
     1940        push(@implContent, "    return throwVMTypeError(state);\n")
     1941    }
     1942    push(@implContent, "}\n\n");
     1943}
     1944
    16461945sub GenerateParametersCheckExpression
    16471946{
     
    17672066    }
    17682067    return $result;
    1769 }
    1770 
    1771 sub GenerateOverloadedFunction
    1772 {
    1773     my ($function, $interface) = @_;
    1774 
    1775     # Generate code for choosing the correct overload to call. Overloads are
    1776     # chosen based on the total number of arguments passed and the type of
    1777     # values passed in non-primitive argument slots. When more than a single
    1778     # overload is applicable, precedence is given according to the order of
    1779     # declaration in the IDL.
    1780 
    1781     my $kind = $function->isStatic ? "Constructor" : (OperationShouldBeOnInstance($interface, $function) ? "Instance" : "Prototype");
    1782     my $interfaceName = $interface->name;
    1783     my $functionName = "js${interfaceName}${kind}Function" . $codeGenerator->WK_ucfirst($function->signature->name);
    1784 
    1785     # FIXME: Implement support for overloaded functions with variadic arguments.
    1786     my $lengthOfLongestOverloadedFunctionParameterList = LengthOfLongestFunctionParameterList($function->{overloads});
    1787 
    1788     push(@implContent, "EncodedJSValue JSC_HOST_CALL ${functionName}(ExecState* state)\n");
    1789     push(@implContent, <<END);
    1790 {
    1791     size_t argsCount = std::min<size_t>($lengthOfLongestOverloadedFunctionParameterList, state->argumentCount());
    1792 END
    1793 
    1794     my %fetchedArguments = ();
    1795     my $leastNumMandatoryParams = 255;
    1796 
    1797     foreach my $overload (@{$function->{overloads}}) {
    1798         my ($numMandatoryParams, $parametersCheck, @neededArguments) = GenerateFunctionParametersCheck($overload);
    1799         $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams < $leastNumMandatoryParams);
    1800 
    1801         foreach my $parameterIndex (@neededArguments) {
    1802             next if exists $fetchedArguments{$parameterIndex};
    1803             push(@implContent, "    JSValue arg$parameterIndex(state->argument($parameterIndex));\n");
    1804             $fetchedArguments{$parameterIndex} = 1;
    1805         }
    1806 
    1807         my $conditionalString = $codeGenerator->GenerateConditionalString($overload->signature);
    1808         push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
    1809 
    1810         push(@implContent, "    if ($parametersCheck)\n");
    1811         push(@implContent, "        return ${functionName}$overload->{overloadIndex}(state);\n");
    1812         push(@implContent, "#endif\n\n") if $conditionalString;
    1813 
    1814     }
    1815     if ($leastNumMandatoryParams >= 1) {
    1816         push(@implContent, "    if (UNLIKELY(argsCount < $leastNumMandatoryParams))\n");
    1817         push(@implContent, "        return throwVMError(state, createNotEnoughArgumentsError(state));\n");
    1818     }
    1819     push(@implContent, <<END);
    1820     return throwVMTypeError(state);
    1821 }
    1822 
    1823 END
    18242068}
    18252069
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp

    r203675 r204028  
    399399{
    400400    size_t argsCount = std::min<size_t>(1, state->argumentCount());
    401 #if ENABLE(TEST_FEATURE)
    402     if (argsCount == 1)
     401    if (argsCount == 1) {
     402        JSValue distinguishingArg = state->uncheckedArgument(0);
     403#if ENABLE(TEST_FEATURE)
     404        if (distinguishingArg.isNumber())
     405            return jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation2(state);
     406#endif
     407#if ENABLE(TEST_FEATURE)
    403408        return jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation1(state);
    404409#endif
    405 
    406 #if ENABLE(TEST_FEATURE)
    407     if (argsCount == 1)
    408         return jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation2(state);
    409 #endif
    410 
    411     if (UNLIKELY(argsCount < 1))
    412         return throwVMError(state, createNotEnoughArgumentsError(state));
    413     return throwVMTypeError(state);
     410    }
     411    return argsCount < 1 ? throwVMError(state, createNotEnoughArgumentsError(state)) : throwVMTypeError(state);
    414412}
    415413
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r203956 r204028  
    38703870{
    38713871    size_t argsCount = std::min<size_t>(1, state->argumentCount());
     3872    if (argsCount == 1) {
     3873        JSValue distinguishingArg = state->uncheckedArgument(0);
    38723874#if ENABLE(TEST_FEATURE)
    3873     if (argsCount == 1)
     3875        if (distinguishingArg.isNumber())
     3876            return jsTestObjPrototypeFunctionEnabledAtRuntimeOperation2(state);
     3877#endif
     3878#if ENABLE(TEST_FEATURE)
    38743879        return jsTestObjPrototypeFunctionEnabledAtRuntimeOperation1(state);
    38753880#endif
    3876 
    3877 #if ENABLE(TEST_FEATURE)
    3878     if (argsCount == 1)
    3879         return jsTestObjPrototypeFunctionEnabledAtRuntimeOperation2(state);
    3880 #endif
    3881 
    3882     if (UNLIKELY(argsCount < 1))
    3883         return throwVMError(state, createNotEnoughArgumentsError(state));
    3884     return throwVMTypeError(state);
     3881    }
     3882    return argsCount < 1 ? throwVMError(state, createNotEnoughArgumentsError(state)) : throwVMTypeError(state);
    38853883}
    38863884
     
    54235421{
    54245422    size_t argsCount = std::min<size_t>(2, state->argumentCount());
    5425     JSValue arg0(state->argument(0));
    5426     JSValue arg1(state->argument(1));
    5427     if ((argsCount == 2 && (arg0.isUndefinedOrNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info()))) && (arg1.isUndefinedOrNull() || arg1.isString() || arg1.isObject())))
     5423    if (argsCount == 0) {
     5424        return jsTestObjPrototypeFunctionOverloadedMethod12(state);
     5425    }
     5426    if (argsCount == 1) {
     5427        JSValue distinguishingArg = state->uncheckedArgument(0);
     5428        if (distinguishingArg.isUndefinedOrNull())
     5429            return jsTestObjPrototypeFunctionOverloadedMethod2(state);
     5430        if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSTestObj::info()))
     5431            return jsTestObjPrototypeFunctionOverloadedMethod2(state);
     5432        if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSTestCallback::info()))
     5433            return jsTestObjPrototypeFunctionOverloadedMethod5(state);
     5434        if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSDOMStringList::info()))
     5435            return jsTestObjPrototypeFunctionOverloadedMethod6(state);
     5436        if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSTestObj::info()))
     5437            return jsTestObjPrototypeFunctionOverloadedMethod8(state);
     5438        if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSBlob::info()))
     5439            return jsTestObjPrototypeFunctionOverloadedMethod12(state);
     5440        if (distinguishingArg.isObject() && isJSArray(distinguishingArg))
     5441            return jsTestObjPrototypeFunctionOverloadedMethod7(state);
     5442        if (distinguishingArg.isObject() && asObject(distinguishingArg)->type() != RegExpObjectType)
     5443            return jsTestObjPrototypeFunctionOverloadedMethod5(state);
     5444        if (distinguishingArg.isNumber())
     5445            return jsTestObjPrototypeFunctionOverloadedMethod4(state);
     5446        return jsTestObjPrototypeFunctionOverloadedMethod3(state);
     5447    }
     5448    if (argsCount == 2) {
     5449        JSValue distinguishingArg = state->uncheckedArgument(1);
     5450        if (distinguishingArg.isUndefined())
     5451            return jsTestObjPrototypeFunctionOverloadedMethod2(state);
     5452        if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSBlob::info()))
     5453            return jsTestObjPrototypeFunctionOverloadedMethod12(state);
     5454        if (distinguishingArg.isNumber())
     5455            return jsTestObjPrototypeFunctionOverloadedMethod2(state);
    54285456        return jsTestObjPrototypeFunctionOverloadedMethod1(state);
    5429     if ((argsCount == 1 && (arg0.isUndefinedOrNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))) || (argsCount == 2 && (arg0.isUndefinedOrNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))))
    5430         return jsTestObjPrototypeFunctionOverloadedMethod2(state);
    5431     if ((argsCount == 1 && (arg0.isUndefinedOrNull() || arg0.isString() || arg0.isObject())))
    5432         return jsTestObjPrototypeFunctionOverloadedMethod3(state);
    5433     if (argsCount == 1)
    5434         return jsTestObjPrototypeFunctionOverloadedMethod4(state);
    5435     if ((argsCount == 1 && (arg0.isNull() || arg0.isObject())))
    5436         return jsTestObjPrototypeFunctionOverloadedMethod5(state);
    5437     if ((argsCount == 1 && (arg0.isUndefinedOrNull() || (arg0.isObject() && asObject(arg0)->inherits(JSDOMStringList::info())))))
    5438         return jsTestObjPrototypeFunctionOverloadedMethod6(state);
    5439     if ((argsCount == 1 && (arg0.isUndefinedOrNull() || (arg0.isObject() && isJSArray(arg0)))))
    5440         return jsTestObjPrototypeFunctionOverloadedMethod7(state);
    5441     if ((argsCount == 1 && ((arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))))
    5442         return jsTestObjPrototypeFunctionOverloadedMethod8(state);
    5443     if ((argsCount == 1 && ((arg0.isObject() && isJSArray(arg0)))))
    5444         return jsTestObjPrototypeFunctionOverloadedMethod9(state);
    5445     if ((argsCount == 1 && ((arg0.isObject() && isJSArray(arg0)))))
    5446         return jsTestObjPrototypeFunctionOverloadedMethod10(state);
    5447     if (argsCount == 1)
    5448         return jsTestObjPrototypeFunctionOverloadedMethod11(state);
    5449     if ()
    5450         return jsTestObjPrototypeFunctionOverloadedMethod12(state);
    5451     if (UNLIKELY(argsCount < 1))
    5452         return throwVMError(state, createNotEnoughArgumentsError(state));
     5457    }
    54535458    return throwVMTypeError(state);
    54545459}
     
    54645469    if (UNLIKELY(state->argumentCount() < 1))
    54655470        return throwVMError(state, createNotEnoughArgumentsError(state));
    5466     TestObj* objArg1 = nullptr;
    5467     if (!state->argument(0).isUndefinedOrNull()) {
    5468         objArg1 = JSTestObj::toWrapped(state->uncheckedArgument(0));
    5469         if (UNLIKELY(!objArg1))
    5470             return throwArgumentTypeError(*state, 0, "objArg1", "TestObject", "overloadedMethodWithOptionalParameter", "TestObj");
    5471     }
    5472     TestObj* objArg2 = nullptr;
     5471    auto strArg = state->argument(0).toWTFString(state);
     5472    if (UNLIKELY(state->hadException()))
     5473        return JSValue::encode(jsUndefined());
     5474    TestObj* objArg = nullptr;
    54735475    if (!state->argument(1).isUndefinedOrNull()) {
    5474         objArg2 = JSTestObj::toWrapped(state->uncheckedArgument(1));
    5475         if (UNLIKELY(!objArg2))
    5476             return throwArgumentTypeError(*state, 1, "objArg2", "TestObject", "overloadedMethodWithOptionalParameter", "TestObj");
    5477     }
    5478     impl.overloadedMethodWithOptionalParameter(WTFMove(objArg1), WTFMove(objArg2));
     5476        objArg = JSTestObj::toWrapped(state->uncheckedArgument(1));
     5477        if (UNLIKELY(!objArg))
     5478            return throwArgumentTypeError(*state, 1, "objArg", "TestObject", "overloadedMethodWithOptionalParameter", "TestObj");
     5479    }
     5480    impl.overloadedMethodWithOptionalParameter(WTFMove(strArg), WTFMove(objArg));
    54795481    return JSValue::encode(jsUndefined());
    54805482}
     
    55065508{
    55075509    size_t argsCount = std::min<size_t>(2, state->argumentCount());
    5508     JSValue arg0(state->argument(0));
    5509     JSValue arg1(state->argument(1));
    5510     if ((argsCount == 1 && (arg0.isUndefinedOrNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))) || (argsCount == 2 && (arg0.isUndefinedOrNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info()))) && (arg1.isUndefinedOrNull() || (arg1.isObject() && asObject(arg1)->inherits(JSTestObj::info())))))
     5510    if (argsCount == 1) {
     5511        JSValue distinguishingArg = state->uncheckedArgument(0);
     5512        if (distinguishingArg.isUndefinedOrNull())
     5513            return jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2(state);
     5514        if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSTestObj::info()))
     5515            return jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2(state);
    55115516        return jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1(state);
    5512     if ((argsCount == 1 && (arg0.isUndefinedOrNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))) || (argsCount == 2 && (arg0.isUndefinedOrNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))))
    5513         return jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2(state);
    5514     if (UNLIKELY(argsCount < 1))
    5515         return throwVMError(state, createNotEnoughArgumentsError(state));
    5516     return throwVMTypeError(state);
     5517    }
     5518    if (argsCount == 2) {
     5519        JSValue distinguishingArg = state->uncheckedArgument(0);
     5520        if (distinguishingArg.isUndefinedOrNull())
     5521            return jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2(state);
     5522        if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSTestObj::info()))
     5523            return jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2(state);
     5524        return jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1(state);
     5525    }
     5526    return argsCount < 1 ? throwVMError(state, createNotEnoughArgumentsError(state)) : throwVMTypeError(state);
    55175527}
    55185528
     
    55705580{
    55715581    size_t argsCount = std::min<size_t>(1, state->argumentCount());
     5582    if (argsCount == 1) {
     5583        JSValue distinguishingArg = state->uncheckedArgument(0);
    55725584#if ENABLE(Condition1)
    5573     if (argsCount == 1)
    5574         return jsTestObjConstructorFunctionOverloadedMethod11(state);
    5575 #endif
    5576 
    5577     JSValue arg0(state->argument(0));
     5585        if (distinguishingArg.isNumber())
     5586            return jsTestObjConstructorFunctionOverloadedMethod11(state);
     5587#endif
    55785588#if ENABLE(Condition1)
    5579     if ((argsCount == 1 && (arg0.isUndefinedOrNull() || arg0.isString() || arg0.isObject())))
    55805589        return jsTestObjConstructorFunctionOverloadedMethod12(state);
    55815590#endif
    5582 
    5583     if (UNLIKELY(argsCount < 1))
    5584         return throwVMError(state, createNotEnoughArgumentsError(state));
    5585     return throwVMTypeError(state);
     5591    }
     5592    return argsCount < 1 ? throwVMError(state, createNotEnoughArgumentsError(state)) : throwVMTypeError(state);
    55865593}
    55875594
     
    60836090{
    60846091    size_t argsCount = std::min<size_t>(1, state->argumentCount());
    6085     if (argsCount == 1)
     6092    if (argsCount == 1) {
     6093        JSValue distinguishingArg = state->uncheckedArgument(0);
     6094        if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSFetchRequest::info()))
     6095            return jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2(state);
     6096        if (distinguishingArg.isNumber())
     6097            return jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1(state);
    60866098        return jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1(state);
    6087     JSValue arg0(state->argument(0));
    6088     if ((argsCount == 1 && ((arg0.isObject() && asObject(arg0)->inherits(JSFetchRequest::info())))))
    6089         return jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2(state);
    6090     if (UNLIKELY(argsCount < 1))
    6091         return throwVMError(state, createNotEnoughArgumentsError(state));
    6092     return throwVMTypeError(state);
     6099    }
     6100    return argsCount < 1 ? throwVMError(state, createNotEnoughArgumentsError(state)) : throwVMTypeError(state);
    60936101}
    60946102
  • trunk/Source/WebCore/bindings/scripts/test/TestObj.idl

    r203956 r204028  
    267267    void    overloadedMethod(Blob... blobArgs);
    268268
    269     void overloadedMethodWithOptionalParameter(TestObj? objArg1, optional TestObj? objArg2 = null);
     269    void overloadedMethodWithOptionalParameter(DOMString strArg, optional TestObj? objArg = null);
    270270    void overloadedMethodWithOptionalParameter(TestObj? objArg, optional long longArg);
    271271#endif
     
    278278    // Static method with conditional on overloaded methods
    279279    [Conditional=Condition1] static void overloadedMethod1(long arg);
    280     [Conditional=Condition1] static void overloadedMethod1([StrictTypeChecking] DOMString type);
     280    [Conditional=Condition1] static void overloadedMethod1(DOMString type);
    281281
    282282    void classMethodWithClamp([Clamp] unsigned short objArgsShort, [Clamp] unsigned long objArgsLong);
  • trunk/Source/WebCore/dom/EventTarget.h

    r203391 r204028  
    140140    };
    141141
    142     void addEventListenerForBindings(const AtomicString& eventType, RefPtr<EventListener>&&, bool useCapture);
    143     void removeEventListenerForBindings(const AtomicString& eventType, RefPtr<EventListener>&&, bool useCapture);
     142    void addEventListenerForBindings(const AtomicString& eventType, RefPtr<EventListener>&&, bool useCapture = false);
     143    void removeEventListenerForBindings(const AtomicString& eventType, RefPtr<EventListener>&&, bool useCapture = false);
    144144    void addEventListenerForBindings(const AtomicString& eventType, RefPtr<EventListener>&&, const AddEventListenerOptions&);
    145145    void removeEventListenerForBindings(const AtomicString& eventType, RefPtr<EventListener>&&, const ListenerOptions&);
  • trunk/Source/WebCore/dom/EventTarget.idl

    r203391 r204028  
    2828] interface EventTarget {
    2929#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
    30     [ImplementedAs=addEventListenerForBindings] void addEventListener([AtomicString] DOMString type, EventListener? listener, optional AddEventListenerOptions options);
    31     [ImplementedAs=removeEventListenerForBindings] void removeEventListener([AtomicString] DOMString type, EventListener? listener, optional EventListenerOptions options);
     30    // FIXME: Should be:
     31    // void addEventListener(DOMString type, EventListener? callback, optional (AddEventListenerOptions or boolean) options);
     32    // void removeEventListener(DOMString type, EventListener? callback, optional (EventListenerOptions or boolean) options);
     33    [ImplementedAs=addEventListenerForBindings] void addEventListener([AtomicString] DOMString type, EventListener? listener);
     34    [ImplementedAs=addEventListenerForBindings] void addEventListener([AtomicString] DOMString type, EventListener? listener, AddEventListenerOptions options);
     35    [ImplementedAs=removeEventListenerForBindings] void removeEventListener([AtomicString] DOMString type, EventListener? listener);
     36    [ImplementedAs=removeEventListenerForBindings] void removeEventListener([AtomicString] DOMString type, EventListener? listener, EventListenerOptions options);
    3237#endif
    3338
    34     [ObjCLegacyUnnamedParameters, ImplementedAs=addEventListenerForBindings] void addEventListener([AtomicString] DOMString type, EventListener? listener, optional boolean useCapture = false);
    35     [ObjCLegacyUnnamedParameters, ImplementedAs=removeEventListenerForBindings] void removeEventListener([AtomicString] DOMString type, EventListener? listener, optional boolean useCapture = false);
     39    [ObjCLegacyUnnamedParameters, ImplementedAs=addEventListenerForBindings] void addEventListener([AtomicString] DOMString type, EventListener? listener, boolean useCapture);
     40    [ObjCLegacyUnnamedParameters, ImplementedAs=removeEventListenerForBindings] void removeEventListener([AtomicString] DOMString type, EventListener? listener, boolean useCapture);
    3641
    3742    [ImplementedAs=dispatchEventForBindings, RaisesException] boolean dispatchEvent(Event event);
  • trunk/Source/WebCore/html/HTMLOptionsCollection.h

    r199335 r204028  
    4545    void add(HTMLElement&, HTMLElement* beforeElement, ExceptionCode&);
    4646    void add(HTMLElement&, int beforeIndex, ExceptionCode&);
     47    void add(HTMLElement& element, ExceptionCode& ec) { add(element, nullptr, ec); }
    4748    void remove(int index);
    4849    void remove(HTMLOptionElement&);
  • trunk/Source/WebCore/html/HTMLOptionsCollection.idl

    r203797 r204028  
    3535
    3636#if (!defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C) && (!defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT)
    37     [RaisesException] void add(HTMLElement element, optional HTMLElement? before = null);
    38     [RaisesException] void add(HTMLElement element, optional long index = 0);
     37    // FIXME: Should be:
     38    // void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
     39    [RaisesException] void add(HTMLElement element);
     40    [RaisesException] void add(HTMLElement element, HTMLElement? before);
     41    [RaisesException] void add(HTMLElement element, long index);
    3942#else
    4043    [RaisesException] void add(HTMLOptionElement option, unsigned long index);
  • trunk/Source/WebCore/html/HTMLSelectElement.h

    r201739 r204028  
    5555    void add(HTMLElement&, HTMLElement* beforeElement, ExceptionCode&);
    5656    void add(HTMLElement&, int beforeIndex, ExceptionCode&);
     57    void add(HTMLElement& element, ExceptionCode& ec) { add(element, nullptr, ec); }
    5758
    5859    using Node::remove;
  • trunk/Source/WebCore/html/HTMLSelectElement.idl

    r203797 r204028  
    5454#endif
    5555
    56     [ObjCLegacyUnnamedParameters, RaisesException] void add(HTMLElement element, optional HTMLElement? before = null);
     56    [ObjCLegacyUnnamedParameters, RaisesException] void add(HTMLElement element, HTMLElement? before);
    5757#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
    58     [RaisesException] void add(HTMLElement element, optional long index = 0);
     58    // FIXME: Should be:
     59    // void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
     60    [RaisesException] void add(HTMLElement element, long index);
     61    [RaisesException] void add(HTMLElement element);
     62
    5963    // In JavaScript, we support both option index and option object parameters.
    6064    // As of this writing this cannot be auto-generated.
Note: See TracChangeset for help on using the changeset viewer.