content/canvas/src/ImageData.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:set ts=2 sw=2 et tw=78: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_dom_ImageData_h
michael@0 8 #define mozilla_dom_ImageData_h
michael@0 9
michael@0 10 #include "nsIDOMCanvasRenderingContext2D.h"
michael@0 11
michael@0 12 #include "mozilla/Attributes.h"
michael@0 13 #include "mozilla/dom/BindingUtils.h"
michael@0 14 #include "mozilla/dom/TypedArray.h"
michael@0 15 #include <stdint.h>
michael@0 16
michael@0 17 #include "nsCycleCollectionParticipant.h"
michael@0 18 #include "nsISupportsImpl.h"
michael@0 19 #include "js/GCAPI.h"
michael@0 20
michael@0 21 namespace mozilla {
michael@0 22 namespace dom {
michael@0 23
michael@0 24 class ImageData MOZ_FINAL : public nsISupports
michael@0 25 {
michael@0 26 public:
michael@0 27 ImageData(uint32_t aWidth, uint32_t aHeight, JSObject& aData)
michael@0 28 : mWidth(aWidth)
michael@0 29 , mHeight(aHeight)
michael@0 30 , mData(&aData)
michael@0 31 {
michael@0 32 MOZ_COUNT_CTOR(ImageData);
michael@0 33 HoldData();
michael@0 34 }
michael@0 35
michael@0 36 ~ImageData()
michael@0 37 {
michael@0 38 MOZ_COUNT_DTOR(ImageData);
michael@0 39 DropData();
michael@0 40 }
michael@0 41
michael@0 42 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
michael@0 43 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ImageData)
michael@0 44
michael@0 45 static ImageData* Constructor(const GlobalObject& aGlobal,
michael@0 46 const uint32_t aWidth,
michael@0 47 const uint32_t aHeight,
michael@0 48 ErrorResult& aRv);
michael@0 49
michael@0 50 static ImageData* Constructor(const GlobalObject& aGlobal,
michael@0 51 const Uint8ClampedArray& aData,
michael@0 52 const uint32_t aWidth,
michael@0 53 const Optional<uint32_t>& aHeight,
michael@0 54 ErrorResult& aRv);
michael@0 55
michael@0 56 uint32_t Width() const
michael@0 57 {
michael@0 58 return mWidth;
michael@0 59 }
michael@0 60 uint32_t Height() const
michael@0 61 {
michael@0 62 return mHeight;
michael@0 63 }
michael@0 64 void GetData(JSContext* cx, JS::MutableHandle<JSObject*> aData) const
michael@0 65 {
michael@0 66 aData.set(GetDataObject());
michael@0 67 }
michael@0 68 JSObject* GetDataObject() const
michael@0 69 {
michael@0 70 JS::ExposeObjectToActiveJS(mData);
michael@0 71 return mData;
michael@0 72 }
michael@0 73
michael@0 74 JSObject* WrapObject(JSContext* cx);
michael@0 75
michael@0 76 private:
michael@0 77 void HoldData();
michael@0 78 void DropData();
michael@0 79
michael@0 80 ImageData() MOZ_DELETE;
michael@0 81
michael@0 82 uint32_t mWidth, mHeight;
michael@0 83 JS::Heap<JSObject*> mData;
michael@0 84 };
michael@0 85
michael@0 86 } // namespace dom
michael@0 87 } // namespace mozilla
michael@0 88
michael@0 89 #endif // mozilla_dom_ImageData_h

mercurial