Changeset 149723 in webkit


Ignore:
Timestamp:
May 8, 2013 1:55:25 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Make optional arguments in CanvasRenderingContext2D match the spec.
https://bugs.webkit.org/show_bug.cgi?id=115723

Patch by Dongseong Hwang <dongseong.hwang@intel.com> on 2013-05-08
Reviewed by Dean Jackson.

Source/WebCore:

WebKit r98985 set many arguments optional although the canvas spec[1] does not
indicate. So this patch corrects CanvasRenderingContext2D.idl to match the spec.

[1] http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas/

Covered by existing tests:

canvas/philip/tests/2d.missingargs.html
fast/canvas/canvas-overloads-strokeRect.html
inspector/profiler/canvas2d/canvas2d-profiler-capturing-basics.html

  • html/canvas/CanvasRenderingContext2D.idl:

LayoutTests:

When tests use <canvas> API with not enough arguments, TypeError
exception is fired now. So three tests are changed to match the canvas
spec.

  • fast/canvas/canvas-overloads-strokeRect-expected.txt:
  • fast/canvas/script-tests/canvas-overloads-strokeRect.js:
  • platform/mac/canvas/philip/tests/2d.missingargs-expected.txt:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r149715 r149723  
     12013-05-08  Dongseong Hwang  <dongseong.hwang@intel.com>
     2
     3        Make optional arguments in CanvasRenderingContext2D match the spec.
     4        https://bugs.webkit.org/show_bug.cgi?id=115723
     5
     6        Reviewed by Dean Jackson.
     7
     8        When tests use <canvas> API with not enough arguments, TypeError
     9        exception is fired now. So three tests are changed to match the canvas
     10        spec.
     11
     12        * fast/canvas/canvas-overloads-strokeRect-expected.txt:
     13        * fast/canvas/script-tests/canvas-overloads-strokeRect.js:
     14        * platform/mac/canvas/philip/tests/2d.missingargs-expected.txt:
     15
    1162013-05-08  Ryosuke Niwa  <rniwa@webkit.org>
    217
  • trunk/LayoutTests/fast/canvas/canvas-overloads-strokeRect-expected.txt

    r87733 r149723  
    44
    55
    6 PASS ctx.strokeRect() is undefined
    7 PASS ctx.strokeRect(0) is undefined
    8 PASS ctx.strokeRect(0, 0) is undefined
    9 PASS ctx.strokeRect(0, 0, 0) is undefined
     6PASS ctx.strokeRect() threw exception TypeError: Not enough arguments.
     7PASS ctx.strokeRect(0) threw exception TypeError: Not enough arguments.
     8PASS ctx.strokeRect(0, 0) threw exception TypeError: Not enough arguments.
     9PASS ctx.strokeRect(0, 0, 0) threw exception TypeError: Not enough arguments.
    1010PASS ctx.strokeRect(0, 0, 0, 0) is undefined
    1111PASS ctx.strokeRect(0, 0, 0, 0, 0) is undefined
  • trunk/LayoutTests/fast/canvas/script-tests/canvas-overloads-strokeRect.js

    r98407 r149723  
    33var ctx = document.createElement('canvas').getContext('2d');
    44
    5 var SyntaxError = "SyntaxError: Syntax error";
    6 var TypeError = "TypeError: Type error";
     5var TypeErrorNotEnoughArguments = "TypeError: Not enough arguments";
    76
    8 shouldBe("ctx.strokeRect()", "undefined");
    9 shouldBe("ctx.strokeRect(0)", "undefined");
    10 shouldBe("ctx.strokeRect(0, 0)", "undefined");
    11 shouldBe("ctx.strokeRect(0, 0, 0)", "undefined");
     7shouldThrow("ctx.strokeRect()", "TypeErrorNotEnoughArguments");
     8shouldThrow("ctx.strokeRect(0)", "TypeErrorNotEnoughArguments");
     9shouldThrow("ctx.strokeRect(0, 0)", "TypeErrorNotEnoughArguments");
     10shouldThrow("ctx.strokeRect(0, 0, 0)", "TypeErrorNotEnoughArguments");
    1211shouldBe("ctx.strokeRect(0, 0, 0, 0)", "undefined");
    1312shouldBe("ctx.strokeRect(0, 0, 0, 0, 0)", "undefined");
  • trunk/LayoutTests/inspector/profiler/canvas2d/canvas2d-profiler-capturing-basics.html

    r133438 r149723  
    231231    for (var i = 0; i < 10; ++i) {
    232232        ctx.rotate(1);
    233         ctx.scale(2);
     233        ctx.scale(2, 2);
    234234        ctx.clip();
    235         ctx.transform(3);
     235        ctx.transform(3, 3, 3, 3, 3, 3);
    236236        ctx.restore();
    237237        assertNumberOfCallsInLog(24 + i);
  • trunk/LayoutTests/platform/mac/canvas/philip/tests/2d.missingargs-expected.txt

    r134859 r149723  
    1 Failed assertion: should throw exception of type TypeError: ctx.scale()
    2 Failed assertion: should throw exception of type TypeError: ctx.scale(1)
    3 Failed assertion: should throw exception of type TypeError: ctx.rotate()
    4 Failed assertion: should throw exception of type TypeError: ctx.translate()
    5 Failed assertion: should throw exception of type TypeError: ctx.translate(0)
    6 Failed assertion: should throw exception of type TypeError: ctx.transform()
    7 Failed assertion: should throw exception of type TypeError: ctx.transform(1)
    8 Failed assertion: should throw exception of type TypeError: ctx.transform(1, 0)
    9 Failed assertion: should throw exception of type TypeError: ctx.transform(1, 0, 0)
    10 Failed assertion: should throw exception of type TypeError: ctx.transform(1, 0, 0, 1)
    11 Failed assertion: should throw exception of type TypeError: ctx.transform(1, 0, 0, 1, 0)
    12 Failed assertion: should throw exception of type TypeError: ctx.setTransform()
    13 Failed assertion: should throw exception of type TypeError: ctx.setTransform(1)
    14 Failed assertion: should throw exception of type TypeError: ctx.setTransform(1, 0)
    15 Failed assertion: should throw exception of type TypeError: ctx.setTransform(1, 0, 0)
    16 Failed assertion: should throw exception of type TypeError: ctx.setTransform(1, 0, 0, 1)
    17 Failed assertion: should throw exception of type TypeError: ctx.setTransform(1, 0, 0, 1, 0)
    18 Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
    19 Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
    20 Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
    21 Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
    22 Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
    23 Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
    24 Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
    25 Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
    26 Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
    27 Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
    28 Failed assertion: should throw exception of type TypeError: ctx.clearRect()
    29 Failed assertion: should throw exception of type TypeError: ctx.clearRect(0)
    30 Failed assertion: should throw exception of type TypeError: ctx.clearRect(0, 0)
    31 Failed assertion: should throw exception of type TypeError: ctx.clearRect(0, 0, 0)
    32 Failed assertion: should throw exception of type TypeError: ctx.fillRect()
    33 Failed assertion: should throw exception of type TypeError: ctx.fillRect(0)
    34 Failed assertion: should throw exception of type TypeError: ctx.fillRect(0, 0)
    35 Failed assertion: should throw exception of type TypeError: ctx.fillRect(0, 0, 0)
    36 Failed assertion: should throw exception of type TypeError: ctx.strokeRect()
    37 Failed assertion: should throw exception of type TypeError: ctx.strokeRect(0)
    38 Failed assertion: should throw exception of type TypeError: ctx.strokeRect(0, 0)
    39 Failed assertion: should throw exception of type TypeError: ctx.strokeRect(0, 0, 0)
    40 Failed assertion: should throw exception of type TypeError: ctx.moveTo()
    41 Failed assertion: should throw exception of type TypeError: ctx.moveTo(0)
    42 Failed assertion: should throw exception of type TypeError: ctx.lineTo()
    43 Failed assertion: should throw exception of type TypeError: ctx.lineTo(0)
    44 Failed assertion: should throw exception of type TypeError: ctx.quadraticCurveTo()
    45 Failed assertion: should throw exception of type TypeError: ctx.quadraticCurveTo(0)
    46 Failed assertion: should throw exception of type TypeError: ctx.quadraticCurveTo(0, 0)
    47 Failed assertion: should throw exception of type TypeError: ctx.quadraticCurveTo(0, 0, 0)
    48 Failed assertion: should throw exception of type TypeError: ctx.bezierCurveTo()
    49 Failed assertion: should throw exception of type TypeError: ctx.bezierCurveTo(0)
    50 Failed assertion: should throw exception of type TypeError: ctx.bezierCurveTo(0, 0)
    51 Failed assertion: should throw exception of type TypeError: ctx.bezierCurveTo(0, 0, 0)
    52 Failed assertion: should throw exception of type TypeError: ctx.bezierCurveTo(0, 0, 0, 0)
    53 Failed assertion: should throw exception of type TypeError: ctx.bezierCurveTo(0, 0, 0, 0, 0)
    54 Failed assertion: should throw exception of type TypeError: ctx.arcTo()
    55 Failed assertion: should throw exception of type TypeError: ctx.arcTo(0)
    56 Failed assertion: should throw exception of type TypeError: ctx.arcTo(0, 0)
    57 Failed assertion: should throw exception of type TypeError: ctx.arcTo(0, 0, 0)
    58 Failed assertion: should throw exception of type TypeError: ctx.arcTo(0, 0, 0, 0)
    59 Failed assertion: should throw exception of type TypeError: ctx.rect()
    60 Failed assertion: should throw exception of type TypeError: ctx.rect(0)
    61 Failed assertion: should throw exception of type TypeError: ctx.rect(0, 0)
    62 Failed assertion: should throw exception of type TypeError: ctx.rect(0, 0, 0)
    63 Failed assertion: should throw exception of type TypeError: ctx.arc()
    64 Failed assertion: should throw exception of type TypeError: ctx.arc(0)
    65 Failed assertion: should throw exception of type TypeError: ctx.arc(0, 0)
    66 Failed assertion: should throw exception of type TypeError: ctx.arc(0, 0, 1)
    67 Failed assertion: should throw exception of type TypeError: ctx.arc(0, 0, 1, 0)
    68 Failed assertion: should throw exception of type TypeError: ctx.isPointInPath()
    69 Failed assertion: should throw exception of type TypeError: ctx.isPointInPath(0)
    70 Failed assertion: should throw exception of type TypeError: ctx.measureText()
    71 Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
    72 Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
    73 Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
    74 Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
    751Failed assertion: expected exception of type TypeError, got: Error: IndexSizeError: DOM Exception 1
    762Failed assertion: expected exception of type TypeError, got: Error: SyntaxError: DOM Exception 12
  • trunk/Source/WebCore/ChangeLog

    r149718 r149723  
     12013-05-08  Dongseong Hwang  <dongseong.hwang@intel.com>
     2
     3        Make optional arguments in CanvasRenderingContext2D match the spec.
     4        https://bugs.webkit.org/show_bug.cgi?id=115723
     5
     6        Reviewed by Dean Jackson.
     7
     8        WebKit r98985 set many arguments optional although the canvas spec[1] does not
     9        indicate. So this patch corrects CanvasRenderingContext2D.idl to match the spec.
     10
     11        [1] http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas/
     12
     13        Covered by existing tests:
     14          canvas/philip/tests/2d.missingargs.html
     15          fast/canvas/canvas-overloads-strokeRect.html
     16          inspector/profiler/canvas2d/canvas2d-profiler-capturing-basics.html
     17
     18        * html/canvas/CanvasRenderingContext2D.idl:
     19
    1202013-05-08  Ryosuke Niwa  <rniwa@webkit.org>
    221
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl

    r149368 r149723  
    3131    void restore();
    3232
    33     void scale([Default=Undefined] optional float sx,
    34                [Default=Undefined] optional float sy);
    35     void rotate([Default=Undefined] optional float angle);
    36     void translate([Default=Undefined] optional float tx,
    37                    [Default=Undefined] optional float ty);
    38     void transform([Default=Undefined] optional float m11,
    39                    [Default=Undefined] optional float m12,
    40                    [Default=Undefined] optional float m21,
    41                    [Default=Undefined] optional float m22,
    42                    [Default=Undefined] optional float dx,
    43                    [Default=Undefined] optional float dy);
    44     void setTransform([Default=Undefined] optional float m11,
    45                       [Default=Undefined] optional float m12,
    46                       [Default=Undefined] optional float m21,
    47                       [Default=Undefined] optional float m22,
    48                       [Default=Undefined] optional float dx,
    49                       [Default=Undefined] optional float dy);
     33    void scale(float sx, float sy);
     34    void rotate(float angle);
     35    void translate(float tx, float ty);
     36    void transform(float m11, float m12, float m21, float m22, float dx, float dy);
     37    void setTransform(float m11, float m12, float m21, float m22, float dx, float dy);
    5038
    5139    attribute float globalAlpha;
    5240    [TreatNullAs=NullString] attribute DOMString globalCompositeOperation;
    5341
    54     CanvasGradient createLinearGradient([Default=Undefined] optional float x0,
    55                                         [Default=Undefined] optional float y0,
    56                                         [Default=Undefined] optional float x1,
    57                                         [Default=Undefined] optional float y1)
     42    CanvasGradient createLinearGradient(float x0, float y0, float x1, float y1)
    5843        raises (DOMException);
    59     CanvasGradient createRadialGradient([Default=Undefined] optional float x0,
    60                                         [Default=Undefined] optional float y0,
    61                                         [Default=Undefined] optional float r0,
    62                                         [Default=Undefined] optional float x1,
    63                                         [Default=Undefined] optional float y1,
    64                                         [Default=Undefined] optional float r1)
     44    CanvasGradient createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1)
    6545        raises (DOMException);
    6646
     
    8262    attribute float webkitLineDashOffset;
    8363
    84     void clearRect([Default=Undefined] optional float x,
    85                    [Default=Undefined] optional float y,
    86                    [Default=Undefined] optional float width,
    87                    [Default=Undefined] optional float height);
    88     void fillRect([Default=Undefined] optional float x,
    89                   [Default=Undefined] optional float y,
    90                   [Default=Undefined] optional float width,
    91                   [Default=Undefined] optional float height);
     64    void clearRect(float x, float y, float width, float height);
     65    void fillRect(float x, float y, float width, float height);
    9266
    9367    void beginPath();
     
    9973    // FIXME: These methods should be shared with CanvasRenderingContext2D in the CanvasPathMethods interface.
    10074    void closePath();
    101     void moveTo([Default=Undefined] optional float x,
    102                 [Default=Undefined] optional float y);
    103     void lineTo([Default=Undefined] optional float x,
    104                 [Default=Undefined] optional float y);
    105     void quadraticCurveTo([Default=Undefined] optional float cpx,
    106                           [Default=Undefined] optional float cpy,
    107                           [Default=Undefined] optional float x,
    108                           [Default=Undefined] optional float y);
    109     void bezierCurveTo([Default=Undefined] optional float cp1x,
    110                        [Default=Undefined] optional float cp1y,
    111                        [Default=Undefined] optional float cp2x,
    112                        [Default=Undefined] optional float cp2y,
    113                        [Default=Undefined] optional float x,
    114                        [Default=Undefined] optional float y);
    115     void arcTo([Default=Undefined] optional float x1,
    116                [Default=Undefined] optional float y1,
    117                [Default=Undefined] optional float x2,
    118                [Default=Undefined] optional float y2,
    119                [Default=Undefined] optional float radius)
     75    void moveTo(float x, float y);
     76    void lineTo(float x, float y);
     77    void quadraticCurveTo(float cpx, float cpy, float x, float y);
     78    void bezierCurveTo(float cp1x, float cp1y, float cp2x, float cp2y, float x, float y);
     79    void arcTo(float x1, float y1, float x2, float y2, float radius)
    12080        raises (DOMException);
    121     void rect([Default=Undefined] optional float x,
    122               [Default=Undefined] optional float y,
    123               [Default=Undefined] optional float width,
    124               [Default=Undefined] optional float height);
    125     void arc([Default=Undefined] optional float x,
    126              [Default=Undefined] optional float y,
    127              [Default=Undefined] optional float radius,
    128              [Default=Undefined] optional float startAngle,
    129              [Default=Undefined] optional float endAngle,
    130              [Default=Undefined] optional boolean anticlockwise)
     81    void rect(float x, float y, float width, float height);
     82    void arc(float x, float y, float radius, float startAngle, float endAngle, [Default=Undefined] optional boolean anticlockwise)
    13183        raises (DOMException);
    13284
     
    13486    void stroke();
    13587    void clip(optional CanvasWindingRule winding);
    136     boolean isPointInPath([Default=Undefined] optional float x,
    137                           [Default=Undefined] optional float y,
    138                           optional CanvasWindingRule winding);
    139     boolean isPointInStroke([Default=Undefined] optional float x,
    140                             [Default=Undefined] optional float y);
     88    boolean isPointInPath(float x, float y, optional CanvasWindingRule winding);
     89    boolean isPointInStroke(float x, float y);
    14190
    14291    // text
     
    14594    attribute DOMString textBaseline;
    14695
    147     TextMetrics measureText([Default=Undefined] optional DOMString text);
     96    TextMetrics measureText(DOMString text);
    14897
    14998    // other
     
    174123    void setFillColor(float c, float m, float y, float k, float a);
    175124
    176     void strokeRect([Default=Undefined] optional float x,
    177                     [Default=Undefined] optional float y,
    178                     [Default=Undefined] optional float width,
    179                     [Default=Undefined] optional float height,
    180                     optional float lineWidth);
     125    void strokeRect(float x, float y, float width, float height, optional float lineWidth);
    181126
    182127    void drawImage(HTMLImageElement? image, float x, float y)
     
    234179
    235180    // pixel manipulation
    236     ImageData getImageData([Default=Undefined] optional float sx, [Default=Undefined] optional float sy,
    237                            [Default=Undefined] optional float sw, [Default=Undefined] optional float sh)
     181    ImageData getImageData(float sx, float sy, float sw, float sh)
    238182        raises(DOMException);
    239183
    240     ImageData webkitGetImageDataHD([Default=Undefined] optional float sx, [Default=Undefined] optional float sy,
    241                                    [Default=Undefined] optional float sw, [Default=Undefined] optional float sh)
     184    ImageData webkitGetImageDataHD(float sx, float sy, float sw, float sh)
    242185        raises(DOMException);
    243186
Note: See TracChangeset for help on using the changeset viewer.