From 80c217bbec94315fdd9469b7ef570ac78c8175e4 Mon Sep 17 00:00:00 2001
From: Makoto Kato <m_kato@ga2.so-net.ne.jp>
Date: Thu, 23 Mar 2017 13:42:49 +0900
Subject: [PATCH] Bug 943287 - Part 2. Use ICU version of nsICollation on all
 platform. r=hsivonen

nsICollation for macOS version uses ICU, so we should use it on all platform since nightly and aurora can use ICU on all platform.

MozReview-Commit-ID: 4nTzDCjOQXJ

--HG--
rename : intl/locale/tests/unit/test_collation_mac_icu.js => intl/locale/tests/unit/test_collation.js
extra : rebase_source : 3b47f9a521e79be929bb4c39d0c68b9438075e4c
---
 intl/build/nsI18nModule.cpp                   |  26 +---
 intl/locale/mac/moz.build                     |   1 -
 intl/locale/moz.build                         |   2 +-
 .../nsCollationMacUC.cpp => nsCollation.cpp}  |  44 +++---
 .../{mac/nsCollationMacUC.h => nsCollation.h} |  12 +-
 intl/locale/nsCollationFactory.cpp            | 102 --------------
 intl/locale/nsCollationFactory.h              |  22 ---
 intl/locale/nsLocaleConstructors.h            |  34 +----
 ...collation_mac_icu.js => test_collation.js} |   0
 intl/locale/tests/unit/xpcshell.ini           |   4 +-
 intl/locale/unix/moz.build                    |   1 -
 intl/locale/unix/nsCollationUnix.h            |  43 ------
 intl/locale/windows/moz.build                 |   1 -
 intl/locale/windows/nsCollationWin.cpp        | 127 ------------------
 intl/locale/windows/nsCollationWin.h          |  35 -----
 15 files changed, 35 insertions(+), 419 deletions(-)
 rename intl/locale/{mac/nsCollationMacUC.cpp => nsCollation.cpp} (79%)
 rename intl/locale/{mac/nsCollationMacUC.h => nsCollation.h} (83%)
 rename intl/locale/tests/unit/{test_collation_mac_icu.js => test_collation.js} (100%)
 delete mode 100644 intl/locale/unix/nsCollationUnix.h
 delete mode 100644 intl/locale/windows/nsCollationWin.cpp
 delete mode 100644 intl/locale/windows/nsCollationWin.h

diff --git a/intl/build/nsI18nModule.cpp b/intl/build/nsI18nModule.cpp
index 8cd517478e344..9be18774107f1 100644
--- a/intl/build/nsI18nModule.cpp
+++ b/intl/build/nsI18nModule.cpp
@@ -61,15 +61,7 @@ NS_DEFINE_NAMED_CID(NS_COLLATIONFACTORY_CID);
 NS_DEFINE_NAMED_CID(NS_SCRIPTABLEDATEFORMAT_CID);
 NS_DEFINE_NAMED_CID(NS_LANGUAGEATOMSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_PLATFORMCHARSET_CID);
-#ifdef XP_WIN
 NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
-#endif
-#ifdef USE_UNIX_LOCALE
-NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
-#endif
-#ifdef USE_MAC_LOCALE
-NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
-#endif
 
 static const mozilla::Module::CIDEntry kIntlCIDs[] = {
     { &kMOZ_LOCALESERVICE_CID, false, nullptr, mozilla::intl::LocaleServiceConstructor },
@@ -89,15 +81,7 @@ static const mozilla::Module::CIDEntry kIntlCIDs[] = {
     { &kNS_SCRIPTABLEDATEFORMAT_CID, false, nullptr, NS_NewScriptableDateFormat },
     { &kNS_LANGUAGEATOMSERVICE_CID, false, nullptr, nsLanguageAtomServiceConstructor },
     { &kNS_PLATFORMCHARSET_CID, false, nullptr, nsPlatformCharsetConstructor },
-#ifdef XP_WIN
-    { &kNS_COLLATION_CID, false, nullptr, nsCollationWinConstructor },
-#endif
-#ifdef USE_UNIX_LOCALE
-    { &kNS_COLLATION_CID, false, nullptr, nsCollationUnixConstructor },
-#endif
-#ifdef USE_MAC_LOCALE
-    { &kNS_COLLATION_CID, false, nullptr, nsCollationMacUCConstructor },
-#endif
+    { &kNS_COLLATION_CID, false, nullptr, nsCollationConstructor },
     { nullptr }
 };
 
@@ -119,15 +103,7 @@ static const mozilla::Module::ContractIDEntry kIntlContracts[] = {
     { NS_SCRIPTABLEDATEFORMAT_CONTRACTID, &kNS_SCRIPTABLEDATEFORMAT_CID },
     { NS_LANGUAGEATOMSERVICE_CONTRACTID, &kNS_LANGUAGEATOMSERVICE_CID },
     { NS_PLATFORMCHARSET_CONTRACTID, &kNS_PLATFORMCHARSET_CID },
-#ifdef XP_WIN
-    { NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
-#endif
-#ifdef USE_UNIX_LOCALE
-    { NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
-#endif
-#ifdef USE_MAC_LOCALE
     { NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
-#endif
     { nullptr }
 };
 
diff --git a/intl/locale/mac/moz.build b/intl/locale/mac/moz.build
index a7bad24d193ca..8f76d2d2a4227 100644
--- a/intl/locale/mac/moz.build
+++ b/intl/locale/mac/moz.build
@@ -5,7 +5,6 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 UNIFIED_SOURCES += [
-    'nsCollationMacUC.cpp',
     'nsMacCharset.cpp',
 ]
 
diff --git a/intl/locale/moz.build b/intl/locale/moz.build
index 85bae150935fa..b1806f816089a 100644
--- a/intl/locale/moz.build
+++ b/intl/locale/moz.build
@@ -33,7 +33,6 @@ XPIDL_MODULE = 'locale'
 EXPORTS += [
     'DateTimeFormat.h',
     'nsCollationCID.h',
-    'nsCollationFactory.h',
     'nsILanguageAtomService.h',
     'nsIPlatformCharset.h',
     'nsPosixLocale.h',
@@ -48,6 +47,7 @@ EXPORTS.mozilla.intl += [
 
 UNIFIED_SOURCES += [
     'LocaleService.cpp',
+    'nsCollation.cpp',
     'nsCollationFactory.cpp',
     'nsLanguageAtomService.cpp',
     'nsLocale.cpp',
diff --git a/intl/locale/mac/nsCollationMacUC.cpp b/intl/locale/nsCollation.cpp
similarity index 79%
rename from intl/locale/mac/nsCollationMacUC.cpp
rename to intl/locale/nsCollation.cpp
index b32154453a693..b4d6837a2949c 100644
--- a/intl/locale/mac/nsCollationMacUC.cpp
+++ b/intl/locale/nsCollation.cpp
@@ -3,23 +3,21 @@
  * 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 "nsIPrefBranch.h"
-#include "nsIPrefService.h"
+#include "nsCollation.h"
 #include "nsIServiceManager.h"
 #include "prmem.h"
 #include "nsString.h"
 
-NS_IMPL_ISUPPORTS(nsCollationMacUC, nsICollation)
+NS_IMPL_ISUPPORTS(nsCollation, nsICollation)
 
-nsCollationMacUC::nsCollationMacUC()
+nsCollation::nsCollation()
   : mInit(false)
   , mHasCollator(false)
   , mLastStrength(-1)
   , mCollatorICU(nullptr)
 { }
 
-nsCollationMacUC::~nsCollationMacUC()
+nsCollation::~nsCollation()
 {
 #ifdef DEBUG
   nsresult res =
@@ -28,9 +26,10 @@ nsCollationMacUC::~nsCollationMacUC()
   NS_ASSERTION(NS_SUCCEEDED(res), "CleanUpCollator failed");
 }
 
-nsresult nsCollationMacUC::ConvertStrength(const int32_t aNSStrength,
-                                           UCollationStrength* aICUStrength,
-                                           UColAttributeValue* aCaseLevelOut)
+nsresult
+nsCollation::ConvertStrength(const int32_t aNSStrength,
+                             UCollationStrength* aICUStrength,
+                             UColAttributeValue* aCaseLevelOut)
 {
   NS_ENSURE_ARG_POINTER(aICUStrength);
   NS_ENSURE_TRUE((aNSStrength < 4), NS_ERROR_FAILURE);
@@ -62,7 +61,8 @@ nsresult nsCollationMacUC::ConvertStrength(const int32_t aNSStrength,
   return NS_OK;
 }
 
-nsresult nsCollationMacUC::EnsureCollator(const int32_t newStrength)
+nsresult
+nsCollation::EnsureCollator(const int32_t newStrength)
 {
   NS_ENSURE_TRUE(mInit, NS_ERROR_NOT_INITIALIZED);
   if (mHasCollator && (mLastStrength == newStrength))
@@ -102,7 +102,8 @@ nsresult nsCollationMacUC::EnsureCollator(const int32_t newStrength)
   return NS_OK;
 }
 
-nsresult nsCollationMacUC::CleanUpCollator(void)
+nsresult
+nsCollation::CleanUpCollator(void)
 {
   if (mHasCollator) {
     ucol_close(mCollatorICU);
@@ -112,10 +113,10 @@ nsresult nsCollationMacUC::CleanUpCollator(void)
   return NS_OK;
 }
 
-NS_IMETHODIMP nsCollationMacUC::Initialize(const nsACString& locale)
+NS_IMETHODIMP
+nsCollation::Initialize(const nsACString& locale)
 {
   NS_ENSURE_TRUE((!mInit), NS_ERROR_ALREADY_INITIALIZED);
-  nsCOMPtr<nsILocale> appLocale;
 
   mLocale = locale;
 
@@ -123,8 +124,9 @@ NS_IMETHODIMP nsCollationMacUC::Initialize(const nsACString& locale)
   return NS_OK;
 }
 
-NS_IMETHODIMP nsCollationMacUC::AllocateRawSortKey(int32_t strength, const nsAString& stringIn,
-                                                   uint8_t** key, uint32_t* outLen)
+NS_IMETHODIMP
+nsCollation::AllocateRawSortKey(int32_t strength, const nsAString& stringIn,
+                                uint8_t** key, uint32_t* outLen)
 {
   NS_ENSURE_TRUE(mInit, NS_ERROR_NOT_INITIALIZED);
   NS_ENSURE_ARG_POINTER(key);
@@ -155,8 +157,9 @@ NS_IMETHODIMP nsCollationMacUC::AllocateRawSortKey(int32_t strength, const nsASt
   return NS_OK;
 }
 
-NS_IMETHODIMP nsCollationMacUC::CompareString(int32_t strength, const nsAString& string1,
-                                              const nsAString& string2, int32_t* result)
+NS_IMETHODIMP
+nsCollation::CompareString(int32_t strength, const nsAString& string1,
+                           const nsAString& string2, int32_t* result)
 {
   NS_ENSURE_TRUE(mInit, NS_ERROR_NOT_INITIALIZED);
   NS_ENSURE_ARG_POINTER(result);
@@ -189,9 +192,10 @@ NS_IMETHODIMP nsCollationMacUC::CompareString(int32_t strength, const nsAString&
   return NS_OK;
 }
 
-NS_IMETHODIMP nsCollationMacUC::CompareRawSortKey(const uint8_t* key1, uint32_t len1,
-                                                  const uint8_t* key2, uint32_t len2,
-                                                  int32_t* result)
+NS_IMETHODIMP
+nsCollation::CompareRawSortKey(const uint8_t* key1, uint32_t len1,
+                               const uint8_t* key2, uint32_t len2,
+                               int32_t* result)
 {
   NS_ENSURE_TRUE(mInit, NS_ERROR_NOT_INITIALIZED);
   NS_ENSURE_ARG_POINTER(key1);
diff --git a/intl/locale/mac/nsCollationMacUC.h b/intl/locale/nsCollation.h
similarity index 83%
rename from intl/locale/mac/nsCollationMacUC.h
rename to intl/locale/nsCollation.h
index ec6f06e564e63..9ef29194ec15d 100644
--- a/intl/locale/mac/nsCollationMacUC.h
+++ b/intl/locale/nsCollation.h
@@ -3,8 +3,8 @@
  * 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_
+#ifndef nsCollation_h_
+#define nsCollation_h_
 
 #include "mozilla/Attributes.h"
 #include "nsICollation.h"
@@ -13,10 +13,10 @@
 
 #include "unicode/ucol.h"
 
-class nsCollationMacUC final : public nsICollation {
+class nsCollation final : public nsICollation {
 
 public:
-  nsCollationMacUC();
+  nsCollation();
 
   // nsISupports interface
   NS_DECL_ISUPPORTS
@@ -25,7 +25,7 @@ public:
   NS_DECL_NSICOLLATION
 
 protected:
-  ~nsCollationMacUC();
+  ~nsCollation();
 
   nsresult ConvertStrength(const int32_t aStrength,
                            UCollationStrength* aStrengthOut,
@@ -41,4 +41,4 @@ private:
   UCollator* mCollatorICU;
 };
 
-#endif  /* nsCollationMacUC_h_ */
+#endif  /* nsCollation_h_ */
diff --git a/intl/locale/nsCollationFactory.cpp b/intl/locale/nsCollationFactory.cpp
index 0e46011b91da9..ba800da3ab0a0 100644
--- a/intl/locale/nsCollationFactory.cpp
+++ b/intl/locale/nsCollationFactory.cpp
@@ -5,15 +5,9 @@
 
 #include "nsCollationFactory.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);
@@ -47,99 +41,3 @@ nsCollationFactory::CreateCollationForLocale(const nsACString& locale, nsICollat
 
   return res;
 }
-
-////////////////////////////////////////////////////////////////////////////////
-
-nsCollation::nsCollation()
-{
-  MOZ_COUNT_CTOR(nsCollation);
-}
-
-nsCollation::~nsCollation()
-{
-  MOZ_COUNT_DTOR(nsCollation);
-}
-
-nsresult nsCollation::NormalizeString(const nsAString& stringIn, nsAString& stringOut)
-{
-  int32_t aLength = stringIn.Length();
-
-  if (aLength <= 64) {
-    char16_t conversionBuffer[64];
-    ToLowerCase(PromiseFlatString(stringIn).get(), conversionBuffer, aLength);
-    stringOut.Assign(conversionBuffer, aLength);
-  }
-  else {
-    char16_t* conversionBuffer;
-    conversionBuffer = new char16_t[aLength];
-    if (!conversionBuffer) {
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-    ToLowerCase(PromiseFlatString(stringIn).get(), conversionBuffer, aLength);
-    stringOut.Assign(conversionBuffer, aLength);
-    delete [] conversionBuffer;
-  }
-  return NS_OK;
-}
-
-nsresult nsCollation::SetCharset(const char* aCharset)
-{
-  NS_ENSURE_ARG_POINTER(aCharset);
-
-  nsDependentCString label(aCharset);
-  nsAutoCString encoding;
-  if (!EncodingUtils::FindEncodingForLabelNoReplacement(label, encoding)) {
-      return NS_ERROR_UCONV_NOCONV;
-  }
-  mEncoder = EncodingUtils::EncoderForEncoding(encoding);
-  return NS_OK;
-}
-
-nsresult nsCollation::UnicodeToChar(const nsAString& aSrc, char** dst)
-{
-  NS_ENSURE_ARG_POINTER(dst);
-
-  nsresult res = NS_OK;
-  if (!mEncoder)
-    res = SetCharset("ISO-8859-1");
-
-  if (NS_SUCCEEDED(res)) {
-    const nsPromiseFlatString& src = PromiseFlatString(aSrc);
-    const char16_t *unichars = src.get();
-    int32_t unicharLength = src.Length();
-    int32_t dstLength;
-    res = mEncoder->GetMaxLength(unichars, unicharLength, &dstLength);
-    if (NS_SUCCEEDED(res)) {
-      int32_t bufLength = dstLength + 1 + 32; // extra 32 bytes for Finish() call
-      *dst = (char *) PR_Malloc(bufLength);
-      if (*dst) {
-        **dst = '\0';
-        res = mEncoder->Convert(unichars, &unicharLength, *dst, &dstLength);
-
-        if (NS_SUCCEEDED(res) || (NS_ERROR_UENC_NOMAPPING == res)) {
-          // Finishes the conversion. The converter has the possibility to write some 
-          // extra data and flush its final state.
-          int32_t finishLength = bufLength - dstLength; // remaining unused buffer length
-          if (finishLength > 0) {
-            res = mEncoder->Finish((*dst + dstLength), &finishLength);
-            if (NS_SUCCEEDED(res)) {
-              (*dst)[dstLength + finishLength] = '\0';
-            }
-          }
-        }
-        if (NS_FAILED(res)) {
-          PR_Free(*dst);
-          *dst = nullptr;
-        }
-      }
-      else {
-        res = NS_ERROR_OUT_OF_MEMORY;
-      }
-    }
-  }
-
-  return res;
-}
-
-
-
diff --git a/intl/locale/nsCollationFactory.h b/intl/locale/nsCollationFactory.h
index 7f3e1769742bf..3d99c1a71ab08 100644
--- a/intl/locale/nsCollationFactory.h
+++ b/intl/locale/nsCollationFactory.h
@@ -12,8 +12,6 @@
 #include "nsCOMPtr.h"
 #include "mozilla/Attributes.h"
 
-class nsIUnicodeEncoder;
-
 // Create a collation interface for the current app's locale.
 // 
 class nsCollationFactory final : public nsICollationFactory {
@@ -27,24 +25,4 @@ public:
   nsCollationFactory() {}
 };
 
-
-struct nsCollation {
-
-public: 
-
-  nsCollation();
-  
-  ~nsCollation();
-
-  // normalize string before collation key generation
-  nsresult NormalizeString(const nsAString& stringIn, nsAString& stringOut);
-
-  // charset conversion util, C string buffer is allocate by PR_Malloc, caller should call PR_Free
-  nsresult SetCharset(const char* aCharset);
-  nsresult UnicodeToChar(const nsAString& aSrc, char** dst);
-
-protected:
-  nsCOMPtr <nsIUnicodeEncoder>            mEncoder;
-};
-
 #endif  /* nsCollationFactory_h__ */
diff --git a/intl/locale/nsLocaleConstructors.h b/intl/locale/nsLocaleConstructors.h
index 39dff6c781671..5161e19a41f5e 100644
--- a/intl/locale/nsLocaleConstructors.h
+++ b/intl/locale/nsLocaleConstructors.h
@@ -6,6 +6,7 @@
 #ifndef nsLocaleConstructors_h__
 #define nsLocaleConstructors_h__
 
+#include "nsCollation.h"
 #include "nsCollationCID.h"
 #include "mozilla/ModuleUtils.h"
 #include "nsILocaleService.h"
@@ -16,26 +17,6 @@
 #include "LocaleService.h"
 #include "OSPreferences.h"
 
-#if defined(XP_MACOSX)
-#define USE_MAC_LOCALE
-#endif
-
-#if defined(XP_UNIX) && !defined(XP_MACOSX)
-#define USE_UNIX_LOCALE
-#endif
-
-#ifdef XP_WIN
-#include "windows/nsCollationWin.h"
-#endif
-
-#ifdef USE_MAC_LOCALE
-#include "mac/nsCollationMacUC.h"
-#endif
-
-#ifdef USE_UNIX_LOCALE
-#include "unix/nsCollationUnix.h"
-#endif
-
 #define NSLOCALE_MAKE_CTOR(ctor_, iface_, func_)          \
 static nsresult                                           \
 ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) \
@@ -54,6 +35,7 @@ ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) \
 
 
 NSLOCALE_MAKE_CTOR(CreateLocaleService, nsILocaleService, NS_NewLocaleService)
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollation)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationFactory)
 //NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableDateTimeFormat)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsLanguageAtomService)
@@ -68,16 +50,4 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(OSPreferences,
 }
 }
 
-#ifdef XP_WIN
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationWin)
-#endif
-
-#ifdef USE_UNIX_LOCALE
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationUnix)
-#endif  
-
-#ifdef USE_MAC_LOCALE
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationMacUC)
-#endif  
-
 #endif
diff --git a/intl/locale/tests/unit/test_collation_mac_icu.js b/intl/locale/tests/unit/test_collation.js
similarity index 100%
rename from intl/locale/tests/unit/test_collation_mac_icu.js
rename to intl/locale/tests/unit/test_collation.js
diff --git a/intl/locale/tests/unit/xpcshell.ini b/intl/locale/tests/unit/xpcshell.ini
index 5e72c860e3822..74173782e34e7 100644
--- a/intl/locale/tests/unit/xpcshell.ini
+++ b/intl/locale/tests/unit/xpcshell.ini
@@ -11,9 +11,7 @@ skip-if = toolkit != "windows" && toolkit != "cocoa"
 [test_bug374040.js]
 skip-if = toolkit == "windows" || toolkit == "cocoa"
 
-[test_collation_mac_icu.js]
-skip-if = toolkit != "cocoa"
-
+[test_collation.js]
 [test_bug1086527.js]
 [test_intl_on_workers.js]
 skip-if = toolkit == "android" # bug 1309447
diff --git a/intl/locale/unix/moz.build b/intl/locale/unix/moz.build
index 633047ed1887f..fcf87eb661de7 100644
--- a/intl/locale/unix/moz.build
+++ b/intl/locale/unix/moz.build
@@ -5,7 +5,6 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 SOURCES += [
-    'nsCollationUnix.cpp',
     'nsPosixLocale.cpp',
 ]
 
diff --git a/intl/locale/unix/nsCollationUnix.h b/intl/locale/unix/nsCollationUnix.h
deleted file mode 100644
index 92be2934f16c4..0000000000000
--- a/intl/locale/unix/nsCollationUnix.h
+++ /dev/null
@@ -1,43 +0,0 @@
-
-/* -*- 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 nsCollationUnix_h__
-#define nsCollationUnix_h__
-
-
-#include "nsICollation.h"
-#include "nsCollationFactory.h"  // static library
-#include "plstr.h"
-#include "mozilla/Attributes.h"
-#include "nsString.h"
-
-
-
-class nsCollationUnix final : public nsICollation {
-
-protected:
-  nsCollation   *mCollation;
-  nsCString     mLocale;
-  nsCString     mSavedLocale;
-  bool          mUseCodePointOrder;
-
-  void DoSetLocale();
-  void DoRestoreLocale();
-
-  ~nsCollationUnix(); 
-
-public:
-  nsCollationUnix();
-
-  // nsISupports interface
-  NS_DECL_ISUPPORTS
-
-  // nsICollation interface
-  NS_DECL_NSICOLLATION
-
-};
-
-#endif  /* nsCollationUnix_h__ */
diff --git a/intl/locale/windows/moz.build b/intl/locale/windows/moz.build
index 555b6cc2619eb..c2f28c21149e5 100644
--- a/intl/locale/windows/moz.build
+++ b/intl/locale/windows/moz.build
@@ -5,7 +5,6 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 SOURCES += [
-    'nsCollationWin.cpp',
     'nsWin32Locale.cpp',
     'nsWinCharset.cpp',
 ]
diff --git a/intl/locale/windows/nsCollationWin.cpp b/intl/locale/windows/nsCollationWin.cpp
deleted file mode 100644
index 76bc8a2d48c88..0000000000000
--- a/intl/locale/windows/nsCollationWin.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/* -*- 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 "nsCollationWin.h"
-#include "nsIServiceManager.h"
-#include "nsIComponentManager.h"
-#include "nsIPlatformCharset.h"
-#include "nsWin32Locale.h"
-#include "nsCOMPtr.h"
-#include "prmem.h"
-#include "plstr.h"
-#include <windows.h>
-
-#undef CompareString
-
-NS_IMPL_ISUPPORTS(nsCollationWin, nsICollation)
-
-
-nsCollationWin::nsCollationWin() : mCollation(nullptr)
-{
-}
-
-nsCollationWin::~nsCollationWin() 
-{
-  if (mCollation)
-    delete mCollation;
-}
-
-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;
-
-  // Get LCID and charset name from locale, if available
-  LCID 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(wideLocale, mappedCharset);
-    if (NS_SUCCEEDED(res)) {
-      mCollation->SetCharset(mappedCharset.get());
-    }
-  }
-
-  return NS_OK;
-}
-
-
-NS_IMETHODIMP nsCollationWin::CompareString(int32_t strength, 
-                                            const nsAString & string1, 
-                                            const nsAString & string2, 
-                                            int32_t *result)
-{
-  int retval;
-  nsresult res;
-  DWORD dwMapFlags = 0;
-
-  if (strength == kCollationCaseInSensitive)
-    dwMapFlags |= NORM_IGNORECASE;
-
-  retval = ::CompareStringW(mLCID, 
-                            dwMapFlags,
-                            (LPCWSTR) PromiseFlatString(string1).get(), 
-                            -1,
-                            (LPCWSTR) PromiseFlatString(string2).get(), 
-                            -1);
-  if (retval) {
-    res = NS_OK;
-    *result = retval - 2;
-  } else {
-    res = NS_ERROR_FAILURE;
-  }
-
-  return res;
-}
- 
-
-nsresult nsCollationWin::AllocateRawSortKey(int32_t strength, 
-                                            const nsAString& stringIn, uint8_t** key, uint32_t* outLen)
-{
-  int byteLen;
-  void *buffer;
-  nsresult res = NS_OK;
-  DWORD dwMapFlags = LCMAP_SORTKEY;
-
-  if (strength == kCollationCaseInSensitive)
-    dwMapFlags |= NORM_IGNORECASE;
-
-  byteLen = LCMapStringW(mLCID, dwMapFlags, 
-                         (LPCWSTR) PromiseFlatString(stringIn).get(),
-                         -1, nullptr, 0);
-  buffer = PR_Malloc(byteLen);
-  if (!buffer) {
-    res = NS_ERROR_OUT_OF_MEMORY;
-  } else {
-    *key = (uint8_t *)buffer;
-    *outLen = LCMapStringW(mLCID, dwMapFlags, 
-                           (LPCWSTR) PromiseFlatString(stringIn).get(),
-                           -1, (LPWSTR) buffer, byteLen);
-  }
-  return res;
-}
-
-nsresult nsCollationWin::CompareRawSortKey(const uint8_t* key1, uint32_t len1, 
-                                           const uint8_t* key2, uint32_t len2, 
-                                           int32_t* result)
-{
-  *result = PL_strcmp((const char *)key1, (const char *)key2);
-  return NS_OK;
-}
diff --git a/intl/locale/windows/nsCollationWin.h b/intl/locale/windows/nsCollationWin.h
deleted file mode 100644
index 4ca1aff08de6e..0000000000000
--- a/intl/locale/windows/nsCollationWin.h
+++ /dev/null
@@ -1,35 +0,0 @@
-
-/* -*- 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 nsCollationWin_h__
-#define nsCollationWin_h__
-
-
-#include "nsICollation.h"
-#include "nsCollationFactory.h"  // static library
-#include "plstr.h"
-
-
-
-class nsCollationWin final : public nsICollation {
-  ~nsCollationWin();
-
-protected:
-  nsCollation   *mCollation;  // XP collation class
-  uint32_t      mLCID;        // Windows platform locale ID
-
-public: 
-  nsCollationWin();
-
-  // nsISupports interface
-  NS_DECL_ISUPPORTS
-
-  // nsICollation interface
-  NS_DECL_NSICOLLATION
-
-};
-
-#endif  /* nsCollationWin_h__ */
-- 
GitLab