mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 550309 - Part d: Try unwrapping to nsIDOMImageData in GetImageData(); r=bz
This commit is contained in:
parent
7ea9d494ee
commit
2d3c91199c
@ -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<JSObject*>* array)
|
||||
{
|
||||
if (!imageData.isObject()) {
|
||||
return xpc_qsThrow(cx, NS_ERROR_DOM_TYPE_MISMATCH_ERR);
|
||||
}
|
||||
|
||||
nsIDOMImageData* domImageData;
|
||||
xpc_qsSelfRef imageDataRef;
|
||||
if (NS_SUCCEEDED(xpc_qsUnwrapArg<nsIDOMImageData>(cx, imageData,
|
||||
&domImageData,
|
||||
&imageDataRef.ptr,
|
||||
&imageData))) {
|
||||
mozilla::dom::ImageData* concreteImageData =
|
||||
static_cast<mozilla::dom::ImageData*>(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) ||
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user