michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef MOZILLA_DOMPOINT_H_ michael@0: #define MOZILLA_DOMPOINT_H_ michael@0: michael@0: #include "nsWrapperCache.h" michael@0: #include "nsISupports.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/ErrorResult.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "mozilla/dom/BindingDeclarations.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class GlobalObject; michael@0: class DOMPointInit; michael@0: michael@0: class DOMPointReadOnly : public nsWrapperCache michael@0: { michael@0: public: michael@0: DOMPointReadOnly(nsISupports* aParent, double aX, double aY, michael@0: double aZ, double aW) michael@0: : mParent(aParent) michael@0: , mX(aX) michael@0: , mY(aY) michael@0: , mZ(aZ) michael@0: , mW(aW) michael@0: { michael@0: SetIsDOMBinding(); michael@0: } michael@0: michael@0: double X() const { return mX; } michael@0: double Y() const { return mY; } michael@0: double Z() const { return mZ; } michael@0: double W() const { return mW; } michael@0: michael@0: protected: michael@0: nsCOMPtr mParent; michael@0: double mX, mY, mZ, mW; michael@0: }; michael@0: michael@0: class DOMPoint MOZ_FINAL : public DOMPointReadOnly michael@0: { michael@0: public: michael@0: DOMPoint(nsISupports* aParent, double aX = 0.0, double aY = 0.0, michael@0: double aZ = 0.0, double aW = 1.0) michael@0: : DOMPointReadOnly(aParent, aX, aY, aZ, aW) michael@0: {} michael@0: michael@0: NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMPoint) michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMPoint) michael@0: michael@0: static already_AddRefed michael@0: Constructor(const GlobalObject& aGlobal, const DOMPointInit& aParams, michael@0: ErrorResult& aRV); michael@0: static already_AddRefed michael@0: Constructor(const GlobalObject& aGlobal, double aX, double aY, michael@0: double aZ, double aW, ErrorResult& aRV); michael@0: michael@0: nsISupports* GetParentObject() const { return mParent; } michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: void SetX(double aX) { mX = aX; } michael@0: void SetY(double aY) { mY = aY; } michael@0: void SetZ(double aZ) { mZ = aZ; } michael@0: void SetW(double aW) { mW = aW; } michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif /*MOZILLA_DOMPOINT_H_*/