2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00: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 21:14:43 +00:00
|
|
|
|
|
|
|
#ifndef nsGeoPosition_h
|
|
|
|
#define nsGeoPosition_h
|
|
|
|
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsIDOMGeoPositionCoords.h"
|
|
|
|
#include "nsIDOMGeoPosition.h"
|
2010-09-21 04:16:37 +00:00
|
|
|
#include "nsString.h"
|
2012-06-15 02:31:55 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-04-12 18:46:27 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "mozilla/dom/Nullable.h"
|
2013-08-28 02:59:14 +00:00
|
|
|
#include "js/TypeDecls.h"
|
2010-09-21 04:16:37 +00:00
|
|
|
|
2010-06-04 21:14:43 +00:00
|
|
|
////////////////////////////////////////////////////
|
|
|
|
// nsGeoPositionCoords
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple object that holds a single point in space.
|
|
|
|
*/
|
2015-03-21 16:28:04 +00:00
|
|
|
class nsGeoPositionCoords final : public nsIDOMGeoPositionCoords
|
2010-06-04 21:14:43 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-07-19 02:21:20 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2010-06-04 21:14:43 +00:00
|
|
|
NS_DECL_NSIDOMGEOPOSITIONCOORDS
|
|
|
|
|
2010-11-16 08:23:05 +00:00
|
|
|
nsGeoPositionCoords(double aLat, double aLong,
|
|
|
|
double aAlt, double aHError,
|
|
|
|
double aVError, double aHeading,
|
|
|
|
double aSpeed);
|
2012-02-27 13:28:25 +00:00
|
|
|
private:
|
2014-06-23 19:56:07 +00:00
|
|
|
~nsGeoPositionCoords();
|
2010-09-21 04:16:37 +00:00
|
|
|
const double mLat, mLong, mAlt, mHError, mVError, mHeading, mSpeed;
|
2010-06-04 21:14:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
// nsGeoPosition
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class nsGeoPosition final : public nsIDOMGeoPosition
|
2010-06-04 21:14:43 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-07-19 02:21:20 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2010-06-04 21:14:43 +00:00
|
|
|
NS_DECL_NSIDOMGEOPOSITION
|
|
|
|
|
|
|
|
nsGeoPosition(double aLat, double aLong,
|
|
|
|
double aAlt, double aHError,
|
|
|
|
double aVError, double aHeading,
|
|
|
|
double aSpeed, long long aTimestamp);
|
|
|
|
|
2010-09-21 04:16:37 +00:00
|
|
|
|
|
|
|
nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
|
|
|
|
long long aTimestamp);
|
|
|
|
|
|
|
|
nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
|
|
|
|
DOMTimeStamp aTimestamp);
|
|
|
|
|
2010-06-04 21:14:43 +00:00
|
|
|
private:
|
|
|
|
~nsGeoPosition();
|
|
|
|
long long mTimestamp;
|
2010-09-21 04:16:37 +00:00
|
|
|
nsRefPtr<nsIDOMGeoPositionCoords> mCoords;
|
2010-06-04 21:14:43 +00:00
|
|
|
};
|
|
|
|
|
2013-04-12 18:46:27 +00:00
|
|
|
////////////////////////////////////////////////////
|
|
|
|
// WebIDL wrappers for the classes above
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class Coordinates;
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class Position final : public nsISupports,
|
2015-03-27 18:52:19 +00:00
|
|
|
public nsWrapperCache
|
2013-04-12 18:46:27 +00:00
|
|
|
{
|
2014-06-23 19:56:07 +00:00
|
|
|
~Position();
|
|
|
|
|
2013-04-12 18:46:27 +00:00
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Position)
|
|
|
|
|
|
|
|
public:
|
|
|
|
Position(nsISupports* aParent, nsIDOMGeoPosition* aGeoPosition);
|
|
|
|
|
|
|
|
nsISupports* GetParentObject() const;
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-04-12 18:46:27 +00:00
|
|
|
|
|
|
|
Coordinates* Coords();
|
|
|
|
|
|
|
|
uint64_t Timestamp() const;
|
|
|
|
|
2013-04-12 18:46:36 +00:00
|
|
|
nsIDOMGeoPosition* GetWrappedGeoPosition() { return mGeoPosition; }
|
|
|
|
|
2013-04-12 18:46:27 +00:00
|
|
|
private:
|
|
|
|
nsRefPtr<Coordinates> mCoordinates;
|
|
|
|
nsCOMPtr<nsISupports> mParent;
|
|
|
|
nsCOMPtr<nsIDOMGeoPosition> mGeoPosition;
|
|
|
|
};
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class Coordinates final : public nsISupports,
|
2015-03-27 18:52:19 +00:00
|
|
|
public nsWrapperCache
|
2013-04-12 18:46:27 +00:00
|
|
|
{
|
2014-06-23 19:56:07 +00:00
|
|
|
~Coordinates();
|
|
|
|
|
2013-04-12 18:46:27 +00:00
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Coordinates)
|
|
|
|
|
|
|
|
public:
|
|
|
|
Coordinates(Position* aPosition, nsIDOMGeoPositionCoords* aCoords);
|
|
|
|
|
|
|
|
Position* GetParentObject() const;
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-04-12 18:46:27 +00: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 21:14:43 +00:00
|
|
|
#endif /* nsGeoPosition_h */
|
|
|
|
|