Bug 1335983 - Migrate nsCollation::CreateCollection to use LocaleService::GetAppLocale. r?jfkthame
MozReview-Commit-ID: bJVrVj2dAS
--- a/dom/xslt/xslt/txXPathResultComparator.cpp
+++ b/dom/xslt/xslt/txXPathResultComparator.cpp
@@ -4,18 +4,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/FloatingPoint.h"
#include "txXPathResultComparator.h"
#include "txExpr.h"
#include "txCore.h"
#include "nsCollationCID.h"
-#include "nsILocale.h"
-#include "nsILocaleService.h"
#include "nsIServiceManager.h"
#include "prmem.h"
#define kAscending (1<<0)
#define kUpperFirst (1<<1)
txResultStringComparator::txResultStringComparator(bool aAscending,
bool aUpperFirst,
@@ -30,35 +28,26 @@ txResultStringComparator::txResultString
if (NS_FAILED(rv))
NS_ERROR("Failed to initialize txResultStringComparator");
}
nsresult txResultStringComparator::init(const nsAFlatString& aLanguage)
{
nsresult rv;
- nsCOMPtr<nsILocaleService> localeService =
- do_GetService(NS_LOCALESERVICE_CONTRACTID, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr<nsILocale> locale;
- if (!aLanguage.IsEmpty()) {
- rv = localeService->NewLocale(aLanguage,
- getter_AddRefs(locale));
- }
- else {
- rv = localeService->GetApplicationLocale(getter_AddRefs(locale));
- }
- NS_ENSURE_SUCCESS(rv, rv);
-
nsCOMPtr<nsICollationFactory> colFactory =
do_CreateInstance(NS_COLLATIONFACTORY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
- rv = colFactory->CreateCollation(locale, getter_AddRefs(mCollation));
+ if (aLanguage.IsEmpty()) {
+ rv = colFactory->CreateCollation(getter_AddRefs(mCollation));
+ } else {
+ rv = colFactory->CreateCollationForLocale(NS_ConvertUTF16toUTF8(aLanguage), getter_AddRefs(mCollation));
+ }
+
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
nsresult
txResultStringComparator::createSortableValue(Expr *aExpr,
txIEvalContext *aContext,
--- a/dom/xul/templates/nsXULContentUtils.cpp
+++ b/dom/xul/templates/nsXULContentUtils.cpp
@@ -47,18 +47,16 @@
#include "nsGkAtoms.h"
#include "mozilla/Logging.h"
#include "prtime.h"
#include "rdf.h"
#include "nsContentUtils.h"
#include "nsIScriptableDateFormat.h"
#include "nsICollation.h"
#include "nsCollationCID.h"
-#include "nsILocale.h"
-#include "nsILocaleService.h"
#include "nsIConsoleService.h"
#include "nsEscape.h"
using namespace mozilla;
//------------------------------------------------------------------------
nsIRDFService* nsXULContentUtils::gRDF;
@@ -122,35 +120,24 @@ nsXULContentUtils::Finish()
}
nsICollation*
nsXULContentUtils::GetCollation()
{
if (!gCollation) {
nsresult rv;
- // get a locale service
- nsCOMPtr<nsILocaleService> localeService =
- do_GetService(NS_LOCALESERVICE_CONTRACTID, &rv);
- if (NS_SUCCEEDED(rv)) {
- nsCOMPtr<nsILocale> locale;
- rv = localeService->GetApplicationLocale(getter_AddRefs(locale));
- if (NS_SUCCEEDED(rv) && locale) {
- nsCOMPtr<nsICollationFactory> colFactory =
- do_CreateInstance(NS_COLLATIONFACTORY_CONTRACTID);
- if (colFactory) {
- rv = colFactory->CreateCollation(locale, &gCollation);
- NS_ASSERTION(NS_SUCCEEDED(rv),
- "couldn't create collation instance");
- } else
- NS_ERROR("couldn't create instance of collation factory");
- } else
- NS_ERROR("unable to get application locale");
+ nsCOMPtr<nsICollationFactory> colFactory =
+ do_CreateInstance(NS_COLLATIONFACTORY_CONTRACTID);
+ if (colFactory) {
+ rv = colFactory->CreateCollation(&gCollation);
+ NS_ASSERTION(NS_SUCCEEDED(rv),
+ "couldn't create collation instance");
} else
- NS_ERROR("couldn't get locale factory");
+ NS_ERROR("couldn't create instance of collation factory");
}
return gCollation;
}
//------------------------------------------------------------------------
nsresult
--- a/intl/locale/mac/nsCollationMacUC.cpp
+++ b/intl/locale/mac/nsCollationMacUC.cpp
@@ -1,42 +1,36 @@
/* -*- Mode: C++; 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/. */
#include "nsCollationMacUC.h"
-#include "nsILocaleService.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIServiceManager.h"
#include "prmem.h"
#include "nsString.h"
NS_IMPL_ISUPPORTS(nsCollationMacUC, nsICollation)
nsCollationMacUC::nsCollationMacUC()
: mInit(false)
, mHasCollator(false)
- , mLocaleICU(nullptr)
, mLastStrength(-1)
, mCollatorICU(nullptr)
{ }
nsCollationMacUC::~nsCollationMacUC()
{
#ifdef DEBUG
nsresult res =
#endif
CleanUpCollator();
NS_ASSERTION(NS_SUCCEEDED(res), "CleanUpCollator failed");
- if (mLocaleICU) {
- free(mLocaleICU);
- mLocaleICU = nullptr;
- }
}
nsresult nsCollationMacUC::ConvertStrength(const int32_t aNSStrength,
UCollationStrength* aICUStrength,
UColAttributeValue* aCaseLevelOut)
{
NS_ENSURE_ARG_POINTER(aICUStrength);
NS_ENSURE_TRUE((aNSStrength < 4), NS_ERROR_FAILURE);
@@ -63,53 +57,29 @@ nsresult nsCollationMacUC::ConvertStreng
}
*aICUStrength = strength;
*aCaseLevelOut = caseLevel;
return NS_OK;
}
-nsresult nsCollationMacUC::ConvertLocaleICU(nsILocale* aNSLocale, char** aICULocale)
-{
- NS_ENSURE_ARG_POINTER(aNSLocale);
- NS_ENSURE_ARG_POINTER(aICULocale);
-
- nsAutoString localeString;
- nsresult res = aNSLocale->GetCategory(NS_LITERAL_STRING("NSILOCALE_COLLATE"), localeString);
- NS_ENSURE_TRUE(NS_SUCCEEDED(res) && !localeString.IsEmpty(),
- NS_ERROR_FAILURE);
- NS_LossyConvertUTF16toASCII tmp(localeString);
- tmp.ReplaceChar('-', '_');
- char* locale = (char*)malloc(tmp.Length() + 1);
- if (!locale) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
- strcpy(locale, tmp.get());
-
- *aICULocale = locale;
-
- return NS_OK;
-}
-
nsresult nsCollationMacUC::EnsureCollator(const int32_t newStrength)
{
NS_ENSURE_TRUE(mInit, NS_ERROR_NOT_INITIALIZED);
if (mHasCollator && (mLastStrength == newStrength))
return NS_OK;
nsresult res;
res = CleanUpCollator();
NS_ENSURE_SUCCESS(res, res);
- NS_ENSURE_TRUE(mLocaleICU, NS_ERROR_NOT_INITIALIZED);
-
UErrorCode status;
status = U_ZERO_ERROR;
- mCollatorICU = ucol_open(mLocaleICU, &status);
+ mCollatorICU = ucol_open(mLocale.get(), &status);
NS_ENSURE_TRUE(U_SUCCESS(status), NS_ERROR_FAILURE);
UCollationStrength strength;
UColAttributeValue caseLevel;
res = ConvertStrength(newStrength, &strength, &caseLevel);
NS_ENSURE_SUCCESS(res, res);
status = U_ZERO_ERROR;
@@ -137,32 +107,22 @@ nsresult nsCollationMacUC::CleanUpCollat
if (mHasCollator) {
ucol_close(mCollatorICU);
mHasCollator = false;
}
return NS_OK;
}
-NS_IMETHODIMP nsCollationMacUC::Initialize(nsILocale* locale)
+NS_IMETHODIMP nsCollationMacUC::Initialize(const nsACString& locale)
{
NS_ENSURE_TRUE((!mInit), NS_ERROR_ALREADY_INITIALIZED);
nsCOMPtr<nsILocale> appLocale;
- nsresult rv;
- if (!locale) {
- nsCOMPtr<nsILocaleService> localeService = do_GetService(NS_LOCALESERVICE_CONTRACTID, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
- rv = localeService->GetApplicationLocale(getter_AddRefs(appLocale));
- NS_ENSURE_SUCCESS(rv, rv);
- locale = appLocale;
- }
-
- rv = ConvertLocaleICU(locale, &mLocaleICU);
- NS_ENSURE_SUCCESS(rv, rv);
+ mLocale = locale;
mInit = true;
return NS_OK;
}
NS_IMETHODIMP nsCollationMacUC::AllocateRawSortKey(int32_t strength, const nsAString& stringIn,
uint8_t** key, uint32_t* outLen)
{
--- a/intl/locale/mac/nsCollationMacUC.h
+++ b/intl/locale/mac/nsCollationMacUC.h
@@ -1,19 +1,20 @@
/* -*- Mode: C++; 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/. */
#ifndef nsCollationMacUC_h_
#define nsCollationMacUC_h_
+#include "mozilla/Attributes.h"
#include "nsICollation.h"
#include "nsCollation.h"
-#include "mozilla/Attributes.h"
+#include "nsString.h"
#include "unicode/ucol.h"
class nsCollationMacUC final : public nsICollation {
public:
nsCollationMacUC();
@@ -21,24 +22,23 @@ public:
NS_DECL_ISUPPORTS
// nsICollation interface
NS_DECL_NSICOLLATION
protected:
~nsCollationMacUC();
- nsresult ConvertLocaleICU(nsILocale* aNSLocale, char** aICULocale);
nsresult ConvertStrength(const int32_t aStrength,
UCollationStrength* aStrengthOut,
UColAttributeValue* aCaseLevelOut);
nsresult EnsureCollator(const int32_t newStrength);
nsresult CleanUpCollator(void);
private:
bool mInit;
bool mHasCollator;
- char* mLocaleICU;
+ nsCString mLocale;
int32_t mLastStrength;
UCollator* mCollatorICU;
};
#endif /* nsCollationMacUC_h_ */
--- a/intl/locale/nsCollation.cpp
+++ b/intl/locale/nsCollation.cpp
@@ -5,38 +5,49 @@
#include "nsCollation.h"
#include "nsCollationCID.h"
#include "nsUnicharUtils.h"
#include "prmem.h"
#include "nsIUnicodeEncoder.h"
#include "nsServiceManagerUtils.h"
#include "mozilla/dom/EncodingUtils.h"
+#include "mozilla/intl/LocaleService.h"
using mozilla::dom::EncodingUtils;
////////////////////////////////////////////////////////////////////////////////
NS_DEFINE_CID(kCollationCID, NS_COLLATION_CID);
NS_IMPL_ISUPPORTS(nsCollationFactory, nsICollationFactory)
-nsresult nsCollationFactory::CreateCollation(nsILocale* locale, nsICollation** instancePtr)
+nsresult nsCollationFactory::CreateCollation(nsICollation** instancePtr)
+{
+ nsAutoCString appLocale;
+ mozilla::intl::LocaleService::GetInstance()->GetAppLocale(appLocale);
+
+ return CreateCollationForLocale(appLocale, instancePtr);
+}
+
+nsresult
+nsCollationFactory::CreateCollationForLocale(const nsACString& locale, nsICollation** instancePtr)
{
// Create a collation interface instance.
//
nsICollation *inst;
nsresult res;
-
+
res = CallCreateInstance(kCollationCID, &inst);
if (NS_FAILED(res)) {
return res;
}
inst->Initialize(locale);
+
*instancePtr = inst;
return res;
}
////////////////////////////////////////////////////////////////////////////////
nsCollation::nsCollation()
--- a/intl/locale/nsCollation.h
+++ b/intl/locale/nsCollation.h
@@ -9,26 +9,27 @@
#include "nsICollation.h"
#include "nsCOMPtr.h"
#include "mozilla/Attributes.h"
class nsIUnicodeEncoder;
-// Create a collation interface for an input locale.
+// Create a collation interface for the current app's locale.
//
class nsCollationFactory final : public nsICollationFactory {
~nsCollationFactory() {}
public:
NS_DECL_ISUPPORTS
- NS_IMETHOD CreateCollation(nsILocale* locale, nsICollation** instancePtr) override;
+ NS_IMETHOD CreateCollation(nsICollation** instancePtr) override;
+ NS_IMETHOD CreateCollationForLocale(const nsACString& locale, nsICollation** instancePtr) override;
nsCollationFactory() {}
};
struct nsCollation {
public:
--- a/intl/locale/nsICollation.idl
+++ b/intl/locale/nsICollation.idl
@@ -6,27 +6,28 @@
#include "nsILocale.idl"
interface nsICollation;
[scriptable, uuid(04971e14-d6b3-4ada-8cbb-c3a13842b349)]
interface nsICollationFactory : nsISupports
{
/**
- * Create the collation for a given locale.
- *
- * Use NULL as the locale parameter to use the user's locale preference
- * from the operating system.
+ * Create a new collation for the current application locale.
*
- * @param locale
- * The locale for which to create the collation or null to use
- * user preference.
- * @return A collation for the given locale.
+ * @return A new collation.
*/
- nsICollation CreateCollation(in nsILocale locale);
+ nsICollation CreateCollation();
+
+ /**
+ * Create a new collation for a given locale.
+ *
+ * @return A new collation.
+ */
+ nsICollation CreateCollationForLocale(in ACString locale);
};
[scriptable, uuid(b0132cc0-3786-4557-9874-910d7def5f93)]
interface nsICollation : nsISupports {
// use the primary comparison for the given locale - no flags
const long kCollationStrengthDefault = 0;
@@ -38,17 +39,17 @@ interface nsICollation : nsISupports {
// case sensitive collation (default)
const long kCollationCaseSensitive = kCollationStrengthDefault;
// case insensitive collation
const long kCollationCaseInSensitive = (kCollationCaseInsensitiveAscii | kCollationAccentInsenstive);
// init this interface to a specified locale (should only be called by collation factory)
- void initialize(in nsILocale locale);
+ void initialize(in ACString locale);
// compare two strings
// result is same as strcmp
long compareString(in long strength, in AString string1, in AString string2);
// allocate sort key from input string
// returns newly allocated key, and its band its byte length
[noscript] void allocateRawSortKey(in long strength,
--- a/intl/locale/unix/nsCollationUnix.cpp
+++ b/intl/locale/unix/nsCollationUnix.cpp
@@ -3,17 +3,16 @@
* 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/. */
#include <locale.h>
#include "prmem.h"
#include "nsCollationUnix.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
-#include "nsILocaleService.h"
#include "nsIPlatformCharset.h"
#include "nsPosixLocale.h"
#include "nsCOMPtr.h"
#include "nsUnicharUtils.h"
#include "nsCRT.h"
//#define DEBUG_UNIX_COLLATION
inline void nsCollationUnix::DoSetLocale()
@@ -39,65 +38,31 @@ nsCollationUnix::nsCollationUnix() : mCo
nsCollationUnix::~nsCollationUnix()
{
if (mCollation)
delete mCollation;
}
NS_IMPL_ISUPPORTS(nsCollationUnix, nsICollation)
-nsresult nsCollationUnix::Initialize(nsILocale* locale)
+nsresult nsCollationUnix::Initialize(const nsACString& locale)
{
#define kPlatformLocaleLength 64
NS_ASSERTION(!mCollation, "Should only be initialized once");
nsresult res;
mCollation = new nsCollation;
- // default platform locale
- mLocale.Assign('C');
-
- nsAutoString localeStr;
- NS_NAMED_LITERAL_STRING(aCategory, "NSILOCALE_COLLATE##PLATFORM");
-
- // get locale string, use app default if no locale specified
- if (locale == nullptr) {
- nsCOMPtr<nsILocaleService> localeService =
- do_GetService(NS_LOCALESERVICE_CONTRACTID, &res);
+ nsCOMPtr <nsIPlatformCharset> platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &res);
+ if (NS_SUCCEEDED(res)) {
+ nsAutoCString mappedCharset;
+ res = platformCharset->GetDefaultCharsetForLocale(NS_ConvertUTF8toUTF16(locale), mappedCharset);
if (NS_SUCCEEDED(res)) {
- nsCOMPtr<nsILocale> appLocale;
- res = localeService->GetApplicationLocale(getter_AddRefs(appLocale));
- if (NS_SUCCEEDED(res)) {
- res = appLocale->GetCategory(aCategory, localeStr);
- NS_ASSERTION(NS_SUCCEEDED(res), "failed to get app locale info");
- }
- }
- }
- else {
- res = locale->GetCategory(aCategory, localeStr);
- NS_ASSERTION(NS_SUCCEEDED(res), "failed to get locale info");
- }
-
- // Get platform locale and charset name from locale, if available
- if (NS_SUCCEEDED(res)) {
- // keep the same behavior as 4.x as well as avoiding Linux collation key problem
- if (localeStr.LowerCaseEqualsLiteral("en_us")) { // note: locale is in platform format
- localeStr.Assign('C');
- }
-
- nsPosixLocale::GetPlatformLocale(localeStr, mLocale);
-
- nsCOMPtr <nsIPlatformCharset> platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &res);
- if (NS_SUCCEEDED(res)) {
- nsAutoCString mappedCharset;
- res = platformCharset->GetDefaultCharsetForLocale(localeStr, mappedCharset);
- if (NS_SUCCEEDED(res)) {
- mCollation->SetCharset(mappedCharset.get());
- }
+ mCollation->SetCharset(mappedCharset.get());
}
}
return NS_OK;
}
nsresult nsCollationUnix::CompareString(int32_t strength,
--- a/intl/locale/windows/nsCollationWin.cpp
+++ b/intl/locale/windows/nsCollationWin.cpp
@@ -2,17 +2,16 @@
/* 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/. */
#include "nsCollationWin.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
-#include "nsILocaleService.h"
#include "nsIPlatformCharset.h"
#include "nsWin32Locale.h"
#include "nsCOMPtr.h"
#include "prmem.h"
#include "plstr.h"
#include <windows.h>
#undef CompareString
@@ -25,59 +24,41 @@ nsCollationWin::nsCollationWin() : mColl
}
nsCollationWin::~nsCollationWin()
{
if (mCollation)
delete mCollation;
}
-nsresult nsCollationWin::Initialize(nsILocale* locale)
+nsresult nsCollationWin::Initialize(const nsACString& locale)
{
NS_ASSERTION(!mCollation, "Should only be initialized once.");
nsresult res;
mCollation = new nsCollation;
+ NS_ConvertASCIItoUTF16 wideLocale(locale);
+
// default LCID (en-US)
mLCID = 1033;
- nsAutoString localeStr;
-
- // get locale string, use app default if no locale specified
- if (!locale) {
- nsCOMPtr<nsILocaleService> localeService =
- do_GetService(NS_LOCALESERVICE_CONTRACTID);
- if (localeService) {
- nsCOMPtr<nsILocale> appLocale;
- res = localeService->GetApplicationLocale(getter_AddRefs(appLocale));
- if (NS_SUCCEEDED(res)) {
- res = appLocale->GetCategory(NS_LITERAL_STRING("NSILOCALE_COLLATE"),
- localeStr);
- }
- }
- }
- else {
- res = locale->GetCategory(NS_LITERAL_STRING("NSILOCALE_COLLATE"),
- localeStr);
- }
-
// Get LCID and charset name from locale, if available
LCID lcid;
- res = nsWin32Locale::GetPlatformLocale(localeStr, &lcid);
+ res = nsWin32Locale::GetPlatformLocale(wideLocale, &lcid);
if (NS_SUCCEEDED(res)) {
mLCID = lcid;
}
nsCOMPtr <nsIPlatformCharset> platformCharset =
do_GetService(NS_PLATFORMCHARSET_CONTRACTID);
if (platformCharset) {
nsAutoCString mappedCharset;
- res = platformCharset->GetDefaultCharsetForLocale(localeStr, mappedCharset);
+ res = platformCharset->GetDefaultCharsetForLocale(wideLocale, mappedCharset);
if (NS_SUCCEEDED(res)) {
mCollation->SetCharset(mappedCharset.get());
}
}
return NS_OK;
}
--- a/js/xpconnect/src/XPCLocale.cpp
+++ b/js/xpconnect/src/XPCLocale.cpp
@@ -121,31 +121,21 @@ private:
}
bool
Compare(JSContext* cx, HandleString src1, HandleString src2, MutableHandleValue rval)
{
nsresult rv;
if (!mCollation) {
- nsCOMPtr<nsILocaleService> localeService =
- do_GetService(NS_LOCALESERVICE_CONTRACTID, &rv);
+ nsCOMPtr<nsICollationFactory> colFactory =
+ do_CreateInstance(NS_COLLATIONFACTORY_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
- nsCOMPtr<nsILocale> locale;
- rv = localeService->GetApplicationLocale(getter_AddRefs(locale));
-
- if (NS_SUCCEEDED(rv)) {
- nsCOMPtr<nsICollationFactory> colFactory =
- do_CreateInstance(NS_COLLATIONFACTORY_CONTRACTID, &rv);
-
- if (NS_SUCCEEDED(rv)) {
- rv = colFactory->CreateCollation(locale, getter_AddRefs(mCollation));
- }
- }
+ rv = colFactory->CreateCollation(getter_AddRefs(mCollation));
}
if (NS_FAILED(rv)) {
xpc::Throw(cx, rv);
return false;
}
}
--- a/storage/mozStorageService.cpp
+++ b/storage/mozStorageService.cpp
@@ -9,18 +9,16 @@
#include "mozStorageService.h"
#include "mozStorageConnection.h"
#include "nsAutoPtr.h"
#include "nsCollationCID.h"
#include "nsEmbedCID.h"
#include "nsThreadUtils.h"
#include "mozStoragePrivateHelpers.h"
-#include "nsILocale.h"
-#include "nsILocaleService.h"
#include "nsIXPConnect.h"
#include "nsIObserverService.h"
#include "nsIPropertyBag2.h"
#include "mozilla/Services.h"
#include "mozilla/Preferences.h"
#include "mozilla/LateWriteChecks.h"
#include "mozIStorageCompletionCallback.h"
#include "mozIStoragePendingStatement.h"
@@ -603,37 +601,24 @@ Service::localeCompareStrings(const nsAS
nsICollation *
Service::getLocaleCollation()
{
mMutex.AssertCurrentThreadOwns();
if (mLocaleCollation)
return mLocaleCollation;
- nsCOMPtr<nsILocaleService> svc(do_GetService(NS_LOCALESERVICE_CONTRACTID));
- if (!svc) {
- NS_WARNING("Could not get locale service");
- return nullptr;
- }
-
- nsCOMPtr<nsILocale> appLocale;
- nsresult rv = svc->GetApplicationLocale(getter_AddRefs(appLocale));
- if (NS_FAILED(rv)) {
- NS_WARNING("Could not get application locale");
- return nullptr;
- }
-
nsCOMPtr<nsICollationFactory> collFact =
do_CreateInstance(NS_COLLATIONFACTORY_CONTRACTID);
if (!collFact) {
NS_WARNING("Could not create collation factory");
return nullptr;
}
- rv = collFact->CreateCollation(appLocale, getter_AddRefs(mLocaleCollation));
+ nsresult rv = collFact->CreateCollation(getter_AddRefs(mLocaleCollation));
if (NS_FAILED(rv)) {
NS_WARNING("Could not create collation");
return nullptr;
}
return mLocaleCollation;
}
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -15,17 +15,16 @@
#include "nsAnnotationService.h"
#include "nsFaviconService.h"
#include "nsPlacesMacros.h"
#include "History.h"
#include "Helpers.h"
#include "nsTArray.h"
#include "nsCollationCID.h"
-#include "nsILocaleService.h"
#include "nsNetUtil.h"
#include "nsPrintfCString.h"
#include "nsPromiseFlatString.h"
#include "nsString.h"
#include "nsUnicharUtils.h"
#include "prsystem.h"
#include "prtime.h"
#include "nsEscape.h"
@@ -4474,28 +4473,21 @@ nsNavHistory::AutoCompleteFeedback(int32
nsICollation *
nsNavHistory::GetCollation()
{
if (mCollation)
return mCollation;
- // locale
- nsCOMPtr<nsILocale> locale;
- nsCOMPtr<nsILocaleService> ls(do_GetService(NS_LOCALESERVICE_CONTRACTID));
- NS_ENSURE_TRUE(ls, nullptr);
- nsresult rv = ls->GetApplicationLocale(getter_AddRefs(locale));
- NS_ENSURE_SUCCESS(rv, nullptr);
-
// collation
nsCOMPtr<nsICollationFactory> cfact =
do_CreateInstance(NS_COLLATIONFACTORY_CONTRACTID);
NS_ENSURE_TRUE(cfact, nullptr);
- rv = cfact->CreateCollation(locale, getter_AddRefs(mCollation));
+ nsresult rv = cfact->CreateCollation(getter_AddRefs(mCollation));
NS_ENSURE_SUCCESS(rv, nullptr);
return mCollation;
}
nsIStringBundle *
nsNavHistory::GetBundle()
{