Bug 590390 - deCOM nsICharsetAlias. r=smontagu

--HG--
rename : intl/locale/public/nsICharsetAlias.h => intl/locale/public/nsCharsetAlias.h
rename : intl/locale/src/nsCharsetAliasImp.cpp => intl/locale/src/nsCharsetAlias.cpp
This commit is contained in:
Makoto Kato 2012-03-05 12:57:51 +09:00
Родитель 6a15ecefcb
Коммит b6e9c4d7bb
34 изменённых файлов: 98 добавлений и 294 удалений

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

@ -44,7 +44,6 @@
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsIParser.h" #include "nsIParser.h"
#include "nsParserCIID.h" #include "nsParserCIID.h"
#include "nsICharsetAlias.h"
#include "nsMimeTypes.h" #include "nsMimeTypes.h"
#include "nsIStreamConverterService.h" #include "nsIStreamConverterService.h"
#include "nsStringStream.h" #include "nsStringStream.h"

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

@ -43,7 +43,6 @@
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsDOMClassInfoID.h" #include "nsDOMClassInfoID.h"
#include "nsDOMError.h" #include "nsDOMError.h"
#include "nsICharsetAlias.h"
#include "nsICharsetDetector.h" #include "nsICharsetDetector.h"
#include "nsICharsetConverterManager.h" #include "nsICharsetConverterManager.h"
#include "nsIConverterInputStream.h" #include "nsIConverterInputStream.h"

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

@ -42,7 +42,7 @@
#include "nsDOMClassInfoID.h" #include "nsDOMClassInfoID.h"
#include "nsDOMFile.h" #include "nsDOMFile.h"
#include "nsDOMError.h" #include "nsDOMError.h"
#include "nsICharsetAlias.h" #include "nsCharsetAlias.h"
#include "nsICharsetDetector.h" #include "nsICharsetDetector.h"
#include "nsICharsetConverterManager.h" #include "nsICharsetConverterManager.h"
#include "nsIConverterInputStream.h" #include "nsIConverterInputStream.h"
@ -495,10 +495,7 @@ nsDOMFileReader::GetAsText(const nsACString &aCharset,
} }
nsCAutoString charset; nsCAutoString charset;
nsCOMPtr<nsICharsetAlias> alias = do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv); rv = nsCharsetAlias::GetPreferred(charsetGuess, charset);
NS_ENSURE_SUCCESS(rv, rv);
rv = alias->GetPreferred(charsetGuess, charset);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = ConvertStream(aFileData, aDataLen, charset.get(), aResult); rv = ConvertStream(aFileData, aDataLen, charset.get(), aResult);

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

@ -147,7 +147,7 @@
#include "nsILink.h" #include "nsILink.h"
#include "nsBlobProtocolHandler.h" #include "nsBlobProtocolHandler.h"
#include "nsICharsetAlias.h" #include "nsCharsetAlias.h"
#include "nsIParser.h" #include "nsIParser.h"
#include "nsIContentSink.h" #include "nsIContentSink.h"
@ -3012,13 +3012,10 @@ nsDocument::SetDocumentCharacterSet(const nsACString& aCharSetID)
mCharacterSet = aCharSetID; mCharacterSet = aCharSetID;
#ifdef DEBUG #ifdef DEBUG
nsCOMPtr<nsICharsetAlias> calias(do_GetService(NS_CHARSETALIAS_CONTRACTID)); nsCAutoString canonicalName;
if (calias) { nsCharsetAlias::GetPreferred(aCharSetID, canonicalName);
nsCAutoString canonicalName; NS_ASSERTION(canonicalName.Equals(aCharSetID),
calias->GetPreferred(aCharSetID, canonicalName); "charset name must be canonical");
NS_ASSERTION(canonicalName.Equals(aCharSetID),
"charset name must be canonical");
}
#endif #endif
PRInt32 n = mCharSetObservers.Length(); PRInt32 n = mCharSetObservers.Length();
@ -3172,16 +3169,10 @@ nsDocument::TryChannelCharset(nsIChannel *aChannel,
nsCAutoString charsetVal; nsCAutoString charsetVal;
nsresult rv = aChannel->GetContentCharset(charsetVal); nsresult rv = aChannel->GetContentCharset(charsetVal);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsICharsetAlias> calias(do_GetService(NS_CHARSETALIAS_CONTRACTID)); rv = nsCharsetAlias::GetPreferred(charsetVal, aCharset);
if (calias) { if(NS_SUCCEEDED(rv)) {
nsCAutoString preferred; aCharsetSource = kCharsetFromChannel;
rv = calias->GetPreferred(charsetVal, return true;
preferred);
if(NS_SUCCEEDED(rv)) {
aCharset = preferred;
aCharsetSource = kCharsetFromChannel;
return true;
}
} }
} }
} }

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

@ -61,7 +61,7 @@
#include "nsIJSContextStack.h" #include "nsIJSContextStack.h"
#include "nsIScriptSecurityManager.h" #include "nsIScriptSecurityManager.h"
#include "nsWeakPtr.h" #include "nsWeakPtr.h"
#include "nsICharsetAlias.h" #include "nsCharsetAlias.h"
#include "nsIScriptGlobalObject.h" #include "nsIScriptGlobalObject.h"
#include "nsDOMClassInfoID.h" #include "nsDOMClassInfoID.h"
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
@ -812,11 +812,7 @@ nsXMLHttpRequest::DetectCharset()
nsresult rv = channel ? channel->GetContentCharset(charsetVal) : nsresult rv = channel ? channel->GetContentCharset(charsetVal) :
NS_ERROR_FAILURE; NS_ERROR_FAILURE;
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsICharsetAlias> calias = rv = nsCharsetAlias::GetPreferred(charsetVal, mResponseCharset);
do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && calias) {
rv = calias->GetPreferred(charsetVal, mResponseCharset);
}
} }
if (NS_FAILED(rv) || mResponseCharset.IsEmpty()) { if (NS_FAILED(rv) || mResponseCharset.IsEmpty()) {

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

@ -60,7 +60,7 @@
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsLinebreakConverter.h" #include "nsLinebreakConverter.h"
#include "nsICharsetConverterManager.h" #include "nsICharsetConverterManager.h"
#include "nsICharsetAlias.h" #include "nsCharsetAlias.h"
#include "nsEscape.h" #include "nsEscape.h"
#include "nsUnicharUtils.h" #include "nsUnicharUtils.h"
#include "nsIMultiplexInputStream.h" #include "nsIMultiplexInputStream.h"
@ -782,7 +782,6 @@ GetSubmitCharset(nsGenericHTMLElement* aForm,
{ {
oCharset.AssignLiteral("UTF-8"); // default to utf-8 oCharset.AssignLiteral("UTF-8"); // default to utf-8
nsresult rv = NS_OK;
nsAutoString acceptCharsetValue; nsAutoString acceptCharsetValue;
aForm->GetAttr(kNameSpaceID_None, nsGkAtoms::acceptcharset, aForm->GetAttr(kNameSpaceID_None, nsGkAtoms::acceptcharset,
acceptCharsetValue); acceptCharsetValue);
@ -792,26 +791,19 @@ GetSubmitCharset(nsGenericHTMLElement* aForm,
PRInt32 offset=0; PRInt32 offset=0;
PRInt32 spPos=0; PRInt32 spPos=0;
// get charset from charsets one by one // get charset from charsets one by one
nsCOMPtr<nsICharsetAlias> calias(do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv)); do {
if (NS_FAILED(rv)) { spPos = acceptCharsetValue.FindChar(PRUnichar(' '), offset);
return; PRInt32 cnt = ((-1==spPos)?(charsetLen-offset):(spPos-offset));
} if (cnt > 0) {
if (calias) { nsAutoString uCharset;
do { acceptCharsetValue.Mid(uCharset, offset, cnt);
spPos = acceptCharsetValue.FindChar(PRUnichar(' '), offset);
PRInt32 cnt = ((-1==spPos)?(charsetLen-offset):(spPos-offset));
if (cnt > 0) {
nsAutoString uCharset;
acceptCharsetValue.Mid(uCharset, offset, cnt);
if (NS_SUCCEEDED(calias-> if (NS_SUCCEEDED(nsCharsetAlias::GetPreferred(NS_LossyConvertUTF16toASCII(uCharset),
GetPreferred(NS_LossyConvertUTF16toASCII(uCharset), oCharset)))
oCharset))) return;
return; }
} offset = spPos + 1;
offset = spPos + 1; } while (spPos != -1);
} while (spPos != -1);
}
} }
// if there are no accept-charset or all the charset are not supported // if there are no accept-charset or all the charset are not supported
// Get the charset from document // Get the charset from document

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

@ -40,8 +40,6 @@
#include "mozilla/Util.h" #include "mozilla/Util.h"
#include "nsICharsetAlias.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsXPIDLString.h" #include "nsXPIDLString.h"
#include "nsPrintfCString.h" #include "nsPrintfCString.h"
@ -102,7 +100,6 @@
#include "nsFrameSelection.h" #include "nsFrameSelection.h"
#include "nsISelectionPrivate.h"//for toStringwithformat code #include "nsISelectionPrivate.h"//for toStringwithformat code
#include "nsICharsetAlias.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsJSUtils.h" #include "nsJSUtils.h"
#include "nsIDocumentEncoder.h" //for outputting selection #include "nsIDocumentEncoder.h" //for outputting selection

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

@ -59,8 +59,6 @@
#include "nsIHttpChannel.h" #include "nsIHttpChannel.h"
#include "nsIURI.h" #include "nsIURI.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsICharsetAlias.h"
#include "nsICharsetAlias.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsDOMError.h" #include "nsDOMError.h"
#include "nsIScriptSecurityManager.h" #include "nsIScriptSecurityManager.h"

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

@ -39,7 +39,7 @@
#include "nsCOMArray.h" #include "nsCOMArray.h"
#include "nsIAuthPrompt.h" #include "nsIAuthPrompt.h"
#include "nsICharsetAlias.h" #include "nsCharsetAlias.h"
#include "nsIDOMNode.h" #include "nsIDOMNode.h"
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "nsIDocument.h" #include "nsIDocument.h"
@ -282,29 +282,23 @@ txStylesheetSink::OnDataAvailable(nsIRequest *aRequest, nsISupports *aContext,
NS_IMETHODIMP NS_IMETHODIMP
txStylesheetSink::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) txStylesheetSink::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
{ {
nsCAutoString charset(NS_LITERAL_CSTRING("UTF-8"));
PRInt32 charsetSource = kCharsetFromDocTypeDefault; PRInt32 charsetSource = kCharsetFromDocTypeDefault;
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest); nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
// check channel's charset... // check channel's charset...
nsCAutoString charsetVal; nsCAutoString charsetVal;
nsresult rv = channel->GetContentCharset(charsetVal); nsCAutoString charset;
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(channel->GetContentCharset(charsetVal))) {
nsCOMPtr<nsICharsetAlias> calias = if (NS_SUCCEEDED(nsCharsetAlias::GetPreferred(charsetVal, charset))) {
do_GetService(NS_CHARSETALIAS_CONTRACTID); charsetSource = kCharsetFromChannel;
if (calias) {
nsCAutoString preferred;
rv = calias->GetPreferred(charsetVal,
preferred);
if (NS_SUCCEEDED(rv)) {
charset = preferred;
charsetSource = kCharsetFromChannel;
}
} }
} }
if (charset.IsEmpty()) {
charset.AssignLiteral("UTF-8");
}
nsCOMPtr<nsIParser> parser = do_QueryInterface(aContext); nsCOMPtr<nsIParser> parser = do_QueryInterface(aContext);
parser->SetDocumentCharset(charset, charsetSource); parser->SetDocumentCharset(charset, charsetSource);
@ -318,6 +312,7 @@ txStylesheetSink::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
bool sniff; bool sniff;
if (NS_SUCCEEDED(uri->SchemeIs("file", &sniff)) && sniff && if (NS_SUCCEEDED(uri->SchemeIs("file", &sniff)) && sniff &&
contentType.Equals(UNKNOWN_CONTENT_TYPE)) { contentType.Equals(UNKNOWN_CONTENT_TYPE)) {
nsresult rv;
nsCOMPtr<nsIStreamConverterService> serv = nsCOMPtr<nsIStreamConverterService> serv =
do_GetService("@mozilla.org/streamConverters;1", &rv); do_GetService("@mozilla.org/streamConverters;1", &rv);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {

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

@ -45,7 +45,7 @@
#include "nsIDocumentTransformer.h" #include "nsIDocumentTransformer.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsIParser.h" #include "nsIParser.h"
#include "nsICharsetAlias.h" #include "nsCharsetAlias.h"
#include "nsIPrincipal.h" #include "nsIPrincipal.h"
#include "txURIUtils.h" #include "txURIUtils.h"
#include "nsContentCreatorFunctions.h" #include "nsContentCreatorFunctions.h"
@ -184,11 +184,9 @@ txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument)
if (!mOutputFormat.mEncoding.IsEmpty()) { if (!mOutputFormat.mEncoding.IsEmpty()) {
NS_LossyConvertUTF16toASCII charset(mOutputFormat.mEncoding); NS_LossyConvertUTF16toASCII charset(mOutputFormat.mEncoding);
nsCAutoString canonicalCharset; nsCAutoString canonicalCharset;
nsCOMPtr<nsICharsetAlias> calias =
do_GetService("@mozilla.org/intl/charsetalias;1");
if (calias && if (NS_SUCCEEDED(nsCharsetAlias::GetPreferred(charset,
NS_SUCCEEDED(calias->GetPreferred(charset, canonicalCharset))) { canonicalCharset))) {
mDocument->SetDocumentCharacterSetSource(kCharsetFromOtherComponent); mDocument->SetDocumentCharacterSetSource(kCharsetFromOtherComponent);
mDocument->SetDocumentCharacterSet(canonicalCharset); mDocument->SetDocumentCharacterSet(canonicalCharset);
} }

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

@ -64,7 +64,7 @@
#include "nsIDocumentTransformer.h" #include "nsIDocumentTransformer.h"
#include "mozilla/css/Loader.h" #include "mozilla/css/Loader.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "nsICharsetAlias.h" #include "nsCharsetAlias.h"
#include "nsIHTMLContentSink.h" #include "nsIHTMLContentSink.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "txXMLUtils.h" #include "txXMLUtils.h"
@ -857,11 +857,7 @@ txMozillaXMLOutput::createResultDocument(const nsSubstring& aName, PRInt32 aNsID
if (!mOutputFormat.mEncoding.IsEmpty()) { if (!mOutputFormat.mEncoding.IsEmpty()) {
NS_LossyConvertUTF16toASCII charset(mOutputFormat.mEncoding); NS_LossyConvertUTF16toASCII charset(mOutputFormat.mEncoding);
nsCAutoString canonicalCharset; nsCAutoString canonicalCharset;
nsCOMPtr<nsICharsetAlias> calias = if (NS_SUCCEEDED(nsCharsetAlias::GetPreferred(charset, canonicalCharset))) {
do_GetService("@mozilla.org/intl/charsetalias;1");
if (calias &&
NS_SUCCEEDED(calias->GetPreferred(charset, canonicalCharset))) {
mDocument->SetDocumentCharacterSetSource(kCharsetFromOtherComponent); mDocument->SetDocumentCharacterSetSource(kCharsetFromOtherComponent);
mDocument->SetDocumentCharacterSet(canonicalCharset); mDocument->SetDocumentCharacterSet(canonicalCharset);
} }

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

@ -45,7 +45,7 @@
#include "nsDOMClassInfoID.h" #include "nsDOMClassInfoID.h"
#include "nsDOMError.h" #include "nsDOMError.h"
#include "nsIDOMFile.h" #include "nsIDOMFile.h"
#include "nsICharsetAlias.h" #include "nsCharsetAlias.h"
#include "nsICharsetDetector.h" #include "nsICharsetDetector.h"
#include "nsIConverterInputStream.h" #include "nsIConverterInputStream.h"
#include "nsIInputStream.h" #include "nsIInputStream.h"
@ -135,12 +135,8 @@ FileReaderSyncPrivate::ReadAsText(nsIDOMBlob* aBlob,
CopyUTF16toUTF8(aEncoding, charsetGuess); CopyUTF16toUTF8(aEncoding, charsetGuess);
} }
nsCOMPtr<nsICharsetAlias> alias =
do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCString charset; nsCString charset;
rv = alias->GetPreferred(charsetGuess, charset); rv = nsCharsetAlias::GetPreferred(charsetGuess, charset);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
return ConvertStream(stream, charset.get(), aResult); return ConvertStream(stream, charset.get(), aResult);

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

@ -36,7 +36,6 @@
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "mozEnglishWordUtils.h" #include "mozEnglishWordUtils.h"
#include "nsICharsetAlias.h"
#include "nsReadableUtils.h" #include "nsReadableUtils.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsUnicharUtils.h" #include "nsUnicharUtils.h"

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

@ -41,7 +41,6 @@
#include "nsIFile.h" #include "nsIFile.h"
#include "nsAppDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h"
#include "nsICharsetConverterManager.h" #include "nsICharsetConverterManager.h"
#include "nsICharsetAlias.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsIPrefService.h" #include "nsIPrefService.h"
#include "nsIPrefBranch.h" #include "nsIPrefBranch.h"

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

@ -37,7 +37,6 @@
#include "mozilla/ModuleUtils.h" #include "mozilla/ModuleUtils.h"
#include "nsICharsetAlias.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nspr.h" #include "nspr.h"

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

@ -89,7 +89,6 @@ NS_DEFINE_NAMED_CID(NS_LOCALESERVICE_CID);
NS_DEFINE_NAMED_CID(NS_COLLATIONFACTORY_CID); NS_DEFINE_NAMED_CID(NS_COLLATIONFACTORY_CID);
NS_DEFINE_NAMED_CID(NS_SCRIPTABLEDATEFORMAT_CID); NS_DEFINE_NAMED_CID(NS_SCRIPTABLEDATEFORMAT_CID);
NS_DEFINE_NAMED_CID(NS_LANGUAGEATOMSERVICE_CID); NS_DEFINE_NAMED_CID(NS_LANGUAGEATOMSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_CHARSETALIAS_CID);
NS_DEFINE_NAMED_CID(NS_PLATFORMCHARSET_CID); NS_DEFINE_NAMED_CID(NS_PLATFORMCHARSET_CID);
#ifdef XP_WIN #ifdef XP_WIN
NS_DEFINE_NAMED_CID(NS_COLLATION_CID); NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
@ -124,7 +123,6 @@ static const mozilla::Module::CIDEntry kIntlCIDs[] = {
{ &kNS_COLLATIONFACTORY_CID, false, NULL, nsCollationFactoryConstructor }, { &kNS_COLLATIONFACTORY_CID, false, NULL, nsCollationFactoryConstructor },
{ &kNS_SCRIPTABLEDATEFORMAT_CID, false, NULL, NS_NewScriptableDateFormat }, { &kNS_SCRIPTABLEDATEFORMAT_CID, false, NULL, NS_NewScriptableDateFormat },
{ &kNS_LANGUAGEATOMSERVICE_CID, false, NULL, nsLanguageAtomServiceConstructor }, { &kNS_LANGUAGEATOMSERVICE_CID, false, NULL, nsLanguageAtomServiceConstructor },
{ &kNS_CHARSETALIAS_CID, false, NULL, nsCharsetAlias2Constructor },
{ &kNS_PLATFORMCHARSET_CID, false, NULL, nsPlatformCharsetConstructor }, { &kNS_PLATFORMCHARSET_CID, false, NULL, nsPlatformCharsetConstructor },
#ifdef XP_WIN #ifdef XP_WIN
{ &kNS_COLLATION_CID, false, NULL, nsCollationWinConstructor }, { &kNS_COLLATION_CID, false, NULL, nsCollationWinConstructor },
@ -161,7 +159,6 @@ static const mozilla::Module::ContractIDEntry kIntlContracts[] = {
{ NS_COLLATIONFACTORY_CONTRACTID, &kNS_COLLATIONFACTORY_CID }, { NS_COLLATIONFACTORY_CONTRACTID, &kNS_COLLATIONFACTORY_CID },
{ NS_SCRIPTABLEDATEFORMAT_CONTRACTID, &kNS_SCRIPTABLEDATEFORMAT_CID }, { NS_SCRIPTABLEDATEFORMAT_CONTRACTID, &kNS_SCRIPTABLEDATEFORMAT_CID },
{ NS_LANGUAGEATOMSERVICE_CONTRACTID, &kNS_LANGUAGEATOMSERVICE_CID }, { NS_LANGUAGEATOMSERVICE_CONTRACTID, &kNS_LANGUAGEATOMSERVICE_CID },
{ NS_CHARSETALIAS_CONTRACTID, &kNS_CHARSETALIAS_CID },
{ NS_PLATFORMCHARSET_CONTRACTID, &kNS_PLATFORMCHARSET_CID }, { NS_PLATFORMCHARSET_CONTRACTID, &kNS_PLATFORMCHARSET_CID },
#ifdef XP_WIN #ifdef XP_WIN
{ NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID }, { NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },

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

@ -47,7 +47,6 @@
// chardet // chardet
#include "nsISupports.h" #include "nsISupports.h"
#include "nsICharsetDetector.h" #include "nsICharsetDetector.h"
#include "nsICharsetAlias.h"
#include "nsICharsetDetectionObserver.h" #include "nsICharsetDetectionObserver.h"
#include "nsIStringCharsetDetector.h" #include "nsIStringCharsetDetector.h"
#include "nsCyrillicDetector.h" #include "nsCyrillicDetector.h"

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

@ -52,7 +52,7 @@ EXPORTS = \
nsPosixLocale.h \ nsPosixLocale.h \
nsIOS2Locale.h \ nsIOS2Locale.h \
nsWin32Locale.h \ nsWin32Locale.h \
nsICharsetAlias.h \ nsCharsetAlias.h \
nsIPlatformCharset.h \ nsIPlatformCharset.h \
nsLocaleCID.h \ nsLocaleCID.h \
$(NULL) $(NULL)

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

@ -1,4 +1,4 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK ***** /* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
* *
@ -12,7 +12,7 @@
* for the specific language governing rights and limitations under the * for the specific language governing rights and limitations under the
* License. * License.
* *
* The Original Code is mozilla.org code. * The Original Code is Mozilla Communicator client code.
* *
* The Initial Developer of the Original Code is * The Initial Developer of the Original Code is
* Netscape Communications Corporation. * Netscape Communications Corporation.
@ -34,27 +34,18 @@
* the terms of any one of the MPL, the GPL or the LGPL. * the terms of any one of the MPL, the GPL or the LGPL.
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#ifndef nsCharsetAlias_h__
#define nsCharsetAlias_h__
#include "nsICharsetAlias.h" #ifndef nsCharsetAlias_h___
#define nsCharsetAlias_h___
//============================================================== #include "nscore.h"
class nsCharsetAlias2 : public nsICharsetAlias #include "nsStringGlue.h"
class nsCharsetAlias
{ {
NS_DECL_ISUPPORTS
public: public:
static nsresult GetPreferred(const nsACString& aAlias, nsACString& aResult);
nsCharsetAlias2(); static nsresult Equals(const nsACString& aCharset1, const nsACString& aCharset2, bool* aResult);
virtual ~nsCharsetAlias2();
NS_IMETHOD GetPreferred(const nsACString& aAlias, nsACString& aResult);
NS_IMETHOD Equals(const nsACString& aCharset1, const nsACString& aCharset2, bool* oResult) ;
}; };
#endif // nsCharsetAlias_h__ #endif /* nsCharsetAlias_h___ */

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

@ -1,69 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsICharsetAlias_h___
#define nsICharsetAlias_h___
#include "nscore.h"
#include "nsStringGlue.h"
#include "nsISupports.h"
/* 0b4028d6-7473-4958-9b3c-4dee46bf68cb */
#define NS_ICHARSETALIAS_IID \
{ 0x0b4028d6, \
0x7473, \
0x4958, \
{0x9b, 0x3c, 0x4d, 0xee, 0x46, 0xbf, 0x68, 0xcb} }
// {98D41C21-CCF3-11d2-B3B1-00805F8A6670}
#define NS_CHARSETALIAS_CID \
{ 0x98d41c21, 0xccf3, 0x11d2, { 0xb3, 0xb1, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 }}
#define NS_CHARSETALIAS_CONTRACTID "@mozilla.org/intl/charsetalias;1"
class nsICharsetAlias : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICHARSETALIAS_IID)
NS_IMETHOD GetPreferred(const nsACString& aAlias, nsACString& aResult) = 0;
NS_IMETHOD Equals(const nsACString& aCharset1, const nsACString& aCharset2, bool* aResult) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsICharsetAlias, NS_ICHARSETALIAS_IID)
#endif /* nsICharsetAlias_h___ */

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

@ -67,7 +67,7 @@ CPPSRCS = \
nsLanguageAtomService.cpp \ nsLanguageAtomService.cpp \
nsLocale.cpp \ nsLocale.cpp \
nsLocaleService.cpp \ nsLocaleService.cpp \
nsCharsetAliasImp.cpp \ nsCharsetAlias.cpp \
nsUConvPropertySearch.cpp \ nsUConvPropertySearch.cpp \
$(NULL) $(NULL)
@ -89,7 +89,7 @@ FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk
nsCharsetAliasImp.$(OBJ_SUFFIX): charsetalias.properties.h nsCharsetAlias.$(OBJ_SUFFIX): charsetalias.properties.h
charsetalias.properties.h: props2arrays.py charsetalias.properties charsetalias.properties.h: props2arrays.py charsetalias.properties
$(PYTHON) $^ $@ $(PYTHON) $^ $@

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

@ -37,7 +37,7 @@
#include "mozilla/Util.h" #include "mozilla/Util.h"
#include "nsICharsetAlias.h" #include "nsCharsetAlias.h"
#include "pratom.h" #include "pratom.h"
// for NS_IMPL_IDS only // for NS_IMPL_IDS only
@ -46,46 +46,34 @@
#include "nsReadableUtils.h" #include "nsReadableUtils.h"
#include "nsUnicharUtils.h" #include "nsUnicharUtils.h"
#include "nsUConvPropertySearch.h" #include "nsUConvPropertySearch.h"
#include "nsCharsetAlias.h"
using namespace mozilla; using namespace mozilla;
//--------------------------------------------------------------
NS_IMPL_THREADSAFE_ISUPPORTS1(nsCharsetAlias2, nsICharsetAlias)
//--------------------------------------------------------------
nsCharsetAlias2::nsCharsetAlias2()
{
}
//--------------------------------------------------------------
nsCharsetAlias2::~nsCharsetAlias2()
{
}
// //
static const char* kAliases[][3] = { static const char* kAliases[][3] = {
#include "charsetalias.properties.h" #include "charsetalias.properties.h"
}; };
//-------------------------------------------------------------- //--------------------------------------------------------------
NS_IMETHODIMP nsCharsetAlias2::GetPreferred(const nsACString& aAlias, // static
nsACString& oResult) nsresult
nsCharsetAlias::GetPreferred(const nsACString& aAlias,
nsACString& oResult)
{ {
if (aAlias.IsEmpty()) return NS_ERROR_NULL_POINTER; if (aAlias.IsEmpty()) return NS_ERROR_NULL_POINTER;
nsCAutoString key(aAlias); nsCAutoString key(aAlias);
ToLowerCase(key); ToLowerCase(key);
nsresult rv = nsUConvPropertySearch::SearchPropertyValue(kAliases, return nsUConvPropertySearch::SearchPropertyValue(kAliases,
ArrayLength(kAliases), key, oResult); ArrayLength(kAliases), key, oResult);
return rv;
} }
//-------------------------------------------------------------- //--------------------------------------------------------------
NS_IMETHODIMP // static
nsCharsetAlias2::Equals(const nsACString& aCharset1, nsresult
const nsACString& aCharset2, bool* oResult) nsCharsetAlias::Equals(const nsACString& aCharset1,
const nsACString& aCharset2, bool* oResult)
{ {
nsresult res = NS_OK; nsresult res = NS_OK;
@ -101,15 +89,15 @@ nsCharsetAlias2::Equals(const nsACString& aCharset1,
*oResult = false; *oResult = false;
nsCAutoString name1; nsCAutoString name1;
nsCAutoString name2; res = GetPreferred(aCharset1, name1);
res = this->GetPreferred(aCharset1, name1); if (NS_FAILED(res))
if(NS_SUCCEEDED(res)) { return res;
res = this->GetPreferred(aCharset2, name2);
if(NS_SUCCEEDED(res)) {
*oResult = name1.Equals(name2);
}
}
return res;
}
nsCAutoString name2;
res = GetPreferred(aCharset2, name2);
if (NS_FAILED(res))
return res;
*oResult = name1.Equals(name2);
return NS_OK;
}

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

@ -46,7 +46,6 @@
#include "nsIScriptableDateFormat.h" #include "nsIScriptableDateFormat.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsLanguageAtomService.h" #include "nsLanguageAtomService.h"
#include "nsCharsetAlias.h"
#include "nsPlatformCharset.h" #include "nsPlatformCharset.h"
#include "nsLocaleCID.h" #include "nsLocaleCID.h"
@ -100,7 +99,6 @@ NSLOCALE_MAKE_CTOR(CreateLocaleService, nsILocaleService, NS_NewLocaleService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationFactory) NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationFactory)
//NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableDateTimeFormat) //NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableDateTimeFormat)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLanguageAtomService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsLanguageAtomService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCharsetAlias2)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPlatformCharset, Init) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPlatformCharset, Init)
#ifdef XP_WIN #ifdef XP_WIN

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

@ -40,7 +40,7 @@
#include "nsString.h" #include "nsString.h"
#include "nsReadableUtils.h" #include "nsReadableUtils.h"
#include "nsUnicharUtils.h" #include "nsUnicharUtils.h"
#include "nsICharsetAlias.h" #include "nsCharsetAlias.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsICategoryManager.h" #include "nsICategoryManager.h"
#include "nsICharsetConverterManager.h" #include "nsICharsetConverterManager.h"
@ -308,10 +308,8 @@ nsCharsetConverterManager::GetCharsetAlias(const char * aCharset,
// We try to obtain the preferred name for this charset from the charset // We try to obtain the preferred name for this charset from the charset
// aliases. // aliases.
nsresult rv; nsresult rv;
nsCOMPtr<nsICharsetAlias> csAlias(do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
rv = csAlias->GetPreferred(nsDependentCString(aCharset), aResult); rv = nsCharsetAlias::GetPreferred(nsDependentCString(aCharset), aResult);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
return NS_OK; return NS_OK;

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

@ -46,8 +46,6 @@
#include "nsIUnicodeEncoder.h" #include "nsIUnicodeEncoder.h"
#include "nsIUnicodeDecoder.h" #include "nsIUnicodeDecoder.h"
#include "nsICharsetAlias.h"
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID); static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
#include <stdio.h> #include <stdio.h>
@ -90,15 +88,6 @@ int main(int argc, const char** argv)
return -1; return -1;
} }
// Get the charset alias manager
nsCOMPtr<nsICharsetAlias> aliasmgr =
do_GetService(NS_CHARSETALIAS_CONTRACTID, &res);
if (NS_FAILED(res))
{
fprintf(stderr, "Cannot get Charset Alias Manager %x\n", res);
return -1;
}
int i; int i;
if(argc > 4) if(argc > 4)
{ {
@ -111,7 +100,7 @@ int main(int argc, const char** argv)
// First check if a charset alias was given, // First check if a charset alias was given,
// and convert to the canonical name // and convert to the canonical name
res = aliasmgr->GetPreferred(nsDependentCString(argv[i+1]), str); res = ccMain->GetCharsetAlias(argv[i+1], str);
if (NS_FAILED(res)) if (NS_FAILED(res))
{ {
fprintf(stderr, "Cannot get charset alias for %s %x\n", fprintf(stderr, "Cannot get charset alias for %s %x\n",
@ -136,7 +125,7 @@ int main(int argc, const char** argv)
// First check if a charset alias was given, // First check if a charset alias was given,
// and convert to the canonical name // and convert to the canonical name
res = aliasmgr->GetPreferred(nsDependentCString(argv[i+1]), str); res = ccMain->GetCharsetAlias(argv[i+1], str);
if (NS_FAILED(res)) if (NS_FAILED(res))
{ {
fprintf(stderr, "Cannot get charset alias for %s %x\n", fprintf(stderr, "Cannot get charset alias for %s %x\n",

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

@ -62,7 +62,6 @@
#include "nsIDOMNode.h" #include "nsIDOMNode.h"
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "nsIDOMWindow.h" #include "nsIDOMWindow.h"
#include "nsICharsetAlias.h"
#include "nsHashtable.h" #include "nsHashtable.h"
#include "nsIURI.h" #include "nsIURI.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"

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

@ -37,11 +37,10 @@
#include "nsICharsetConverterManager.h" #include "nsICharsetConverterManager.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "nsICharsetAlias.h" #include "nsCharsetAlias.h"
#include "nsEncoderDecoderUtils.h" #include "nsEncoderDecoderUtils.h"
#include "nsTraceRefcnt.h" #include "nsTraceRefcnt.h"
static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID);
void void
nsHtml5MetaScanner::sniff(nsHtml5ByteReadable* bytes, nsIUnicodeDecoder** decoder, nsACString& charset) nsHtml5MetaScanner::sniff(nsHtml5ByteReadable* bytes, nsIUnicodeDecoder** decoder, nsACString& charset)
@ -82,12 +81,7 @@ nsHtml5MetaScanner::tryCharset(nsString* charset)
return true; return true;
} }
nsCAutoString preferred; nsCAutoString preferred;
nsCOMPtr<nsICharsetAlias> calias(do_GetService(kCharsetAliasCID, &res)); res = nsCharsetAlias::GetPreferred(encoding, preferred);
if (NS_FAILED(res)) {
NS_ERROR("Could not get CharsetAlias service.");
return false;
}
res = calias->GetPreferred(encoding, preferred);
if (NS_FAILED(res)) { if (NS_FAILED(res)) {
return false; return false;
} }

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

@ -42,7 +42,6 @@
#include "nsScriptLoader.h" #include "nsScriptLoader.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsIStyleSheetLinkingElement.h" #include "nsIStyleSheetLinkingElement.h"
#include "nsICharsetAlias.h"
#include "nsIWebShellServices.h" #include "nsIWebShellServices.h"
#include "nsIDocShell.h" #include "nsIDocShell.h"
#include "nsEncoderDecoderUtils.h" #include "nsEncoderDecoderUtils.h"

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

@ -40,7 +40,7 @@
#include "nsHtml5StreamParser.h" #include "nsHtml5StreamParser.h"
#include "nsICharsetConverterManager.h" #include "nsICharsetConverterManager.h"
#include "nsICharsetAlias.h" #include "nsCharsetAlias.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "nsEncoderDecoderUtils.h" #include "nsEncoderDecoderUtils.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
@ -60,7 +60,6 @@
using namespace mozilla; using namespace mozilla;
static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID);
PRInt32 nsHtml5StreamParser::sTimerInitialDelay = 120; PRInt32 nsHtml5StreamParser::sTimerInitialDelay = 120;
PRInt32 nsHtml5StreamParser::sTimerSubsequentDelay = 120; PRInt32 nsHtml5StreamParser::sTimerSubsequentDelay = 120;
@ -1171,13 +1170,8 @@ nsHtml5StreamParser::PreferredForInternalEncodingDecl(nsACString& aEncoding)
} }
nsresult rv = NS_OK; nsresult rv = NS_OK;
nsCOMPtr<nsICharsetAlias> calias(do_GetService(kCharsetAliasCID, &rv));
if (NS_FAILED(rv)) {
NS_NOTREACHED("Charset alias service not available.");
return false;
}
bool eq; bool eq;
rv = calias->Equals(newEncoding, mCharset, &eq); rv = nsCharsetAlias::Equals(newEncoding, mCharset, &eq);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
NS_NOTREACHED("Charset name equality check failed."); NS_NOTREACHED("Charset name equality check failed.");
return false; return false;
@ -1192,7 +1186,7 @@ nsHtml5StreamParser::PreferredForInternalEncodingDecl(nsACString& aEncoding)
nsCAutoString preferred; nsCAutoString preferred;
rv = calias->GetPreferred(newEncoding, preferred); rv = nsCharsetAlias::GetPreferred(newEncoding, preferred);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
// the encoding name is bogus // the encoding name is bogus
return false; return false;

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

@ -48,7 +48,6 @@
#include "nsHtml5TreeOpExecutor.h" #include "nsHtml5TreeOpExecutor.h"
#include "nsHtml5OwningUTF16Buffer.h" #include "nsHtml5OwningUTF16Buffer.h"
#include "nsIInputStream.h" #include "nsIInputStream.h"
#include "nsICharsetAlias.h"
#include "mozilla/Mutex.h" #include "mozilla/Mutex.h"
#include "nsHtml5AtomTable.h" #include "nsHtml5AtomTable.h"
#include "nsHtml5Speculation.h" #include "nsHtml5Speculation.h"

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

@ -47,7 +47,7 @@
#include "nsIChannel.h" #include "nsIChannel.h"
#include "nsICachingChannel.h" #include "nsICachingChannel.h"
#include "nsICacheEntryDescriptor.h" #include "nsICacheEntryDescriptor.h"
#include "nsICharsetAlias.h" #include "nsCharsetAlias.h"
#include "nsICharsetConverterManager.h" #include "nsICharsetConverterManager.h"
#include "nsIInputStream.h" #include "nsIInputStream.h"
#include "CNavDTD.h" #include "CNavDTD.h"
@ -161,7 +161,6 @@ public:
//-------------- End ParseContinue Event Definition ------------------------ //-------------- End ParseContinue Event Definition ------------------------
nsICharsetAlias* nsParser::sCharsetAliasService = nsnull;
nsICharsetConverterManager* nsParser::sCharsetConverterManager = nsnull; nsICharsetConverterManager* nsParser::sCharsetConverterManager = nsnull;
/** /**
@ -173,15 +172,10 @@ nsParser::Init()
{ {
nsresult rv; nsresult rv;
nsCOMPtr<nsICharsetAlias> charsetAlias =
do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsICharsetConverterManager> charsetConverter = nsCOMPtr<nsICharsetConverterManager> charsetConverter =
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv); do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
charsetAlias.swap(sCharsetAliasService);
charsetConverter.swap(sCharsetConverterManager); charsetConverter.swap(sCharsetConverterManager);
return NS_OK; return NS_OK;
@ -194,7 +188,6 @@ nsParser::Init()
// static // static
void nsParser::Shutdown() void nsParser::Shutdown()
{ {
NS_IF_RELEASE(sCharsetAliasService);
NS_IF_RELEASE(sCharsetConverterManager); NS_IF_RELEASE(sCharsetConverterManager);
} }
@ -2064,8 +2057,7 @@ ParserWriteFunc(nsIInputStream* in,
((count >= 4) && ((count >= 4) &&
DetectByteOrderMark((const unsigned char*)buf, DetectByteOrderMark((const unsigned char*)buf,
theNumRead, guess, guessSource))) { theNumRead, guess, guessSource))) {
nsCOMPtr<nsICharsetAlias> alias(do_GetService(NS_CHARSETALIAS_CONTRACTID)); result = nsCharsetAlias::GetPreferred(guess, preferred);
result = alias->GetPreferred(guess, preferred);
// Only continue if it's a recognized charset and not // Only continue if it's a recognized charset and not
// one of a designated set that we ignore. // one of a designated set that we ignore.
if (NS_SUCCEEDED(result) && if (NS_SUCCEEDED(result) &&

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

@ -89,7 +89,6 @@
#include "nsWeakReference.h" #include "nsWeakReference.h"
class nsICharsetConverterManager; class nsICharsetConverterManager;
class nsICharsetAlias;
class nsIDTD; class nsIDTD;
class nsScanner; class nsScanner;
class nsIThreadPool; class nsIThreadPool;
@ -357,10 +356,6 @@ class nsParser : public nsIParser,
*/ */
void HandleParserContinueEvent(class nsParserContinueEvent *); void HandleParserContinueEvent(class nsParserContinueEvent *);
static nsICharsetAlias* GetCharsetAliasService() {
return sCharsetAliasService;
}
static nsICharsetConverterManager* GetCharsetConverterManager() { static nsICharsetConverterManager* GetCharsetConverterManager() {
return sCharsetConverterManager; return sCharsetConverterManager;
} }
@ -465,7 +460,6 @@ protected:
bool mProcessingNetworkData; bool mProcessingNetworkData;
static nsICharsetAlias* sCharsetAliasService;
static nsICharsetConverterManager* sCharsetConverterManager; static nsICharsetConverterManager* sCharsetConverterManager;
}; };

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

@ -42,7 +42,7 @@
#include "nsDebug.h" #include "nsDebug.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsICharsetConverterManager.h" #include "nsICharsetConverterManager.h"
#include "nsICharsetAlias.h" #include "nsCharsetAlias.h"
#include "nsReadableUtils.h" #include "nsReadableUtils.h"
#include "nsIInputStream.h" #include "nsIInputStream.h"
#include "nsILocalFile.h" #include "nsILocalFile.h"
@ -154,14 +154,11 @@ nsresult nsScanner::SetDocumentCharset(const nsACString& aCharset , PRInt32 aSou
if (aSource < mCharsetSource) // priority is lower the the current one , just if (aSource < mCharsetSource) // priority is lower the the current one , just
return NS_OK; return NS_OK;
nsICharsetAlias* calias = nsParser::GetCharsetAliasService();
NS_ASSERTION(calias, "Must have the charset alias service!");
nsresult res = NS_OK; nsresult res = NS_OK;
if (!mCharset.IsEmpty()) if (!mCharset.IsEmpty())
{ {
bool same; bool same;
res = calias->Equals(aCharset, mCharset, &same); res = nsCharsetAlias::Equals(aCharset, mCharset, &same);
if(NS_SUCCEEDED(res) && same) if(NS_SUCCEEDED(res) && same)
{ {
return NS_OK; // no difference, don't change it return NS_OK; // no difference, don't change it
@ -170,7 +167,7 @@ nsresult nsScanner::SetDocumentCharset(const nsACString& aCharset , PRInt32 aSou
// different, need to change it // different, need to change it
nsCString charsetName; nsCString charsetName;
res = calias->GetPreferred(aCharset, charsetName); res = nsCharsetAlias::GetPreferred(aCharset, charsetName);
if(NS_FAILED(res) && (mCharsetSource == kCharsetUninitialized)) if(NS_FAILED(res) && (mCharsetSource == kCharsetUninitialized))
{ {

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

@ -39,7 +39,7 @@
#include "nsIInputStream.h" #include "nsIInputStream.h"
#include "nsNetCID.h" #include "nsNetCID.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsICharsetAlias.h" #include "nsCharsetAlias.h"
#include "nsParserCIID.h" #include "nsParserCIID.h"
#include "nsStreamUtils.h" #include "nsStreamUtils.h"
#include "nsStringStream.h" #include "nsStringStream.h"
@ -648,17 +648,11 @@ nsSAXXMLReader::TryChannelCharset(nsIChannel *aChannel,
nsCAutoString charsetVal; nsCAutoString charsetVal;
nsresult rv = aChannel->GetContentCharset(charsetVal); nsresult rv = aChannel->GetContentCharset(charsetVal);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsICharsetAlias> if (NS_FAILED(nsCharsetAlias::GetPreferred(charsetVal, aCharset)))
calias(do_GetService(NS_CHARSETALIAS_CONTRACTID)); return false;
if (calias) {
nsCAutoString preferred; aCharsetSource = kCharsetFromChannel;
rv = calias->GetPreferred(charsetVal, preferred); return true;
if (NS_SUCCEEDED(rv)) {
aCharset = preferred;
aCharsetSource = kCharsetFromChannel;
return true;
}
}
} }
} }