Issue #325 Part 7: Remove non-Intl legacy code paths from IndexedDB.

This commit is contained in:
wolfbeast 2018-05-04 16:15:59 +02:00 • committed by Roy Tam
commit d4d0fbf3d5
9 changed files with 1 additions and 58 deletions

View file

@ -7767,12 +7767,10 @@ private:
virtual void virtual void
SendResults() override; SendResults() override;
#ifdef ENABLE_INTL_API
static nsresult static nsresult
UpdateLocaleAwareIndex(mozIStorageConnection* aConnection, UpdateLocaleAwareIndex(mozIStorageConnection* aConnection,
const IndexMetadata& aIndexMetadata, const IndexMetadata& aIndexMetadata,
const nsCString& aLocale); const nsCString& aLocale);
#endif
}; };
class OpenDatabaseOp::VersionChangeOp final class OpenDatabaseOp::VersionChangeOp final
@ -20064,9 +20062,6 @@ DatabaseOperationBase::BindKeyRangeToStatement(
mozIStorageStatement* aStatement, mozIStorageStatement* aStatement,
const nsCString& aLocale) const nsCString& aLocale)
{ {
#ifndef ENABLE_INTL_API
return BindKeyRangeToStatement(aKeyRange, aStatement);
#else
MOZ_ASSERT(!IsOnBackgroundThread()); MOZ_ASSERT(!IsOnBackgroundThread());
MOZ_ASSERT(aStatement); MOZ_ASSERT(aStatement);
MOZ_ASSERT(!aLocale.IsEmpty()); MOZ_ASSERT(!aLocale.IsEmpty());
@ -20104,7 +20099,6 @@ DatabaseOperationBase::BindKeyRangeToStatement(
} }
return NS_OK; return NS_OK;
#endif
} }
// static // static
@ -22197,7 +22191,6 @@ OpenDatabaseOp::LoadDatabaseInformation(mozIStorageConnection* aConnection)
indexMetadata->mCommonMetadata.multiEntry() = !!scratch; indexMetadata->mCommonMetadata.multiEntry() = !!scratch;
#ifdef ENABLE_INTL_API
const bool localeAware = !stmt->IsNull(6); const bool localeAware = !stmt->IsNull(6);
if (localeAware) { if (localeAware) {
rv = stmt->GetUTF8String(6, indexMetadata->mCommonMetadata.locale()); rv = stmt->GetUTF8String(6, indexMetadata->mCommonMetadata.locale());
@ -22227,7 +22220,6 @@ OpenDatabaseOp::LoadDatabaseInformation(mozIStorageConnection* aConnection)
} }
} }
} }
#endif
if (NS_WARN_IF(!objectStoreMetadata->mIndexes.Put(indexId, indexMetadata, if (NS_WARN_IF(!objectStoreMetadata->mIndexes.Put(indexId, indexMetadata,
fallible))) { fallible))) {
@ -22253,7 +22245,6 @@ OpenDatabaseOp::LoadDatabaseInformation(mozIStorageConnection* aConnection)
return NS_OK; return NS_OK;
} }
#ifdef ENABLE_INTL_API
/* static */ /* static */
nsresult nsresult
OpenDatabaseOp::UpdateLocaleAwareIndex(mozIStorageConnection* aConnection, OpenDatabaseOp::UpdateLocaleAwareIndex(mozIStorageConnection* aConnection,
@ -22371,7 +22362,6 @@ OpenDatabaseOp::UpdateLocaleAwareIndex(mozIStorageConnection* aConnection,
rv = metaStmt->Execute(); rv = metaStmt->Execute();
return rv; return rv;
} }
#endif
nsresult nsresult
OpenDatabaseOp::BeginVersionChange() OpenDatabaseOp::BeginVersionChange()
@ -28191,15 +28181,12 @@ OpenOp::GetRangeKeyInfo(bool aLowerBound, Key* aKey, bool* aOpen)
if (range.isOnly()) { if (range.isOnly()) {
*aKey = range.lower(); *aKey = range.lower();
*aOpen = false; *aOpen = false;
#ifdef ENABLE_INTL_API
if (mCursor->IsLocaleAware()) { if (mCursor->IsLocaleAware()) {
range.lower().ToLocaleBasedKey(*aKey, mCursor->mLocale); range.lower().ToLocaleBasedKey(*aKey, mCursor->mLocale);
} }
#endif
} else { } else {
*aKey = aLowerBound ? range.lower() : range.upper(); *aKey = aLowerBound ? range.lower() : range.upper();
*aOpen = aLowerBound ? range.lowerOpen() : range.upperOpen(); *aOpen = aLowerBound ? range.lowerOpen() : range.upperOpen();
#ifdef ENABLE_INTL_API
if (mCursor->IsLocaleAware()) { if (mCursor->IsLocaleAware()) {
if (aLowerBound) { if (aLowerBound) {
range.lower().ToLocaleBasedKey(*aKey, mCursor->mLocale); range.lower().ToLocaleBasedKey(*aKey, mCursor->mLocale);
@ -28207,7 +28194,6 @@ OpenOp::GetRangeKeyInfo(bool aLowerBound, Key* aKey, bool* aOpen)
range.upper().ToLocaleBasedKey(*aKey, mCursor->mLocale); range.upper().ToLocaleBasedKey(*aKey, mCursor->mLocale);
} }
} }
#endif
} }
} else { } else {
*aOpen = false; *aOpen = false;

View file

@ -65,13 +65,11 @@ IDBCursor::IDBCursor(Type aType,
} }
} }
#ifdef ENABLE_INTL_API
bool bool
IDBCursor::IsLocaleAware() const IDBCursor::IsLocaleAware() const
{ {
return mSourceIndex && !mSourceIndex->Locale().IsEmpty(); return mSourceIndex && !mSourceIndex->Locale().IsEmpty();
} }
#endif
IDBCursor::~IDBCursor() IDBCursor::~IDBCursor()
{ {
@ -437,7 +435,6 @@ IDBCursor::Continue(JSContext* aCx,
return; return;
} }
#ifdef ENABLE_INTL_API
if (IsLocaleAware() && !key.IsUnset()) { if (IsLocaleAware() && !key.IsUnset()) {
Key tmp; Key tmp;
aRv = key.ToLocaleBasedKey(tmp, mSourceIndex->Locale()); aRv = key.ToLocaleBasedKey(tmp, mSourceIndex->Locale());
@ -448,9 +445,6 @@ IDBCursor::Continue(JSContext* aCx,
} }
const Key& sortKey = IsLocaleAware() ? mSortKey : mKey; const Key& sortKey = IsLocaleAware() ? mSortKey : mKey;
#else
const Key& sortKey = mKey;
#endif
if (!key.IsUnset()) { if (!key.IsUnset()) {
switch (mDirection) { switch (mDirection) {
@ -547,7 +541,6 @@ IDBCursor::ContinuePrimaryKey(JSContext* aCx,
return; return;
} }
#ifdef ENABLE_INTL_API
if (IsLocaleAware() && !key.IsUnset()) { if (IsLocaleAware() && !key.IsUnset()) {
Key tmp; Key tmp;
aRv = key.ToLocaleBasedKey(tmp, mSourceIndex->Locale()); aRv = key.ToLocaleBasedKey(tmp, mSourceIndex->Locale());
@ -558,9 +551,6 @@ IDBCursor::ContinuePrimaryKey(JSContext* aCx,
} }
const Key& sortKey = IsLocaleAware() ? mSortKey : mKey; const Key& sortKey = IsLocaleAware() ? mSortKey : mKey;
#else
const Key& sortKey = mKey;
#endif
if (key.IsUnset()) { if (key.IsUnset()) {
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR);

View file

@ -205,11 +205,9 @@ private:
~IDBCursor(); ~IDBCursor();
#ifdef ENABLE_INTL_API
// Checks if this is a locale aware cursor (ie. the index's sortKey is unset) // Checks if this is a locale aware cursor (ie. the index's sortKey is unset)
bool bool
IsLocaleAware() const; IsLocaleAware() const;
#endif
void void
DropJSObjects(); DropJSObjects();

View file

@ -1086,9 +1086,7 @@ IDBObjectStore::AppendIndexUpdateInfo(
{ {
nsresult rv; nsresult rv;
#ifdef ENABLE_INTL_API
const bool localeAware = !aLocale.IsEmpty(); const bool localeAware = !aLocale.IsEmpty();
#endif
if (!aMultiEntry) { if (!aMultiEntry) {
Key key; Key key;
@ -1106,14 +1104,12 @@ IDBObjectStore::AppendIndexUpdateInfo(
IndexUpdateInfo* updateInfo = aUpdateInfoArray.AppendElement(); IndexUpdateInfo* updateInfo = aUpdateInfoArray.AppendElement();
updateInfo->indexId() = aIndexID; updateInfo->indexId() = aIndexID;
updateInfo->value() = key; updateInfo->value() = key;
#ifdef ENABLE_INTL_API
if (localeAware) { if (localeAware) {
rv = key.ToLocaleBasedKey(updateInfo->localizedValue(), aLocale); rv = key.ToLocaleBasedKey(updateInfo->localizedValue(), aLocale);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
} }
} }
#endif
return NS_OK; return NS_OK;
} }
@ -1153,14 +1149,12 @@ IDBObjectStore::AppendIndexUpdateInfo(
IndexUpdateInfo* updateInfo = aUpdateInfoArray.AppendElement(); IndexUpdateInfo* updateInfo = aUpdateInfoArray.AppendElement();
updateInfo->indexId() = aIndexID; updateInfo->indexId() = aIndexID;
updateInfo->value() = value; updateInfo->value() = value;
#ifdef ENABLE_INTL_API
if (localeAware) { if (localeAware) {
rv = value.ToLocaleBasedKey(updateInfo->localizedValue(), aLocale); rv = value.ToLocaleBasedKey(updateInfo->localizedValue(), aLocale);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
} }
} }
#endif
} }
} }
else { else {
@ -1174,14 +1168,12 @@ IDBObjectStore::AppendIndexUpdateInfo(
IndexUpdateInfo* updateInfo = aUpdateInfoArray.AppendElement(); IndexUpdateInfo* updateInfo = aUpdateInfoArray.AppendElement();
updateInfo->indexId() = aIndexID; updateInfo->indexId() = aIndexID;
updateInfo->value() = value; updateInfo->value() = value;
#ifdef ENABLE_INTL_API
if (localeAware) { if (localeAware) {
rv = value.ToLocaleBasedKey(updateInfo->localizedValue(), aLocale); rv = value.ToLocaleBasedKey(updateInfo->localizedValue(), aLocale);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
} }
} }
#endif
} }
return NS_OK; return NS_OK;
@ -2052,11 +2044,9 @@ IDBObjectStore::CreateIndex(const nsAString& aName,
// Valid locale names are always ASCII as per BCP-47. // Valid locale names are always ASCII as per BCP-47.
nsCString locale = NS_LossyConvertUTF16toASCII(aOptionalParameters.mLocale); nsCString locale = NS_LossyConvertUTF16toASCII(aOptionalParameters.mLocale);
bool autoLocale = locale.EqualsASCII("auto"); bool autoLocale = locale.EqualsASCII("auto");
#ifdef ENABLE_INTL_API
if (autoLocale) { if (autoLocale) {
locale = IndexedDatabaseManager::GetLocale(); locale = IndexedDatabaseManager::GetLocale();
} }
#endif
IndexMetadata* metadata = indexes.AppendElement( IndexMetadata* metadata = indexes.AppendElement(
IndexMetadata(transaction->NextIndexId(), nsString(aName), keyPath, IndexMetadata(transaction->NextIndexId(), nsString(aName), keyPath,

View file

@ -59,10 +59,8 @@
#include "mozilla/dom/IDBTransactionBinding.h" #include "mozilla/dom/IDBTransactionBinding.h"
#include "mozilla/dom/IDBVersionChangeEventBinding.h" #include "mozilla/dom/IDBVersionChangeEventBinding.h"
#ifdef ENABLE_INTL_API
#include "nsCharSeparatedTokenizer.h" #include "nsCharSeparatedTokenizer.h"
#include "unicode/locid.h" #include "unicode/locid.h"
#endif
#define IDB_STR "indexedDB" #define IDB_STR "indexedDB"
@ -430,7 +428,6 @@ IndexedDatabaseManager::Init()
Preferences::RegisterCallbackAndCall(MaxSerializedMsgSizePrefChangeCallback, Preferences::RegisterCallbackAndCall(MaxSerializedMsgSizePrefChangeCallback,
kPrefMaxSerilizedMsgSize); kPrefMaxSerilizedMsgSize);
#ifdef ENABLE_INTL_API
const nsAdoptingCString& acceptLang = const nsAdoptingCString& acceptLang =
Preferences::GetLocalizedCString("intl.accept_languages"); Preferences::GetLocalizedCString("intl.accept_languages");
@ -449,7 +446,6 @@ IndexedDatabaseManager::Init()
if (mLocale.IsEmpty()) { if (mLocale.IsEmpty()) {
mLocale.AssignLiteral("en_US"); mLocale.AssignLiteral("en_US");
} }
#endif
return NS_OK; return NS_OK;
} }
@ -1088,7 +1084,6 @@ IndexedDatabaseManager::LoggingModePrefChangedCallback(
} }
} }
#ifdef ENABLE_INTL_API
// static // static
const nsCString& const nsCString&
IndexedDatabaseManager::GetLocale() IndexedDatabaseManager::GetLocale()
@ -1098,7 +1093,6 @@ IndexedDatabaseManager::GetLocale()
return idbManager->mLocale; return idbManager->mLocale;
} }
#endif
NS_IMPL_ADDREF(IndexedDatabaseManager) NS_IMPL_ADDREF(IndexedDatabaseManager)
NS_IMPL_RELEASE_WITH_DESTROY(IndexedDatabaseManager, Destroy()) NS_IMPL_RELEASE_WITH_DESTROY(IndexedDatabaseManager, Destroy())

View file

@ -186,10 +186,8 @@ public:
nsresult nsresult
FlushPendingFileDeletions(); FlushPendingFileDeletions();
#ifdef ENABLE_INTL_API
static const nsCString& static const nsCString&
GetLocale(); GetLocale();
#endif
static mozilla::Mutex& static mozilla::Mutex&
FileMutex() FileMutex()
@ -238,9 +236,7 @@ private:
// and FileInfo.mSliceRefCnt // and FileInfo.mSliceRefCnt
mozilla::Mutex mFileMutex; mozilla::Mutex mFileMutex;
#ifdef ENABLE_INTL_API
nsCString mLocale; nsCString mLocale;
#endif
indexedDB::BackgroundUtilsChild* mBackgroundActor; indexedDB::BackgroundUtilsChild* mBackgroundActor;

View file

@ -22,9 +22,7 @@
#include "ReportInternalError.h" #include "ReportInternalError.h"
#include "xpcpublic.h" #include "xpcpublic.h"
#ifdef ENABLE_INTL_API
#include "unicode/ucol.h" #include "unicode/ucol.h"
#endif
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
@ -108,7 +106,6 @@ namespace indexedDB {
[1, 2] // 0x60 bf f0 0 0 0 0 0 0 0x10 c0 [1, 2] // 0x60 bf f0 0 0 0 0 0 0 0x10 c0
[[]] // 0x80 [[]] // 0x80
*/ */
#ifdef ENABLE_INTL_API
nsresult nsresult
Key::ToLocaleBasedKey(Key& aTarget, const nsCString& aLocale) const Key::ToLocaleBasedKey(Key& aTarget, const nsCString& aLocale) const
{ {
@ -202,7 +199,6 @@ Key::ToLocaleBasedKey(Key& aTarget, const nsCString& aLocale) const
aTarget.TrimBuffer(); aTarget.TrimBuffer();
return NS_OK; return NS_OK;
} }
#endif
nsresult nsresult
Key::EncodeJSValInternal(JSContext* aCx, JS::Handle<JS::Value> aVal, Key::EncodeJSValInternal(JSContext* aCx, JS::Handle<JS::Value> aVal,
@ -483,7 +479,6 @@ Key::EncodeAsString(const T* aStart, const T* aEnd, uint8_t aType)
NS_ASSERTION(buffer == mBuffer.EndReading(), "Wrote wrong number of bytes"); NS_ASSERTION(buffer == mBuffer.EndReading(), "Wrote wrong number of bytes");
} }
#ifdef ENABLE_INTL_API
nsresult nsresult
Key::EncodeLocaleString(const nsDependentString& aString, uint8_t aTypeOffset, Key::EncodeLocaleString(const nsDependentString& aString, uint8_t aTypeOffset,
const nsCString& aLocale) const nsCString& aLocale)
@ -522,7 +517,6 @@ Key::EncodeLocaleString(const nsDependentString& aString, uint8_t aTypeOffset,
aTypeOffset); aTypeOffset);
return NS_OK; return NS_OK;
} }
#endif
// static // static
nsresult nsresult

View file

@ -214,10 +214,8 @@ public:
nsresult nsresult
AppendItem(JSContext* aCx, bool aFirstOfArray, JS::Handle<JS::Value> aVal); AppendItem(JSContext* aCx, bool aFirstOfArray, JS::Handle<JS::Value> aVal);
#ifdef ENABLE_INTL_API
nsresult nsresult
ToLocaleBasedKey(Key& aTarget, const nsCString& aLocale) const; ToLocaleBasedKey(Key& aTarget, const nsCString& aLocale) const;
#endif
void void
FinishArray() FinishArray()
@ -298,11 +296,9 @@ private:
void void
EncodeAsString(const T* aStart, const T* aEnd, uint8_t aType); EncodeAsString(const T* aStart, const T* aEnd, uint8_t aType);
#ifdef ENABLE_INTL_API
nsresult nsresult
EncodeLocaleString(const nsDependentString& aString, uint8_t aTypeOffset, EncodeLocaleString(const nsDependentString& aString, uint8_t aTypeOffset,
const nsCString& aLocale); const nsCString& aLocale);
#endif
void void
EncodeNumber(double aFloat, uint8_t aType); EncodeNumber(double aFloat, uint8_t aType);

View file

@ -17,8 +17,7 @@ XPCSHELL_TESTS_MANIFESTS += [
'test/unit/xpcshell-parent-process.ini' 'test/unit/xpcshell-parent-process.ini'
] ]
if CONFIG['ENABLE_INTL_API']: MOCHITEST_MANIFESTS += ['test/mochitest-intl-api.ini']
MOCHITEST_MANIFESTS += ['test/mochitest-intl-api.ini']
EXPORTS.mozilla.dom += [ EXPORTS.mozilla.dom += [
'IDBCursor.h', 'IDBCursor.h',