mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 871846 - Implement IDBLocaleAwareKeyRange. r=janv r=sicking
This commit is contained in:
parent
1a38ea5c34
commit
bcf9e2f368
@ -635,6 +635,13 @@ DOMInterfaces = {
|
||||
|
||||
'IDBKeyRange': {
|
||||
'nativeType': 'mozilla::dom::indexedDB::IDBKeyRange',
|
||||
'headerFile': 'mozilla/dom/indexedDB/IDBKeyRange.h',
|
||||
'wrapperCache': False,
|
||||
},
|
||||
|
||||
'IDBLocaleAwareKeyRange': {
|
||||
'nativeType': 'mozilla::dom::indexedDB::IDBLocaleAwareKeyRange',
|
||||
'headerFile': 'mozilla/dom/indexedDB/IDBKeyRange.h',
|
||||
'wrapperCache': False,
|
||||
},
|
||||
|
||||
|
@ -64,6 +64,23 @@ IDBKeyRange::~IDBKeyRange()
|
||||
DropJSObjects();
|
||||
}
|
||||
|
||||
IDBLocaleAwareKeyRange::IDBLocaleAwareKeyRange(nsISupports* aGlobal,
|
||||
bool aLowerOpen,
|
||||
bool aUpperOpen,
|
||||
bool aIsOnly)
|
||||
: IDBKeyRange(aGlobal, aLowerOpen, aUpperOpen, aIsOnly)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mOwningThread = PR_GetCurrentThread();
|
||||
#endif
|
||||
AssertIsOnOwningThread();
|
||||
}
|
||||
|
||||
IDBLocaleAwareKeyRange::~IDBLocaleAwareKeyRange()
|
||||
{
|
||||
DropJSObjects();
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
void
|
||||
@ -233,6 +250,8 @@ NS_INTERFACE_MAP_END
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(IDBKeyRange)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(IDBKeyRange)
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(IDBLocaleAwareKeyRange, IDBKeyRange)
|
||||
|
||||
void
|
||||
IDBKeyRange::DropJSObjects()
|
||||
{
|
||||
@ -253,6 +272,12 @@ IDBKeyRange::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::M
|
||||
return IDBKeyRangeBinding::Wrap(aCx, this, aGivenProto, aReflector);
|
||||
}
|
||||
|
||||
bool
|
||||
IDBLocaleAwareKeyRange::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
|
||||
{
|
||||
return IDBLocaleAwareKeyRangeBinding::Wrap(aCx, this, aGivenProto, aReflector);
|
||||
}
|
||||
|
||||
void
|
||||
IDBKeyRange::GetLower(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
|
||||
ErrorResult& aRv)
|
||||
@ -385,6 +410,36 @@ IDBKeyRange::Bound(const GlobalObject& aGlobal,
|
||||
return keyRange.forget();
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<IDBLocaleAwareKeyRange>
|
||||
IDBLocaleAwareKeyRange::Bound(const GlobalObject& aGlobal,
|
||||
JS::Handle<JS::Value> aLower,
|
||||
JS::Handle<JS::Value> aUpper,
|
||||
bool aLowerOpen,
|
||||
bool aUpperOpen,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsRefPtr<IDBLocaleAwareKeyRange> keyRange =
|
||||
new IDBLocaleAwareKeyRange(aGlobal.GetAsSupports(), aLowerOpen, aUpperOpen, false);
|
||||
|
||||
aRv = GetKeyFromJSVal(aGlobal.Context(), aLower, keyRange->Lower());
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
aRv = GetKeyFromJSVal(aGlobal.Context(), aUpper, keyRange->Upper());
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (keyRange->Lower() == keyRange->Upper() && (aLowerOpen || aUpperOpen)) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return keyRange.forget();
|
||||
}
|
||||
|
||||
} // namespace indexedDB
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -31,9 +31,10 @@ namespace indexedDB {
|
||||
|
||||
class SerializedKeyRange;
|
||||
|
||||
class IDBKeyRange final
|
||||
class IDBKeyRange
|
||||
: public nsISupports
|
||||
{
|
||||
protected:
|
||||
nsCOMPtr<nsISupports> mGlobal;
|
||||
Key mLower;
|
||||
Key mUpper;
|
||||
@ -169,13 +170,39 @@ public:
|
||||
return mUpperOpen;
|
||||
}
|
||||
|
||||
private:
|
||||
protected:
|
||||
IDBKeyRange(nsISupports* aGlobal,
|
||||
bool aLowerOpen,
|
||||
bool aUpperOpen,
|
||||
bool aIsOnly);
|
||||
|
||||
~IDBKeyRange();
|
||||
virtual ~IDBKeyRange();
|
||||
};
|
||||
|
||||
class IDBLocaleAwareKeyRange final
|
||||
: public IDBKeyRange
|
||||
{
|
||||
IDBLocaleAwareKeyRange(nsISupports* aGlobal,
|
||||
bool aLowerOpen,
|
||||
bool aUpperOpen,
|
||||
bool aIsOnly);
|
||||
|
||||
~IDBLocaleAwareKeyRange();
|
||||
|
||||
public:
|
||||
static already_AddRefed<IDBLocaleAwareKeyRange>
|
||||
Bound(const GlobalObject& aGlobal,
|
||||
JS::Handle<JS::Value> aLower,
|
||||
JS::Handle<JS::Value> aUpper,
|
||||
bool aLowerOpen,
|
||||
bool aUpperOpen,
|
||||
ErrorResult& aRv);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// WebIDL
|
||||
bool
|
||||
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
|
||||
};
|
||||
|
||||
} // namespace indexedDB
|
||||
|
@ -623,6 +623,7 @@ IndexedDatabaseManager::DefineIndexedDB(JSContext* aCx,
|
||||
!IDBFactoryBinding::GetConstructorObject(aCx, aGlobal) ||
|
||||
!IDBIndexBinding::GetConstructorObject(aCx, aGlobal) ||
|
||||
!IDBKeyRangeBinding::GetConstructorObject(aCx, aGlobal) ||
|
||||
!IDBLocaleAwareKeyRangeBinding::GetConstructorObject(aCx, aGlobal) ||
|
||||
!IDBMutableFileBinding::GetConstructorObject(aCx, aGlobal) ||
|
||||
!IDBObjectStoreBinding::GetConstructorObject(aCx, aGlobal) ||
|
||||
!IDBOpenDBRequestBinding::GetConstructorObject(aCx, aGlobal) ||
|
||||
|
@ -28,3 +28,10 @@ interface IDBKeyRange {
|
||||
[NewObject, Throws]
|
||||
static IDBKeyRange bound (any lower, any upper, optional boolean lowerOpen = false, optional boolean upperOpen = false);
|
||||
};
|
||||
|
||||
[Exposed=(Window,Worker),
|
||||
Func="mozilla::dom::indexedDB::IndexedDatabaseManager::ExperimentalFeaturesEnabled"]
|
||||
interface IDBLocaleAwareKeyRange : IDBKeyRange {
|
||||
[NewObject, Throws]
|
||||
static IDBLocaleAwareKeyRange bound (any lower, any upper, optional boolean lowerOpen = false, optional boolean upperOpen = false);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user