dom/src/geolocation/nsGeoPosition.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/src/geolocation/nsGeoPosition.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,145 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsGeoPosition_h
    1.10 +#define nsGeoPosition_h
    1.11 +
    1.12 +#include "nsAutoPtr.h"
    1.13 +#include "nsIDOMGeoPositionCoords.h"
    1.14 +#include "nsIDOMGeoPosition.h"
    1.15 +#include "nsString.h"
    1.16 +#include "mozilla/Attributes.h"
    1.17 +#include "nsCycleCollectionParticipant.h"
    1.18 +#include "nsWrapperCache.h"
    1.19 +#include "mozilla/dom/Nullable.h"
    1.20 +#include "js/TypeDecls.h"
    1.21 +
    1.22 +////////////////////////////////////////////////////
    1.23 +// nsGeoPositionCoords
    1.24 +////////////////////////////////////////////////////
    1.25 +
    1.26 +/**
    1.27 + * Simple object that holds a single point in space.
    1.28 + */
    1.29 +class nsGeoPositionCoords MOZ_FINAL : public nsIDOMGeoPositionCoords
    1.30 +{
    1.31 +public:
    1.32 +  NS_DECL_THREADSAFE_ISUPPORTS
    1.33 +  NS_DECL_NSIDOMGEOPOSITIONCOORDS
    1.34 +  
    1.35 +  nsGeoPositionCoords(double aLat, double aLong,
    1.36 +                      double aAlt, double aHError,
    1.37 +                      double aVError, double aHeading,
    1.38 +                      double aSpeed);
    1.39 +  ~nsGeoPositionCoords();
    1.40 +private:
    1.41 +  const double mLat, mLong, mAlt, mHError, mVError, mHeading, mSpeed;
    1.42 +};
    1.43 +
    1.44 +
    1.45 +////////////////////////////////////////////////////
    1.46 +// nsGeoPosition
    1.47 +////////////////////////////////////////////////////
    1.48 +
    1.49 +class nsGeoPosition MOZ_FINAL : public nsIDOMGeoPosition
    1.50 +{
    1.51 +public:
    1.52 +  NS_DECL_THREADSAFE_ISUPPORTS
    1.53 +  NS_DECL_NSIDOMGEOPOSITION
    1.54 +  
    1.55 +  nsGeoPosition(double aLat, double aLong,
    1.56 +                double aAlt, double aHError,
    1.57 +                double aVError, double aHeading,
    1.58 +                double aSpeed, long long aTimestamp);
    1.59 +  
    1.60 +
    1.61 +  nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
    1.62 +                long long aTimestamp);
    1.63 +
    1.64 +  nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
    1.65 +                DOMTimeStamp aTimestamp);
    1.66 +
    1.67 +private:
    1.68 +  ~nsGeoPosition();
    1.69 +  long long mTimestamp;
    1.70 +  nsRefPtr<nsIDOMGeoPositionCoords> mCoords;
    1.71 +};
    1.72 +
    1.73 +////////////////////////////////////////////////////
    1.74 +// WebIDL wrappers for the classes above
    1.75 +////////////////////////////////////////////////////
    1.76 +
    1.77 +namespace mozilla {
    1.78 +namespace dom {
    1.79 +
    1.80 +class Coordinates;
    1.81 +
    1.82 +class Position MOZ_FINAL : public nsISupports,
    1.83 +                           public nsWrapperCache
    1.84 +{
    1.85 +public:
    1.86 +  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    1.87 +  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Position)
    1.88 +
    1.89 +public:
    1.90 +  Position(nsISupports* aParent, nsIDOMGeoPosition* aGeoPosition);
    1.91 +
    1.92 +  ~Position();
    1.93 +
    1.94 +  nsISupports* GetParentObject() const;
    1.95 +
    1.96 +  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.97 +
    1.98 +  Coordinates* Coords();
    1.99 +
   1.100 +  uint64_t Timestamp() const;
   1.101 +
   1.102 +  nsIDOMGeoPosition* GetWrappedGeoPosition() { return mGeoPosition; }
   1.103 +
   1.104 +private:
   1.105 +  nsRefPtr<Coordinates> mCoordinates;
   1.106 +  nsCOMPtr<nsISupports> mParent;
   1.107 +  nsCOMPtr<nsIDOMGeoPosition> mGeoPosition;
   1.108 +};
   1.109 +
   1.110 +class Coordinates MOZ_FINAL : public nsISupports,
   1.111 +                              public nsWrapperCache
   1.112 +{
   1.113 +public:
   1.114 +  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   1.115 +  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Coordinates)
   1.116 +
   1.117 +public:
   1.118 +  Coordinates(Position* aPosition, nsIDOMGeoPositionCoords* aCoords);
   1.119 +
   1.120 +  ~Coordinates();
   1.121 +
   1.122 +  Position* GetParentObject() const;
   1.123 +
   1.124 +  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
   1.125 +
   1.126 +  double Latitude() const;
   1.127 +
   1.128 +  double Longitude() const;
   1.129 +
   1.130 +  Nullable<double> GetAltitude() const;
   1.131 +
   1.132 +  double Accuracy() const;
   1.133 +
   1.134 +  Nullable<double> GetAltitudeAccuracy() const;
   1.135 +
   1.136 +  Nullable<double> GetHeading() const;
   1.137 +
   1.138 +  Nullable<double> GetSpeed() const;
   1.139 +private:
   1.140 +  nsRefPtr<Position> mPosition;
   1.141 +  nsCOMPtr<nsIDOMGeoPositionCoords> mCoords;
   1.142 +};
   1.143 +
   1.144 +} // namespace dom
   1.145 +} // namespace mozilla
   1.146 +
   1.147 +#endif /* nsGeoPosition_h */
   1.148 +

mercurial