зеркало из https://github.com/mozilla/gecko-dev.git
Bug 850442 - Part 2 - Convert PositionError. r=bz
This commit is contained in:
Родитель
f06d787b23
Коммит
13bec84c07
|
@ -661,6 +661,10 @@ DOMInterfaces = {
|
|||
'headerFile': 'nsGeoPosition.h'
|
||||
},
|
||||
|
||||
'PositionError': {
|
||||
'headerFile': 'nsGeolocation.h'
|
||||
},
|
||||
|
||||
'PropertyNodeList': {
|
||||
'headerFile': 'HTMLPropertiesCollection.h',
|
||||
'resultNotAddRefed': [ 'item' ]
|
||||
|
|
|
@ -215,52 +215,54 @@ private:
|
|||
};
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// nsDOMGeoPositionError
|
||||
// PositionError
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
class nsDOMGeoPositionError MOZ_FINAL : public nsIDOMGeoPositionError
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMGEOPOSITIONERROR
|
||||
DOMCI_DATA(GeoPositionError, PositionError)
|
||||
|
||||
nsDOMGeoPositionError(int16_t aCode);
|
||||
void NotifyCallback(nsIDOMGeoPositionErrorCallback* callback);
|
||||
|
||||
private:
|
||||
~nsDOMGeoPositionError();
|
||||
int16_t mCode;
|
||||
};
|
||||
|
||||
DOMCI_DATA(GeoPositionError, nsDOMGeoPositionError)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsDOMGeoPositionError)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PositionError)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeoPositionError)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPositionError)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(GeoPositionError)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsDOMGeoPositionError)
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsDOMGeoPositionError)
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(PositionError, mParent)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(PositionError)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(PositionError)
|
||||
|
||||
nsDOMGeoPositionError::nsDOMGeoPositionError(int16_t aCode)
|
||||
PositionError::PositionError(nsGeolocation* aParent, int16_t aCode)
|
||||
: mCode(aCode)
|
||||
, mParent(aParent)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
nsDOMGeoPositionError::~nsDOMGeoPositionError(){}
|
||||
PositionError::~PositionError(){}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMGeoPositionError::GetCode(int16_t *aCode)
|
||||
PositionError::GetCode(int16_t *aCode)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCode);
|
||||
*aCode = mCode;
|
||||
*aCode = Code();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsGeolocation*
|
||||
PositionError::GetParentObject() const
|
||||
{
|
||||
return mParent;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
PositionError::WrapObject(JSContext* aCx, JSObject* aScope)
|
||||
{
|
||||
return PositionErrorBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMGeoPositionError::NotifyCallback(nsIDOMGeoPositionErrorCallback* aCallback)
|
||||
PositionError::NotifyCallback(nsIDOMGeoPositionErrorCallback* aCallback)
|
||||
{
|
||||
if (!aCallback) {
|
||||
return;
|
||||
|
@ -337,7 +339,9 @@ NS_IMPL_CYCLE_COLLECTION_3(nsGeolocationRequest, mCallback, mErrorCallback, mLoc
|
|||
void
|
||||
nsGeolocationRequest::NotifyError(int16_t errorCode)
|
||||
{
|
||||
nsRefPtr<nsDOMGeoPositionError> positionError = new nsDOMGeoPositionError(errorCode);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsRefPtr<PositionError> positionError = new PositionError(mLocator, errorCode);
|
||||
if (!positionError) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "nsITimer.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
#include "nsWeakPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
@ -27,6 +28,7 @@
|
|||
#include "nsIDOMGeoPositionErrorCallback.h"
|
||||
#include "nsIDOMNavigatorGeolocation.h"
|
||||
#include "nsIGeolocation.h"
|
||||
#include "mozilla/dom/PositionErrorBinding.h"
|
||||
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
|
@ -253,4 +255,40 @@ private:
|
|||
nsTArray<PendingRequest> mPendingRequests;
|
||||
};
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class PositionError MOZ_FINAL : public nsIDOMGeoPositionError,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PositionError)
|
||||
|
||||
NS_DECL_NSIDOMGEOPOSITIONERROR
|
||||
|
||||
PositionError(nsGeolocation* aParent, int16_t aCode);
|
||||
|
||||
nsGeolocation* GetParentObject() const;
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
|
||||
|
||||
int16_t Code() const {
|
||||
return mCode;
|
||||
}
|
||||
|
||||
void GetMessage(nsString& aRetVal) const {
|
||||
aRetVal.Truncate();
|
||||
}
|
||||
|
||||
void NotifyCallback(nsIDOMGeoPositionErrorCallback* callback);
|
||||
private:
|
||||
~PositionError();
|
||||
int16_t mCode;
|
||||
nsRefPtr<nsGeolocation> mParent;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* nsGeoLocation_h */
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://www.w3.org/TR/geolocation-API
|
||||
*
|
||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface PositionError {
|
||||
const unsigned short PERMISSION_DENIED = 1;
|
||||
const unsigned short POSITION_UNAVAILABLE = 2;
|
||||
const unsigned short TIMEOUT = 3;
|
||||
readonly attribute unsigned short code;
|
||||
readonly attribute DOMString message;
|
||||
};
|
|
@ -165,6 +165,7 @@ webidl_files = \
|
|||
PerformanceNavigation.webidl \
|
||||
PerformanceTiming.webidl \
|
||||
Position.webidl \
|
||||
PositionError.webidl \
|
||||
ProcessingInstruction.webidl \
|
||||
Range.webidl \
|
||||
Rect.webidl \
|
||||
|
|
Загрузка…
Ссылка в новой задаче