1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/src/DOMPoint.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,77 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef MOZILLA_DOMPOINT_H_ 1.10 +#define MOZILLA_DOMPOINT_H_ 1.11 + 1.12 +#include "nsWrapperCache.h" 1.13 +#include "nsISupports.h" 1.14 +#include "nsCycleCollectionParticipant.h" 1.15 +#include "mozilla/Attributes.h" 1.16 +#include "mozilla/ErrorResult.h" 1.17 +#include "nsCOMPtr.h" 1.18 +#include "mozilla/dom/BindingDeclarations.h" 1.19 + 1.20 +namespace mozilla { 1.21 +namespace dom { 1.22 + 1.23 +class GlobalObject; 1.24 +class DOMPointInit; 1.25 + 1.26 +class DOMPointReadOnly : public nsWrapperCache 1.27 +{ 1.28 +public: 1.29 + DOMPointReadOnly(nsISupports* aParent, double aX, double aY, 1.30 + double aZ, double aW) 1.31 + : mParent(aParent) 1.32 + , mX(aX) 1.33 + , mY(aY) 1.34 + , mZ(aZ) 1.35 + , mW(aW) 1.36 + { 1.37 + SetIsDOMBinding(); 1.38 + } 1.39 + 1.40 + double X() const { return mX; } 1.41 + double Y() const { return mY; } 1.42 + double Z() const { return mZ; } 1.43 + double W() const { return mW; } 1.44 + 1.45 +protected: 1.46 + nsCOMPtr<nsISupports> mParent; 1.47 + double mX, mY, mZ, mW; 1.48 +}; 1.49 + 1.50 +class DOMPoint MOZ_FINAL : public DOMPointReadOnly 1.51 +{ 1.52 +public: 1.53 + DOMPoint(nsISupports* aParent, double aX = 0.0, double aY = 0.0, 1.54 + double aZ = 0.0, double aW = 1.0) 1.55 + : DOMPointReadOnly(aParent, aX, aY, aZ, aW) 1.56 + {} 1.57 + 1.58 + NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMPoint) 1.59 + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMPoint) 1.60 + 1.61 + static already_AddRefed<DOMPoint> 1.62 + Constructor(const GlobalObject& aGlobal, const DOMPointInit& aParams, 1.63 + ErrorResult& aRV); 1.64 + static already_AddRefed<DOMPoint> 1.65 + Constructor(const GlobalObject& aGlobal, double aX, double aY, 1.66 + double aZ, double aW, ErrorResult& aRV); 1.67 + 1.68 + nsISupports* GetParentObject() const { return mParent; } 1.69 + virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; 1.70 + 1.71 + void SetX(double aX) { mX = aX; } 1.72 + void SetY(double aY) { mY = aY; } 1.73 + void SetZ(double aZ) { mZ = aZ; } 1.74 + void SetW(double aW) { mW = aW; } 1.75 +}; 1.76 + 1.77 +} 1.78 +} 1.79 + 1.80 +#endif /*MOZILLA_DOMPOINT_H_*/