2010-06-04 14:14:43 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-06-04 14:14:43 -07:00
|
|
|
|
|
|
|
#ifndef nsGeoPosition_h
|
|
|
|
#define nsGeoPosition_h
|
|
|
|
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsIDOMGeoPositionCoords.h"
|
|
|
|
#include "nsIDOMGeoPosition.h"
|
2010-09-20 21:16:37 -07:00
|
|
|
#include "nsString.h"
|
2012-06-14 19:31:55 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-04-12 11:46:27 -07:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "mozilla/dom/Nullable.h"
|
2013-08-27 19:59:14 -07:00
|
|
|
#include "js/TypeDecls.h"
|
2010-09-20 21:16:37 -07:00
|
|
|
|
2010-06-04 14:14:43 -07:00
|
|
|
////////////////////////////////////////////////////
|
|
|
|
// nsGeoPositionCoords
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple object that holds a single point in space.
|
|
|
|
*/
|
2012-02-27 05:28:25 -08:00
|
|
|
class nsGeoPositionCoords MOZ_FINAL : public nsIDOMGeoPositionCoords
|
2010-06-04 14:14:43 -07:00
|
|
|
{
|
|
|
|
public:
|
2013-07-18 19:21:20 -07:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2010-06-04 14:14:43 -07:00
|
|
|
NS_DECL_NSIDOMGEOPOSITIONCOORDS
|
|
|
|
|
2010-11-16 00:23:05 -08:00
|
|
|
nsGeoPositionCoords(double aLat, double aLong,
|
|
|
|
double aAlt, double aHError,
|
|
|
|
double aVError, double aHeading,
|
|
|
|
double aSpeed);
|
2012-02-27 05:28:25 -08:00
|
|
|
private:
|
2014-06-23 12:56:07 -07:00
|
|
|
~nsGeoPositionCoords();
|
2010-09-20 21:16:37 -07:00
|
|
|
const double mLat, mLong, mAlt, mHError, mVError, mHeading, mSpeed;
|
2010-06-04 14:14:43 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
// nsGeoPosition
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
2012-06-14 19:31:55 -07:00
|
|
|
class nsGeoPosition MOZ_FINAL : public nsIDOMGeoPosition
|
2010-06-04 14:14:43 -07:00
|
|
|
{
|
|
|
|
public:
|
2013-07-18 19:21:20 -07:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2010-06-04 14:14:43 -07:00
|
|
|
NS_DECL_NSIDOMGEOPOSITION
|
|
|
|
|
|
|
|
nsGeoPosition(double aLat, double aLong,
|
|
|
|
double aAlt, double aHError,
|
|
|
|
double aVError, double aHeading,
|
|
|
|
double aSpeed, long long aTimestamp);
|
|
|
|
|
2010-09-20 21:16:37 -07:00
|
|
|
|
|
|
|
nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
|
|
|
|
long long aTimestamp);
|
|
|
|
|
|
|
|
nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
|
|
|
|
DOMTimeStamp aTimestamp);
|
|
|
|
|
2010-06-04 14:14:43 -07:00
|
|
|
private:
|
|
|
|
~nsGeoPosition();
|
|
|
|
long long mTimestamp;
|
2010-09-20 21:16:37 -07:00
|
|
|
nsRefPtr<nsIDOMGeoPositionCoords> mCoords;
|
2010-06-04 14:14:43 -07:00
|
|
|
};
|
|
|
|
|
2013-04-12 11:46:27 -07:00
|
|
|
////////////////////////////////////////////////////
|
|
|
|
// WebIDL wrappers for the classes above
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class Coordinates;
|
|
|
|
|
|
|
|
class Position MOZ_FINAL : public nsISupports,
|
|
|
|
public nsWrapperCache
|
|
|
|
{
|
2014-06-23 12:56:07 -07:00
|
|
|
~Position();
|
|
|
|
|
2013-04-12 11:46:27 -07:00
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Position)
|
|
|
|
|
|
|
|
public:
|
|
|
|
Position(nsISupports* aParent, nsIDOMGeoPosition* aGeoPosition);
|
|
|
|
|
|
|
|
nsISupports* GetParentObject() const;
|
|
|
|
|
2014-04-08 15:27:18 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2013-04-12 11:46:27 -07:00
|
|
|
|
|
|
|
Coordinates* Coords();
|
|
|
|
|
|
|
|
uint64_t Timestamp() const;
|
|
|
|
|
2013-04-12 11:46:36 -07:00
|
|
|
nsIDOMGeoPosition* GetWrappedGeoPosition() { return mGeoPosition; }
|
|
|
|
|
2013-04-12 11:46:27 -07:00
|
|
|
private:
|
|
|
|
nsRefPtr<Coordinates> mCoordinates;
|
|
|
|
nsCOMPtr<nsISupports> mParent;
|
|
|
|
nsCOMPtr<nsIDOMGeoPosition> mGeoPosition;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Coordinates MOZ_FINAL : public nsISupports,
|
|
|
|
public nsWrapperCache
|
|
|
|
{
|
2014-06-23 12:56:07 -07:00
|
|
|
~Coordinates();
|
|
|
|
|
2013-04-12 11:46:27 -07:00
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Coordinates)
|
|
|
|
|
|
|
|
public:
|
|
|
|
Coordinates(Position* aPosition, nsIDOMGeoPositionCoords* aCoords);
|
|
|
|
|
|
|
|
Position* GetParentObject() const;
|
|
|
|
|
2014-04-08 15:27:18 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2013-04-12 11:46:27 -07:00
|
|
|
|
|
|
|
double Latitude() const;
|
|
|
|
|
|
|
|
double Longitude() const;
|
|
|
|
|
|
|
|
Nullable<double> GetAltitude() const;
|
|
|
|
|
|
|
|
double Accuracy() const;
|
|
|
|
|
|
|
|
Nullable<double> GetAltitudeAccuracy() const;
|
|
|
|
|
|
|
|
Nullable<double> GetHeading() const;
|
|
|
|
|
|
|
|
Nullable<double> GetSpeed() const;
|
|
|
|
private:
|
|
|
|
nsRefPtr<Position> mPosition;
|
|
|
|
nsCOMPtr<nsIDOMGeoPositionCoords> mCoords;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2010-06-04 14:14:43 -07:00
|
|
|
#endif /* nsGeoPosition_h */
|
|
|
|
|