1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsGeoPosition_h
7 #define nsGeoPosition_h
10 #include "nsIDOMGeoPositionCoords.h"
11 #include "nsIDOMGeoPosition.h"
13 #include "mozilla/Attributes.h"
14 #include "nsCycleCollectionParticipant.h"
15 #include "nsWrapperCache.h"
16 #include "mozilla/dom/Nullable.h"
17 #include "js/TypeDecls.h"
19 ////////////////////////////////////////////////////
20 // nsGeoPositionCoords
21 ////////////////////////////////////////////////////
24 * Simple object that holds a single point in space.
26 class nsGeoPositionCoords MOZ_FINAL
: public nsIDOMGeoPositionCoords
29 NS_DECL_THREADSAFE_ISUPPORTS
30 NS_DECL_NSIDOMGEOPOSITIONCOORDS
32 nsGeoPositionCoords(double aLat
, double aLong
,
33 double aAlt
, double aHError
,
34 double aVError
, double aHeading
,
37 ~nsGeoPositionCoords();
38 const double mLat
, mLong
, mAlt
, mHError
, mVError
, mHeading
, mSpeed
;
42 ////////////////////////////////////////////////////
44 ////////////////////////////////////////////////////
46 class nsGeoPosition MOZ_FINAL
: public nsIDOMGeoPosition
49 NS_DECL_THREADSAFE_ISUPPORTS
50 NS_DECL_NSIDOMGEOPOSITION
52 nsGeoPosition(double aLat
, double aLong
,
53 double aAlt
, double aHError
,
54 double aVError
, double aHeading
,
55 double aSpeed
, long long aTimestamp
);
58 nsGeoPosition(nsIDOMGeoPositionCoords
*aCoords
,
59 long long aTimestamp
);
61 nsGeoPosition(nsIDOMGeoPositionCoords
*aCoords
,
62 DOMTimeStamp aTimestamp
);
67 nsRefPtr
<nsIDOMGeoPositionCoords
> mCoords
;
70 ////////////////////////////////////////////////////
71 // WebIDL wrappers for the classes above
72 ////////////////////////////////////////////////////
79 class Position MOZ_FINAL
: public nsISupports
,
85 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
86 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Position
)
89 Position(nsISupports
* aParent
, nsIDOMGeoPosition
* aGeoPosition
);
91 nsISupports
* GetParentObject() const;
93 virtual JSObject
* WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
;
95 Coordinates
* Coords();
97 uint64_t Timestamp() const;
99 nsIDOMGeoPosition
* GetWrappedGeoPosition() { return mGeoPosition
; }
102 nsRefPtr
<Coordinates
> mCoordinates
;
103 nsCOMPtr
<nsISupports
> mParent
;
104 nsCOMPtr
<nsIDOMGeoPosition
> mGeoPosition
;
107 class Coordinates MOZ_FINAL
: public nsISupports
,
108 public nsWrapperCache
113 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
114 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Coordinates
)
117 Coordinates(Position
* aPosition
, nsIDOMGeoPositionCoords
* aCoords
);
119 Position
* GetParentObject() const;
121 virtual JSObject
* WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
;
123 double Latitude() const;
125 double Longitude() const;
127 Nullable
<double> GetAltitude() const;
129 double Accuracy() const;
131 Nullable
<double> GetAltitudeAccuracy() const;
133 Nullable
<double> GetHeading() const;
135 Nullable
<double> GetSpeed() const;
137 nsRefPtr
<Position
> mPosition
;
138 nsCOMPtr
<nsIDOMGeoPositionCoords
> mCoords
;
142 } // namespace mozilla
144 #endif /* nsGeoPosition_h */