Bug 801712 part 1. Add the WebIDL binding API to ImageData. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 22 Oct 2012 13:08:52 -0400
changeset 111174 c9773896322992cd5cce897d871e2c414f7515f5
parent 111173 480088c6114cf1e3eedc17b525061d74a080f0db
child 111175 c8ad798b2ced652b26163fdeecadca5b08042419
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewerspeterv
bugs801712
milestone19.0a1
Bug 801712 part 1. Add the WebIDL binding API to ImageData. r=peterv
content/canvas/src/CanvasRenderingContext2D.cpp
content/canvas/src/ImageData.cpp
content/canvas/src/ImageData.h
content/canvas/src/WebGLContextGL.cpp
js/xpconnect/src/dom_quickstubs.qsconf
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -4342,17 +4342,17 @@ CanvasRenderingContext2D::PutImageData(J
   if (!FloatValidate(dx, dy)) {
     error.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
     return;
   }
 
   dom::Uint8ClampedArray arr(cx, imageData->GetDataObject());
 
   error = PutImageData_explicit(JS_DoubleToInt32(dx), JS_DoubleToInt32(dy),
-                                imageData->GetWidth(), imageData->GetHeight(),
+                                imageData->Width(), imageData->Height(),
                                 arr.Data(), arr.Length(), false, 0, 0, 0, 0);
 }
 
 void
 CanvasRenderingContext2D::PutImageData(JSContext* cx,
                                        ImageData* imageData, double dx,
                                        double dy, double dirtyX,
                                        double dirtyY, double dirtyWidth,
@@ -4362,17 +4362,17 @@ CanvasRenderingContext2D::PutImageData(J
   if (!FloatValidate(dx, dy, dirtyX, dirtyY, dirtyWidth, dirtyHeight)) {
     error.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
     return;
   }
 
   dom::Uint8ClampedArray arr(cx, imageData->GetDataObject());
 
   error = PutImageData_explicit(JS_DoubleToInt32(dx), JS_DoubleToInt32(dy),
-                                imageData->GetWidth(), imageData->GetHeight(),
+                                imageData->Width(), imageData->Height(),
                                 arr.Data(), arr.Length(), true,
                                 JS_DoubleToInt32(dirtyX),
                                 JS_DoubleToInt32(dirtyY),
                                 JS_DoubleToInt32(dirtyWidth),
                                 JS_DoubleToInt32(dirtyHeight));
 }
 
 // void putImageData (in ImageData d, in float x, in float y);
@@ -4573,18 +4573,18 @@ CanvasRenderingContext2D::CreateImageDat
   return mozilla::dom::CreateImageData(cx, this, w, h, error);
 }
 
 already_AddRefed<ImageData>
 CanvasRenderingContext2D::CreateImageData(JSContext* cx,
                                           ImageData* imagedata,
                                           ErrorResult& error)
 {
-  return mozilla::dom::CreateImageData(cx, this, imagedata->GetWidth(),
-                                       imagedata->GetHeight(), error);
+  return mozilla::dom::CreateImageData(cx, this, imagedata->Width(),
+                                       imagedata->Height(), error);
 }
 
 NS_IMETHODIMP
 CanvasRenderingContext2D::CreateImageData(const JS::Value &arg1,
                                           const JS::Value &arg2,
                                           JSContext* cx,
                                           uint8_t optional_argc,
                                           nsIDOMImageData** retval)
--- a/content/canvas/src/ImageData.cpp
+++ b/content/canvas/src/ImageData.cpp
@@ -39,25 +39,25 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ImageData)
   tmp->DropData();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 /* readonly attribute unsigned long width; */
 NS_IMETHODIMP
 ImageData::GetWidth(uint32_t* aWidth)
 {
-  *aWidth = GetWidth();
+  *aWidth = Width();
   return NS_OK;
 }
 
 /* readonly attribute unsigned long height; */
 NS_IMETHODIMP
 ImageData::GetHeight(uint32_t* aHeight)
 {
-  *aHeight = GetHeight();
+  *aHeight = Height();
   return NS_OK;
 }
 
 /* readonly attribute jsval data; */
 NS_IMETHODIMP
 ImageData::GetData(JSContext* aCx, JS::Value* aData)
 {
   *aData = JS::ObjectOrNullValue(GetDataObject());
--- a/content/canvas/src/ImageData.h
+++ b/content/canvas/src/ImageData.h
@@ -38,29 +38,29 @@ public:
     MOZ_COUNT_DTOR(ImageData);
     DropData();
   }
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_NSIDOMIMAGEDATA
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ImageData)
 
-  uint32_t GetWidth()
+  uint32_t Width() const
   {
     return mWidth;
   }
-  uint32_t GetHeight()
+  uint32_t Height() const
   {
     return mHeight;
   }
-  JSObject* GetData(JSContext* cx)
+  JSObject* Data(JSContext* cx) const
   {
     return GetDataObject();
   }
-  JSObject* GetDataObject()
+  JSObject* GetDataObject() const
   {
     xpc_UnmarkGrayObject(mData);
     return mData;
   }
 
 private:
   void HoldData();
   void DropData();
--- a/content/canvas/src/WebGLContextGL.cpp
+++ b/content/canvas/src/WebGLContextGL.cpp
@@ -4884,18 +4884,18 @@ WebGLContext::TexImage2D(JSContext* cx, 
         return;
 
     if (!pixels) {
         // Spec says to generate an INVALID_VALUE error
         return ErrorInvalidValue("texImage2D: null ImageData");
     }
     
     Uint8ClampedArray arr(cx, pixels->GetDataObject());
-    return TexImage2D_base(target, level, internalformat, pixels->GetWidth(),
-                           pixels->GetHeight(), 4*pixels->GetWidth(), 0,
+    return TexImage2D_base(target, level, internalformat, pixels->Width(),
+                           pixels->Height(), 4*pixels->Width(), 0,
                            format, type, arr.Data(), arr.Length(), -1,
                            WebGLTexelConversions::RGBA8, false);
 }
 
 
 void
 WebGLContext::TexSubImage2D_base(WebGLenum target, WebGLint level,
                                  WebGLint xoffset, WebGLint yoffset,
@@ -5038,18 +5038,18 @@ WebGLContext::TexSubImage2D(JSContext* c
     if (!IsContextStable())
         return;
 
     if (!pixels)
         return ErrorInvalidValue("texSubImage2D: pixels must not be null!");
 
     Uint8ClampedArray arr(cx, pixels->GetDataObject());
     return TexSubImage2D_base(target, level, xoffset, yoffset,
-                              pixels->GetWidth(), pixels->GetHeight(),
-                              4*pixels->GetWidth(), format, type,
+                              pixels->Width(), pixels->Height(),
+                              4*pixels->Width(), format, type,
                               arr.Data(), arr.Length(),
                               -1,
                               WebGLTexelConversions::RGBA8, false);
 }
 
 bool
 WebGLContext::LoseContext()
 {
--- a/js/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/xpconnect/src/dom_quickstubs.qsconf
@@ -995,20 +995,20 @@ customMethodCalls = {
         'unwrapThisFailureFatal' : False
         },
     'nsIDOMWindow_SetOnmouseleave' : {
         'thisType' : 'nsIDOMWindow',
         'unwrapThisFailureFatal' : False
         },
     'nsIDOMImageData_GetWidth': {
         'thisType': 'nsIDOMImageData',
-        'code': 'uint32_t result = static_cast<mozilla::dom::ImageData*>(self)->GetWidth();',
+        'code': 'uint32_t result = static_cast<mozilla::dom::ImageData*>(self)->Width();',
         'canFail': False
         },
     'nsIDOMImageData_GetHeight': {
         'thisType': 'nsIDOMImageData',
-        'code': 'uint32_t result = static_cast<mozilla::dom::ImageData*>(self)->GetHeight();',
+        'code': 'uint32_t result = static_cast<mozilla::dom::ImageData*>(self)->Height();',
         'canFail': False
         },
     'nsIDOMImageData_GetData': {
         'canFail': False
         }
     }