Changeset 57889 in webkit


Ignore:
Timestamp:
Apr 20, 2010 7:16:33 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-20 Yaar Schnitman <yaar@chromium.org>

Reviewed by Nate Chapin.

Null value should be legit value for wrapped types. This requires some cleanup in canvas which was missing built-in null argument checks;
https://bugs.webkit.org/show_bug.cgi?id=37810

  • bindings/js/JSCanvasRenderingContext2DCustom.cpp: (WebCore::JSCanvasRenderingContext2D::drawImage): Passes ec to drawImage(3) too
  • bindings/scripts/CodeGeneratorV8.pm: A null value is now legit value for wrapped types.
  • bindings/v8/test/V8TestObj.cpp: (WebCore::TestObjInternal::overloadedMethodCallback):
  • html/canvas/CanvasRenderingContext2D.cpp: (WebCore::CanvasRenderingContext2D::drawImage): Added null checks. (WebCore::CanvasRenderingContext2D::createPattern): Added null checks.
  • html/canvas/CanvasRenderingContext2D.h: Added needed raises "DOMException".
  • html/canvas/CanvasRenderingContext2D.idl: Added needed raises "DOMException".
Location:
trunk/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r57888 r57889  
     12010-04-20  Yaar Schnitman  <yaar@chromium.org>
     2
     3        Reviewed by Nate Chapin.
     4
     5        Null value should be legit value for wrapped types. This requires some cleanup in canvas which was missing built-in null argument checks;
     6        https://bugs.webkit.org/show_bug.cgi?id=37810
     7
     8        * bindings/js/JSCanvasRenderingContext2DCustom.cpp:
     9        (WebCore::JSCanvasRenderingContext2D::drawImage): Passes ec to drawImage(3) too
     10        * bindings/scripts/CodeGeneratorV8.pm: A null value is now legit value for wrapped types.
     11        * bindings/v8/test/V8TestObj.cpp:
     12        (WebCore::TestObjInternal::overloadedMethodCallback):
     13        * html/canvas/CanvasRenderingContext2D.cpp:
     14        (WebCore::CanvasRenderingContext2D::drawImage): Added null checks.
     15        (WebCore::CanvasRenderingContext2D::createPattern): Added null checks.
     16        * html/canvas/CanvasRenderingContext2D.h: Added needed raises "DOMException".
     17        * html/canvas/CanvasRenderingContext2D.idl: Added needed raises "DOMException".
     18
    1192010-04-20  Evan Stade  <estade@chromium.org>
    220
  • trunk/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp

    r57738 r57889  
    199199        switch (args.size()) {
    200200            case 3:
    201                 context->drawImage(imgElt, args.at(1).toFloat(exec), args.at(2).toFloat(exec));
     201                context->drawImage(imgElt, args.at(1).toFloat(exec), args.at(2).toFloat(exec), ec);
    202202                break;
    203203            case 5:
     
    220220        switch (args.size()) {
    221221            case 3:
    222                 context->drawImage(canvas, args.at(1).toFloat(exec), args.at(2).toFloat(exec));
     222                context->drawImage(canvas, args.at(1).toFloat(exec), args.at(2).toFloat(exec), ec);
    223223                break;
    224224            case 5:
     
    242242            switch (args.size()) {
    243243                case 3:
    244                     context->drawImage(video, args.at(1).toFloat(exec), args.at(2).toFloat(exec));
     244                    context->drawImage(video, args.at(1).toFloat(exec), args.at(2).toFloat(exec), ec);
    245245                    break;
    246246                case 5:
  • trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r57787 r57889  
    10371037        # be converted to a string via .toString).
    10381038        push(@andExpression, "(${value}->IsNull() || ${value}->IsUndefined() || ${value}->IsString() || ${value}->IsObject())") if $codeGenerator->IsStringType($type);
    1039         push(@andExpression, "V8${type}::HasInstance($value)") if IsWrapperType($type);
     1039        push(@andExpression, "(${value}->IsNull() || V8${type}::HasInstance($value))") if IsWrapperType($type);
    10401040
    10411041        $parameterIndex++;
  • trunk/WebCore/bindings/v8/test/V8TestObj.cpp

    r57787 r57889  
    306306static v8::Handle<v8::Value> overloadedMethodCallback(const v8::Arguments& args) {
    307307    INC_STATS("DOM.TestObj.overloadedMethod");
    308     if ((args.Length() == 2 && V8TestObj::HasInstance(args[0]) && (args[1]->IsNull() || args[1]->IsUndefined() || args[1]->IsString() || args[1]->IsObject()))) {
     308    if ((args.Length() == 2 && (args[0]->IsNull() || V8TestObj::HasInstance(args[0])) && (args[1]->IsNull() || args[1]->IsUndefined() || args[1]->IsString() || args[1]->IsObject()))) {
    309309        return overloadedMethod1Callback(args);
    310     } else if ((args.Length() == 1 && V8TestObj::HasInstance(args[0])) || (args.Length() == 2 && V8TestObj::HasInstance(args[0]))) {
     310    } else if ((args.Length() == 1 && (args[0]->IsNull() || V8TestObj::HasInstance(args[0]))) || (args.Length() == 2 && (args[0]->IsNull() || V8TestObj::HasInstance(args[0])))) {
    311311        return overloadedMethod2Callback(args);
    312312    } else if ((args.Length() == 1 && (args[0]->IsNull() || args[0]->IsUndefined() || args[0]->IsString() || args[0]->IsObject()))) {
  • trunk/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r57787 r57889  
    955955}
    956956
    957 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, float x, float y)
    958 {
    959     ASSERT(image);
     957void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, float x, float y, ExceptionCode& ec)
     958{
     959    if (!image) {
     960        ec = TYPE_MISMATCH_ERR;
     961        return;
     962    }
    960963    IntSize s = size(image);
    961     ExceptionCode ec;
    962964    drawImage(image, x, y, s.width(), s.height(), ec);
    963965}
     
    966968    float x, float y, float width, float height, ExceptionCode& ec)
    967969{
    968     ASSERT(image);
     970    if (!image) {
     971        ec = TYPE_MISMATCH_ERR;
     972        return;
     973    }
    969974    IntSize s = size(image);
    970975    drawImage(image, FloatRect(0, 0, s.width(), s.height()), FloatRect(x, y, width, height), ec);
     
    975980    float dx, float dy, float dw, float dh, ExceptionCode& ec)
    976981{
     982    if (!image) {
     983        ec = TYPE_MISMATCH_ERR;
     984        return;
     985    }
    977986    drawImage(image, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh), ec);
    978987}
     
    981990    ExceptionCode& ec)
    982991{
    983     ASSERT(image);
     992    if (!image) {
     993        ec = TYPE_MISMATCH_ERR;
     994        return;
     995    }
    984996
    985997    ec = 0;
     
    10161028}
    10171029
    1018 void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* canvas, float x, float y)
    1019 {
    1020     ASSERT(canvas);
    1021     ExceptionCode ec;
     1030void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* canvas, float x, float y, ExceptionCode& ec)
     1031{
     1032    if (!canvas) {
     1033        ec = TYPE_MISMATCH_ERR;
     1034        return;
     1035    }
    10221036    drawImage(canvas, x, y, canvas->width(), canvas->height(), ec);
    10231037}
     
    10261040    float x, float y, float width, float height, ExceptionCode& ec)
    10271041{
    1028     ASSERT(canvas);
     1042    if (!canvas) {
     1043        ec = TYPE_MISMATCH_ERR;
     1044        return;
     1045    }
    10291046    drawImage(canvas, FloatRect(0, 0, canvas->width(), canvas->height()), FloatRect(x, y, width, height), ec);
    10301047}
     
    10401057    const FloatRect& dstRect, ExceptionCode& ec)
    10411058{
    1042     ASSERT(sourceCanvas);
     1059    if (!sourceCanvas) {
     1060        ec = TYPE_MISMATCH_ERR;
     1061        return;
     1062    }
    10431063
    10441064    ec = 0;
     
    10761096
    10771097#if ENABLE(VIDEO)
    1078 void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, float x, float y)
    1079 {
    1080     ASSERT(video);
     1098void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, float x, float y, ExceptionCode& ec)
     1099{
     1100    if (!video) {
     1101        ec = TYPE_MISMATCH_ERR;
     1102        return;
     1103    }
    10811104    IntSize s = size(video);
    1082     ExceptionCode ec;
    10831105    drawImage(video, x, y, s.width(), s.height(), ec);
    10841106}
     
    10871109                                         float x, float y, float width, float height, ExceptionCode& ec)
    10881110{
    1089     ASSERT(video);
     1111    if (!video) {
     1112        ec = TYPE_MISMATCH_ERR;
     1113        return;
     1114    }
    10901115    IntSize s = size(video);
    10911116    drawImage(video, FloatRect(0, 0, s.width(), s.height()), FloatRect(x, y, width, height), ec);
     
    11021127                                         ExceptionCode& ec)
    11031128{
    1104     ASSERT(video);
     1129    if (!video) {
     1130        ec = TYPE_MISMATCH_ERR;
     1131        return;
     1132    }
    11051133   
    11061134    ec = 0;
     
    12211249    const String& repetitionType, ExceptionCode& ec)
    12221250{
     1251    if (!image) {
     1252        ec = TYPE_MISMATCH_ERR;
     1253        return 0;
     1254    }
    12231255    bool repeatX, repeatY;
    12241256    ec = 0;
     
    12431275    const String& repetitionType, ExceptionCode& ec)
    12441276{
     1277    if (!canvas) {
     1278        ec = TYPE_MISMATCH_ERR;
     1279        return 0;
     1280    }
    12451281    if (!canvas->width() || !canvas->height()) {
    12461282        ec = INVALID_STATE_ERR;
  • trunk/WebCore/html/canvas/CanvasRenderingContext2D.h

    r57787 r57889  
    155155        void clearShadow();
    156156
    157         void drawImage(HTMLImageElement*, float x, float y);
     157        void drawImage(HTMLImageElement*, float x, float y, ExceptionCode&);
    158158        void drawImage(HTMLImageElement*, float x, float y, float width, float height, ExceptionCode&);
    159159        void drawImage(HTMLImageElement*, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, ExceptionCode&);
    160160        void drawImage(HTMLImageElement*, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&);
    161         void drawImage(HTMLCanvasElement*, float x, float y);
     161        void drawImage(HTMLCanvasElement*, float x, float y, ExceptionCode&);
    162162        void drawImage(HTMLCanvasElement*, float x, float y, float width, float height, ExceptionCode&);
    163163        void drawImage(HTMLCanvasElement*, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, ExceptionCode&);
    164164        void drawImage(HTMLCanvasElement*, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&);
    165165#if ENABLE(VIDEO)
    166         void drawImage(HTMLVideoElement*, float x, float y);
     166        void drawImage(HTMLVideoElement*, float x, float y, ExceptionCode&);
    167167        void drawImage(HTMLVideoElement*, float x, float y, float width, float height, ExceptionCode&);
    168168        void drawImage(HTMLVideoElement*, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, ExceptionCode&);
  • trunk/WebCore/html/canvas/CanvasRenderingContext2D.idl

    r57787 r57889  
    114114        void strokeRect(in float x, in float y, in float width, in float height, in [Optional] float lineWidth);
    115115
    116         void drawImage(in HTMLImageElement image, in float x, in float y);
     116        void drawImage(in HTMLImageElement image, in float x, in float y)
     117            raises (DOMException);
    117118        void drawImage(in HTMLImageElement image, in float x, in float y, in float width, in float height)
    118119            raises (DOMException);
    119120        void drawImage(in HTMLImageElement image, in float sx, in float sy, in float sw, in float sh, in float dx, in float dy, in float dw, in float dh)
    120121            raises (DOMException);
    121         void drawImage(in HTMLCanvasElement canvas, in float x, in float y);
     122        void drawImage(in HTMLCanvasElement canvas, in float x, in float y)
     123            raises (DOMException);
    122124        void drawImage(in HTMLCanvasElement canvas, in float x, in float y, in float width, in float height)
    123125            raises (DOMException);
     
    125127            raises (DOMException);
    126128#if defined(ENABLE_VIDEO) && ENABLE_VIDEO
    127         void drawImage(in HTMLVideoElement video, in float x, in float y);
     129        void drawImage(in HTMLVideoElement video, in float x, in float y)
     130            raises (DOMException);
    128131        void drawImage(in HTMLVideoElement video, in float x, in float y, in float width, in float height)
    129132            raises (DOMException);
Note: See TracChangeset for help on using the changeset viewer.