2012-03-16 13:44:08 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 et tw=78: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_ImageData_h
|
|
|
|
#define mozilla_dom_ImageData_h
|
|
|
|
|
|
|
|
#include "nsIDOMCanvasRenderingContext2D.h"
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
2014-01-28 17:04:40 +04:00
|
|
|
#include "mozilla/dom/BindingUtils.h"
|
|
|
|
#include "mozilla/dom/TypedArray.h"
|
2013-07-30 18:25:31 +04:00
|
|
|
#include <stdint.h>
|
2012-03-16 13:44:08 +04:00
|
|
|
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2014-02-27 01:36:35 +04:00
|
|
|
#include "nsISupportsImpl.h"
|
2013-09-09 07:28:48 +04:00
|
|
|
#include "js/GCAPI.h"
|
2012-03-16 13:44:08 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class ImageData final : public nsISupports
|
2012-03-16 13:44:08 +04:00
|
|
|
{
|
2014-06-26 17:30:49 +04:00
|
|
|
~ImageData()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(ImageData);
|
|
|
|
DropData();
|
|
|
|
}
|
|
|
|
|
2012-03-16 13:44:08 +04:00
|
|
|
public:
|
|
|
|
ImageData(uint32_t aWidth, uint32_t aHeight, JSObject& aData)
|
|
|
|
: mWidth(aWidth)
|
|
|
|
, mHeight(aHeight)
|
|
|
|
, mData(&aData)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ImageData);
|
|
|
|
HoldData();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ImageData)
|
|
|
|
|
2014-08-28 02:43:55 +04:00
|
|
|
static already_AddRefed<ImageData>
|
|
|
|
Constructor(const GlobalObject& aGlobal,
|
|
|
|
const uint32_t aWidth,
|
|
|
|
const uint32_t aHeight,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
static already_AddRefed<ImageData>
|
|
|
|
Constructor(const GlobalObject& aGlobal,
|
|
|
|
const Uint8ClampedArray& aData,
|
|
|
|
const uint32_t aWidth,
|
|
|
|
const Optional<uint32_t>& aHeight,
|
|
|
|
ErrorResult& aRv);
|
2014-01-28 17:04:40 +04:00
|
|
|
|
2012-10-22 21:08:52 +04:00
|
|
|
uint32_t Width() const
|
2012-03-16 13:44:08 +04:00
|
|
|
{
|
|
|
|
return mWidth;
|
|
|
|
}
|
2012-10-22 21:08:52 +04:00
|
|
|
uint32_t Height() const
|
2012-03-16 13:44:08 +04:00
|
|
|
{
|
|
|
|
return mHeight;
|
|
|
|
}
|
2014-06-12 00:26:52 +04:00
|
|
|
void GetData(JSContext* cx, JS::MutableHandle<JSObject*> aData) const
|
2012-06-13 19:14:15 +04:00
|
|
|
{
|
2014-06-12 00:26:52 +04:00
|
|
|
aData.set(GetDataObject());
|
2012-06-13 19:14:15 +04:00
|
|
|
}
|
2012-10-22 21:08:52 +04:00
|
|
|
JSObject* GetDataObject() const
|
2012-03-16 13:44:08 +04:00
|
|
|
{
|
2013-09-09 07:28:48 +04:00
|
|
|
JS::ExposeObjectToActiveJS(mData);
|
2012-03-16 13:44:08 +04:00
|
|
|
return mData;
|
|
|
|
}
|
|
|
|
|
Bug 1117172 part 2. Change the non-wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, Codegen.py, and
StructuredClone.cpp. The rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/WrapObject\((JSContext *\* *(?:aCx|cx)),(\s*)(JS::MutableHandle<JSObject\*> aReflector)/WrapObject(\1,\2JS::Handle<JSObject*> aGivenProto,\2\3/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx)), this, aReflector/\1, this, aGivenProto, aReflector/'
2015-03-19 17:13:32 +03:00
|
|
|
bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
|
2012-10-22 21:08:52 +04:00
|
|
|
|
2012-03-16 13:44:08 +04:00
|
|
|
private:
|
|
|
|
void HoldData();
|
|
|
|
void DropData();
|
|
|
|
|
2015-01-07 02:35:02 +03:00
|
|
|
ImageData() = delete;
|
2012-03-16 13:44:08 +04:00
|
|
|
|
|
|
|
uint32_t mWidth, mHeight;
|
2013-06-18 14:00:38 +04:00
|
|
|
JS::Heap<JSObject*> mData;
|
2012-03-16 13:44:08 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_ImageData_h
|