1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_GeolocationPosition_h
8 #define mozilla_dom_GeolocationPosition_h
10 #include "nsIDOMGeoPositionCoords.h"
11 #include "nsIDOMGeoPosition.h"
13 #include "nsCycleCollectionParticipant.h"
14 #include "nsWrapperCache.h"
15 #include "js/TypeDecls.h"
17 ////////////////////////////////////////////////////
18 // nsGeoPositionCoords
19 ////////////////////////////////////////////////////
22 * Simple object that holds a single point in space.
24 class nsGeoPositionCoords final
: public nsIDOMGeoPositionCoords
{
26 NS_DECL_THREADSAFE_ISUPPORTS
27 NS_DECL_NSIDOMGEOPOSITIONCOORDS
29 nsGeoPositionCoords(double aLat
, double aLong
, double aAlt
, double aHError
,
30 double aVError
, double aHeading
, double aSpeed
);
33 ~nsGeoPositionCoords();
34 const double mLat
, mLong
, mAlt
, mHError
, mVError
, mHeading
, mSpeed
;
37 ////////////////////////////////////////////////////
39 ////////////////////////////////////////////////////
41 class nsGeoPosition final
: public nsIDOMGeoPosition
{
43 NS_DECL_THREADSAFE_ISUPPORTS
44 NS_DECL_NSIDOMGEOPOSITION
46 nsGeoPosition(double aLat
, double aLong
, double aAlt
, double aHError
,
47 double aVError
, double aHeading
, double aSpeed
,
48 EpochTimeStamp aTimestamp
);
50 nsGeoPosition(nsIDOMGeoPositionCoords
* aCoords
, EpochTimeStamp aTimestamp
);
54 EpochTimeStamp mTimestamp
;
55 RefPtr
<nsIDOMGeoPositionCoords
> mCoords
;
58 ////////////////////////////////////////////////////
59 // WebIDL wrappers for the classes above
60 ////////////////////////////////////////////////////
62 namespace mozilla::dom
{
64 class GeolocationCoordinates
;
66 class GeolocationPosition final
: public nsISupports
, public nsWrapperCache
{
67 ~GeolocationPosition();
70 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
71 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(GeolocationPosition
)
74 GeolocationPosition(nsISupports
* aParent
, nsIDOMGeoPosition
* aGeoPosition
);
76 nsISupports
* GetParentObject() const;
78 virtual JSObject
* WrapObject(JSContext
* aCx
,
79 JS::Handle
<JSObject
*> aGivenProto
) override
;
81 GeolocationCoordinates
* Coords();
83 uint64_t Timestamp() const;
85 nsIDOMGeoPosition
* GetWrappedGeoPosition() { return mGeoPosition
; }
88 RefPtr
<GeolocationCoordinates
> mCoordinates
;
89 nsCOMPtr
<nsISupports
> mParent
;
90 nsCOMPtr
<nsIDOMGeoPosition
> mGeoPosition
;
93 } // namespace mozilla::dom
95 #endif /* mozilla_dom_GeolocationPosition_h */