b=578439; fix webgl quickstubs; r=vladimir
authorBenoit Jacob <bjacob@mozilla.com>
Fri, 16 Jul 2010 10:30:31 -0400
changeset 47808 974d991f537a7d75fae634d598002477393662e6
parent 47807 cdeaa6dff0a787ecdb83605d3782c969e3ec4a8c
child 47809 a4c91b5940306bc88f1654fd78740ceee9fc25e5
push id14427
push userbjacob@mozilla.com
push dateFri, 16 Jul 2010 14:33:00 +0000
treeherdermozilla-central@77a1e90f665d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvladimir
bugs578439
milestone2.0b2pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
b=578439; fix webgl quickstubs; r=vladimir
content/canvas/src/CustomQS_WebGL.h
--- a/content/canvas/src/CustomQS_WebGL.h
+++ b/content/canvas/src/CustomQS_WebGL.h
@@ -107,16 +107,17 @@ nsICanvasRenderingContextWebGL_BufferDat
     int32 usage;
 
     if (!JS_ValueToECMAInt32(cx, argv[0], &target))
         return JS_FALSE;
     if (!JS_ValueToECMAInt32(cx, argv[2], &usage))
         return JS_FALSE;
 
     if (!JSVAL_IS_PRIMITIVE(argv[1])) {
+
         JSObject *arg2 = JSVAL_TO_OBJECT(argv[1]);
         if (js_IsArrayBuffer(arg2)) {
             wb = js::ArrayBuffer::fromJSObject(arg2);
         } else if (js_IsTypedArray(arg2)) {
             wa = js::TypedArray::fromJSObject(arg2);
         }
     }
 
@@ -270,20 +271,19 @@ nsICanvasRenderingContextWebGL_ReadPixel
         }
         JSObject *retval = js_CreateTypedArrayWithBuffer(cx, js::TypedArray::TYPE_UINT8,
                                                          abufObject, 0, byteLength);
 
         *vp = OBJECT_TO_JSVAL(retval);
         return JS_TRUE; // return here to be unaffected by the *vp = JSVAL_VOID; below
 
         /*** END old API deprecated code ***/
-    } else if (   argc == 7
-               && JSVAL_IS_OBJECT(argv[6])
-               && !JSVAL_IS_PRIMITIVE(argv[6]))
-        {
+    } else if (argc == 7 &&
+               !JSVAL_IS_PRIMITIVE(argv[6]))
+    {
         JSObject *argv6 = JSVAL_TO_OBJECT(argv[6]);
         if (js_IsArrayBuffer(argv6)) {
             rv = self->ReadPixels_buf(argv0, argv1, argv2, argv3,
                                       argv4, argv5, js::ArrayBuffer::fromJSObject(argv6));
         } else if (js_IsTypedArray(argv6)) {
             rv = self->ReadPixels_array(argv0, argv1, argv2, argv3,
                                         argv4, argv5,
                                         js::TypedArray::fromJSObject(argv6));
@@ -344,57 +344,66 @@ nsICanvasRenderingContextWebGL_TexImage2
         xpc_qsSelfRef eltRef;
         rv = xpc_qsUnwrapArg<nsIDOMElement>(cx, argv[2], &elt, &eltRef.ptr, &argv[2]);
         if (NS_FAILED(rv)) return JS_FALSE;
 
         GET_OPTIONAL_UINT32_ARG(argv3, 3);
         GET_OPTIONAL_UINT32_ARG(argv4, 4);
 
         rv = self->TexImage2D_dom_old_API_deprecated(argv0, argv1, elt, argv3, argv4);
-    } else if (argc > 5 && JSVAL_IS_OBJECT(argv[5])) {
+    } else if (argc > 5 &&
+               !JSVAL_IS_PRIMITIVE(argv[5]))
+    {
+
         // implement the variants taking a DOMElement as argv[5]
         GET_UINT32_ARG(argv2, 2);
         GET_UINT32_ARG(argv3, 3);
         GET_UINT32_ARG(argv4, 4);
 
         nsIDOMElement *elt;
         xpc_qsSelfRef eltRef;
         rv = xpc_qsUnwrapArg<nsIDOMElement>(cx, argv[5], &elt, &eltRef.ptr, &argv[5]);
         if (NS_FAILED(rv)) return JS_FALSE;
 
         rv = self->TexImage2D_dom(argv0, argv1, argv2, argv3, argv4, elt);
 
         if (NS_FAILED(rv)) {
             // failed to interprete argv[5] as a DOMElement, now try to interprete it as ImageData
             JSObject *argv5 = JSVAL_TO_OBJECT(argv[5]);
+
             jsval js_width, js_height, js_data;
             JS_GetProperty(cx, argv5, "width", &js_width);
             JS_GetProperty(cx, argv5, "height", &js_height);
             JS_GetProperty(cx, argv5, "data", &js_data);
             if (js_width  == JSVAL_VOID ||
                 js_height == JSVAL_VOID ||
                 js_data   == JSVAL_VOID)
             {
                 xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 5);
                 return JS_FALSE;
             }
             int32 int_width, int_height;
             JSObject *obj_data = JSVAL_TO_OBJECT(js_data);
             if (!JS_ValueToECMAInt32(cx, js_width, &int_width) ||
-                !JS_ValueToECMAInt32(cx, js_height, &int_height) ||
-                !js_IsTypedArray(obj_data))
+                !JS_ValueToECMAInt32(cx, js_height, &int_height))
+            {
+                return JS_FALSE;
+            }
+            if (!js_IsTypedArray(obj_data))
             {
                 xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 5);
                 return JS_FALSE;
             }
             rv = self->TexImage2D_array(argv0, argv1, argv2,
                                         int_width, int_height, 0,
                                         argv3, argv4, js::TypedArray::fromJSObject(obj_data));
         }
-    } else if (argc > 8 && JSVAL_IS_OBJECT(argv[8])) {
+    } else if (argc > 8 &&
+               JSVAL_IS_OBJECT(argv[8])) // here, we allow null !
+    {
         // implement the variants taking a buffer/array as argv[8]
         GET_UINT32_ARG(argv2, 2);
         GET_INT32_ARG(argv3, 3);
         GET_INT32_ARG(argv4, 4);
         GET_INT32_ARG(argv5, 5);
         GET_UINT32_ARG(argv6, 6);
         GET_UINT32_ARG(argv7, 7);
 
@@ -456,17 +465,19 @@ nsICanvasRenderingContextWebGL_TexSubIma
     jsval *argv = JS_ARGV(cx, vp);
 
     // arguments common to all cases
     GET_UINT32_ARG(argv0, 0);
     GET_INT32_ARG(argv1, 1);
     GET_INT32_ARG(argv2, 2);
     GET_INT32_ARG(argv3, 3);
 
-    if (argc > 6 && JSVAL_IS_OBJECT(argv[6])) {
+    if (argc > 6 &&
+        !JSVAL_IS_PRIMITIVE(argv[6]))
+    {
         // implement the variants taking a DOMElement as argv[6]
         GET_UINT32_ARG(argv4, 4);
         GET_UINT32_ARG(argv5, 5);
 
         nsIDOMElement *elt;
         xpc_qsSelfRef eltRef;
         rv = xpc_qsUnwrapArg<nsIDOMElement>(cx, argv[6], &elt, &eltRef.ptr, &argv[6]);
         if (NS_FAILED(rv)) return JS_FALSE;
@@ -485,28 +496,33 @@ nsICanvasRenderingContextWebGL_TexSubIma
                 js_data   == JSVAL_VOID)
             {
                 xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 6);
                 return JS_FALSE;
             }
             int32 int_width, int_height;
             JSObject *obj_data = JSVAL_TO_OBJECT(js_data);
             if (!JS_ValueToECMAInt32(cx, js_width, &int_width) ||
-                !JS_ValueToECMAInt32(cx, js_height, &int_height) ||
-                !js_IsTypedArray(obj_data))
+                !JS_ValueToECMAInt32(cx, js_height, &int_height))
+            {
+                return JS_FALSE;
+            }
+            if (!js_IsTypedArray(obj_data))
             {
                 xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 6);
                 return JS_FALSE;
             }
             rv = self->TexSubImage2D_array(argv0, argv1, argv2, argv3,
                                            int_width, int_height,
                                            argv4, argv5,
                                            js::TypedArray::fromJSObject(obj_data));
         }
-    } else if (argc > 8 && JSVAL_IS_OBJECT(argv[8])) {
+    } else if (argc > 8 &&
+               !JSVAL_IS_PRIMITIVE(argv[8]))
+    {
         // implement the variants taking a buffer/array as argv[8]
         GET_INT32_ARG(argv4, 4);
         GET_INT32_ARG(argv5, 5);
         GET_UINT32_ARG(argv6, 6);
         GET_UINT32_ARG(argv7, 7);
 
         JSObject *argv8 = JSVAL_TO_OBJECT(argv[8]);
         // try to grab either a js::ArrayBuffer or js::TypedArray