Bug 668933 intl should use mozilla::Preferences r=smontagu

This commit is contained in:
Masayuki Nakano 2011-07-06 11:34:00 +09:00
Родитель e0e870708c
Коммит 6b00a93d8a
2 изменённых файлов: 9 добавлений и 16 удалений

Просмотреть файл

@ -44,8 +44,9 @@
#include "nsIDirectoryEnumerator.h"
#include "nsDirectoryServiceDefs.h"
#include "nsUnicharUtils.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "mozilla/Preferences.h"
using namespace mozilla;
#define INTL_HYPHENATIONALIAS_PREFIX "intl.hyphenation-alias."
@ -225,30 +226,25 @@ nsHyphenationManager::LoadPatternListFromDir(nsIFile *aDir)
void
nsHyphenationManager::LoadAliases()
{
nsresult rv;
nsCOMPtr<nsIPrefBranch> prefBranch =
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
nsIPrefBranch* prefRootBranch = Preferences::GetRootBranch();
if (!prefRootBranch) {
return;
}
PRUint32 prefCount;
char **prefNames;
rv = prefBranch->GetChildList(INTL_HYPHENATIONALIAS_PREFIX,
&prefCount, &prefNames);
nsresult rv = prefRootBranch->GetChildList(INTL_HYPHENATIONALIAS_PREFIX,
&prefCount, &prefNames);
if (NS_SUCCEEDED(rv) && prefCount > 0) {
for (PRUint32 i = 0; i < prefCount; ++i) {
char *prefValue;
rv = prefBranch->GetCharPref(prefNames[i], &prefValue);
if (NS_SUCCEEDED(rv)) {
nsAdoptingCString value = Preferences::GetCString(prefNames[i]);
if (value) {
nsCAutoString alias(prefNames[i]);
alias.Cut(0, strlen(INTL_HYPHENATIONALIAS_PREFIX));
ToLowerCase(alias);
nsCAutoString value(prefValue);
ToLowerCase(value);
nsCOMPtr<nsIAtom> aliasAtom = do_GetAtom(alias);
nsCOMPtr<nsIAtom> valueAtom = do_GetAtom(value);
mHyphAliases.Put(aliasAtom, valueAtom);
NS_Free(prefValue);
}
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(prefCount, prefNames);

Просмотреть файл

@ -45,9 +45,6 @@
#include "nsIPlatformCharset.h"
#include "nsPosixLocale.h"
#include "nsCOMPtr.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPrefLocalizedString.h"
#include "nsUnicharUtils.h"
#include "nsCRT.h"
//#define DEBUG_UNIX_COLLATION