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
|
|
|
|
|
|
|
#include "nsGeoPosition.h"
|
2013-04-12 22:46:27 +04:00
|
|
|
|
|
|
|
#include "mozilla/dom/PositionBinding.h"
|
|
|
|
#include "mozilla/dom/CoordinatesBinding.h"
|
2010-06-05 01:14:43 +04:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
// nsGeoPositionCoords
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
nsGeoPositionCoords::nsGeoPositionCoords(double aLat, double aLong,
|
|
|
|
double aAlt, double aHError,
|
|
|
|
double aVError, double aHeading,
|
2010-09-21 08:16:37 +04:00
|
|
|
double aSpeed)
|
|
|
|
: mLat(aLat)
|
|
|
|
, mLong(aLong)
|
|
|
|
, mAlt(aAlt)
|
|
|
|
, mHError(aHError)
|
|
|
|
, mVError(aVError)
|
|
|
|
, mHeading(aHeading)
|
|
|
|
, mSpeed(aSpeed)
|
2010-06-05 01:14:43 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGeoPositionCoords::~nsGeoPositionCoords()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsGeoPositionCoords)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeoPositionCoords)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPositionCoords)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2013-07-19 06:21:20 +04:00
|
|
|
NS_IMPL_ADDREF(nsGeoPositionCoords)
|
|
|
|
NS_IMPL_RELEASE(nsGeoPositionCoords)
|
2010-06-05 01:14:43 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPositionCoords::GetLatitude(double *aLatitude)
|
|
|
|
{
|
|
|
|
*aLatitude = mLat;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPositionCoords::GetLongitude(double *aLongitude)
|
|
|
|
{
|
|
|
|
*aLongitude = mLong;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPositionCoords::GetAltitude(double *aAltitude)
|
|
|
|
{
|
|
|
|
*aAltitude = mAlt;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPositionCoords::GetAccuracy(double *aAccuracy)
|
|
|
|
{
|
|
|
|
*aAccuracy = mHError;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPositionCoords::GetAltitudeAccuracy(double *aAltitudeAccuracy)
|
|
|
|
{
|
|
|
|
*aAltitudeAccuracy = mVError;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPositionCoords::GetHeading(double *aHeading)
|
|
|
|
{
|
|
|
|
*aHeading = mHeading;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPositionCoords::GetSpeed(double *aSpeed)
|
|
|
|
{
|
|
|
|
*aSpeed = mSpeed;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
// nsGeoPosition
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
nsGeoPosition::nsGeoPosition(double aLat, double aLong,
|
|
|
|
double aAlt, double aHError,
|
|
|
|
double aVError, double aHeading,
|
|
|
|
double aSpeed, long long aTimestamp) :
|
|
|
|
mTimestamp(aTimestamp)
|
|
|
|
{
|
|
|
|
mCoords = new nsGeoPositionCoords(aLat, aLong,
|
|
|
|
aAlt, aHError,
|
|
|
|
aVError, aHeading,
|
|
|
|
aSpeed);
|
|
|
|
}
|
2010-09-21 08:16:37 +04:00
|
|
|
|
|
|
|
nsGeoPosition::nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
|
|
|
|
long long aTimestamp) :
|
2010-10-14 20:12:57 +04:00
|
|
|
mTimestamp(aTimestamp),
|
|
|
|
mCoords(aCoords)
|
2010-09-21 08:16:37 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGeoPosition::nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
|
|
|
|
DOMTimeStamp aTimestamp) :
|
|
|
|
mTimestamp(aTimestamp),
|
2012-03-09 10:16:25 +04:00
|
|
|
mCoords(aCoords)
|
2010-09-21 08:16:37 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-06-05 01:14:43 +04:00
|
|
|
nsGeoPosition::~nsGeoPosition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsGeoPosition)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeoPosition)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPosition)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2013-07-19 06:21:20 +04:00
|
|
|
NS_IMPL_ADDREF(nsGeoPosition)
|
|
|
|
NS_IMPL_RELEASE(nsGeoPosition)
|
2010-06-05 01:14:43 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPosition::GetTimestamp(DOMTimeStamp* aTimestamp)
|
|
|
|
{
|
|
|
|
*aTimestamp = mTimestamp;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGeoPosition::GetCoords(nsIDOMGeoPositionCoords * *aCoords)
|
|
|
|
{
|
|
|
|
NS_IF_ADDREF(*aCoords = mCoords);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-04-12 22:46:27 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
|
2014-04-29 12:57:00 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Position, mParent, mCoordinates)
|
2013-04-12 22:46:27 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(Position)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(Position)
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Position)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
Position::Position(nsISupports* aParent, nsIDOMGeoPosition* aGeoPosition)
|
|
|
|
: mParent(aParent)
|
|
|
|
, mGeoPosition(aGeoPosition)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Position::~Position()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsISupports*
|
|
|
|
Position::GetParentObject() const
|
|
|
|
{
|
|
|
|
return mParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
Position::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-04-12 22:46:27 +04:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return PositionBinding::Wrap(aCx, this, aGivenProto);
|
2013-04-12 22:46:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
Coordinates*
|
|
|
|
Position::Coords()
|
|
|
|
{
|
|
|
|
if (!mCoordinates) {
|
|
|
|
nsCOMPtr<nsIDOMGeoPositionCoords> coords;
|
|
|
|
mGeoPosition->GetCoords(getter_AddRefs(coords));
|
|
|
|
MOZ_ASSERT(coords, "coords should not be null");
|
|
|
|
|
|
|
|
mCoordinates = new Coordinates(this, coords);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mCoordinates;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t
|
|
|
|
Position::Timestamp() const
|
|
|
|
{
|
|
|
|
uint64_t rv;
|
|
|
|
|
|
|
|
mGeoPosition->GetTimestamp(&rv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2014-04-29 12:57:00 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Coordinates, mPosition)
|
2013-04-12 22:46:27 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(Coordinates)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(Coordinates)
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Coordinates)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
Coordinates::Coordinates(Position* aPosition, nsIDOMGeoPositionCoords* aCoords)
|
|
|
|
: mPosition(aPosition)
|
|
|
|
, mCoords(aCoords)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Coordinates::~Coordinates()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Position*
|
|
|
|
Coordinates::GetParentObject() const
|
|
|
|
{
|
|
|
|
return mPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
Coordinates::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-04-12 22:46:27 +04:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return CoordinatesBinding::Wrap(aCx, this, aGivenProto);
|
2013-04-12 22:46:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define GENERATE_COORDS_WRAPPED_GETTER(name) \
|
|
|
|
double \
|
|
|
|
Coordinates::name() const \
|
|
|
|
{ \
|
|
|
|
double rv; \
|
|
|
|
mCoords->Get##name(&rv); \
|
|
|
|
return rv; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GENERATE_COORDS_WRAPPED_GETTER_NULLABLE(name) \
|
|
|
|
Nullable<double> \
|
|
|
|
Coordinates::Get##name() const \
|
|
|
|
{ \
|
|
|
|
double rv; \
|
|
|
|
mCoords->Get##name(&rv); \
|
|
|
|
return Nullable<double>(rv); \
|
|
|
|
}
|
|
|
|
|
|
|
|
GENERATE_COORDS_WRAPPED_GETTER(Latitude)
|
|
|
|
GENERATE_COORDS_WRAPPED_GETTER(Longitude)
|
|
|
|
GENERATE_COORDS_WRAPPED_GETTER_NULLABLE(Altitude)
|
|
|
|
GENERATE_COORDS_WRAPPED_GETTER(Accuracy)
|
|
|
|
GENERATE_COORDS_WRAPPED_GETTER_NULLABLE(AltitudeAccuracy)
|
|
|
|
GENERATE_COORDS_WRAPPED_GETTER_NULLABLE(Heading)
|
|
|
|
GENERATE_COORDS_WRAPPED_GETTER_NULLABLE(Speed)
|
|
|
|
|
|
|
|
#undef GENERATE_COORDS_WRAPPED_GETTER
|
|
|
|
#undef GENERATE_COORDS_WRAPPED_GETTER_NULLABLE
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|