fix for bug 209220 - now that i18n APIs take ASCII charset names, update consumers to avoid excess conversions.. which usually means storing charset names as ASCII and updating a few other APIs

r=jkeiser, sr=jst and some great comments from jshin@mailaps.org
This commit is contained in:
alecf%flett.org 2003-06-17 16:40:34 +00:00
Родитель ada2856ce5
Коммит 5614718dd3
90 изменённых файлов: 420 добавлений и 452 удалений

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

@ -157,8 +157,8 @@ public:
* will trigger a startDocumentLoad if necessary to answer the
* question.
*/
NS_IMETHOD GetDocumentCharacterSet(nsAString& oCharSetID) = 0;
NS_IMETHOD SetDocumentCharacterSet(const nsAString& aCharSetID) = 0;
NS_IMETHOD GetDocumentCharacterSet(nsACString& oCharSetID) = 0;
NS_IMETHOD SetDocumentCharacterSet(const nsACString& aCharSetID) = 0;
NS_IMETHOD GetDocumentCharacterSetSource(PRInt32* aCharsetSource) = 0;
NS_IMETHOD SetDocumentCharacterSetSource(PRInt32 aCharsetSource) = 0;

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

@ -213,7 +213,7 @@ public:
*
* Possible result codes: NS_ERROR_NO_CHARSET_CONVERTER
*/
NS_IMETHOD SetCharset(const nsAString& aCharset) = 0;
NS_IMETHOD SetCharset(const nsACString& aCharset) = 0;
/**
* Set a wrap column. This may have no effect in some types of encoders.

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

@ -387,13 +387,13 @@ mozSanitizingHTMLSerializer::AddDocTypeDecl(const nsIParserNode& aNode)
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::SetDocumentCharset(nsAString& aCharset)
mozSanitizingHTMLSerializer::SetDocumentCharset(nsACString& aCharset)
{
// No idea, if this works - it isn't invoked by |TestOutput|.
Write(NS_LITERAL_STRING("\n<meta http-equiv=\"Context-Type\" content=\"text/html; charset=")
/* Danger: breaking the line within the string literal, like
"foo"\n"bar", breaks win32! */
+ aCharset + NS_LITERAL_STRING("\">\n"));
+ NS_ConvertASCIItoUCS2(aCharset) + NS_LITERAL_STRING("\">\n"));
return NS_OK;
}

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

@ -107,7 +107,7 @@ public:
{ return NS_OK; }
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsAString& aCharset);
NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }
// nsIHTMLContentSink

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

@ -178,7 +178,7 @@ nsresult nsCopySupport::HTMLCopy(nsISelection *aSel, nsIDocument *aDoc, PRInt16
}
//Mohamed
else {
nsAutoString bidiCharset;
nsCAutoString bidiCharset;
context->GetBidiCharset(bidiCharset);
if (bidiCharset.EqualsIgnoreCase("UTF-8") || (!isVisual)) {
if ( (GET_BIDI_OPTION_CLIPBOARDTEXTMODE(bidiOptions) == IBMBIDI_CLIPBOARDTEXTMODE_VISUAL) || (!isBidiSystem) ) {

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

@ -482,7 +482,7 @@ NS_IMPL_RELEASE_USING_AGGREGATOR(nsXPathDocumentTearoff, mDocument)
// bother initializing members to 0.
nsDocument::nsDocument()
: mCharacterSet(NS_LITERAL_STRING("ISO-8859-1")),
: mCharacterSet(NS_LITERAL_CSTRING("ISO-8859-1")),
mNextContentID(NS_CONTENT_ID_COUNTER_BASE)
{
@ -954,7 +954,7 @@ nsDocument::SetBaseTarget(const nsAString &aBaseTarget)
}
NS_IMETHODIMP
nsDocument::GetDocumentCharacterSet(nsAString& aCharSetID)
nsDocument::GetDocumentCharacterSet(nsACString& aCharSetID)
{
aCharSetID = mCharacterSet;
@ -962,7 +962,7 @@ nsDocument::GetDocumentCharacterSet(nsAString& aCharSetID)
}
NS_IMETHODIMP
nsDocument::SetDocumentCharacterSet(const nsAString& aCharSetID)
nsDocument::SetDocumentCharacterSet(const nsACString& aCharSetID)
{
if (!mCharacterSet.Equals(aCharSetID)) {
mCharacterSet = aCharSetID;
@ -974,7 +974,7 @@ nsDocument::SetDocumentCharacterSet(const nsAString& aCharSetID)
NS_STATIC_CAST(nsIObserver *, mCharSetObservers.ElementAt(i));
observer->Observe(NS_STATIC_CAST(nsIDocument *, this), "charset",
PromiseFlatString(aCharSetID).get());
NS_ConvertASCIItoUCS2(aCharSetID).get());
}
}
@ -2569,7 +2569,11 @@ nsDocument::GetStyleSheets(nsIDOMStyleSheetList** aStyleSheets)
NS_IMETHODIMP
nsDocument::GetCharacterSet(nsAString& aCharacterSet)
{
return GetDocumentCharacterSet(aCharacterSet);
nsCAutoString charset;
nsresult rv = GetDocumentCharacterSet(charset);
if (NS_SUCCEEDED(rv))
CopyASCIItoUCS2(charset, aCharacterSet);
return rv;
}
NS_IMETHODIMP
@ -3972,7 +3976,7 @@ nsDocument::GetXMLDeclaration(nsAString& aVersion, nsAString& aEncoding,
if (mXMLDeclarationBits & XML_DECLARATION_BITS_ENCODING_EXISTS) {
// This is what we have stored, not necessarily what was written
// in the original
GetDocumentCharacterSet(aEncoding);
GetCharacterSet(aEncoding);
}
if (mXMLDeclarationBits & XML_DECLARATION_BITS_STANDALONE_EXISTS) {

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

@ -314,8 +314,8 @@ public:
* Return a standard name for the document's character set. This will
* trigger a startDocumentLoad if necessary to answer the question.
*/
NS_IMETHOD GetDocumentCharacterSet(nsAString& oCharsetID);
NS_IMETHOD SetDocumentCharacterSet(const nsAString& aCharSetID);
NS_IMETHOD GetDocumentCharacterSet(nsACString& oCharsetID);
NS_IMETHOD SetDocumentCharacterSet(const nsACString& aCharSetID);
NS_IMETHOD GetDocumentCharacterSetSource(PRInt32* aCharsetSource);
NS_IMETHOD SetDocumentCharacterSetSource(PRInt32 aCharsetSource);
@ -606,7 +606,7 @@ protected:
nsWeakPtr mDocumentContainer;
nsString mCharacterSet;
nsCString mCharacterSet;
PRInt32 mCharacterSetSource;
nsVoidArray mCharSetObservers;

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

@ -109,7 +109,7 @@ public:
NS_IMETHOD SetRange(nsIDOMRange* aRange);
NS_IMETHOD SetNode(nsIDOMNode* aNode);
NS_IMETHOD SetWrapColumn(PRUint32 aWC);
NS_IMETHOD SetCharset(const nsAString& aCharset);
NS_IMETHOD SetCharset(const nsACString& aCharset);
NS_IMETHOD GetMimeType(nsAString& aMimeType);
NS_IMETHOD EncodeToStream(nsIOutputStream* aStream);
NS_IMETHOD EncodeToString(nsAString& aOutputString);
@ -273,9 +273,9 @@ nsDocumentEncoder::SetNode(nsIDOMNode* aNode)
}
NS_IMETHODIMP
nsDocumentEncoder::SetCharset(const nsAString& aCharset)
nsDocumentEncoder::SetCharset(const nsACString& aCharset)
{
CopyUCS2toASCII(aCharset, mCharset);
mCharset = aCharset;
return NS_OK;
}

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

@ -447,18 +447,19 @@ protected:
#endif // NS_DEBUG
#endif // NS_PRINTING
/* character set member data */
PRInt32 mHintCharsetSource;
nsCString mHintCharset;
nsCString mDefaultCharacterSet;
nsCString mForceCharacterSet;
nsCString mPrevDocCharacterSet;
// document management data
// these items are specific to markup documents (html and xml)
// may consider splitting these out into a subclass
PRPackedBool mAllowPlugins;
PRPackedBool mIsSticky;
/* character set member data */
nsString mDefaultCharacterSet;
nsString mHintCharset;
PRInt32 mHintCharsetSource;
nsString mForceCharacterSet;
nsString mPrevDocCharacterSet;
};
//------------------------------------------------------------------
@ -2322,9 +2323,8 @@ NS_IMETHODIMP DocumentViewerImpl::GetTextZoom(float* aTextZoom)
// XXX: SEMANTIC CHANGE!
// returns a copy of the string. Caller is responsible for freeing result
// using Recycle(aDefaultCharacterSet)
NS_IMETHODIMP DocumentViewerImpl::GetDefaultCharacterSet(PRUnichar** aDefaultCharacterSet)
NS_IMETHODIMP DocumentViewerImpl::GetDefaultCharacterSet(nsACString& aDefaultCharacterSet)
{
NS_ENSURE_ARG_POINTER(aDefaultCharacterSet);
NS_ENSURE_STATE(mContainer);
if (mDefaultCharacterSet.IsEmpty())
@ -2348,69 +2348,64 @@ NS_IMETHODIMP DocumentViewerImpl::GetDefaultCharacterSet(PRUnichar** aDefaultCha
}
if (!defCharset.IsEmpty())
mDefaultCharacterSet.Assign(defCharset.get());
CopyUCS2toASCII(defCharset, mDefaultCharacterSet);
else
mDefaultCharacterSet.Assign(NS_LITERAL_STRING("ISO-8859-1"));
mDefaultCharacterSet.Assign(NS_LITERAL_CSTRING("ISO-8859-1"));
}
*aDefaultCharacterSet = ToNewUnicode(mDefaultCharacterSet);
aDefaultCharacterSet = mDefaultCharacterSet;
return NS_OK;
}
static void
SetChildDefaultCharacterSet(nsIMarkupDocumentViewer* aChild, void* aClosure)
{
aChild->SetDefaultCharacterSet((PRUnichar*) aClosure);
const nsACString* charset = NS_STATIC_CAST(nsACString*, aClosure);
aChild->SetDefaultCharacterSet(*charset);
}
NS_IMETHODIMP DocumentViewerImpl::SetDefaultCharacterSet(const PRUnichar* aDefaultCharacterSet)
NS_IMETHODIMP
DocumentViewerImpl::SetDefaultCharacterSet(const nsACString& aDefaultCharacterSet)
{
mDefaultCharacterSet = aDefaultCharacterSet; // this does a copy of aDefaultCharacterSet
// now set the default char set on all children of mContainer
return CallChildren(SetChildDefaultCharacterSet,
(void*) aDefaultCharacterSet);
(void*) &aDefaultCharacterSet);
}
// XXX: SEMANTIC CHANGE!
// returns a copy of the string. Caller is responsible for freeing result
// using Recycle(aForceCharacterSet)
NS_IMETHODIMP DocumentViewerImpl::GetForceCharacterSet(PRUnichar** aForceCharacterSet)
NS_IMETHODIMP DocumentViewerImpl::GetForceCharacterSet(nsACString& aForceCharacterSet)
{
NS_ENSURE_ARG_POINTER(aForceCharacterSet);
nsAutoString emptyStr;
if (mForceCharacterSet.Equals(emptyStr)) {
*aForceCharacterSet = nsnull;
}
else {
*aForceCharacterSet = ToNewUnicode(mForceCharacterSet);
}
aForceCharacterSet = mForceCharacterSet;
return NS_OK;
}
static void
SetChildForceCharacterSet(nsIMarkupDocumentViewer* aChild, void* aClosure)
{
aChild->SetForceCharacterSet((PRUnichar*) aClosure);
const nsACString* charset = NS_STATIC_CAST(nsACString*, aClosure);
aChild->SetForceCharacterSet(*charset);
}
NS_IMETHODIMP DocumentViewerImpl::SetForceCharacterSet(const PRUnichar* aForceCharacterSet)
NS_IMETHODIMP
DocumentViewerImpl::SetForceCharacterSet(const nsACString& aForceCharacterSet)
{
mForceCharacterSet = aForceCharacterSet;
// now set the force char set on all children of mContainer
return CallChildren(SetChildForceCharacterSet, (void*) aForceCharacterSet);
return CallChildren(SetChildForceCharacterSet, (void*) &aForceCharacterSet);
}
// XXX: SEMANTIC CHANGE!
// returns a copy of the string. Caller is responsible for freeing result
// using Recycle(aHintCharacterSet)
NS_IMETHODIMP DocumentViewerImpl::GetHintCharacterSet(PRUnichar * *aHintCharacterSet)
NS_IMETHODIMP DocumentViewerImpl::GetHintCharacterSet(nsACString& aHintCharacterSet)
{
NS_ENSURE_ARG_POINTER(aHintCharacterSet);
if(kCharsetUninitialized == mHintCharsetSource) {
*aHintCharacterSet = nsnull;
aHintCharacterSet.Truncate();
} else {
*aHintCharacterSet = ToNewUnicode(mHintCharset);
aHintCharacterSet = mHintCharset;
// this can't possibly be right. we can't set a value just because somebody got a related value!
//mHintCharsetSource = kCharsetUninitialized;
}
@ -2426,11 +2421,9 @@ NS_IMETHODIMP DocumentViewerImpl::GetHintCharacterSetSource(PRInt32 *aHintCharac
}
NS_IMETHODIMP DocumentViewerImpl::GetPrevDocCharacterSet(PRUnichar * *aPrevDocCharacterSet)
NS_IMETHODIMP DocumentViewerImpl::GetPrevDocCharacterSet(nsACString& aPrevDocCharacterSet)
{
NS_ENSURE_ARG_POINTER(aPrevDocCharacterSet);
*aPrevDocCharacterSet = ToNewUnicode(mPrevDocCharacterSet);
aPrevDocCharacterSet = mPrevDocCharacterSet;
return NS_OK;
}
@ -2438,15 +2431,17 @@ NS_IMETHODIMP DocumentViewerImpl::GetPrevDocCharacterSet(PRUnichar * *aPrevDocCh
static void
SetChildPrevDocCharacterSet(nsIMarkupDocumentViewer* aChild, void* aClosure)
{
aChild->SetPrevDocCharacterSet((PRUnichar*) aClosure);
const nsACString* charset = NS_STATIC_CAST(nsACString*, aClosure);
aChild->SetPrevDocCharacterSet(*charset);
}
NS_IMETHODIMP DocumentViewerImpl::SetPrevDocCharacterSet(const PRUnichar* aPrevDocCharacterSet)
NS_IMETHODIMP
DocumentViewerImpl::SetPrevDocCharacterSet(const nsACString& aPrevDocCharacterSet)
{
mPrevDocCharacterSet = aPrevDocCharacterSet;
return CallChildren(SetChildPrevDocCharacterSet,
(void*) aPrevDocCharacterSet);
(void*) &aPrevDocCharacterSet);
}
@ -2456,7 +2451,8 @@ SetChildHintCharacterSetSource(nsIMarkupDocumentViewer* aChild, void* aClosure)
aChild->SetHintCharacterSetSource(NS_PTR_TO_INT32(aClosure));
}
NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSetSource(PRInt32 aHintCharacterSetSource)
NS_IMETHODIMP
DocumentViewerImpl::SetHintCharacterSetSource(PRInt32 aHintCharacterSetSource)
{
mHintCharsetSource = aHintCharacterSetSource;
// now set the hint char set source on all children of mContainer
@ -2467,14 +2463,16 @@ NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSetSource(PRInt32 aHintCharact
static void
SetChildHintCharacterSet(nsIMarkupDocumentViewer* aChild, void* aClosure)
{
aChild->SetHintCharacterSet((PRUnichar*) aClosure);
const nsACString* charset = NS_STATIC_CAST(nsACString*, aClosure);
aChild->SetHintCharacterSet(*charset);
}
NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSet(const PRUnichar* aHintCharacterSet)
NS_IMETHODIMP
DocumentViewerImpl::SetHintCharacterSet(const nsACString& aHintCharacterSet)
{
mHintCharset = aHintCharacterSet;
// now set the hint char set on all children of mContainer
return CallChildren(SetChildHintCharacterSet, (void*) aHintCharacterSet);
return CallChildren(SetChildHintCharacterSet, (void*) &aHintCharacterSet);
}
static void

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

@ -164,13 +164,13 @@ nsFrameLoader::LoadFrame()
nsCOMPtr<nsIURI> base_uri;
doc->GetBaseURL(getter_AddRefs(base_uri));
nsAutoString doc_charset;
nsCAutoString doc_charset;
doc->GetDocumentCharacterSet(doc_charset);
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), src,
doc_charset.IsEmpty() ? nsnull :
NS_ConvertUCS2toUTF8(doc_charset).get(), base_uri);
doc_charset.get(), base_uri);
NS_ENSURE_SUCCESS(rv, rv);
// Check for security

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

@ -2972,11 +2972,11 @@ nsGenericElement::TriggerLink(nsIPresContext* aPresContext,
// Resolve url to an absolute url
nsCOMPtr<nsIURI> targetURI;
nsAutoString docCharset;
nsCAutoString docCharset;
if (mDocument &&
NS_SUCCEEDED(mDocument->GetDocumentCharacterSet(docCharset))) {
rv = NS_NewURI(getter_AddRefs(targetURI), aURLSpec,
NS_LossyConvertUCS2toASCII(docCharset).get(), aBaseURL);
docCharset.get(), aBaseURL);
} else {
rv = NS_NewURI(getter_AddRefs(targetURI), aURLSpec, nsnull, aBaseURL);
}

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

@ -598,13 +598,13 @@ nsImageLoadingContent::StringToURI(const nsACString& aSpec,
NS_ENSURE_SUCCESS(rv, rv);
// (2) Get the charset
nsAutoString charset;
nsCAutoString charset;
aDocument->GetDocumentCharacterSet(charset);
// (3) Construct the silly thing
return NS_NewURI(aURI,
aSpec,
charset.IsEmpty() ? nsnull : NS_ConvertUCS2toUTF8(charset).get(),
charset.IsEmpty() ? nsnull : charset.get(),
baseURL,
sIOService);
}

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

@ -103,7 +103,7 @@ public:
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode) { return NS_OK; }
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode) { return NS_OK; }
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsAString& aCharset) { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }
// nsIHTMLContentSink

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

@ -809,9 +809,7 @@ nsScriptLoader::OnStreamComplete(nsIStreamLoader* aLoader,
if (characterSet.IsEmpty()) {
// charset from document default
nsAutoString uCharset;
rv = mDocument->GetDocumentCharacterSet(uCharset);
CopyUCS2toASCII(uCharset, characterSet);
rv = mDocument->GetDocumentCharacterSet(characterSet);
}
NS_ASSERTION(NS_SUCCEEDED(rv), "Could not get document charset!");

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

@ -1276,10 +1276,7 @@ nsFormSubmission::GetSubmitCharset(nsIHTMLContent* aForm,
nsCOMPtr<nsIDocument> doc;
aForm->GetDocument(getter_AddRefs(doc));
if (doc) {
nsAutoString docCharset;
rv = doc->GetDocumentCharacterSet(docCharset);
if (NS_SUCCEEDED(rv))
CopyUCS2toASCII(docCharset, oCharset);
rv = doc->GetDocumentCharacterSet(oCharset);
}
if (aCtrlsModAtSubmit==IBMBIDI_CONTROLSTEXTMODE_VISUAL

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

@ -246,7 +246,7 @@ public:
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD FlushPendingNotifications();
NS_IMETHOD SetDocumentCharset(nsAString& aCharset);
NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
// nsIHTMLContentSink
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
@ -4361,12 +4361,11 @@ HTMLContentSink::ScrollToRef(PRBool aReallyScroll)
// document's charset.
if (NS_FAILED(rv)) {
nsAutoString docCharset;
nsCAutoString docCharset;
rv = mDocument->GetDocumentCharacterSet(docCharset);
if (NS_SUCCEEDED(rv)) {
NS_LossyConvertUCS2toASCII charset(docCharset);
rv = CharsetConvRef(charset, unescapedRef, ref);
rv = CharsetConvRef(docCharset, unescapedRef, ref);
if (NS_SUCCEEDED(rv) && !ref.IsEmpty())
rv = shell->GoToAnchor(ref, aReallyScroll);
@ -4928,12 +4927,11 @@ HTMLContentSink::PrefetchHref(const nsAString &aHref, PRBool aExplicit)
do_GetService(NS_PREFETCHSERVICE_CONTRACTID));
if (prefetchService) {
// construct URI using document charset
nsAutoString charset;
nsCAutoString charset;
mDocument->GetDocumentCharacterSet(charset);
nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), aHref,
charset.IsEmpty() ? nsnull
: NS_LossyConvertUCS2toASCII(charset).get(),
charset.IsEmpty() ? nsnull : charset.get(),
mDocumentBaseURL);
if (uri)
prefetchService->PrefetchURI(uri, mDocumentURI, aExplicit);
@ -5815,7 +5813,7 @@ HTMLContentSink::FlushPendingNotifications()
}
NS_IMETHODIMP
HTMLContentSink::SetDocumentCharset(nsAString& aCharset)
HTMLContentSink::SetDocumentCharset(nsACString& aCharset)
{
if (mDocShell) {
// the following logic to get muCV is copied from
@ -5851,7 +5849,7 @@ HTMLContentSink::SetDocumentCharset(nsAString& aCharset)
}
if (muCV) {
muCV->SetPrevDocCharacterSet(PromiseFlatString(aCharset).get());
muCV->SetPrevDocCharacterSet(aCharset);
}
}

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

@ -475,15 +475,15 @@ nsHTMLDocument::CreateShell(nsIPresContext* aContext,
PRBool
nsHTMLDocument::TryHintCharset(nsIMarkupDocumentViewer* aMarkupDV,
PRInt32& aCharsetSource, nsAString& aCharset)
PRInt32& aCharsetSource, nsACString& aCharset)
{
if (aMarkupDV) {
PRInt32 requestCharsetSource;
nsresult rv = aMarkupDV->GetHintCharacterSetSource(&requestCharsetSource);
if(NS_SUCCEEDED(rv) && kCharsetUninitialized != requestCharsetSource) {
PRUnichar* requestCharset;
rv = aMarkupDV->GetHintCharacterSet(&requestCharset);
nsCAutoString requestCharset;
rv = aMarkupDV->GetHintCharacterSet(requestCharset);
aMarkupDV->SetHintCharacterSetSource((PRInt32)(kCharsetUninitialized));
if(requestCharsetSource <= aCharsetSource)
@ -493,8 +493,6 @@ nsHTMLDocument::TryHintCharset(nsIMarkupDocumentViewer* aMarkupDV,
aCharsetSource = requestCharsetSource;
aCharset = requestCharset;
Recycle(requestCharset);
return PR_TRUE;
}
}
@ -507,28 +505,27 @@ PRBool
nsHTMLDocument::TryUserForcedCharset(nsIMarkupDocumentViewer* aMarkupDV,
nsIDocumentCharsetInfo* aDocInfo,
PRInt32& aCharsetSource,
nsAString& aCharset)
nsACString& aCharset)
{
nsresult rv = NS_OK;
if(kCharsetFromUserForced <= aCharsetSource)
return PR_TRUE;
PRUnichar* forceCharsetFromDocShell = nsnull;
nsCAutoString forceCharsetFromDocShell;
if (aMarkupDV) {
rv = aMarkupDV->GetForceCharacterSet(&forceCharsetFromDocShell);
rv = aMarkupDV->GetForceCharacterSet(forceCharsetFromDocShell);
}
if(NS_SUCCEEDED(rv) && forceCharsetFromDocShell) {
if(NS_SUCCEEDED(rv) && !forceCharsetFromDocShell.IsEmpty()) {
aCharset = forceCharsetFromDocShell;
Recycle(forceCharsetFromDocShell);
//TODO: we should define appropriate constant for force charset
aCharsetSource = kCharsetFromUserForced;
} else if (aDocInfo) {
nsCOMPtr<nsIAtom> csAtom;
aDocInfo->GetForcedCharset(getter_AddRefs(csAtom));
if (csAtom) {
csAtom->ToString(aCharset);
csAtom->ToUTF8String(aCharset);
aCharsetSource = kCharsetFromUserForced;
aDocInfo->SetForcedCharset(nsnull);
return PR_TRUE;
@ -541,7 +538,7 @@ nsHTMLDocument::TryUserForcedCharset(nsIMarkupDocumentViewer* aMarkupDV,
PRBool
nsHTMLDocument::TryCacheCharset(nsICacheEntryDescriptor* aCacheDescriptor,
PRInt32& aCharsetSource,
nsAString& aCharset)
nsACString& aCharset)
{
nsresult rv;
@ -554,7 +551,7 @@ nsHTMLDocument::TryCacheCharset(nsICacheEntryDescriptor* aCacheDescriptor,
getter_Copies(cachedCharset));
if (NS_SUCCEEDED(rv) && !cachedCharset.IsEmpty())
{
aCharset.Assign(NS_ConvertASCIItoUCS2(cachedCharset));
aCharset = cachedCharset;
aCharsetSource = kCharsetFromCache;
return PR_TRUE;
@ -567,7 +564,7 @@ PRBool
nsHTMLDocument::TryBookmarkCharset(nsIDocShell* aDocShell,
nsIChannel* aChannel,
PRInt32& aCharsetSource,
nsAString& aCharset)
nsACString& aCharset)
{
if (kCharsetFromBookmarks <= aCharsetSource) {
return PR_TRUE;
@ -599,7 +596,7 @@ nsHTMLDocument::TryBookmarkCharset(nsIDocShell* aDocShell,
nsnull,
charset);
if (NS_SUCCEEDED(rv) && !charset.IsEmpty()) {
aCharset = NS_ConvertASCIItoUCS2(charset);
aCharset = charset;
return PR_TRUE;
}
}
@ -610,7 +607,7 @@ nsHTMLDocument::TryBookmarkCharset(nsIDocShell* aDocShell,
PRBool
nsHTMLDocument::TryParentCharset(nsIDocumentCharsetInfo* aDocInfo,
PRInt32& aCharsetSource,
nsAString& aCharset)
nsACString& aCharset)
{
if (aDocInfo) {
PRInt32 source;
@ -632,7 +629,7 @@ nsHTMLDocument::TryParentCharset(nsIDocumentCharsetInfo* aDocInfo,
aDocInfo->GetParentCharset(getter_AddRefs(csAtom));
if (csAtom) {
csAtom->ToString(aCharset);
csAtom->ToUTF8String(aCharset);
aCharsetSource = source;
return PR_TRUE;
}
@ -642,19 +639,19 @@ nsHTMLDocument::TryParentCharset(nsIDocumentCharsetInfo* aDocInfo,
PRBool
nsHTMLDocument::UseWeakDocTypeDefault(PRInt32& aCharsetSource,
nsAString& aCharset)
nsACString& aCharset)
{
if (kCharsetFromWeakDocTypeDefault <= aCharsetSource)
return PR_TRUE;
// fallback value in case docshell return error
aCharset.Assign(NS_LITERAL_STRING("ISO-8859-1"));
aCharset = NS_LITERAL_CSTRING("ISO-8859-1");
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
if (prefs) {
nsXPIDLString defCharset;
nsresult rv = prefs->GetLocalizedUnicharPref("intl.charset.default",
getter_Copies(defCharset));
if (NS_SUCCEEDED(rv) && !defCharset.IsEmpty()) {
aCharset.Assign(defCharset);
CopyUCS2toASCII(defCharset, aCharset);
aCharsetSource = kCharsetFromWeakDocTypeDefault;
}
}
@ -663,7 +660,8 @@ nsHTMLDocument::UseWeakDocTypeDefault(PRInt32& aCharsetSource,
PRBool
nsHTMLDocument::TryChannelCharset(nsIChannel *aChannel,
PRInt32& aCharsetSource, nsAString& aCharset)
PRInt32& aCharsetSource,
nsACString& aCharset)
{
if(kCharsetFromChannel <= aCharsetSource) {
return PR_TRUE;
@ -679,7 +677,7 @@ nsHTMLDocument::TryChannelCharset(nsIChannel *aChannel,
rv = calias->GetPreferred(charsetVal,
preferred);
if(NS_SUCCEEDED(rv)) {
CopyASCIItoUCS2(preferred, aCharset);
aCharset = preferred;
aCharsetSource = kCharsetFromChannel;
return PR_TRUE;
}
@ -691,19 +689,19 @@ nsHTMLDocument::TryChannelCharset(nsIChannel *aChannel,
PRBool
nsHTMLDocument::TryDefaultCharset( nsIMarkupDocumentViewer* aMarkupDV,
PRInt32& aCharsetSource,
nsAString& aCharset)
PRInt32& aCharsetSource,
nsACString& aCharset)
{
if(kCharsetFromUserDefault <= aCharsetSource)
return PR_TRUE;
PRUnichar* defaultCharsetFromDocShell = NULL;
nsCAutoString defaultCharsetFromDocShell;
if (aMarkupDV) {
nsresult rv =
aMarkupDV->GetDefaultCharacterSet(&defaultCharsetFromDocShell);
aMarkupDV->GetDefaultCharacterSet(defaultCharsetFromDocShell);
if(NS_SUCCEEDED(rv)) {
aCharset = defaultCharsetFromDocShell;
Recycle(defaultCharsetFromDocShell);
aCharsetSource = kCharsetFromUserDefault;
return PR_TRUE;
}
@ -712,7 +710,7 @@ nsHTMLDocument::TryDefaultCharset( nsIMarkupDocumentViewer* aMarkupDV,
}
void
nsHTMLDocument::StartAutodetection(nsIDocShell *aDocShell, nsAString& aCharset,
nsHTMLDocument::StartAutodetection(nsIDocShell *aDocShell, nsACString& aCharset,
const char* aCommand)
{
nsCOMPtr <nsIParserFilter> cdetflt;
@ -751,7 +749,7 @@ nsHTMLDocument::StartAutodetection(nsIDocShell *aDocShell, nsAString& aCharset,
nsCOMPtr<nsIWebShellServices> wss = do_QueryInterface(aDocShell);
if (wss) {
rv_detect = adp->Init(wss, cdet, this, mParser,
PromiseFlatString(aCharset).get(), aCommand);
PromiseFlatCString(aCharset).get(), aCommand);
if (mParser)
mParser->SetParserFilter(cdetflt);
@ -900,7 +898,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
aURL->GetSpec(urlSpec);
PRInt32 charsetSource = kCharsetUninitialized;
nsAutoString charset;
nsCAutoString charset;
// The following charset resolving calls has implied knowledge about
// charset source priority order. Each try will return true if the
@ -943,8 +941,8 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
}
if (isPostPage && muCV && kCharsetFromHintPrevDoc > charsetSource) {
nsXPIDLString requestCharset;
muCV->GetPrevDocCharacterSet(getter_Copies(requestCharset));
nsCAutoString requestCharset;
muCV->GetPrevDocCharacterSet(requestCharset);
if (!requestCharset.IsEmpty()) {
charsetSource = kCharsetFromHintPrevDoc;
charset = requestCharset;
@ -959,7 +957,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
// Check if 864 but in Implicit mode !
if ((mTexttype == IBMBIDI_TEXTTYPE_LOGICAL) &&
(charset.EqualsIgnoreCase("ibm864"))) {
charset.Assign(NS_LITERAL_STRING("IBM864i"));
charset = NS_LITERAL_CSTRING("IBM864i");
}
SetDocumentCharacterSet(charset);
@ -967,11 +965,11 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
// set doc charset to muCV for next document.
if (muCV)
muCV->SetPrevDocCharacterSet(charset.get());
muCV->SetPrevDocCharacterSet(charset);
if(cacheDescriptor) {
rv = cacheDescriptor->SetMetaDataElement("charset",
NS_ConvertUCS2toUTF8(charset).get());
charset.get());
NS_ASSERTION(NS_SUCCEEDED(rv),"cannot SetMetaDataElement");
}

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

@ -295,30 +295,30 @@ protected:
static PRBool TryHintCharset(nsIMarkupDocumentViewer* aMarkupDV,
PRInt32& aCharsetSource,
nsAString& aCharset);
nsACString& aCharset);
static PRBool TryUserForcedCharset(nsIMarkupDocumentViewer* aMarkupDV,
nsIDocumentCharsetInfo* aDocInfo,
PRInt32& aCharsetSource,
nsAString& aCharset);
nsACString& aCharset);
static PRBool TryCacheCharset(nsICacheEntryDescriptor* aCacheDescriptor,
PRInt32& aCharsetSource,
nsAString& aCharset);
nsACString& aCharset);
static PRBool TryBookmarkCharset(nsIDocShell* aDocShell,
nsIChannel* aChannel,
PRInt32& aCharsetSource,
nsAString& aCharset);
nsACString& aCharset);
static PRBool TryParentCharset(nsIDocumentCharsetInfo* aDocInfo,
PRInt32& charsetSource, nsAString& aCharset);
PRInt32& charsetSource, nsACString& aCharset);
static PRBool UseWeakDocTypeDefault(PRInt32& aCharsetSource,
nsAString& aCharset);
nsACString& aCharset);
static PRBool TryChannelCharset(nsIChannel *aChannel,
PRInt32& aCharsetSource,
nsAString& aCharset);
nsACString& aCharset);
static PRBool TryDefaultCharset(nsIMarkupDocumentViewer* aMarkupDV,
PRInt32& aCharsetSource,
nsAString& aCharset);
nsACString& aCharset);
void StartAutodetection(nsIDocShell *aDocShell, nsAString& aCharset,
void StartAutodetection(nsIDocShell *aDocShell, nsACString& aCharset,
const char* aCommand);
PRUint32 mIsWriting : 1;

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

@ -82,7 +82,7 @@ public:
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsAString& aCharset) { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
// nsIHTMLContentSink
NS_IMETHOD BeginContext(PRInt32 aID);

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

@ -259,7 +259,7 @@ nsMediaDocument::UpdateTitleAndCharset(const nsACString& aTypeStr,
if (!originCharset.IsEmpty()) {
// set doc. charset to that of the referring document if known so that
// filepicker comes up with the correct non-ascii filename.
SetDocumentCharacterSet(NS_ConvertASCIItoUCS2(originCharset));
SetDocumentCharacterSet(originCharset);
if (!fileName.IsEmpty()) {
nsresult rv;
nsCOMPtr<nsITextToSubURI> textToSubURI =

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

@ -633,9 +633,7 @@ SheetLoadData::OnDetermineCharset(nsIUnicharStreamLoader* aLoader,
if (NS_FAILED(result) && mLoader->mDocument) {
// no useful data on charset. Try the document charset.
// That needs no resolution, since it's already fully resolved
nsAutoString docCharset;
mLoader->mDocument->GetDocumentCharacterSet(docCharset);
CopyUCS2toASCII(docCharset, charset);
mLoader->mDocument->GetDocumentCharacterSet(charset);
#ifdef DEBUG_bzbarsky
fprintf(stderr, "Set from document: %s\n",
charset.get());

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

@ -84,7 +84,7 @@ NS_MakeAbsoluteURIWithCharset(nsACString &aResult,
nsCOMPtr<nsIURI> absURI;
nsresult rv;
nsAutoString originCharset; // XXX why store charset as UCS2?
nsCAutoString originCharset; // XXX why store charset as UCS2?
if (aDocument && NS_FAILED(aDocument->GetDocumentCharacterSet(originCharset)))
originCharset.Truncate();
@ -96,7 +96,7 @@ NS_MakeAbsoluteURIWithCharset(nsACString &aResult,
originCharset.Truncate();
rv = nsHTMLUtils::IOService->NewURI(NS_ConvertUCS2toUTF8(aSpec),
NS_LossyConvertUCS2toASCII(originCharset).get(),
originCharset.get(),
aBaseURI, getter_AddRefs(absURI));
if (NS_FAILED(rv)) return rv;

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

@ -361,12 +361,11 @@ nsXMLContentSink::ScrollToRef(PRBool aReallyScroll)
// document's charset.
if (NS_FAILED(rv)) {
nsAutoString docCharset;
nsCAutoString docCharset;
rv = mDocument->GetDocumentCharacterSet(docCharset);
if (NS_SUCCEEDED(rv)) {
rv = CharsetConvRef(NS_LossyConvertUCS2toASCII(docCharset),
unescapedRef, ref);
rv = CharsetConvRef(docCharset, unescapedRef, ref);
if (NS_SUCCEEDED(rv) && !ref.IsEmpty())
rv = shell->GoToAnchor(ref, aReallyScroll);
@ -1235,7 +1234,7 @@ nsXMLContentSink::ProcessMETATag(nsIContent* aContent)
}
NS_IMETHODIMP
nsXMLContentSink::SetDocumentCharset(nsAString& aCharset)
nsXMLContentSink::SetDocumentCharset(nsACString& aCharset)
{
if (mDocument) {
return mDocument->SetDocumentCharacterSet(aCharset);

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

@ -105,7 +105,7 @@ public:
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsAString& aCharset);
NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
// nsICSSLoaderObserver
NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify);

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

@ -606,7 +606,7 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
aDocListener, aReset, aSink);
if (NS_FAILED(rv)) return rv;
nsAutoString charset(NS_LITERAL_STRING("UTF-8"));
nsCAutoString charset(NS_LITERAL_CSTRING("UTF-8"));
PRInt32 charsetSource = kCharsetFromDocTypeDefault;
nsCOMPtr<nsIURI> aUrl;
@ -621,9 +621,8 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
if(NS_SUCCEEDED(rv) && (nsnull != calias) ) {
nsCAutoString preferred;
rv = calias->GetPreferred(charsetVal, preferred);
rv = calias->GetPreferred(charsetVal, charset);
if(NS_SUCCEEDED(rv)){
CopyASCIItoUCS2(preferred, charset);
charsetSource = kCharsetFromChannel;
}
}

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

@ -137,7 +137,7 @@ public:
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsAString& aCharset);
NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
// nsIXULContentSink
NS_IMETHOD Init(nsIDocument* aDocument, nsIXULPrototypeDocument* aPrototype);
@ -575,7 +575,7 @@ XULContentSinkImpl::ProcessStyleLink(nsIContent* aElement,
}
NS_IMETHODIMP
XULContentSinkImpl::SetDocumentCharset(nsAString& aCharset)
XULContentSinkImpl::SetDocumentCharset(nsACString& aCharset)
{
nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument);
if (doc) {

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

@ -366,7 +366,7 @@ nsXULDocument::nsXULDocument(void)
// bother initializing members to 0.
// Override the default in nsDocument
mCharacterSet.Assign(NS_LITERAL_STRING("UTF-8"));
mCharacterSet.Assign(NS_LITERAL_CSTRING("UTF-8"));
}
nsXULDocument::~nsXULDocument()
@ -2459,7 +2459,7 @@ nsXULDocument::PrepareToLoadPrototype(nsIURI* aURI, const char* aCommand,
parser->SetCommand(nsCRT::strcmp(aCommand, "view-source") ? eViewNormal :
eViewSource);
parser->SetDocumentCharset(NS_LITERAL_STRING("UTF-8"),
parser->SetDocumentCharset(NS_LITERAL_CSTRING("UTF-8"),
kCharsetFromDocTypeDefault);
parser->SetContentSink(sink); // grabs a reference to the parser

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

@ -1113,13 +1113,13 @@ nsresult nsDocShell::FindTarget(const PRUnichar *aWindowTarget,
muCV = do_QueryInterface(cv);
target_muCV = do_QueryInterface(target_cv);
if (muCV && target_muCV) {
nsXPIDLString defaultCharset;
nsXPIDLString prevDocCharset;
rv = muCV->GetDefaultCharacterSet(getter_Copies(defaultCharset));
nsCAutoString defaultCharset;
nsCAutoString prevDocCharset;
rv = muCV->GetDefaultCharacterSet(defaultCharset);
if(NS_SUCCEEDED(rv)) {
target_muCV->SetDefaultCharacterSet(defaultCharset);
}
rv = muCV->GetPrevDocCharacterSet(getter_Copies(prevDocCharset));
rv = muCV->GetPrevDocCharacterSet(prevDocCharset);
if(NS_SUCCEEDED(rv)) {
target_muCV->SetPrevDocCharacterSet(prevDocCharset);
}
@ -1326,7 +1326,7 @@ nsDocShell::SetCurrentURI(nsIURI *aURI)
}
NS_IMETHODIMP
nsDocShell::GetCharset(PRUnichar** aCharset)
nsDocShell::GetCharset(char** aCharset)
{
NS_ENSURE_ARG_POINTER(aCharset);
*aCharset = nsnull;
@ -1337,15 +1337,15 @@ nsDocShell::GetCharset(PRUnichar** aCharset)
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
presShell->GetDocument(getter_AddRefs(doc));
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
nsAutoString charset;
nsCAutoString charset;
NS_ENSURE_SUCCESS(doc->GetDocumentCharacterSet(charset), NS_ERROR_FAILURE);
*aCharset = ToNewUnicode(charset);
*aCharset = ToNewCString(charset);
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::SetCharset(const PRUnichar* aCharset)
nsDocShell::SetCharset(const char* aCharset)
{
// set the default charset
nsCOMPtr<nsIContentViewer> viewer;
@ -1353,8 +1353,8 @@ nsDocShell::SetCharset(const PRUnichar* aCharset)
if (viewer) {
nsCOMPtr<nsIMarkupDocumentViewer> muDV(do_QueryInterface(viewer));
if (muDV) {
NS_ENSURE_SUCCESS(muDV->SetDefaultCharacterSet(aCharset),
NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(muDV->SetDefaultCharacterSet(nsDependentCString(aCharset)),
NS_ERROR_FAILURE);
}
}
@ -2081,7 +2081,7 @@ nsDocShell::AddChild(nsIDocShellTreeItem * aChild)
res = docv->GetDocument(getter_AddRefs(doc));
if (NS_FAILED(res) || (!doc))
return NS_OK;
nsAutoString parentCS;
nsCAutoString parentCS;
res = doc->GetDocumentCharacterSet(parentCS);
if (NS_FAILED(res))
return NS_OK;
@ -4663,11 +4663,11 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer)
NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShell> parent(do_QueryInterface(parentAsItem));
nsXPIDLString defaultCharset;
nsXPIDLString forceCharset;
nsXPIDLString hintCharset;
nsCAutoString defaultCharset;
nsCAutoString forceCharset;
nsCAutoString hintCharset;
PRInt32 hintCharsetSource;
nsXPIDLString prevDocCharset;
nsCAutoString prevDocCharset;
float textZoom;
// |newMUDV| also serves as a flag to set the data from the above vars
nsCOMPtr<nsIMarkupDocumentViewer> newMUDV;
@ -4693,14 +4693,13 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer)
newMUDV = do_QueryInterface(aNewViewer,&rv);
if (newMUDV) {
NS_ENSURE_SUCCESS(oldMUDV->
GetDefaultCharacterSet(getter_Copies
(defaultCharset)),
GetDefaultCharacterSet(defaultCharset),
NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(oldMUDV->
GetForceCharacterSet(getter_Copies(forceCharset)),
GetForceCharacterSet(forceCharset),
NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(oldMUDV->
GetHintCharacterSet(getter_Copies(hintCharset)),
GetHintCharacterSet(hintCharset),
NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(oldMUDV->
GetHintCharacterSetSource(&hintCharsetSource),
@ -4709,7 +4708,7 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer)
GetTextZoom(&textZoom),
NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(oldMUDV->
GetPrevDocCharacterSet(getter_Copies(prevDocCharset)),
GetPrevDocCharacterSet(prevDocCharset),
NS_ERROR_FAILURE);
}
}
@ -5829,7 +5828,7 @@ nsDocShell::ScrollIfAnchor(nsIURI * aURI, PRBool * aWasAnchor,
nsCOMPtr<nsIDocument> doc;
rv = docv->GetDocument(getter_AddRefs(doc));
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
nsAutoString aCharset;
nsCAutoString aCharset;
rv = doc->GetDocumentCharacterSet(aCharset);
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
@ -5840,9 +5839,8 @@ nsDocShell::ScrollIfAnchor(nsIURI * aURI, PRBool * aWasAnchor,
// Unescape and convert to unicode
nsXPIDLString uStr;
NS_LossyConvertUCS2toASCII charset(aCharset);
rv = textToSubURI->UnEscapeAndConvert(charset.get(),
rv = textToSubURI->UnEscapeAndConvert(aCharset.get(),
PromiseFlatCString(sNewRef).get(),
getter_Copies(uStr));
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);

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

@ -53,17 +53,17 @@ interface nsIMarkupDocumentViewer : nsISupports
/*
XXX Comment here!
*/
attribute wstring defaultCharacterSet;
attribute ACString defaultCharacterSet;
/*
XXX Comment here!
*/
attribute wstring forceCharacterSet;
attribute ACString forceCharacterSet;
/*
XXX Comment here!
*/
attribute wstring hintCharacterSet;
attribute ACString hintCharacterSet;
/*
XXX Comment here!
@ -73,7 +73,7 @@ interface nsIMarkupDocumentViewer : nsISupports
/*
character set from prev document
*/
attribute wstring prevDocCharacterSet;
attribute ACString prevDocCharacterSet;
//void GetCharacterSetHint(in wstring hintCharset, in PRInt32 charsetSource);

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

@ -389,7 +389,7 @@ nsWebShell::LoadDocument(const char* aURL,
muDV->GetHintCharacterSetSource(&hint);
if( aSource > hint )
{
muDV->SetHintCharacterSet(NS_ConvertASCIItoUCS2(aCharset).get());
muDV->SetHintCharacterSet(nsDependentCString(aCharset));
muDV->SetHintCharacterSetSource(aSource);
if(eCharsetReloadRequested != mCharsetReloadState)
{
@ -425,7 +425,7 @@ nsWebShell::ReloadDocument(const char* aCharset,
muDV->GetHintCharacterSetSource(&hint);
if( aSource > hint )
{
muDV->SetHintCharacterSet(NS_ConvertASCIItoUCS2(aCharset).get());
muDV->SetHintCharacterSet(nsDependentCString(aCharset));
muDV->SetHintCharacterSetSource(aSource);
if(eCharsetReloadRequested != mCharsetReloadState)
{

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

@ -3469,14 +3469,13 @@ GlobalWindowImpl::ConvertCharset(const nsAString& aStr,
{
nsresult result = NS_OK;
nsCOMPtr<nsIUnicodeEncoder> encoder;
nsAutoString charset;
nsCOMPtr<nsICharsetConverterManager>
ccm(do_GetService(kCharsetConverterManagerCID));
NS_ENSURE_TRUE(ccm, NS_ERROR_FAILURE);
// Get the document character set
charset.Assign(NS_LITERAL_STRING("UTF-8")); // default to utf-8
nsCAutoString charset(NS_LITERAL_CSTRING("UTF-8")); // default to utf-8
if (mDocument) {
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
@ -3487,7 +3486,7 @@ GlobalWindowImpl::ConvertCharset(const nsAString& aStr,
return result;
// Get an encoder for the character set
result = ccm->GetUnicodeEncoderRaw(NS_LossyConvertUCS2toASCII(charset).get(),
result = ccm->GetUnicodeEncoderRaw(charset.get(),
getter_AddRefs(encoder));
if (NS_FAILED(result))
return result;
@ -3580,7 +3579,7 @@ GlobalWindowImpl::Unescape(const nsAString& aStr,
NS_ENSURE_TRUE(ccm, NS_ERROR_NOT_AVAILABLE);
// Get the document character set; default to utf-8 if all else fails
nsAutoString charset(NS_LITERAL_STRING("UTF-8"));
nsCAutoString charset(NS_LITERAL_CSTRING("UTF-8"));
if (mDocument) {
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
@ -3593,7 +3592,7 @@ GlobalWindowImpl::Unescape(const nsAString& aStr,
// Get a decoder for the character set
nsCOMPtr<nsIUnicodeDecoder> decoder;
rv = ccm->GetUnicodeDecoderRaw(NS_LossyConvertUCS2toASCII(charset).get(),
rv = ccm->GetUnicodeDecoderRaw(charset.get(),
getter_AddRefs(decoder));
NS_ENSURE_SUCCESS(rv, rv);

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

@ -97,12 +97,7 @@ static nsresult GetDocumentCharacterSetForURI(const nsAString& aHref, nsACString
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
nsAutoString charset;
rv = doc->GetDocumentCharacterSet(charset);
NS_ENSURE_SUCCESS(rv, rv);
CopyUCS2toASCII(charset, aCharset);
rv = doc->GetDocumentCharacterSet(aCharset);
return rv;
}

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

@ -151,7 +151,7 @@ interface nsIEditor : nsISupports
readonly attribute boolean documentModified;
/** Sets the current 'Save' document character set */
attribute AString documentCharacterSet;
attribute ACString documentCharacterSet;
/** to be used ONLY when we need to override the doc's modification
* state (such as when it's saved).

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

@ -961,7 +961,7 @@ nsEditor::GetDocumentModified(PRBool *outDocModified)
}
NS_IMETHODIMP
nsEditor::GetDocumentCharacterSet(nsAString &characterSet)
nsEditor::GetDocumentCharacterSet(nsACString &characterSet)
{
nsresult rv;
nsCOMPtr<nsIDocument> doc;
@ -981,7 +981,7 @@ nsEditor::GetDocumentCharacterSet(nsAString &characterSet)
}
NS_IMETHODIMP
nsEditor::SetDocumentCharacterSet(const nsAString& characterSet)
nsEditor::SetDocumentCharacterSet(const nsACString& characterSet)
{
nsresult rv;
nsCOMPtr<nsIDocument> doc;

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

@ -243,7 +243,7 @@ nsPlaintextEditor::EndEditorInit()
}
NS_IMETHODIMP
nsPlaintextEditor::SetDocumentCharacterSet(const nsAString & characterSet)
nsPlaintextEditor::SetDocumentCharacterSet(const nsACString & characterSet)
{
nsresult result;
@ -290,7 +290,7 @@ nsPlaintextEditor::SetDocumentCharacterSet(const nsAString & characterSet)
// set attribute to <original prefix> charset=text/html
result = nsEditor::SetAttribute(metaElement, content,
Substring(originalStart, start) +
charsetEquals + characterSet);
charsetEquals + NS_ConvertASCIItoUCS2(characterSet));
if (NS_SUCCEEDED(result))
newMetaCharset = PR_FALSE;
break;
@ -321,7 +321,7 @@ nsPlaintextEditor::SetDocumentCharacterSet(const nsAString & characterSet)
if (NS_SUCCEEDED(result)) {
// not undoable, undo should undo CreateNode
result = metaElement->SetAttribute(NS_LITERAL_STRING("content"),
NS_LITERAL_STRING("text/html;charset=") + characterSet);
NS_LITERAL_STRING("text/html;charset=") + NS_ConvertASCIItoUCS2(characterSet));
}
}
}
@ -1425,7 +1425,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanCopy(PRBool *aCanCopy)
NS_IMETHODIMP
nsPlaintextEditor::GetAndInitDocEncoder(const nsAString& aFormatType,
PRUint32 aFlags,
const nsAString& aCharset,
const nsACString& aCharset,
nsIDocumentEncoder** encoder)
{
nsCOMPtr<nsIPresShell> presShell;
@ -1446,7 +1446,7 @@ nsPlaintextEditor::GetAndInitDocEncoder(const nsAString& aFormatType,
NS_ENSURE_SUCCESS(rv, rv);
if (!aCharset.IsEmpty()
&& !(aCharset.Equals(NS_LITERAL_STRING("null"))))
&& !(aCharset.Equals(NS_LITERAL_CSTRING("null"))))
docEncoder->SetCharset(aCharset);
PRInt32 wc;
@ -1530,10 +1530,10 @@ nsPlaintextEditor::OutputToString(const nsAString& aFormatType,
return rv;
}
nsAutoString charsetStr;
nsCAutoString charsetStr;
rv = GetDocumentCharacterSet(charsetStr);
if(NS_FAILED(rv) || charsetStr.IsEmpty())
charsetStr = NS_LITERAL_STRING("ISO-8859-1");
charsetStr = NS_LITERAL_CSTRING("ISO-8859-1");
nsCOMPtr<nsIDocumentEncoder> encoder;
rv = GetAndInitDocEncoder(aFormatType, aFlags, charsetStr, getter_AddRefs(encoder));
@ -1547,7 +1547,7 @@ nsPlaintextEditor::OutputToString(const nsAString& aFormatType,
NS_IMETHODIMP
nsPlaintextEditor::OutputToStream(nsIOutputStream* aOutputStream,
const nsAString& aFormatType,
const nsAString& aCharset,
const nsACString& aCharset,
PRUint32 aFlags)
{
nsresult rv;

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

@ -123,7 +123,7 @@ public:
NS_IMETHOD DeleteSelection(EDirection aAction);
NS_IMETHOD SetDocumentCharacterSet(const nsAString & characterSet);
NS_IMETHOD SetDocumentCharacterSet(const nsACString & characterSet);
/** we override this here to install event listeners */
NS_IMETHOD PostCreate();
@ -151,7 +151,7 @@ public:
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
const nsAString& aFormatType,
const nsAString& aCharsetOverride,
const nsACString& aCharsetOverride,
PRUint32 aFlags);
@ -212,7 +212,7 @@ protected:
// Helpers for output routines
NS_IMETHOD GetAndInitDocEncoder(const nsAString& aFormatType,
PRUint32 aFlags,
const nsAString& aCharset,
const nsACString& aCharset,
nsIDocumentEncoder** encoder);
// key event helpers

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

@ -1572,7 +1572,7 @@ nsresult nsWebBrowserPersist::SaveDocumentInternal(
getter_Copies(realContentType));
nsCAutoString contentType; contentType.AssignWithConversion(realContentType);
nsAutoString charType; // Empty
nsCAutoString charType; // Empty
// Save the document
nsCOMPtr<nsIDocument> docAsDoc = do_QueryInterface(aDocument);
@ -1629,7 +1629,7 @@ nsresult nsWebBrowserPersist::SaveDocuments()
getter_Copies(realContentType));
nsCAutoString contentType; contentType.AssignWithConversion(realContentType.get());
nsAutoString charType; // Empty
nsCAutoString charType; // Empty
// Save the document, fixing up the links as it goes out
rv = SaveDocumentWithFixup(
@ -3315,7 +3315,7 @@ nsresult
nsWebBrowserPersist::SaveDocumentWithFixup(
nsIDocument *aDocument, nsIDocumentEncoderNodeFixup *aNodeFixup,
nsIURI *aFile, PRBool aReplaceExisting, const nsACString &aFormatType,
const nsString &aSaveCharset, PRUint32 aFlags)
const nsCString &aSaveCharset, PRUint32 aFlags)
{
NS_ENSURE_ARG_POINTER(aFile);
@ -3362,13 +3362,13 @@ nsWebBrowserPersist::SaveDocumentWithFixup(
if (mWrapColumn && (aFlags & ENCODE_FLAGS_WRAP))
encoder->SetWrapColumn(mWrapColumn);
nsAutoString charsetStr(aSaveCharset);
nsCAutoString charsetStr(aSaveCharset);
if (charsetStr.IsEmpty())
{
rv = aDocument->GetDocumentCharacterSet(charsetStr);
if(NS_FAILED(rv))
{
charsetStr.Assign(NS_LITERAL_STRING("ISO-8859-1"));
charsetStr = NS_LITERAL_CSTRING("ISO-8859-1");
}
}
rv = encoder->SetCharset(charsetStr);

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

@ -131,7 +131,7 @@ private:
nsresult SaveDocumentWithFixup(
nsIDocument *pDocument, nsIDocumentEncoderNodeFixup *pFixup,
nsIURI *aFile, PRBool aReplaceExisting, const nsACString &aFormatType,
const nsString &aSaveCharset, PRUint32 aFlags);
const nsCString &aSaveCharset, PRUint32 aFlags);
nsresult SaveSubframeContent(
nsIDOMDocument *aFrameContent, URIData *aData);
nsresult SetDocumentBase(nsIDOMDocument *aDocument, nsIURI *aBaseURI);

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

@ -702,7 +702,7 @@ nsWindowWatcher::OpenWindowJS(nsIDOMWindow *aParent,
newDocShell->GetContentViewer(getter_AddRefs(newContentViewer));
nsCOMPtr<nsIMarkupDocumentViewer> newMarkupDocViewer(do_QueryInterface(newContentViewer));
if (doc && newMarkupDocViewer) {
nsXPIDLString charset;
nsCAutoString charset;
rv = doc->GetDocumentCharacterSet(charset);
if (NS_SUCCEEDED(rv))
newMarkupDocViewer->SetDefaultCharacterSet(charset);

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

@ -111,7 +111,7 @@ public:
NS_IMETHOD WillResume(void) { return NS_OK; }
NS_IMETHOD SetParser(nsIParser* aParser) { return NS_OK; }
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsAString& aCharset) { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
private:
nsRefPtr<txStylesheetCompiler> mCompiler;
@ -296,7 +296,7 @@ txStylesheetSink::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
}
nsCOMPtr<nsIParser> parser = do_QueryInterface(aContext);
parser->SetDocumentCharset(NS_ConvertASCIItoUCS2(charset), charsetSource);
parser->SetDocumentCharset(charset, charsetSource);
nsCAutoString contentType;
channel->GetContentType(contentType);

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

@ -99,9 +99,9 @@ static nsresult SetUpEncoder(nsIDOMNode *aRoot, const char* aCharset, nsIDocumen
if (NS_FAILED(rv))
return rv;
nsAutoString charset;
nsCAutoString charset;
if (aCharset) {
charset.AssignWithConversion(aCharset);
charset = aCharset;
} else {
rv = document->GetDocumentCharacterSet(charset);
if (NS_FAILED(rv))

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

@ -355,7 +355,7 @@ NS_IMETHODIMP nsXMLHttpRequest::GetResponseXML(nsIDOMDocument **aResponseXML)
* from HTTP headers.
*/
nsresult
nsXMLHttpRequest::DetectCharset(nsAString& aCharset)
nsXMLHttpRequest::DetectCharset(nsACString& aCharset)
{
aCharset.Truncate();
nsresult rv;
@ -364,11 +364,7 @@ nsXMLHttpRequest::DetectCharset(nsAString& aCharset)
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsICharsetAlias> calias(do_GetService(kCharsetAliasCID,&rv));
if(NS_SUCCEEDED(rv) && calias) {
nsCAutoString preferred;
rv = calias->GetPreferred(charsetVal, preferred);
if(NS_SUCCEEDED(rv)) {
CopyASCIItoUCS2(preferred, aCharset);
}
rv = calias->GetPreferred(charsetVal, aCharset);
}
}
return rv;
@ -390,7 +386,7 @@ nsXMLHttpRequest::ConvertBodyToText(PRUnichar **aOutBuffer)
nsresult rv = NS_OK;
nsAutoString dataCharset;
nsCAutoString dataCharset;
nsCOMPtr<nsIDocument> document(do_QueryInterface(mDocument));
if (document) {
rv = document->GetDocumentCharacterSet(dataCharset);
@ -399,11 +395,11 @@ nsXMLHttpRequest::ConvertBodyToText(PRUnichar **aOutBuffer)
} else {
if (NS_FAILED(DetectCharset(dataCharset)) || dataCharset.IsEmpty()) {
// MS documentation states UTF-8 is default for responseText
dataCharset.Assign(NS_LITERAL_STRING("UTF-8"));
dataCharset.Assign(NS_LITERAL_CSTRING("UTF-8"));
}
}
if (dataCharset.Equals(NS_LITERAL_STRING("ASCII"))) {
if (dataCharset.Equals(NS_LITERAL_CSTRING("ASCII"))) {
*aOutBuffer = ToNewUnicode(nsDependentCString(mResponseBody.get(),dataLen));
if (!*aOutBuffer)
return NS_ERROR_OUT_OF_MEMORY;
@ -415,7 +411,7 @@ nsXMLHttpRequest::ConvertBodyToText(PRUnichar **aOutBuffer)
return rv;
nsCOMPtr<nsIUnicodeDecoder> decoder;
rv = ccm->GetUnicodeDecoderRaw(NS_LossyConvertUCS2toASCII(dataCharset).get(),
rv = ccm->GetUnicodeDecoderRaw(dataCharset.get(),
getter_AddRefs(decoder));
if (NS_FAILED(rv))
return rv;

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

@ -108,7 +108,7 @@ protected:
nsresult GetStreamForWString(const PRUnichar* aStr,
PRInt32 aLength,
nsIInputStream** aStream);
nsresult DetectCharset(nsAString& aCharset);
nsresult DetectCharset(nsACString& aCharset);
nsresult ConvertBodyToText(PRUnichar **aOutBuffer);
static NS_METHOD StreamReaderFunc(nsIInputStream* in,
void* closure,

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

@ -1369,7 +1369,7 @@ NS_IMETHODIMP nsFontMetricsGTK::Init(const nsFont& aFont, nsIAtom* aLangGroup,
{
NS_ASSERTION(!(nsnull == aContext), "attempt to init fontmetrics with null device context");
nsresult res;
nsresult res = NS_OK;
mDocConverterType = nsnull;
if (!gInitialized) {

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

@ -121,7 +121,7 @@ public:
* Set the document character set. This should be passed on to the
* document itself.
*/
NS_IMETHOD SetDocumentCharset(nsAString& aCharset)=0;
NS_IMETHOD SetDocumentCharset(nsACString& aCharset)=0;
};
#endif /* nsIContentSink_h___ */

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

@ -188,8 +188,8 @@ class nsIParser : public nsISupports {
* @param aCharsetSource- the soure of the chares
* @return nada
*/
NS_IMETHOD_(void) SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource)=0;
NS_IMETHOD_(void) GetDocumentCharset(nsAString& oCharset, PRInt32& oSource)=0;
NS_IMETHOD_(void) SetDocumentCharset(const nsACString& aCharset, PRInt32 aSource)=0;
NS_IMETHOD_(void) GetDocumentCharset(nsACString& oCharset, PRInt32& oSource)=0;
NS_IMETHOD_(void) SetParserFilter(nsIParserFilter* aFilter) = 0;

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

@ -106,7 +106,7 @@ public:
NS_IMETHOD WillResume(void) { return NS_OK; }
NS_IMETHOD SetParser(nsIParser* aParser) { return NS_OK; }
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsAString& aCharset) { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
NS_IMETHOD WillProcessTokens(void) { return NS_OK; }
NS_IMETHOD DidProcessTokens(void) { return NS_OK; }
NS_IMETHOD WillProcessAToken(void) { return NS_OK; }

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

@ -1574,9 +1574,10 @@ nsObserverEntry::Notify(nsIParserNode* aNode,
if (theTag <= NS_HTML_TAG_MAX) {
nsVoidArray* theObservers = mObservers[theTag];
if (theObservers) {
nsAutoString theCharsetValue;
PRInt32 theCharsetSource;
aParser->GetDocumentCharset(theCharsetValue,theCharsetSource);
nsCAutoString charset;
aParser->GetDocumentCharset(charset,theCharsetSource);
NS_ConvertASCIItoUCS2 theCharsetValue(charset);
PRInt32 theAttrCount = aNode->GetAttributeCount();
PRInt32 theObserversCount = theObservers->Count();

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

@ -74,7 +74,7 @@ public:
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsAString& aCharset) { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }
// nsIHTMLContentSink

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

@ -305,7 +305,7 @@ nsParser::nsParser() {
}
#endif
mCharset.Assign(NS_LITERAL_STRING("ISO-8859-1"));
mCharset.Assign(NS_LITERAL_CSTRING("ISO-8859-1"));
mParserContext=0;
mStreamStatus=0;
mCharsetSource=kCharsetUninitialized;
@ -487,7 +487,7 @@ NS_IMETHODIMP_(void) nsParser::SetCommand(eParserCommands aParserCommand)
* @return nada
*/
NS_IMETHODIMP_(void)
nsParser::SetDocumentCharset(const nsAString& aCharset, PRInt32 aCharsetSource)
nsParser::SetDocumentCharset(const nsACString& aCharset, PRInt32 aCharsetSource)
{
mCharset = aCharset;
mCharsetSource = aCharsetSource;
@ -495,7 +495,7 @@ nsParser::SetDocumentCharset(const nsAString& aCharset, PRInt32 aCharsetSource)
mParserContext->mScanner->SetDocumentCharset(aCharset, aCharsetSource);
}
void nsParser::SetSinkCharset(nsAString& aCharset)
void nsParser::SetSinkCharset(nsACString& aCharset)
{
if (mSink) {
mSink->SetDocumentCharset(aCharset);
@ -1998,7 +1998,7 @@ static inline PRBool IsSecondMarker(unsigned char aChar)
}
}
static PRBool DetectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsString& oCharset, PRInt32& oCharsetSource) {
static PRBool DetectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsCString& oCharset, PRInt32& oCharsetSource) {
oCharsetSource= kCharsetFromAutoDetection;
oCharset.Truncate();
// See http://www.w3.org/TR/2000/REC-xml-20001006#sec-guessing
@ -2013,26 +2013,26 @@ static PRBool DetectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS
// 00 00
if((0xFE==aBytes[2]) && (0xFF==aBytes[3])) {
// 00 00 FE FF UCS-4, big-endian machine (1234 order)
oCharset.AssignWithConversion(UCS4_BE);
oCharset.Assign(UCS4_BE);
} else if((0x00==aBytes[2]) && (0x3C==aBytes[3])) {
// 00 00 00 3C UCS-4, big-endian machine (1234 order)
oCharset.AssignWithConversion(UCS4_BE);
oCharset.Assign(UCS4_BE);
} else if((0xFF==aBytes[2]) && (0xFE==aBytes[3])) {
// 00 00 FF FE UCS-4, unusual octet order (2143)
oCharset.AssignWithConversion(UCS4_2143);
oCharset.Assign(UCS4_2143);
} else if((0x3C==aBytes[2]) && (0x00==aBytes[3])) {
// 00 00 3C 00 UCS-4, unusual octet order (2143)
oCharset.AssignWithConversion(UCS4_2143);
oCharset.Assign(UCS4_2143);
}
oCharsetSource = kCharsetFromByteOrderMark;
} else if((0x3C==aBytes[1]) && (0x00==aBytes[2])) {
// 00 3C 00
if(IsSecondMarker(aBytes[3])) {
// 00 3C 00 SM UTF-16, big-endian, no Byte Order Mark
oCharset.AssignWithConversion(UTF16_BE);
oCharset.Assign(UTF16_BE);
} else if((0x00==aBytes[3])) {
// 00 3C 00 00 UCS-4, unusual octet order (3412)
oCharset.AssignWithConversion(UCS4_3412);
oCharset.Assign(UCS4_3412);
}
oCharsetSource = kCharsetFromByteOrderMark;
}
@ -2042,10 +2042,10 @@ static PRBool DetectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS
// 3C 00 XX 00
if(IsSecondMarker(aBytes[2])) {
// 3C 00 SM 00 UTF-16, little-endian, no Byte Order Mark
oCharset.AssignWithConversion(UTF16_LE);
oCharset.Assign(UTF16_LE);
} else if((0x00==aBytes[2])) {
// 3C 00 00 00 UCS-4, little-endian machine (4321 order)
oCharset.AssignWithConversion(UCS4_LE);
oCharset.Assign(UCS4_LE);
}
oCharsetSource = kCharsetFromByteOrderMark;
// For html, meta tag detector is invoked before this so that we have
@ -2115,7 +2115,7 @@ static PRBool DetectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS
// encoding value is invalid if it is UTF-16
if (count > 0 &&
(0 != PL_strcmp("UTF-16", (char*)(aBytes+encStart)))) {
oCharset.AssignWithConversion((char*)(aBytes+encStart),count);
oCharset.Assign((char*)(aBytes+encStart),count);
oCharsetSource = kCharsetFromMetaTag;
}
encodingFound = PR_TRUE;
@ -2135,7 +2135,7 @@ static PRBool DetectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS
if((0xBB==aBytes[1]) && (0xBF==aBytes[2])) {
// EF BB BF
// Win2K UTF-8 BOM
oCharset.AssignWithConversion(UTF8);
oCharset.Assign(UTF8);
oCharsetSource= kCharsetFromByteOrderMark;
}
break;
@ -2143,10 +2143,10 @@ static PRBool DetectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS
if(0xFF==aBytes[1]) {
if(0x00==aBytes[2] && 0x00==aBytes[3]) {
// FE FF 00 00 UCS-4, unusual octet order (3412)
oCharset.AssignWithConversion(UCS4_3412);
oCharset.Assign(UCS4_3412);
} else {
// FE FF UTF-16, big-endian
oCharset.AssignWithConversion(UTF16_BE);
oCharset.Assign(UTF16_BE);
}
oCharsetSource= kCharsetFromByteOrderMark;
}
@ -2155,11 +2155,11 @@ static PRBool DetectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS
if(0xFE==aBytes[1]) {
if(0x00==aBytes[2] && 0x00==aBytes[3])
// FF FE 00 00 UTF-32, little-endian
oCharset.AssignWithConversion(UCS4_LE);
oCharset.Assign(UCS4_LE);
else
// FF FE
// UTF-16, little-endian
oCharset.AssignWithConversion(UTF16_LE);
oCharset.Assign(UTF16_LE);
oCharsetSource= kCharsetFromByteOrderMark;
}
break;
@ -2181,7 +2181,7 @@ inline const char GetNextChar(nsACString::const_iterator& aStart,
PRBool
nsParser::DetectMetaTag(const char* aBytes,
PRInt32 aLen,
nsString& aCharset,
nsCString& aCharset,
PRInt32& aCharsetSource)
{
aCharsetSource= kCharsetFromMetaTag;
@ -2280,7 +2280,7 @@ nsParser::DetectMetaTag(const char* aBytes,
// return true if we successfully got something for charset
if (currPos != tokEnd) {
aCharset.Assign(NS_ConvertASCIItoUCS2(currPos.get(), tokEnd.get() - currPos.get()));
aCharset.Assign(currPos.get(), tokEnd.get() - currPos.get());
return PR_TRUE;
}
@ -2324,7 +2324,7 @@ ParserWriteFunc(nsIInputStream* in,
if(pws->mNeedCharsetCheck) {
PRInt32 guessSource;
nsAutoString guess;
nsCAutoString guess;
nsCAutoString preferred;
pws->mNeedCharsetCheck = PR_FALSE;
@ -2334,7 +2334,7 @@ ParserWriteFunc(nsIInputStream* in,
DetectByteOrderMark((const unsigned char*)buf,
theNumRead, guess, guessSource))) {
nsCOMPtr<nsICharsetAlias> alias(do_GetService(NS_CHARSETALIAS_CONTRACTID));
result = alias->GetPreferred(NS_LossyConvertUCS2toASCII(guess), preferred);
result = alias->GetPreferred(guess, preferred);
// Only continue if it's a recognized charset and not
// one of a designated set that we ignore.
if (NS_SUCCEEDED(result) &&
@ -2344,9 +2344,9 @@ ParserWriteFunc(nsIInputStream* in,
!preferred.Equals(NS_LITERAL_CSTRING("UTF-16LE")) &&
!preferred.Equals(NS_LITERAL_CSTRING("UTF-32BE")) &&
!preferred.Equals(NS_LITERAL_CSTRING("UTF-32LE"))))) {
guess.Assign(NS_ConvertASCIItoUCS2(preferred));
guess = preferred;
pws->mParser->SetDocumentCharset(guess, guessSource);
pws->mParser->SetSinkCharset(guess);
pws->mParser->SetSinkCharset(preferred);
nsCOMPtr<nsICachingChannel> channel(do_QueryInterface(pws->mRequest));
if (channel) {
nsCOMPtr<nsISupports> cacheToken;
@ -2358,7 +2358,7 @@ ParserWriteFunc(nsIInputStream* in,
nsresult rv =
#endif
cacheDescriptor->SetMetaDataElement("charset",
NS_ConvertUCS2toUTF8(guess).get());
guess.get());
NS_ASSERTION(NS_SUCCEEDED(rv),"cannot SetMetaDataElement");
}
}

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

@ -160,9 +160,9 @@ class nsParser : public nsIParser,
* @param aCharsetSource- the source of the charset
* @return nada
*/
NS_IMETHOD_(void) SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource);
NS_IMETHOD_(void) SetDocumentCharset(const nsACString& aCharset, PRInt32 aSource);
NS_IMETHOD_(void) GetDocumentCharset(nsAString& aCharset, PRInt32& aSource)
NS_IMETHOD_(void) GetDocumentCharset(nsACString& aCharset, PRInt32& aSource)
{
aCharset = mCharset;
aSource = mCharsetSource;
@ -330,10 +330,10 @@ class nsParser : public nsIParser,
*/
PRBool DetectMetaTag(const char* aBytes,
PRInt32 aLen,
nsString& oCharset,
nsCString& oCharset,
PRInt32& oCharsetSource);
void SetSinkCharset(nsAString& aCharset);
void SetSinkCharset(nsACString& aCharset);
/**
* Removes continue parsing events
@ -453,7 +453,7 @@ protected:
PRUint16 mFlags;
nsString mUnusedInput;
nsString mCharset;
nsCString mCharset;
nsString mCommandStr;

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

@ -108,7 +108,7 @@ MOZ_DECL_CTOR_COUNTER(nsScanner)
* @param aMode represents the parser mode (nav, other)
* @return
*/
nsScanner::nsScanner(const nsAString& anHTMLString, const nsString& aCharset, PRInt32 aSource)
nsScanner::nsScanner(const nsAString& anHTMLString, const nsACString& aCharset, PRInt32 aSource)
{
MOZ_COUNT_CTOR(nsScanner);
@ -134,7 +134,7 @@ nsScanner::nsScanner(const nsAString& anHTMLString, const nsString& aCharset, PR
* @param aFilename --
* @return
*/
nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream, const nsString& aCharset, PRInt32 aSource) :
nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream, const nsACString& aCharset, PRInt32 aSource) :
mFilename(aFilename)
{
MOZ_COUNT_CTOR(nsScanner);
@ -173,7 +173,7 @@ nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream, const nsString& a
* @param aFilename --
* @return
*/
nsScanner::nsScanner(const nsAString& aFilename,nsIInputStream* aStream,const nsString& aCharset, PRInt32 aSource) :
nsScanner::nsScanner(const nsAString& aFilename,nsIInputStream* aStream,const nsACString& aCharset, PRInt32 aSource) :
mFilename(aFilename)
{
MOZ_COUNT_CTOR(nsScanner);
@ -195,7 +195,7 @@ nsScanner::nsScanner(const nsAString& aFilename,nsIInputStream* aStream,const ns
}
nsresult nsScanner::SetDocumentCharset(const nsAString& aCharset , PRInt32 aSource) {
nsresult nsScanner::SetDocumentCharset(const nsACString& aCharset , PRInt32 aSource) {
nsresult res = NS_OK;
@ -204,17 +204,17 @@ nsresult nsScanner::SetDocumentCharset(const nsAString& aCharset , PRInt32 aSour
nsCOMPtr<nsICharsetAlias> calias(do_GetService(kCharsetAliasCID, &res));
NS_ASSERTION( nsnull != calias, "cannot find charset alias");
nsCAutoString charsetName = NS_LossyConvertUCS2toASCII(aCharset);
if( NS_SUCCEEDED(res) && (nsnull != calias))
{
PRBool same = PR_FALSE;
res = calias->Equals(charsetName, mCharset, &same);
res = calias->Equals(aCharset, mCharset, &same);
if(NS_SUCCEEDED(res) && same)
{
return NS_OK; // no difference, don't change it
}
// different, need to change it
res = calias->GetPreferred(charsetName, charsetName);
nsCAutoString charsetName;
res = calias->GetPreferred(aCharset, charsetName);
if(NS_FAILED(res) && (kCharsetUninitialized == mCharsetSource) )
{

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

@ -95,7 +95,7 @@ class nsScanner {
* @param aMode represents the parser mode (nav, other)
* @return
*/
nsScanner(const nsAString& anHTMLString, const nsString& aCharset, PRInt32 aSource);
nsScanner(const nsAString& anHTMLString, const nsACString& aCharset, PRInt32 aSource);
/**
* Use this constructor if you want i/o to be based on
@ -107,7 +107,7 @@ class nsScanner {
* @param aMode represents the parser mode (nav, other)
* @return
*/
nsScanner(nsString& aFilename,PRBool aCreateStream, const nsString& aCharset, PRInt32 aSource);
nsScanner(nsString& aFilename,PRBool aCreateStream, const nsACString& aCharset, PRInt32 aSource);
/**
* Use this constructor if you want i/o to be stream based.
@ -118,7 +118,7 @@ class nsScanner {
* @param aMode represents the parser mode (nav, other)
* @return
*/
nsScanner(const nsAString& aFilename, nsIInputStream* aStream, const nsString& aCharset, PRInt32 aSource);
nsScanner(const nsAString& aFilename, nsIInputStream* aStream, const nsACString& aCharset, PRInt32 aSource);
~nsScanner();
@ -346,7 +346,7 @@ class nsScanner {
* @param aCharsetSource- where the charset info came from
* @return
*/
nsresult SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource);
nsresult SetDocumentCharset(const nsACString& aCharset, PRInt32 aSource);
void BindSubstring(nsSlidingSubstring& aSubstring, const nsReadingIterator<PRUnichar>& aStart, const nsReadingIterator<PRUnichar>& aEnd);
void CurrentPosition(nsReadingIterator<PRUnichar>& aPosition);

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

@ -65,6 +65,6 @@ public:
*/
NS_IMETHOD Init(nsIWebShellServices* aWebShell, nsICharsetDetector *aDetector,
nsIDocument* aDocument, nsIParser* aParser,
const PRUnichar* aCharset, const char* aCommand=nsnull) = 0;
const char* aCharset, const char* aCommand=nsnull) = 0;
};
#endif /* nsICDETAdaptor_h__ */

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

@ -80,7 +80,7 @@ interface nsIDocCharset : nsISupports
*
* A force also sets the fallback encoding for this frame.
*/
attribute wstring charset;
attribute string charset;
};

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

@ -55,7 +55,7 @@ NS_IMETHODIMP nsMyObserver::Notify(
nsresult rv = NS_OK;
if(mWeakRefParser) {
nsAutoString existingCharset;
nsCAutoString existingCharset;
PRInt32 existingSource;
mWeakRefParser->GetDocumentCharset(existingCharset, existingSource);
if (existingSource >= kCharsetFromAutoDetection)
@ -68,7 +68,7 @@ NS_IMETHODIMP nsMyObserver::Notify(
rv = mWebShellSvc->StopDocumentLoad();
rv = mWebShellSvc->ReloadDocument(aCharset, kCharsetFromAutoDetection);
} else {
nsAutoString newcharset; newcharset.AssignWithConversion(aCharset);
nsDependentCString newcharset(aCharset);
if (mWeakRefParser) {
mWeakRefParser->SetDocumentCharset(newcharset, kCharsetFromAutoDetection);
nsCOMPtr<nsIContentSink> contentSink = mWeakRefParser->GetContentSink();
@ -85,7 +85,7 @@ NS_IMETHODIMP nsMyObserver::Notify(
NS_IMETHODIMP nsMyObserver::Init( nsIWebShellServices* aWebShellSvc,
nsIDocument* aDocument,
nsIParser* aParser,
const PRUnichar* aCharset,
const char* aCharset,
const char* aCommand)
{
if(aCommand) {
@ -126,7 +126,7 @@ NS_IMPL_ISUPPORTS2 (nsDetectionAdaptor, nsIParserFilter, nsICharsetDetectionAdap
//--------------------------------------------------------------
NS_IMETHODIMP nsDetectionAdaptor::Init(
nsIWebShellServices* aWebShellSvc, nsICharsetDetector *aDetector,
nsIDocument* aDocument, nsIParser* aParser, const PRUnichar* aCharset,
nsIDocument* aDocument, nsIParser* aParser, const char* aCharset,
const char* aCommand)
{
if((nsnull != aWebShellSvc) && (nsnull != aDetector) && (nsnull != aCharset))

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

@ -72,7 +72,7 @@ class nsMyObserver : public nsICharsetDetectionObserver
NS_IMETHOD Init(nsIWebShellServices* aWebShellSvc,
nsIDocument* aDocument,
nsIParser* aParser,
const PRUnichar* aCharset,
const char* aCharset,
const char* aCommand);
// Methods to support nsICharsetDetectionObserver
@ -92,7 +92,7 @@ class nsMyObserver : public nsICharsetDetectionObserver
//detector outlives parser, we might want to change weak reference here.
nsIDocument* mWeakRefDocument;
nsIParser* mWeakRefParser;
nsAutoString mCharset;
nsCAutoString mCharset;
nsCAutoString mCommand;
};
@ -111,7 +111,7 @@ class nsDetectionAdaptor :
NS_IMETHOD Init(nsIWebShellServices* aWebShellSvc, nsICharsetDetector *aDetector,
nsIDocument* aDocument,
nsIParser* aParser,
const PRUnichar* aCharset,
const char* aCharset,
const char* aCommand=nsnull);
// Methode to suppor nsIParserFilter

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

@ -447,18 +447,19 @@ protected:
#endif // NS_DEBUG
#endif // NS_PRINTING
/* character set member data */
PRInt32 mHintCharsetSource;
nsCString mHintCharset;
nsCString mDefaultCharacterSet;
nsCString mForceCharacterSet;
nsCString mPrevDocCharacterSet;
// document management data
// these items are specific to markup documents (html and xml)
// may consider splitting these out into a subclass
PRPackedBool mAllowPlugins;
PRPackedBool mIsSticky;
/* character set member data */
nsString mDefaultCharacterSet;
nsString mHintCharset;
PRInt32 mHintCharsetSource;
nsString mForceCharacterSet;
nsString mPrevDocCharacterSet;
};
//------------------------------------------------------------------
@ -2322,9 +2323,8 @@ NS_IMETHODIMP DocumentViewerImpl::GetTextZoom(float* aTextZoom)
// XXX: SEMANTIC CHANGE!
// returns a copy of the string. Caller is responsible for freeing result
// using Recycle(aDefaultCharacterSet)
NS_IMETHODIMP DocumentViewerImpl::GetDefaultCharacterSet(PRUnichar** aDefaultCharacterSet)
NS_IMETHODIMP DocumentViewerImpl::GetDefaultCharacterSet(nsACString& aDefaultCharacterSet)
{
NS_ENSURE_ARG_POINTER(aDefaultCharacterSet);
NS_ENSURE_STATE(mContainer);
if (mDefaultCharacterSet.IsEmpty())
@ -2348,69 +2348,64 @@ NS_IMETHODIMP DocumentViewerImpl::GetDefaultCharacterSet(PRUnichar** aDefaultCha
}
if (!defCharset.IsEmpty())
mDefaultCharacterSet.Assign(defCharset.get());
CopyUCS2toASCII(defCharset, mDefaultCharacterSet);
else
mDefaultCharacterSet.Assign(NS_LITERAL_STRING("ISO-8859-1"));
mDefaultCharacterSet.Assign(NS_LITERAL_CSTRING("ISO-8859-1"));
}
*aDefaultCharacterSet = ToNewUnicode(mDefaultCharacterSet);
aDefaultCharacterSet = mDefaultCharacterSet;
return NS_OK;
}
static void
SetChildDefaultCharacterSet(nsIMarkupDocumentViewer* aChild, void* aClosure)
{
aChild->SetDefaultCharacterSet((PRUnichar*) aClosure);
const nsACString* charset = NS_STATIC_CAST(nsACString*, aClosure);
aChild->SetDefaultCharacterSet(*charset);
}
NS_IMETHODIMP DocumentViewerImpl::SetDefaultCharacterSet(const PRUnichar* aDefaultCharacterSet)
NS_IMETHODIMP
DocumentViewerImpl::SetDefaultCharacterSet(const nsACString& aDefaultCharacterSet)
{
mDefaultCharacterSet = aDefaultCharacterSet; // this does a copy of aDefaultCharacterSet
// now set the default char set on all children of mContainer
return CallChildren(SetChildDefaultCharacterSet,
(void*) aDefaultCharacterSet);
(void*) &aDefaultCharacterSet);
}
// XXX: SEMANTIC CHANGE!
// returns a copy of the string. Caller is responsible for freeing result
// using Recycle(aForceCharacterSet)
NS_IMETHODIMP DocumentViewerImpl::GetForceCharacterSet(PRUnichar** aForceCharacterSet)
NS_IMETHODIMP DocumentViewerImpl::GetForceCharacterSet(nsACString& aForceCharacterSet)
{
NS_ENSURE_ARG_POINTER(aForceCharacterSet);
nsAutoString emptyStr;
if (mForceCharacterSet.Equals(emptyStr)) {
*aForceCharacterSet = nsnull;
}
else {
*aForceCharacterSet = ToNewUnicode(mForceCharacterSet);
}
aForceCharacterSet = mForceCharacterSet;
return NS_OK;
}
static void
SetChildForceCharacterSet(nsIMarkupDocumentViewer* aChild, void* aClosure)
{
aChild->SetForceCharacterSet((PRUnichar*) aClosure);
const nsACString* charset = NS_STATIC_CAST(nsACString*, aClosure);
aChild->SetForceCharacterSet(*charset);
}
NS_IMETHODIMP DocumentViewerImpl::SetForceCharacterSet(const PRUnichar* aForceCharacterSet)
NS_IMETHODIMP
DocumentViewerImpl::SetForceCharacterSet(const nsACString& aForceCharacterSet)
{
mForceCharacterSet = aForceCharacterSet;
// now set the force char set on all children of mContainer
return CallChildren(SetChildForceCharacterSet, (void*) aForceCharacterSet);
return CallChildren(SetChildForceCharacterSet, (void*) &aForceCharacterSet);
}
// XXX: SEMANTIC CHANGE!
// returns a copy of the string. Caller is responsible for freeing result
// using Recycle(aHintCharacterSet)
NS_IMETHODIMP DocumentViewerImpl::GetHintCharacterSet(PRUnichar * *aHintCharacterSet)
NS_IMETHODIMP DocumentViewerImpl::GetHintCharacterSet(nsACString& aHintCharacterSet)
{
NS_ENSURE_ARG_POINTER(aHintCharacterSet);
if(kCharsetUninitialized == mHintCharsetSource) {
*aHintCharacterSet = nsnull;
aHintCharacterSet.Truncate();
} else {
*aHintCharacterSet = ToNewUnicode(mHintCharset);
aHintCharacterSet = mHintCharset;
// this can't possibly be right. we can't set a value just because somebody got a related value!
//mHintCharsetSource = kCharsetUninitialized;
}
@ -2426,11 +2421,9 @@ NS_IMETHODIMP DocumentViewerImpl::GetHintCharacterSetSource(PRInt32 *aHintCharac
}
NS_IMETHODIMP DocumentViewerImpl::GetPrevDocCharacterSet(PRUnichar * *aPrevDocCharacterSet)
NS_IMETHODIMP DocumentViewerImpl::GetPrevDocCharacterSet(nsACString& aPrevDocCharacterSet)
{
NS_ENSURE_ARG_POINTER(aPrevDocCharacterSet);
*aPrevDocCharacterSet = ToNewUnicode(mPrevDocCharacterSet);
aPrevDocCharacterSet = mPrevDocCharacterSet;
return NS_OK;
}
@ -2438,15 +2431,17 @@ NS_IMETHODIMP DocumentViewerImpl::GetPrevDocCharacterSet(PRUnichar * *aPrevDocCh
static void
SetChildPrevDocCharacterSet(nsIMarkupDocumentViewer* aChild, void* aClosure)
{
aChild->SetPrevDocCharacterSet((PRUnichar*) aClosure);
const nsACString* charset = NS_STATIC_CAST(nsACString*, aClosure);
aChild->SetPrevDocCharacterSet(*charset);
}
NS_IMETHODIMP DocumentViewerImpl::SetPrevDocCharacterSet(const PRUnichar* aPrevDocCharacterSet)
NS_IMETHODIMP
DocumentViewerImpl::SetPrevDocCharacterSet(const nsACString& aPrevDocCharacterSet)
{
mPrevDocCharacterSet = aPrevDocCharacterSet;
return CallChildren(SetChildPrevDocCharacterSet,
(void*) aPrevDocCharacterSet);
(void*) &aPrevDocCharacterSet);
}
@ -2456,7 +2451,8 @@ SetChildHintCharacterSetSource(nsIMarkupDocumentViewer* aChild, void* aClosure)
aChild->SetHintCharacterSetSource(NS_PTR_TO_INT32(aClosure));
}
NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSetSource(PRInt32 aHintCharacterSetSource)
NS_IMETHODIMP
DocumentViewerImpl::SetHintCharacterSetSource(PRInt32 aHintCharacterSetSource)
{
mHintCharsetSource = aHintCharacterSetSource;
// now set the hint char set source on all children of mContainer
@ -2467,14 +2463,16 @@ NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSetSource(PRInt32 aHintCharact
static void
SetChildHintCharacterSet(nsIMarkupDocumentViewer* aChild, void* aClosure)
{
aChild->SetHintCharacterSet((PRUnichar*) aClosure);
const nsACString* charset = NS_STATIC_CAST(nsACString*, aClosure);
aChild->SetHintCharacterSet(*charset);
}
NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSet(const PRUnichar* aHintCharacterSet)
NS_IMETHODIMP
DocumentViewerImpl::SetHintCharacterSet(const nsACString& aHintCharacterSet)
{
mHintCharset = aHintCharacterSet;
// now set the hint char set on all children of mContainer
return CallChildren(SetChildHintCharacterSet, (void*) aHintCharacterSet);
return CallChildren(SetChildHintCharacterSet, (void*) &aHintCharacterSet);
}
static void

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

@ -109,7 +109,7 @@ nsPresContext::PrefChangedCallback(const char* aPrefName, void* instance_data)
#ifdef IBMBIDI
PRBool
IsVisualCharset(const nsAutoString& aCharset)
IsVisualCharset(const nsCAutoString& aCharset)
{
if (aCharset.EqualsIgnoreCase("ibm864") // Arabic//ahmed
|| aCharset.EqualsIgnoreCase("ibm862") // Hebrew
@ -683,7 +683,7 @@ nsPresContext::SetShell(nsIPresShell* aShell)
}
if (mLangService) {
nsAutoString charset;
nsCAutoString charset;
doc->AddCharSetObserver(this);
doc->GetDocumentCharacterSet(charset);
UpdateCharSet(charset.get());
@ -704,10 +704,10 @@ nsPresContext::GetShell(nsIPresShell** aResult)
}
void
nsPresContext::UpdateCharSet(const PRUnichar* aCharSet)
nsPresContext::UpdateCharSet(const char* aCharSet)
{
if (mLangService) {
mLangService->LookupCharSet(NS_LossyConvertUCS2toASCII(aCharSet).get(),
mLangService->LookupCharSet(aCharSet,
getter_AddRefs(mLanguage));
GetFontPreferences();
if (mLanguage) {
@ -742,7 +742,7 @@ nsPresContext::Observe(nsISupports* aSubject,
const PRUnichar* aData)
{
if (!nsCRT::strcmp(aTopic, "charset")) {
UpdateCharSet(aData);
UpdateCharSet(NS_LossyConvertUCS2toASCII(aData).get());
if (mDeviceContext) {
mDeviceContext->FlushFontCache();
ClearStyleDataAndReflow();
@ -1641,7 +1641,7 @@ nsPresContext::GetIsBidiSystem(PRBool& aResult) const
}
NS_IMETHODIMP
nsPresContext::GetBidiCharset(nsAString &aCharSet) const
nsPresContext::GetBidiCharset(nsACString &aCharSet) const
{
aCharSet = mCharset;
return NS_OK;

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

@ -503,7 +503,7 @@ public:
/**
* Get the document charset
*/
NS_IMETHOD GetBidiCharset(nsAString &aCharSet) const = 0;
NS_IMETHOD GetBidiCharset(nsACString &aCharSet) const = 0;
#endif // IBMBIDI

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

@ -503,7 +503,7 @@ public:
/**
* Get the document charset
*/
NS_IMETHOD GetBidiCharset(nsAString &aCharSet) const = 0;
NS_IMETHOD GetBidiCharset(nsACString &aCharSet) const = 0;
#endif // IBMBIDI

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

@ -503,7 +503,7 @@ public:
/**
* Get the document charset
*/
NS_IMETHOD GetBidiCharset(nsAString &aCharSet) const = 0;
NS_IMETHOD GetBidiCharset(nsACString &aCharSet) const = 0;
#endif // IBMBIDI

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

@ -178,7 +178,7 @@ nsresult nsCopySupport::HTMLCopy(nsISelection *aSel, nsIDocument *aDoc, PRInt16
}
//Mohamed
else {
nsAutoString bidiCharset;
nsCAutoString bidiCharset;
context->GetBidiCharset(bidiCharset);
if (bidiCharset.EqualsIgnoreCase("UTF-8") || (!isVisual)) {
if ( (GET_BIDI_OPTION_CLIPBOARDTEXTMODE(bidiOptions) == IBMBIDI_CLIPBOARDTEXTMODE_VISUAL) || (!isBidiSystem) ) {

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

@ -109,7 +109,7 @@ nsPresContext::PrefChangedCallback(const char* aPrefName, void* instance_data)
#ifdef IBMBIDI
PRBool
IsVisualCharset(const nsAutoString& aCharset)
IsVisualCharset(const nsCAutoString& aCharset)
{
if (aCharset.EqualsIgnoreCase("ibm864") // Arabic//ahmed
|| aCharset.EqualsIgnoreCase("ibm862") // Hebrew
@ -683,7 +683,7 @@ nsPresContext::SetShell(nsIPresShell* aShell)
}
if (mLangService) {
nsAutoString charset;
nsCAutoString charset;
doc->AddCharSetObserver(this);
doc->GetDocumentCharacterSet(charset);
UpdateCharSet(charset.get());
@ -704,10 +704,10 @@ nsPresContext::GetShell(nsIPresShell** aResult)
}
void
nsPresContext::UpdateCharSet(const PRUnichar* aCharSet)
nsPresContext::UpdateCharSet(const char* aCharSet)
{
if (mLangService) {
mLangService->LookupCharSet(NS_LossyConvertUCS2toASCII(aCharSet).get(),
mLangService->LookupCharSet(aCharSet,
getter_AddRefs(mLanguage));
GetFontPreferences();
if (mLanguage) {
@ -742,7 +742,7 @@ nsPresContext::Observe(nsISupports* aSubject,
const PRUnichar* aData)
{
if (!nsCRT::strcmp(aTopic, "charset")) {
UpdateCharSet(aData);
UpdateCharSet(NS_LossyConvertUCS2toASCII(aData).get());
if (mDeviceContext) {
mDeviceContext->FlushFontCache();
ClearStyleDataAndReflow();
@ -1641,7 +1641,7 @@ nsPresContext::GetIsBidiSystem(PRBool& aResult) const
}
NS_IMETHODIMP
nsPresContext::GetBidiCharset(nsAString &aCharSet) const
nsPresContext::GetBidiCharset(nsACString &aCharSet) const
{
aCharSet = mCharset;
return NS_OK;

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

@ -192,7 +192,7 @@ public:
//Mohamed 17-1-01
NS_IMETHOD SetIsBidiSystem(PRBool aIsBidi);
NS_IMETHOD GetIsBidiSystem(PRBool &aResult) const;
NS_IMETHOD GetBidiCharset(nsAString &aCharSet) const;
NS_IMETHOD GetBidiCharset(nsACString &aCharSet) const;
//Mohamed End
#endif // IBMBIDI
@ -276,7 +276,7 @@ protected:
#ifdef IBMBIDI
nsBidiPresUtils* mBidiUtils;
PRUint32 mBidi;
nsAutoString mCharset; // the charset we are using
nsCAutoString mCharset; // the charset we are using
#endif // IBMBIDI
#ifdef DEBUG
@ -292,7 +292,7 @@ protected:
void GetUserPreferences();
void GetFontPreferences();
void GetDocumentColorPreferences();
void UpdateCharSet(const PRUnichar* aCharSet);
void UpdateCharSet(const char* aCharSet);
void SetImgAnimations(nsCOMPtr<nsIContent>& aParent, PRUint16 aMode);
private:

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

@ -466,10 +466,10 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext)
nsCOMPtr<nsIURI> actionURL;
nsXPIDLCString scheme;
PRBool isJSURL = PR_FALSE;
nsAutoString docCharset;
nsCAutoString docCharset;
document->GetDocumentCharacterSet(docCharset);
if (NS_SUCCEEDED(result = NS_NewURI(getter_AddRefs(actionURL), href,
NS_LossyConvertUCS2toASCII(docCharset).get(),
docCharset.get(),
docURL))) {
result = actionURL->SchemeIs("javascript", &isJSURL);
}
@ -486,7 +486,7 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext)
}
nsCOMPtr<nsIURI> uri;
result = NS_NewURI(getter_AddRefs(uri), href,
NS_LossyConvertUCS2toASCII(docCharset).get(), docURL);
docCharset.get(), docURL);
if (NS_FAILED(result)) return result;
// Now pass on absolute url to the click handler
@ -510,9 +510,7 @@ void nsIsIndexFrame::GetSubmitCharset(nsCString& oCharset)
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
if (doc) {
nsAutoString docCharset;
doc->GetDocumentCharacterSet(docCharset);
CopyUCS2toASCII(docCharset, oCharset);
doc->GetDocumentCharacterSet(oCharset);
}
}

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

@ -1708,13 +1708,13 @@ nsImageFrame::HandleEvent(nsIPresContext* aPresContext,
NS_ASSERTION(nodeInfo, "Image content without a nodeinfo?");
nsCOMPtr<nsIDocument> doc;
nodeInfo->GetDocument(getter_AddRefs(doc));
nsAutoString charset;
nsCAutoString charset;
if (doc) {
doc->GetDocumentCharacterSet(charset);
}
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), src,
NS_LossyConvertUCS2toASCII(charset).get(),
charset.get(),
baseURL);
NS_ENSURE_SUCCESS(rv, rv);
@ -1895,7 +1895,7 @@ nsImageFrame::LoadIcon(const nsAString& aSpec,
}
void
nsImageFrame::GetDocumentCharacterSet(nsAString& aCharset) const
nsImageFrame::GetDocumentCharacterSet(nsACString& aCharset) const
{
nsresult rv;
nsCOMPtr<nsIHTMLContent> htmlContent(do_QueryInterface(mContent, &rv));
@ -1913,10 +1913,10 @@ nsImageFrame::SpecToURI(const nsAString& aSpec, nsIIOService *aIOService,
{
nsCOMPtr<nsIURI> baseURI;
GetBaseURI(getter_AddRefs(baseURI));
nsAutoString charset;
nsCAutoString charset;
GetDocumentCharacterSet(charset);
NS_NewURI(aURI, aSpec,
charset.IsEmpty() ? nsnull : NS_ConvertUCS2toUTF8(charset).get(),
charset.IsEmpty() ? nsnull : charset.get(),
baseURI, aIOService);
}

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

@ -204,7 +204,7 @@ private:
inline void GetLoadGroup(nsIPresContext *aPresContext,
nsILoadGroup **aLoadGroup);
nscoord GetContinuationOffset(nscoord* aWidth = 0) const;
void GetDocumentCharacterSet(nsAString& aCharset) const;
void GetDocumentCharacterSet(nsACString& aCharset) const;
/**
* This function will recalculate mTransform. If a non-null image

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

@ -979,11 +979,11 @@ nsObjectFrame::MakeAbsoluteURL(nsIURI* *aFullURI,
aSrc.Trim(" \n\r\t\b", PR_TRUE, PR_TRUE, PR_FALSE);
// get document charset
nsAutoString originCharset;
nsCAutoString originCharset;
if (document && NS_FAILED(document->GetDocumentCharacterSet(originCharset)))
originCharset.Truncate();
return NS_NewURI(aFullURI, aSrc, NS_LossyConvertUCS2toASCII(originCharset).get(),
return NS_NewURI(aFullURI, aSrc, originCharset.get(),
aBaseURI, nsHTMLUtils::IOService);
}
@ -2736,7 +2736,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result)
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get document");
if (NS_FAILED(rv)) return rv;
nsString charset;
nsCAutoString charset;
rv = doc->GetDocumentCharacterSet(charset);
NS_ASSERTION(NS_SUCCEEDED(rv), "can't get charset");
if (NS_FAILED(rv)) return rv;
@ -2744,11 +2744,11 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result)
if (charset.IsEmpty()) return NS_OK;
// common charsets and those not requiring conversion first
if (charset == NS_LITERAL_STRING("us-acsii")) {
if (charset == NS_LITERAL_CSTRING("us-acsii")) {
*result = PL_strdup("US_ASCII");
} else if (charset == NS_LITERAL_STRING("ISO-8859-1") ||
!nsCRT::strncmp(charset.get(), NS_LITERAL_STRING("UTF").get(), 3)) {
*result = ToNewUTF8String(charset);
} else if (charset == NS_LITERAL_CSTRING("ISO-8859-1") ||
!nsCRT::strncmp(charset.get(), "UTF", 3)) {
*result = ToNewCString(charset);
} else {
if (!gCharsetMap) {
gCharsetMap = new nsHashtable(sizeof(charsets)/sizeof(moz2javaCharset));
@ -2759,10 +2759,10 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result)
gCharsetMap->Put(&key, (void *)(charsets[i].javaName));
}
}
nsCStringKey mozKey(NS_LossyConvertUCS2toASCII(charset).get());
nsCStringKey mozKey(charset);
// if found mapping, return it; otherwise return original charset
char *mapping = (char *)gCharsetMap->Get(&mozKey);
*result = mapping ? PL_strdup(mapping) : ToNewUTF8String(charset);
*result = mapping ? PL_strdup(mapping) : ToNewCString(charset);
}
return (*result) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;

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

@ -1708,13 +1708,13 @@ nsImageFrame::HandleEvent(nsIPresContext* aPresContext,
NS_ASSERTION(nodeInfo, "Image content without a nodeinfo?");
nsCOMPtr<nsIDocument> doc;
nodeInfo->GetDocument(getter_AddRefs(doc));
nsAutoString charset;
nsCAutoString charset;
if (doc) {
doc->GetDocumentCharacterSet(charset);
}
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), src,
NS_LossyConvertUCS2toASCII(charset).get(),
charset.get(),
baseURL);
NS_ENSURE_SUCCESS(rv, rv);
@ -1895,7 +1895,7 @@ nsImageFrame::LoadIcon(const nsAString& aSpec,
}
void
nsImageFrame::GetDocumentCharacterSet(nsAString& aCharset) const
nsImageFrame::GetDocumentCharacterSet(nsACString& aCharset) const
{
nsresult rv;
nsCOMPtr<nsIHTMLContent> htmlContent(do_QueryInterface(mContent, &rv));
@ -1913,10 +1913,10 @@ nsImageFrame::SpecToURI(const nsAString& aSpec, nsIIOService *aIOService,
{
nsCOMPtr<nsIURI> baseURI;
GetBaseURI(getter_AddRefs(baseURI));
nsAutoString charset;
nsCAutoString charset;
GetDocumentCharacterSet(charset);
NS_NewURI(aURI, aSpec,
charset.IsEmpty() ? nsnull : NS_ConvertUCS2toUTF8(charset).get(),
charset.IsEmpty() ? nsnull : charset.get(),
baseURI, aIOService);
}

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

@ -204,7 +204,7 @@ private:
inline void GetLoadGroup(nsIPresContext *aPresContext,
nsILoadGroup **aLoadGroup);
nscoord GetContinuationOffset(nscoord* aWidth = 0) const;
void GetDocumentCharacterSet(nsAString& aCharset) const;
void GetDocumentCharacterSet(nsACString& aCharset) const;
/**
* This function will recalculate mTransform. If a non-null image

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

@ -979,11 +979,11 @@ nsObjectFrame::MakeAbsoluteURL(nsIURI* *aFullURI,
aSrc.Trim(" \n\r\t\b", PR_TRUE, PR_TRUE, PR_FALSE);
// get document charset
nsAutoString originCharset;
nsCAutoString originCharset;
if (document && NS_FAILED(document->GetDocumentCharacterSet(originCharset)))
originCharset.Truncate();
return NS_NewURI(aFullURI, aSrc, NS_LossyConvertUCS2toASCII(originCharset).get(),
return NS_NewURI(aFullURI, aSrc, originCharset.get(),
aBaseURI, nsHTMLUtils::IOService);
}
@ -2736,7 +2736,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result)
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get document");
if (NS_FAILED(rv)) return rv;
nsString charset;
nsCAutoString charset;
rv = doc->GetDocumentCharacterSet(charset);
NS_ASSERTION(NS_SUCCEEDED(rv), "can't get charset");
if (NS_FAILED(rv)) return rv;
@ -2744,11 +2744,11 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result)
if (charset.IsEmpty()) return NS_OK;
// common charsets and those not requiring conversion first
if (charset == NS_LITERAL_STRING("us-acsii")) {
if (charset == NS_LITERAL_CSTRING("us-acsii")) {
*result = PL_strdup("US_ASCII");
} else if (charset == NS_LITERAL_STRING("ISO-8859-1") ||
!nsCRT::strncmp(charset.get(), NS_LITERAL_STRING("UTF").get(), 3)) {
*result = ToNewUTF8String(charset);
} else if (charset == NS_LITERAL_CSTRING("ISO-8859-1") ||
!nsCRT::strncmp(charset.get(), "UTF", 3)) {
*result = ToNewCString(charset);
} else {
if (!gCharsetMap) {
gCharsetMap = new nsHashtable(sizeof(charsets)/sizeof(moz2javaCharset));
@ -2759,10 +2759,10 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result)
gCharsetMap->Put(&key, (void *)(charsets[i].javaName));
}
}
nsCStringKey mozKey(NS_LossyConvertUCS2toASCII(charset).get());
nsCStringKey mozKey(charset);
// if found mapping, return it; otherwise return original charset
char *mapping = (char *)gCharsetMap->Get(&mozKey);
*result = mapping ? PL_strdup(mapping) : ToNewUTF8String(charset);
*result = mapping ? PL_strdup(mapping) : ToNewCString(charset);
}
return (*result) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;

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

@ -466,10 +466,10 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext)
nsCOMPtr<nsIURI> actionURL;
nsXPIDLCString scheme;
PRBool isJSURL = PR_FALSE;
nsAutoString docCharset;
nsCAutoString docCharset;
document->GetDocumentCharacterSet(docCharset);
if (NS_SUCCEEDED(result = NS_NewURI(getter_AddRefs(actionURL), href,
NS_LossyConvertUCS2toASCII(docCharset).get(),
docCharset.get(),
docURL))) {
result = actionURL->SchemeIs("javascript", &isJSURL);
}
@ -486,7 +486,7 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext)
}
nsCOMPtr<nsIURI> uri;
result = NS_NewURI(getter_AddRefs(uri), href,
NS_LossyConvertUCS2toASCII(docCharset).get(), docURL);
docCharset.get(), docURL);
if (NS_FAILED(result)) return result;
// Now pass on absolute url to the click handler
@ -510,9 +510,7 @@ void nsIsIndexFrame::GetSubmitCharset(nsCString& oCharset)
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
if (doc) {
nsAutoString docCharset;
doc->GetDocumentCharacterSet(docCharset);
CopyUCS2toASCII(docCharset, oCharset);
doc->GetDocumentCharacterSet(oCharset);
}
}

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

@ -633,9 +633,7 @@ SheetLoadData::OnDetermineCharset(nsIUnicharStreamLoader* aLoader,
if (NS_FAILED(result) && mLoader->mDocument) {
// no useful data on charset. Try the document charset.
// That needs no resolution, since it's already fully resolved
nsAutoString docCharset;
mLoader->mDocument->GetDocumentCharacterSet(docCharset);
CopyUCS2toASCII(docCharset, charset);
mLoader->mDocument->GetDocumentCharacterSet(charset);
#ifdef DEBUG_bzbarsky
fprintf(stderr, "Set from document: %s\n",
charset.get());

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

@ -55,7 +55,7 @@ interface nsIMessenger : nsISupports {
const long eMoveMsg = 2;
const long eCopyMsg = 3;
void setDisplayCharset(in wstring aCharset);
void setDisplayCharset(in string aCharset);
readonly attribute nsITransactionManager transactionManager;

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

@ -408,7 +408,7 @@ nsMessenger::SetWindow(nsIDOMWindowInternal *aWin, nsIMsgWindow *aMsgWindow)
return NS_OK;
}
NS_IMETHODIMP nsMessenger::SetDisplayCharset(const PRUnichar * aCharset)
NS_IMETHODIMP nsMessenger::SetDisplayCharset(const char * aCharset)
{
if (mCurrentDisplayCharset.Equals(aCharset))
return NS_OK;
@ -422,7 +422,7 @@ NS_IMETHODIMP nsMessenger::SetDisplayCharset(const PRUnichar * aCharset)
{
nsCOMPtr<nsIMarkupDocumentViewer> muDV = do_QueryInterface(cv);
if (muDV) {
muDV->SetForceCharacterSet(aCharset);
muDV->SetForceCharacterSet(nsDependentCString(aCharset));
}
@ -555,7 +555,7 @@ nsMessenger::OpenURL(const char *aURL)
NS_ENSURE_ARG_POINTER(aURL);
// This is to setup the display DocShell as UTF-8 capable...
SetDisplayCharset(NS_LITERAL_STRING("UTF-8").get());
SetDisplayCharset("UTF-8");
char *unescapedUrl = PL_strdup(aURL);
if (!unescapedUrl)
@ -594,7 +594,7 @@ nsMessenger::LoadURL(nsIDOMWindowInternal *aWin, const char *aURL)
{
NS_ENSURE_ARG_POINTER(aURL);
SetDisplayCharset(NS_LITERAL_STRING("UTF-8").get());
SetDisplayCharset("UTF-8");
nsAutoString uriString(NS_ConvertASCIItoUCS2(aURL).get());
// Cleanup the empty spaces that might be on each end.

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

@ -93,7 +93,7 @@ private:
// String bundles...
nsCOMPtr<nsIStringBundle> mStringBundle;
nsString mCurrentDisplayCharset;
nsCString mCurrentDisplayCharset;
nsCOMPtr<nsISupports> mSearchContext;
nsCString mLastDisplayURI; // this used when the user attempts to force a charset reload of a message...we need to get the last displayed

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

@ -571,7 +571,6 @@ nsMsgPrintEngine::InitializeDisplayCharset()
// libmime always converts to UTF-8 (both HTML and XML)
if (mDocShell)
{
nsAutoString aForceCharacterSet(NS_LITERAL_STRING("UTF-8"));
nsCOMPtr<nsIContentViewer> cv;
mDocShell->GetContentViewer(getter_AddRefs(cv));
if (cv)
@ -579,7 +578,7 @@ nsMsgPrintEngine::InitializeDisplayCharset()
nsCOMPtr<nsIMarkupDocumentViewer> muDV = do_QueryInterface(cv);
if (muDV)
{
muDV->SetForceCharacterSet(aForceCharacterSet.get());
muDV->SetForceCharacterSet(NS_LITERAL_CSTRING("UTF-8"));
}
}
}

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

@ -751,7 +751,7 @@ nsresult nsMsgCompose::SetDocumentCharset(const char *charset)
m_compFields->SetCharacterSet(charset);
// notify the change to editor
m_editor->SetDocumentCharacterSet(NS_ConvertASCIItoUCS2(charset));
m_editor->SetDocumentCharacterSet(nsDependentCString(charset));
return NS_OK;
}
@ -1257,9 +1257,7 @@ NS_IMETHODIMP nsMsgCompose::InitEditor(nsIEditor* aEditor, nsIDOMWindow* aConten
m_editor = aEditor;
// Set the charset
nsAutoString msgCharSet;
msgCharSet.AssignWithConversion(m_compFields->GetCharacterSet());
const nsDependentCString msgCharSet(m_compFields->GetCharacterSet());
m_editor->SetDocumentCharacterSet(msgCharSet);
nsCOMPtr<nsIScriptGlobalObject> globalObj = do_QueryInterface(m_window);
@ -1274,8 +1272,8 @@ NS_IMETHODIMP nsMsgCompose::InitEditor(nsIEditor* aEditor, nsIDOMWindow* aConten
{
nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV);
if (markupCV) {
NS_ENSURE_SUCCESS(markupCV->SetDefaultCharacterSet(msgCharSet.get()), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(markupCV->SetForceCharacterSet(msgCharSet.get()), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(markupCV->SetDefaultCharacterSet(msgCharSet), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(markupCV->SetForceCharacterSet(msgCharSet), NS_ERROR_FAILURE);
}
}

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

@ -121,7 +121,7 @@ public:
* Set the document character set. This should be passed on to the
* document itself.
*/
NS_IMETHOD SetDocumentCharset(nsAString& aCharset)=0;
NS_IMETHOD SetDocumentCharset(nsACString& aCharset)=0;
};
#endif /* nsIContentSink_h___ */

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

@ -188,8 +188,8 @@ class nsIParser : public nsISupports {
* @param aCharsetSource- the soure of the chares
* @return nada
*/
NS_IMETHOD_(void) SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource)=0;
NS_IMETHOD_(void) GetDocumentCharset(nsAString& oCharset, PRInt32& oSource)=0;
NS_IMETHOD_(void) SetDocumentCharset(const nsACString& aCharset, PRInt32 aSource)=0;
NS_IMETHOD_(void) GetDocumentCharset(nsACString& oCharset, PRInt32& oSource)=0;
NS_IMETHOD_(void) SetParserFilter(nsIParserFilter* aFilter) = 0;

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

@ -106,7 +106,7 @@ public:
NS_IMETHOD WillResume(void) { return NS_OK; }
NS_IMETHOD SetParser(nsIParser* aParser) { return NS_OK; }
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsAString& aCharset) { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
NS_IMETHOD WillProcessTokens(void) { return NS_OK; }
NS_IMETHOD DidProcessTokens(void) { return NS_OK; }
NS_IMETHOD WillProcessAToken(void) { return NS_OK; }

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

@ -1574,9 +1574,10 @@ nsObserverEntry::Notify(nsIParserNode* aNode,
if (theTag <= NS_HTML_TAG_MAX) {
nsVoidArray* theObservers = mObservers[theTag];
if (theObservers) {
nsAutoString theCharsetValue;
PRInt32 theCharsetSource;
aParser->GetDocumentCharset(theCharsetValue,theCharsetSource);
nsCAutoString charset;
aParser->GetDocumentCharset(charset,theCharsetSource);
NS_ConvertASCIItoUCS2 theCharsetValue(charset);
PRInt32 theAttrCount = aNode->GetAttributeCount();
PRInt32 theObserversCount = theObservers->Count();

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

@ -74,7 +74,7 @@ public:
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsAString& aCharset) { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }
// nsIHTMLContentSink

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

@ -305,7 +305,7 @@ nsParser::nsParser() {
}
#endif
mCharset.Assign(NS_LITERAL_STRING("ISO-8859-1"));
mCharset.Assign(NS_LITERAL_CSTRING("ISO-8859-1"));
mParserContext=0;
mStreamStatus=0;
mCharsetSource=kCharsetUninitialized;
@ -487,7 +487,7 @@ NS_IMETHODIMP_(void) nsParser::SetCommand(eParserCommands aParserCommand)
* @return nada
*/
NS_IMETHODIMP_(void)
nsParser::SetDocumentCharset(const nsAString& aCharset, PRInt32 aCharsetSource)
nsParser::SetDocumentCharset(const nsACString& aCharset, PRInt32 aCharsetSource)
{
mCharset = aCharset;
mCharsetSource = aCharsetSource;
@ -495,7 +495,7 @@ nsParser::SetDocumentCharset(const nsAString& aCharset, PRInt32 aCharsetSource)
mParserContext->mScanner->SetDocumentCharset(aCharset, aCharsetSource);
}
void nsParser::SetSinkCharset(nsAString& aCharset)
void nsParser::SetSinkCharset(nsACString& aCharset)
{
if (mSink) {
mSink->SetDocumentCharset(aCharset);
@ -1998,7 +1998,7 @@ static inline PRBool IsSecondMarker(unsigned char aChar)
}
}
static PRBool DetectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsString& oCharset, PRInt32& oCharsetSource) {
static PRBool DetectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsCString& oCharset, PRInt32& oCharsetSource) {
oCharsetSource= kCharsetFromAutoDetection;
oCharset.Truncate();
// See http://www.w3.org/TR/2000/REC-xml-20001006#sec-guessing
@ -2013,26 +2013,26 @@ static PRBool DetectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS
// 00 00
if((0xFE==aBytes[2]) && (0xFF==aBytes[3])) {
// 00 00 FE FF UCS-4, big-endian machine (1234 order)
oCharset.AssignWithConversion(UCS4_BE);
oCharset.Assign(UCS4_BE);
} else if((0x00==aBytes[2]) && (0x3C==aBytes[3])) {
// 00 00 00 3C UCS-4, big-endian machine (1234 order)
oCharset.AssignWithConversion(UCS4_BE);
oCharset.Assign(UCS4_BE);
} else if((0xFF==aBytes[2]) && (0xFE==aBytes[3])) {
// 00 00 FF FE UCS-4, unusual octet order (2143)
oCharset.AssignWithConversion(UCS4_2143);
oCharset.Assign(UCS4_2143);
} else if((0x3C==aBytes[2]) && (0x00==aBytes[3])) {
// 00 00 3C 00 UCS-4, unusual octet order (2143)
oCharset.AssignWithConversion(UCS4_2143);
oCharset.Assign(UCS4_2143);
}
oCharsetSource = kCharsetFromByteOrderMark;
} else if((0x3C==aBytes[1]) && (0x00==aBytes[2])) {
// 00 3C 00
if(IsSecondMarker(aBytes[3])) {
// 00 3C 00 SM UTF-16, big-endian, no Byte Order Mark
oCharset.AssignWithConversion(UTF16_BE);
oCharset.Assign(UTF16_BE);
} else if((0x00==aBytes[3])) {
// 00 3C 00 00 UCS-4, unusual octet order (3412)
oCharset.AssignWithConversion(UCS4_3412);
oCharset.Assign(UCS4_3412);
}
oCharsetSource = kCharsetFromByteOrderMark;
}
@ -2042,10 +2042,10 @@ static PRBool DetectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS
// 3C 00 XX 00
if(IsSecondMarker(aBytes[2])) {
// 3C 00 SM 00 UTF-16, little-endian, no Byte Order Mark
oCharset.AssignWithConversion(UTF16_LE);
oCharset.Assign(UTF16_LE);
} else if((0x00==aBytes[2])) {
// 3C 00 00 00 UCS-4, little-endian machine (4321 order)
oCharset.AssignWithConversion(UCS4_LE);
oCharset.Assign(UCS4_LE);
}
oCharsetSource = kCharsetFromByteOrderMark;
// For html, meta tag detector is invoked before this so that we have
@ -2115,7 +2115,7 @@ static PRBool DetectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS
// encoding value is invalid if it is UTF-16
if (count > 0 &&
(0 != PL_strcmp("UTF-16", (char*)(aBytes+encStart)))) {
oCharset.AssignWithConversion((char*)(aBytes+encStart),count);
oCharset.Assign((char*)(aBytes+encStart),count);
oCharsetSource = kCharsetFromMetaTag;
}
encodingFound = PR_TRUE;
@ -2135,7 +2135,7 @@ static PRBool DetectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS
if((0xBB==aBytes[1]) && (0xBF==aBytes[2])) {
// EF BB BF
// Win2K UTF-8 BOM
oCharset.AssignWithConversion(UTF8);
oCharset.Assign(UTF8);
oCharsetSource= kCharsetFromByteOrderMark;
}
break;
@ -2143,10 +2143,10 @@ static PRBool DetectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS
if(0xFF==aBytes[1]) {
if(0x00==aBytes[2] && 0x00==aBytes[3]) {
// FE FF 00 00 UCS-4, unusual octet order (3412)
oCharset.AssignWithConversion(UCS4_3412);
oCharset.Assign(UCS4_3412);
} else {
// FE FF UTF-16, big-endian
oCharset.AssignWithConversion(UTF16_BE);
oCharset.Assign(UTF16_BE);
}
oCharsetSource= kCharsetFromByteOrderMark;
}
@ -2155,11 +2155,11 @@ static PRBool DetectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS
if(0xFE==aBytes[1]) {
if(0x00==aBytes[2] && 0x00==aBytes[3])
// FF FE 00 00 UTF-32, little-endian
oCharset.AssignWithConversion(UCS4_LE);
oCharset.Assign(UCS4_LE);
else
// FF FE
// UTF-16, little-endian
oCharset.AssignWithConversion(UTF16_LE);
oCharset.Assign(UTF16_LE);
oCharsetSource= kCharsetFromByteOrderMark;
}
break;
@ -2181,7 +2181,7 @@ inline const char GetNextChar(nsACString::const_iterator& aStart,
PRBool
nsParser::DetectMetaTag(const char* aBytes,
PRInt32 aLen,
nsString& aCharset,
nsCString& aCharset,
PRInt32& aCharsetSource)
{
aCharsetSource= kCharsetFromMetaTag;
@ -2280,7 +2280,7 @@ nsParser::DetectMetaTag(const char* aBytes,
// return true if we successfully got something for charset
if (currPos != tokEnd) {
aCharset.Assign(NS_ConvertASCIItoUCS2(currPos.get(), tokEnd.get() - currPos.get()));
aCharset.Assign(currPos.get(), tokEnd.get() - currPos.get());
return PR_TRUE;
}
@ -2324,7 +2324,7 @@ ParserWriteFunc(nsIInputStream* in,
if(pws->mNeedCharsetCheck) {
PRInt32 guessSource;
nsAutoString guess;
nsCAutoString guess;
nsCAutoString preferred;
pws->mNeedCharsetCheck = PR_FALSE;
@ -2334,7 +2334,7 @@ ParserWriteFunc(nsIInputStream* in,
DetectByteOrderMark((const unsigned char*)buf,
theNumRead, guess, guessSource))) {
nsCOMPtr<nsICharsetAlias> alias(do_GetService(NS_CHARSETALIAS_CONTRACTID));
result = alias->GetPreferred(NS_LossyConvertUCS2toASCII(guess), preferred);
result = alias->GetPreferred(guess, preferred);
// Only continue if it's a recognized charset and not
// one of a designated set that we ignore.
if (NS_SUCCEEDED(result) &&
@ -2344,9 +2344,9 @@ ParserWriteFunc(nsIInputStream* in,
!preferred.Equals(NS_LITERAL_CSTRING("UTF-16LE")) &&
!preferred.Equals(NS_LITERAL_CSTRING("UTF-32BE")) &&
!preferred.Equals(NS_LITERAL_CSTRING("UTF-32LE"))))) {
guess.Assign(NS_ConvertASCIItoUCS2(preferred));
guess = preferred;
pws->mParser->SetDocumentCharset(guess, guessSource);
pws->mParser->SetSinkCharset(guess);
pws->mParser->SetSinkCharset(preferred);
nsCOMPtr<nsICachingChannel> channel(do_QueryInterface(pws->mRequest));
if (channel) {
nsCOMPtr<nsISupports> cacheToken;
@ -2358,7 +2358,7 @@ ParserWriteFunc(nsIInputStream* in,
nsresult rv =
#endif
cacheDescriptor->SetMetaDataElement("charset",
NS_ConvertUCS2toUTF8(guess).get());
guess.get());
NS_ASSERTION(NS_SUCCEEDED(rv),"cannot SetMetaDataElement");
}
}

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

@ -160,9 +160,9 @@ class nsParser : public nsIParser,
* @param aCharsetSource- the source of the charset
* @return nada
*/
NS_IMETHOD_(void) SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource);
NS_IMETHOD_(void) SetDocumentCharset(const nsACString& aCharset, PRInt32 aSource);
NS_IMETHOD_(void) GetDocumentCharset(nsAString& aCharset, PRInt32& aSource)
NS_IMETHOD_(void) GetDocumentCharset(nsACString& aCharset, PRInt32& aSource)
{
aCharset = mCharset;
aSource = mCharsetSource;
@ -330,10 +330,10 @@ class nsParser : public nsIParser,
*/
PRBool DetectMetaTag(const char* aBytes,
PRInt32 aLen,
nsString& oCharset,
nsCString& oCharset,
PRInt32& oCharsetSource);
void SetSinkCharset(nsAString& aCharset);
void SetSinkCharset(nsACString& aCharset);
/**
* Removes continue parsing events
@ -453,7 +453,7 @@ protected:
PRUint16 mFlags;
nsString mUnusedInput;
nsString mCharset;
nsCString mCharset;
nsString mCommandStr;

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

@ -108,7 +108,7 @@ MOZ_DECL_CTOR_COUNTER(nsScanner)
* @param aMode represents the parser mode (nav, other)
* @return
*/
nsScanner::nsScanner(const nsAString& anHTMLString, const nsString& aCharset, PRInt32 aSource)
nsScanner::nsScanner(const nsAString& anHTMLString, const nsACString& aCharset, PRInt32 aSource)
{
MOZ_COUNT_CTOR(nsScanner);
@ -134,7 +134,7 @@ nsScanner::nsScanner(const nsAString& anHTMLString, const nsString& aCharset, PR
* @param aFilename --
* @return
*/
nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream, const nsString& aCharset, PRInt32 aSource) :
nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream, const nsACString& aCharset, PRInt32 aSource) :
mFilename(aFilename)
{
MOZ_COUNT_CTOR(nsScanner);
@ -173,7 +173,7 @@ nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream, const nsString& a
* @param aFilename --
* @return
*/
nsScanner::nsScanner(const nsAString& aFilename,nsIInputStream* aStream,const nsString& aCharset, PRInt32 aSource) :
nsScanner::nsScanner(const nsAString& aFilename,nsIInputStream* aStream,const nsACString& aCharset, PRInt32 aSource) :
mFilename(aFilename)
{
MOZ_COUNT_CTOR(nsScanner);
@ -195,7 +195,7 @@ nsScanner::nsScanner(const nsAString& aFilename,nsIInputStream* aStream,const ns
}
nsresult nsScanner::SetDocumentCharset(const nsAString& aCharset , PRInt32 aSource) {
nsresult nsScanner::SetDocumentCharset(const nsACString& aCharset , PRInt32 aSource) {
nsresult res = NS_OK;
@ -204,17 +204,17 @@ nsresult nsScanner::SetDocumentCharset(const nsAString& aCharset , PRInt32 aSour
nsCOMPtr<nsICharsetAlias> calias(do_GetService(kCharsetAliasCID, &res));
NS_ASSERTION( nsnull != calias, "cannot find charset alias");
nsCAutoString charsetName = NS_LossyConvertUCS2toASCII(aCharset);
if( NS_SUCCEEDED(res) && (nsnull != calias))
{
PRBool same = PR_FALSE;
res = calias->Equals(charsetName, mCharset, &same);
res = calias->Equals(aCharset, mCharset, &same);
if(NS_SUCCEEDED(res) && same)
{
return NS_OK; // no difference, don't change it
}
// different, need to change it
res = calias->GetPreferred(charsetName, charsetName);
nsCAutoString charsetName;
res = calias->GetPreferred(aCharset, charsetName);
if(NS_FAILED(res) && (kCharsetUninitialized == mCharsetSource) )
{

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

@ -95,7 +95,7 @@ class nsScanner {
* @param aMode represents the parser mode (nav, other)
* @return
*/
nsScanner(const nsAString& anHTMLString, const nsString& aCharset, PRInt32 aSource);
nsScanner(const nsAString& anHTMLString, const nsACString& aCharset, PRInt32 aSource);
/**
* Use this constructor if you want i/o to be based on
@ -107,7 +107,7 @@ class nsScanner {
* @param aMode represents the parser mode (nav, other)
* @return
*/
nsScanner(nsString& aFilename,PRBool aCreateStream, const nsString& aCharset, PRInt32 aSource);
nsScanner(nsString& aFilename,PRBool aCreateStream, const nsACString& aCharset, PRInt32 aSource);
/**
* Use this constructor if you want i/o to be stream based.
@ -118,7 +118,7 @@ class nsScanner {
* @param aMode represents the parser mode (nav, other)
* @return
*/
nsScanner(const nsAString& aFilename, nsIInputStream* aStream, const nsString& aCharset, PRInt32 aSource);
nsScanner(const nsAString& aFilename, nsIInputStream* aStream, const nsACString& aCharset, PRInt32 aSource);
~nsScanner();
@ -346,7 +346,7 @@ class nsScanner {
* @param aCharsetSource- where the charset info came from
* @return
*/
nsresult SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource);
nsresult SetDocumentCharset(const nsACString& aCharset, PRInt32 aSource);
void BindSubstring(nsSlidingSubstring& aSubstring, const nsReadingIterator<PRUnichar>& aStart, const nsReadingIterator<PRUnichar>& aEnd);
void CurrentPosition(nsReadingIterator<PRUnichar>& aPosition);

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

@ -163,7 +163,7 @@ public:
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsAString& aCharset) { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
// nsIRDFContentSink
NS_IMETHOD Init(nsIURI* aURL);

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

@ -79,7 +79,7 @@ nsRDFXMLParser::ParseAsync(nsIRDFDataSource* aSink, nsIURI* aBaseURI, nsIStreamL
nsCOMPtr<nsIParser> parser = do_CreateInstance(kParserCID, &rv);
if (NS_FAILED(rv)) return rv;
parser->SetDocumentCharset(NS_LITERAL_STRING("UTF-8"),
parser->SetDocumentCharset(NS_LITERAL_CSTRING("UTF-8"),
kCharsetFromDocTypeDefault);
parser->SetContentSink(sink);
@ -110,7 +110,7 @@ nsRDFXMLParser::ParseString(nsIRDFDataSource* aSink, nsIURI* aBaseURI, const nsA
nsCOMPtr<nsIParser> parser = do_CreateInstance(kParserCID, &rv);
if (NS_FAILED(rv)) return rv;
parser->SetDocumentCharset(NS_LITERAL_STRING("UTF-8"),
parser->SetDocumentCharset(NS_LITERAL_CSTRING("UTF-8"),
kCharsetFromDocTypeDefault);
parser->SetContentSink(sink);