Bug 1394215 - remove use of nsIAtom in nsICharsetConverterManager.idl. r=njn
authorJorg K <jorgk@jorgk.com>
Mon, 28 Aug 2017 02:39:15 +0200
changeset 29634 4cdc9415f29b71b84ed88cee9b24b85a253b268d
parent 29633 19b1cdcc93f30773ff9992d8bfe87820f8ac1a92
child 29635 799ad314120ff7db0d2e372c99036cd7ec30bbbd
push id378
push userclokep@gmail.com
push dateMon, 13 Nov 2017 18:45:35 +0000
reviewersnjn
bugs1394215
Bug 1394215 - remove use of nsIAtom in nsICharsetConverterManager.idl. r=njn
mailnews/intl/nsCharsetConverterManager.cpp
mailnews/intl/nsICharsetConverterManager.idl
mailnews/mime/src/mimemoz2.cpp
--- a/mailnews/intl/nsCharsetConverterManager.cpp
+++ b/mailnews/intl/nsCharsetConverterManager.cpp
@@ -160,44 +160,42 @@ NS_IMETHODIMP
 nsCharsetConverterManager::GetCharsetData(const char * aCharset, 
                                           const char16_t * aProp,
                                           nsAString& aResult)
 {
   return GetCharsetDataImpl(aCharset, aProp, aResult);
 }
 
 NS_IMETHODIMP
-nsCharsetConverterManager::GetCharsetLangGroup(const char * aCharset, 
-                                               nsIAtom** aResult)
+nsCharsetConverterManager::GetCharsetLangGroup(const char * aCharset,
+                                               nsACString& aResult)
 {
   // resolve the charset first
   nsAutoCString charset;
 
   nsresult rv = GetCharsetAlias(aCharset, charset);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // fully qualify to possibly avoid vtable call
   return nsCharsetConverterManager::GetCharsetLangGroupRaw(charset.get(),
                                                            aResult);
 }
 
 NS_IMETHODIMP
-nsCharsetConverterManager::GetCharsetLangGroupRaw(const char * aCharset, 
-                                                  nsIAtom** aResult)
+nsCharsetConverterManager::GetCharsetLangGroupRaw(const char * aCharset,
+                                                  nsACString& aResult)
 {
-
-  *aResult = nullptr;
   nsAutoString langGroup;
   // fully qualify to possibly avoid vtable call
   nsresult rv = nsCharsetConverterManager::GetCharsetData(
       aCharset, u".LangGroup", langGroup);
 
   if (NS_SUCCEEDED(rv)) {
-    ToLowerCase(langGroup); // use lowercase for all language atoms
-    *aResult = NS_Atomize(langGroup).take();
+    ToLowerCase(langGroup); // use lowercase for all language groups
+    aResult = NS_ConvertUTF16toUTF8(langGroup);
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsCharsetConverterManager::Mutf7ToUnicode(const char* aSrc, nsAString& aDest)
 {
--- a/mailnews/intl/nsICharsetConverterManager.idl
+++ b/mailnews/intl/nsICharsetConverterManager.idl
@@ -1,15 +1,14 @@
 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* 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 "nsISupports.idl"
-#include "nsIAtom.idl"
 
 %{ C++
 #include "mozilla/Encoding.h"
 
 // XXX change to NS_CHARSETCONVERTERMANAGER_CID
 #define NS_ICHARSETCONVERTERMANAGER_CID \
   {0x3c1c0163, 0x9bd0, 0x11d3, { 0x9d, 0x9, 0x0, 0x50, 0x4, 0x0, 0x7, 0xb2}}
 
@@ -53,17 +52,17 @@ interface nsICharsetConverterManager : n
     /**
      * Get the language group for the given charset. This is similar to 
      * calling <tt>getCharsetData</tt> with the <tt>prop</tt> "LangGroup".
      * 
      * @param aCharset name of the character encoding, e.g. 'iso-8859-15'.
      * @throws if aCharset is an unknown charset.
      * @return the language code for the character encoding.
      */
-    nsIAtom getCharsetLangGroup(in string aCharset);
-    nsIAtom getCharsetLangGroupRaw(in string aCharset);
+    AUTF8String getCharsetLangGroup(in string aCharset);
+    AUTF8String getCharsetLangGroupRaw(in string aCharset);
 
     /**
      * Support for Modified UTF-7 (MUTF-7) used by IMAP.
      */
     AString mutf7ToUnicode(in string aMutf7);
     ACString unicodeToMutf7(in wstring aUnicode);
 };
--- a/mailnews/mime/src/mimemoz2.cpp
+++ b/mailnews/mime/src/mimemoz2.cpp
@@ -2006,30 +2006,26 @@ nsresult GetMailNewsFont(MimeObject *obj
       ((MimeInlineTextClass*)&mimeInlineTextClass)->initialize_charset(obj);
 
     if (!text->charset || !(*text->charset))
       charset.Assign("us-ascii");
     else
       charset.Assign(text->charset);
 
     nsCOMPtr<nsICharsetConverterManager> charSetConverterManager2;
-    nsCOMPtr<nsIAtom> langGroupAtom;
     nsAutoCString prefStr;
 
     ToLowerCase(charset);
 
     charSetConverterManager2 = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
     if ( NS_FAILED(rv))
       return rv;
 
     // get a language, e.g. x-western, ja
-    rv = charSetConverterManager2->GetCharsetLangGroup(charset.get(), getter_AddRefs(langGroupAtom));
-    if (NS_FAILED(rv))
-      return rv;
-    rv = langGroupAtom->ToUTF8String(fontLang);
+    rv = charSetConverterManager2->GetCharsetLangGroup(charset.get(), fontLang);
     if (NS_FAILED(rv))
       return rv;
 
     // get a font size from pref
     prefStr.Assign(!styleFixed ? "font.size.variable." : "font.size.fixed.");
     prefStr.Append(fontLang);
     rv = prefBranch->GetIntPref(prefStr.get(), fontPixelSize);
     if (NS_FAILED(rv))