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
|
|
|
|
|
2020-07-22 18:12:10 +03:00
|
|
|
#include <cstdint>
|
|
|
|
#include <utility>
|
|
|
|
#include "js/RootingAPI.h"
|
|
|
|
#include "mozilla/AlreadyAddRefed.h"
|
|
|
|
#include "mozilla/Assertions.h"
|
2014-01-28 17:04:40 +04:00
|
|
|
#include "mozilla/dom/TypedArray.h"
|
2012-03-16 13:44:08 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2020-07-22 18:12:10 +03:00
|
|
|
#include "nsISupports.h"
|
2019-06-25 09:44:38 +03:00
|
|
|
|
2020-11-23 19:06:52 +03:00
|
|
|
class JSObject;
|
2019-06-25 09:44:38 +03:00
|
|
|
class nsIGlobalObject;
|
2020-11-23 19:06:52 +03:00
|
|
|
struct JSContext;
|
|
|
|
struct JSStructuredCloneReader;
|
|
|
|
struct JSStructuredCloneWriter;
|
2012-03-16 13:44:08 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2020-07-22 18:12:10 +03:00
|
|
|
class ErrorResult;
|
|
|
|
|
2012-03-16 13:44:08 +04:00
|
|
|
namespace dom {
|
|
|
|
|
2020-11-23 19:06:52 +03:00
|
|
|
class GlobalObject;
|
|
|
|
template <typename T>
|
|
|
|
class Optional;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class ImageData final : public nsISupports {
|
2014-06-26 17:30:49 +04:00
|
|
|
~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) {
|
|
|
|
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);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-08-28 02:43:55 +04:00
|
|
|
static already_AddRefed<ImageData> Constructor(
|
|
|
|
const GlobalObject& aGlobal, const Uint8ClampedArray& aData,
|
|
|
|
const uint32_t aWidth, const Optional<uint32_t>& aHeight,
|
|
|
|
ErrorResult& aRv);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-10-22 21:08:52 +04:00
|
|
|
uint32_t Width() const { return mWidth; }
|
|
|
|
uint32_t Height() const { return mHeight; }
|
2014-06-12 00:26:52 +04:00
|
|
|
void GetData(JSContext* cx, JS::MutableHandle<JSObject*> aData) const {
|
|
|
|
aData.set(GetDataObject());
|
2012-06-13 19:14:15 +04:00
|
|
|
}
|
2012-10-22 21:08:52 +04:00
|
|
|
JSObject* GetDataObject() const { return mData; }
|
2012-03-16 13:44:08 +04:00
|
|
|
|
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
|
|
|
|
2019-06-25 09:44:38 +03:00
|
|
|
//[Serializable] implementation
|
|
|
|
static already_AddRefed<ImageData> ReadStructuredClone(
|
|
|
|
JSContext* aCx, nsIGlobalObject* aGlobal,
|
|
|
|
JSStructuredCloneReader* aReader);
|
|
|
|
bool WriteStructuredClone(JSContext* aCx,
|
|
|
|
JSStructuredCloneWriter* aWriter) const;
|
|
|
|
|
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
|