2015-05-03 22:32:37 +03: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 15:12:37 +04: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-05 01:14:43 +04:00
|
|
|
|
|
|
|
#ifndef nsGeoPosition_h
|
|
|
|
#define nsGeoPosition_h
|
|
|
|
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsIDOMGeoPositionCoords.h"
|
|
|
|
#include "nsIDOMGeoPosition.h"
|
2010-09-21 08:16:37 +04:00
|
|
|
#include "nsString.h"
|
2012-06-15 06:31:55 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-04-12 22:46:27 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "mozilla/dom/Nullable.h"
|
2013-08-28 06:59:14 +04:00
|
|
|
#include "js/TypeDecls.h"
|
2010-09-21 08:16:37 +04:00
|
|
|
|
2010-06-05 01:14:43 +04:00
|
|
|
////////////////////////////////////////////////////
|
|
|
|
// nsGeoPositionCoords
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple object that holds a single point in space.
|
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsGeoPositionCoords final : public nsIDOMGeoPositionCoords
|
2010-06-05 01:14:43 +04:00
|
|
|
{
|
|
|
|
public:
|
2013-07-19 06:21:20 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2010-06-05 01:14:43 +04:00
|
|
|
NS_DECL_NSIDOMGEOPOSITIONCOORDS
|
|
|
|
|
2010-11-16 11:23:05 +03:00
|
|
|
nsGeoPositionCoords(double aLat, double aLong,
|
|
|
|
double aAlt, double aHError,
|
|
|
|
double aVError, double aHeading,
|
|
|
|
double aSpeed);
|
2012-02-27 17:28:25 +04:00
|
|
|
private:
|
2014-06-23 23:56:07 +04:00
|
|
|
~nsGeoPositionCoords();
|
2010-09-21 08:16:37 +04:00
|
|
|
const double mLat, mLong, mAlt, mHError, mVError, mHeading, mSpeed;
|
2010-06-05 01:14:43 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
// nsGeoPosition
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsGeoPosition final : public nsIDOMGeoPosition
|
2010-06-05 01:14:43 +04:00
|
|
|
{
|
|
|
|
public:
|
2013-07-19 06:21:20 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2010-06-05 01:14:43 +04: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 08:16:37 +04:00
|
|
|
|
|
|
|
nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
|
|
|
|
long long aTimestamp);
|
|
|
|
|
|
|
|
nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
|
|
|
|
DOMTimeStamp aTimestamp);
|
|
|
|
|
2010-06-05 01:14:43 +04:00
|
|
|
private:
|
|
|
|
~nsGeoPosition();
|
|
|
|
long long mTimestamp;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsIDOMGeoPositionCoords> mCoords;
|
2010-06-05 01:14:43 +04:00
|
|
|
};
|
|
|
|
|
2013-04-12 22:46:27 +04:00
|
|
|
////////////////////////////////////////////////////
|
|
|
|
// WebIDL wrappers for the classes above
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class Coordinates;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class Position final : public nsISupports,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsWrapperCache
|
2013-04-12 22:46:27 +04:00
|
|
|
{
|
2014-06-23 23:56:07 +04:00
|
|
|
~Position();
|
|
|
|
|
2013-04-12 22:46:27 +04: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 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-04-12 22:46:27 +04:00
|
|
|
|
|
|
|
Coordinates* Coords();
|
|
|
|
|
|
|
|
uint64_t Timestamp() const;
|
|
|
|
|
2013-04-12 22:46:36 +04:00
|
|
|
nsIDOMGeoPosition* GetWrappedGeoPosition() { return mGeoPosition; }
|
|
|
|
|
2013-04-12 22:46:27 +04:00
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Coordinates> mCoordinates;
|
2013-04-12 22:46:27 +04:00
|
|
|
nsCOMPtr<nsISupports> mParent;
|
|
|
|
nsCOMPtr<nsIDOMGeoPosition> mGeoPosition;
|
|
|
|
};
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class Coordinates final : public nsISupports,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsWrapperCache
|
2013-04-12 22:46:27 +04:00
|
|
|
{
|
2014-06-23 23:56:07 +04:00
|
|
|
~Coordinates();
|
|
|
|
|
2013-04-12 22:46:27 +04: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 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-04-12 22:46:27 +04: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:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Position> mPosition;
|
2013-04-12 22:46:27 +04:00
|
|
|
nsCOMPtr<nsIDOMGeoPositionCoords> mCoords;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2010-06-05 01:14:43 +04:00
|
|
|
#endif /* nsGeoPosition_h */
|
|
|
|
|