Changeset 87732 in webkit


Ignore:
Timestamp:
May 31, 2011 9:15:27 AM (13 years ago)
Author:
andreas.kling@nokia.com
Message:

2011-05-31 Andreas Kling <kling@webkit.org>

Reviewed by Antti Koivisto.

Canvas/JSC: Auto-generate overloads for setFillColor()
https://bugs.webkit.org/show_bug.cgi?id=61635

Move CanvasRenderingContext2D.setStrokeColor() to auto-generated JSC bindings.

There is a subtle difference to the previous behavior: invalid numbers of
arguments now raise TypeError instead of SyntaxError. This is in accordance
with Web IDL, but doesn't matter much anyway since this method is WebKit-only.

Test: fast/canvas/canvas-overloads-setFillColor.html

  • bindings/js/JSCanvasRenderingContext2DCustom.cpp:
  • html/canvas/CanvasRenderingContext2D.idl:

2011-05-31 Andreas Kling <kling@webkit.org>

Reviewed by Antti Koivisto.

Canvas/JSC: Auto-generate overloads for setFillColor()
https://bugs.webkit.org/show_bug.cgi?id=61635

Add a test to verify the behavior of setFillColor() when called with
different numbers of arguments.

  • fast/canvas/canvas-overloads-setFillColor-expected.txt: Added.
  • fast/canvas/canvas-overloads-setFillColor.html: Added.
  • fast/canvas/script-tests/canvas-overloads-setFillColor.js: Added.
Location:
trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r87731 r87732  
     12011-05-31  Andreas Kling  <kling@webkit.org>
     2
     3        Reviewed by Antti Koivisto.
     4
     5        Canvas/JSC: Auto-generate overloads for setFillColor()
     6        https://bugs.webkit.org/show_bug.cgi?id=61635
     7
     8        Add a test to verify the behavior of setFillColor() when called with
     9        different numbers of arguments.
     10
     11        * fast/canvas/canvas-overloads-setFillColor-expected.txt: Added.
     12        * fast/canvas/canvas-overloads-setFillColor.html: Added.
     13        * fast/canvas/script-tests/canvas-overloads-setFillColor.js: Added.
     14
    1152011-05-31  Andreas Kling  <kling@webkit.org>
    216
  • trunk/Source/WebCore/ChangeLog

    r87731 r87732  
     12011-05-31  Andreas Kling  <kling@webkit.org>
     2
     3        Reviewed by Antti Koivisto.
     4
     5        Canvas/JSC: Auto-generate overloads for setFillColor()
     6        https://bugs.webkit.org/show_bug.cgi?id=61635
     7
     8        Move CanvasRenderingContext2D.setStrokeColor() to auto-generated JSC bindings.
     9
     10        There is a subtle difference to the previous behavior: invalid numbers of
     11        arguments now raise TypeError instead of SyntaxError. This is in accordance
     12        with Web IDL, but doesn't matter much anyway since this method is WebKit-only.
     13
     14        Test: fast/canvas/canvas-overloads-setFillColor.html
     15
     16        * bindings/js/JSCanvasRenderingContext2DCustom.cpp:
     17        * html/canvas/CanvasRenderingContext2D.idl:
     18
    1192011-05-31  Andreas Kling  <kling@webkit.org>
    220
  • trunk/Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp

    r87731 r87732  
    9595    context->setFillStyle(toHTMLCanvasStyle(exec, value));
    9696}
    97 
    98 JSValue JSCanvasRenderingContext2D::setFillColor(ExecState* exec)
    99 {
    100     CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
    101 
    102     // string arg = named color
    103     // number arg = gray color
    104     // string arg, number arg = named color, alpha
    105     // number arg, number arg = gray color, alpha
    106     // 4 args = r, g, b, a
    107     // 5 args = c, m, y, k, a
    108     switch (exec->argumentCount()) {
    109         case 1:
    110             if (exec->argument(0).isString())
    111                 context->setFillColor(ustringToString(asString(exec->argument(0))->value(exec)));
    112             else
    113                 context->setFillColor(exec->argument(0).toFloat(exec));
    114             break;
    115         case 2:
    116             if (exec->argument(0).isString())
    117                 context->setFillColor(ustringToString(asString(exec->argument(0))->value(exec)), exec->argument(1).toFloat(exec));
    118             else
    119                 context->setFillColor(exec->argument(0).toFloat(exec), exec->argument(1).toFloat(exec));
    120             break;
    121         case 4:
    122             context->setFillColor(exec->argument(0).toFloat(exec), exec->argument(1).toFloat(exec),
    123                                   exec->argument(2).toFloat(exec), exec->argument(3).toFloat(exec));
    124             break;
    125         case 5:
    126             context->setFillColor(exec->argument(0).toFloat(exec), exec->argument(1).toFloat(exec),
    127                                   exec->argument(2).toFloat(exec), exec->argument(3).toFloat(exec), exec->argument(4).toFloat(exec));
    128             break;
    129         default:
    130             return throwSyntaxError(exec);
    131     }
    132     return jsUndefined();
    133 }   
    13497
    13598JSValue JSCanvasRenderingContext2D::strokeRect(ExecState* exec)
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl

    r87731 r87732  
    108108        void setStrokeColor(in float c, in float m, in float y, in float k, in float a);
    109109
    110 #if defined(V8_BINDING) && V8_BINDING
    111110        void setFillColor(in DOMString color, in [Optional] float alpha);
    112111        void setFillColor(in float grayLevel, in [Optional] float alpha);
     
    114113        void setFillColor(in float c, in float m, in float y, in float k, in float a);
    115114
     115#if defined(V8_BINDING) && V8_BINDING
    116116        void strokeRect(in float x, in float y, in float width, in float height, in [Optional] float lineWidth);
    117117
     
    157157#else
    158158        // FIXME: Remove 'else' once JSC supports overloads too.
    159         [Custom] void setFillColor(/* 1 */);
    160159        [Custom] void strokeRect(/* 4 */);
    161160        [Custom] void drawImage(/* 3 */);
Note: See TracChangeset for help on using the changeset viewer.