Backed out changeset 58dbd2146e24 (bug 944961) for bustage.
[gecko.git] / content / canvas / src / ImageData.h
blob40e6fb913f079bd6194b7f724450e0fc70957223
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 et tw=78: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_ImageData_h
8 #define mozilla_dom_ImageData_h
10 #include "nsIDOMCanvasRenderingContext2D.h"
12 #include "mozilla/Attributes.h"
13 #include <stdint.h>
15 #include "nsCycleCollectionParticipant.h"
16 #include "nsTraceRefcnt.h"
17 #include "js/GCAPI.h"
19 namespace mozilla {
20 namespace dom {
22 class ImageData MOZ_FINAL : public nsISupports
24 public:
25 ImageData(uint32_t aWidth, uint32_t aHeight, JSObject& aData)
26 : mWidth(aWidth)
27 , mHeight(aHeight)
28 , mData(&aData)
30 MOZ_COUNT_CTOR(ImageData);
31 HoldData();
34 ~ImageData()
36 MOZ_COUNT_DTOR(ImageData);
37 DropData();
40 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
41 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ImageData)
43 uint32_t Width() const
45 return mWidth;
47 uint32_t Height() const
49 return mHeight;
51 JSObject* Data(JSContext* cx) const
53 return GetDataObject();
55 JSObject* GetDataObject() const
57 JS::ExposeObjectToActiveJS(mData);
58 return mData;
61 JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> scope);
63 private:
64 void HoldData();
65 void DropData();
67 ImageData() MOZ_DELETE;
69 uint32_t mWidth, mHeight;
70 JS::Heap<JSObject*> mData;
73 } // namespace dom
74 } // namespace mozilla
76 #endif // mozilla_dom_ImageData_h