Changeset 57889 in webkit
- Timestamp:
- Apr 20, 2010 7:16:33 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r57888 r57889 1 2010-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 1 19 2010-04-20 Evan Stade <estade@chromium.org> 2 20 -
trunk/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp
r57738 r57889 199 199 switch (args.size()) { 200 200 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); 202 202 break; 203 203 case 5: … … 220 220 switch (args.size()) { 221 221 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); 223 223 break; 224 224 case 5: … … 242 242 switch (args.size()) { 243 243 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); 245 245 break; 246 246 case 5: -
trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm
r57787 r57889 1037 1037 # be converted to a string via .toString). 1038 1038 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); 1040 1040 1041 1041 $parameterIndex++; -
trunk/WebCore/bindings/v8/test/V8TestObj.cpp
r57787 r57889 306 306 static v8::Handle<v8::Value> overloadedMethodCallback(const v8::Arguments& args) { 307 307 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()))) { 309 309 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])))) { 311 311 return overloadedMethod2Callback(args); 312 312 } 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 955 955 } 956 956 957 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, float x, float y) 958 { 959 ASSERT(image); 957 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, float x, float y, ExceptionCode& ec) 958 { 959 if (!image) { 960 ec = TYPE_MISMATCH_ERR; 961 return; 962 } 960 963 IntSize s = size(image); 961 ExceptionCode ec;962 964 drawImage(image, x, y, s.width(), s.height(), ec); 963 965 } … … 966 968 float x, float y, float width, float height, ExceptionCode& ec) 967 969 { 968 ASSERT(image); 970 if (!image) { 971 ec = TYPE_MISMATCH_ERR; 972 return; 973 } 969 974 IntSize s = size(image); 970 975 drawImage(image, FloatRect(0, 0, s.width(), s.height()), FloatRect(x, y, width, height), ec); … … 975 980 float dx, float dy, float dw, float dh, ExceptionCode& ec) 976 981 { 982 if (!image) { 983 ec = TYPE_MISMATCH_ERR; 984 return; 985 } 977 986 drawImage(image, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh), ec); 978 987 } … … 981 990 ExceptionCode& ec) 982 991 { 983 ASSERT(image); 992 if (!image) { 993 ec = TYPE_MISMATCH_ERR; 994 return; 995 } 984 996 985 997 ec = 0; … … 1016 1028 } 1017 1029 1018 void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* canvas, float x, float y) 1019 { 1020 ASSERT(canvas); 1021 ExceptionCode ec; 1030 void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* canvas, float x, float y, ExceptionCode& ec) 1031 { 1032 if (!canvas) { 1033 ec = TYPE_MISMATCH_ERR; 1034 return; 1035 } 1022 1036 drawImage(canvas, x, y, canvas->width(), canvas->height(), ec); 1023 1037 } … … 1026 1040 float x, float y, float width, float height, ExceptionCode& ec) 1027 1041 { 1028 ASSERT(canvas); 1042 if (!canvas) { 1043 ec = TYPE_MISMATCH_ERR; 1044 return; 1045 } 1029 1046 drawImage(canvas, FloatRect(0, 0, canvas->width(), canvas->height()), FloatRect(x, y, width, height), ec); 1030 1047 } … … 1040 1057 const FloatRect& dstRect, ExceptionCode& ec) 1041 1058 { 1042 ASSERT(sourceCanvas); 1059 if (!sourceCanvas) { 1060 ec = TYPE_MISMATCH_ERR; 1061 return; 1062 } 1043 1063 1044 1064 ec = 0; … … 1076 1096 1077 1097 #if ENABLE(VIDEO) 1078 void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, float x, float y) 1079 { 1080 ASSERT(video); 1098 void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, float x, float y, ExceptionCode& ec) 1099 { 1100 if (!video) { 1101 ec = TYPE_MISMATCH_ERR; 1102 return; 1103 } 1081 1104 IntSize s = size(video); 1082 ExceptionCode ec;1083 1105 drawImage(video, x, y, s.width(), s.height(), ec); 1084 1106 } … … 1087 1109 float x, float y, float width, float height, ExceptionCode& ec) 1088 1110 { 1089 ASSERT(video); 1111 if (!video) { 1112 ec = TYPE_MISMATCH_ERR; 1113 return; 1114 } 1090 1115 IntSize s = size(video); 1091 1116 drawImage(video, FloatRect(0, 0, s.width(), s.height()), FloatRect(x, y, width, height), ec); … … 1102 1127 ExceptionCode& ec) 1103 1128 { 1104 ASSERT(video); 1129 if (!video) { 1130 ec = TYPE_MISMATCH_ERR; 1131 return; 1132 } 1105 1133 1106 1134 ec = 0; … … 1221 1249 const String& repetitionType, ExceptionCode& ec) 1222 1250 { 1251 if (!image) { 1252 ec = TYPE_MISMATCH_ERR; 1253 return 0; 1254 } 1223 1255 bool repeatX, repeatY; 1224 1256 ec = 0; … … 1243 1275 const String& repetitionType, ExceptionCode& ec) 1244 1276 { 1277 if (!canvas) { 1278 ec = TYPE_MISMATCH_ERR; 1279 return 0; 1280 } 1245 1281 if (!canvas->width() || !canvas->height()) { 1246 1282 ec = INVALID_STATE_ERR; -
trunk/WebCore/html/canvas/CanvasRenderingContext2D.h
r57787 r57889 155 155 void clearShadow(); 156 156 157 void drawImage(HTMLImageElement*, float x, float y );157 void drawImage(HTMLImageElement*, float x, float y, ExceptionCode&); 158 158 void drawImage(HTMLImageElement*, float x, float y, float width, float height, ExceptionCode&); 159 159 void drawImage(HTMLImageElement*, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, ExceptionCode&); 160 160 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&); 162 162 void drawImage(HTMLCanvasElement*, float x, float y, float width, float height, ExceptionCode&); 163 163 void drawImage(HTMLCanvasElement*, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, ExceptionCode&); 164 164 void drawImage(HTMLCanvasElement*, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&); 165 165 #if ENABLE(VIDEO) 166 void drawImage(HTMLVideoElement*, float x, float y );166 void drawImage(HTMLVideoElement*, float x, float y, ExceptionCode&); 167 167 void drawImage(HTMLVideoElement*, float x, float y, float width, float height, ExceptionCode&); 168 168 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 114 114 void strokeRect(in float x, in float y, in float width, in float height, in [Optional] float lineWidth); 115 115 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); 117 118 void drawImage(in HTMLImageElement image, in float x, in float y, in float width, in float height) 118 119 raises (DOMException); 119 120 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) 120 121 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); 122 124 void drawImage(in HTMLCanvasElement canvas, in float x, in float y, in float width, in float height) 123 125 raises (DOMException); … … 125 127 raises (DOMException); 126 128 #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); 128 131 void drawImage(in HTMLVideoElement video, in float x, in float y, in float width, in float height) 129 132 raises (DOMException);
Note: See TracChangeset
for help on using the changeset viewer.