diff --git a/content/canvas/src/CustomQS_Canvas.h b/content/canvas/src/CustomQS_Canvas.h index 731b3032279..44c54914716 100644 --- a/content/canvas/src/CustomQS_Canvas.h +++ b/content/canvas/src/CustomQS_Canvas.h @@ -7,6 +7,8 @@ #include "jsapi.h" +#include "mozilla/dom/ImageData.h" + static bool GetPositiveInt(JSContext* cx, JSObject& obj, const char* name, uint32_t* out) { @@ -24,13 +26,28 @@ GetPositiveInt(JSContext* cx, JSObject& obj, const char* name, uint32_t* out) } static bool -GetImageData(JSContext* cx, const JS::Value& imageData, +GetImageData(JSContext* cx, JS::Value& imageData, uint32_t* width, uint32_t* height, JS::Anchor* array) { if (!imageData.isObject()) { return xpc_qsThrow(cx, NS_ERROR_DOM_TYPE_MISMATCH_ERR); } + nsIDOMImageData* domImageData; + xpc_qsSelfRef imageDataRef; + if (NS_SUCCEEDED(xpc_qsUnwrapArg(cx, imageData, + &domImageData, + &imageDataRef.ptr, + &imageData))) { + mozilla::dom::ImageData* concreteImageData = + static_cast(domImageData); + *width = concreteImageData->GetWidth(); + *height = concreteImageData->GetHeight(); + array->set(concreteImageData->GetDataObject()); + return true; + } + + // TODO - bug 625804: Remove support for duck-typed ImageData. JSObject& dataObject = imageData.toObject(); if (!GetPositiveInt(cx, dataObject, "width", width) || diff --git a/dom/base/nsDOMClassInfoID.h b/dom/base/nsDOMClassInfoID.h index 5e4c796d76a..6fd25a775c3 100644 --- a/dom/base/nsDOMClassInfoID.h +++ b/dom/base/nsDOMClassInfoID.h @@ -91,7 +91,8 @@ DOMCI_CASTABLE_INTERFACE(nsSVGStylableElement, nsIContent, 9, _extra) \ DOMCI_CASTABLE_INTERFACE(nsIDOMWebGLRenderingContext, \ nsIDOMWebGLRenderingContext, 10, _extra) \ DOMCI_CASTABLE_INTERFACE(nsIWebGLUniformLocation, \ - nsIWebGLUniformLocation, 11, _extra) + nsIWebGLUniformLocation, 11, _extra) \ +DOMCI_CASTABLE_INTERFACE(nsIDOMImageData, nsIDOMImageData, 12, _extra) // Make sure all classes mentioned in DOMCI_CASTABLE_INTERFACES // have been declared.