diff --git a/htmlparser/public/nsIParser.h b/htmlparser/public/nsIParser.h index 326ac77ffb6..134f805c425 100644 --- a/htmlparser/public/nsIParser.h +++ b/htmlparser/public/nsIParser.h @@ -187,8 +187,8 @@ class nsIParser : public nsISupports { * @param aCharsetSource- the soure of the chares * @return nada */ - virtual void SetDocumentCharset(nsString& aCharset, PRInt32 aSource)=0; - virtual void GetDocumentCharset(nsString& oCharset, PRInt32& oSource)=0; + virtual void SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource)=0; + virtual void GetDocumentCharset(nsAString& oCharset, PRInt32& oSource)=0; virtual nsIParserFilter* SetParserFilter(nsIParserFilter* aFilter) = 0; diff --git a/htmlparser/src/nsParser.cpp b/htmlparser/src/nsParser.cpp index 41977e5cf4f..b0fe39d5dfe 100644 --- a/htmlparser/src/nsParser.cpp +++ b/htmlparser/src/nsParser.cpp @@ -501,7 +501,7 @@ void nsParser::SetCommand(eParserCommands aParserCommand){ * @param aCharsetSource- the soure of the chares * @return nada */ -void nsParser::SetDocumentCharset(nsString& aCharset, PRInt32 aCharsetSource){ +void nsParser::SetDocumentCharset(const nsAString& aCharset, PRInt32 aCharsetSource){ mCharset = aCharset; mCharsetSource = aCharsetSource; if(mParserContext && mParserContext->mScanner) @@ -756,7 +756,7 @@ static PRBool ParseDocTypeDecl(const nsString &aBuffer, // The PI-skipping is a bit of a hack. PRInt32 theIndex = 0; do { - theIndex = aBuffer.FindChar('<', PR_FALSE, theIndex, -1); + theIndex = aBuffer.FindChar('<', theIndex); if (theIndex == kNotFound) break; PRUnichar nextChar = aBuffer.CharAt(theIndex+1); if (nextChar == PRUnichar('!')) { @@ -769,9 +769,9 @@ static PRBool ParseDocTypeDecl(const nsString &aBuffer, } theIndex = ParsePS(aBuffer,tmpIndex); // -1, not 0, in case it's another markup declaration - theIndex = aBuffer.FindChar('>', PR_FALSE, theIndex, -1); + theIndex = aBuffer.FindChar('>', theIndex); } else if (nextChar == PRUnichar('?')) { - theIndex = aBuffer.FindChar('>', PR_FALSE, theIndex, -1); + theIndex = aBuffer.FindChar('>', theIndex); } else { break; } @@ -806,7 +806,7 @@ static PRBool ParseDocTypeDecl(const nsString &aBuffer, PRInt32 PublicIDStart = theIndex + 1; PRInt32 PublicIDEnd = - aBuffer.FindChar(lit, PR_FALSE, PublicIDStart, -1); + aBuffer.FindChar(lit, PublicIDStart); if (kNotFound == PublicIDEnd) return PR_FALSE; theIndex = ParsePS(aBuffer, PublicIDEnd + 1); @@ -823,7 +823,7 @@ static PRBool ParseDocTypeDecl(const nsString &aBuffer, *aResultFlags |= PARSE_DTD_HAVE_SYSTEM_ID; PRInt32 SystemIDStart = theIndex + 1; PRInt32 SystemIDEnd = - aBuffer.FindChar(next, PR_FALSE, SystemIDStart, -1); + aBuffer.FindChar(next, SystemIDStart); if (kNotFound == SystemIDEnd) return PR_FALSE; } else if (next == PRUnichar('[')) { diff --git a/htmlparser/src/nsParser.h b/htmlparser/src/nsParser.h index 62a06186d54..a62a5440842 100644 --- a/htmlparser/src/nsParser.h +++ b/htmlparser/src/nsParser.h @@ -160,9 +160,9 @@ class nsParser : public nsIParser, * @param aCharsetSource- the soure of the chares * @return nada */ - virtual void SetDocumentCharset(nsString& aCharset, PRInt32 aSource); + virtual void SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource); - void GetDocumentCharset(nsString& aCharset, PRInt32& aSource) + void GetDocumentCharset(nsAString& aCharset, PRInt32& aSource) { aCharset = mCharset; aSource = mCharsetSource; diff --git a/htmlparser/src/nsScanner.cpp b/htmlparser/src/nsScanner.cpp index b72a3d9c29d..cb7f34e72a7 100644 --- a/htmlparser/src/nsScanner.cpp +++ b/htmlparser/src/nsScanner.cpp @@ -181,7 +181,7 @@ nsScanner::nsScanner(nsString& aFilename,nsInputStream& aStream,const nsString& } -nsresult nsScanner::SetDocumentCharset(const nsString& aCharset , PRInt32 aSource) { +nsresult nsScanner::SetDocumentCharset(const nsAString& aCharset , PRInt32 aSource) { nsresult res = NS_OK; diff --git a/htmlparser/src/nsScanner.h b/htmlparser/src/nsScanner.h index 6d46384ff63..dfbb57f0609 100644 --- a/htmlparser/src/nsScanner.h +++ b/htmlparser/src/nsScanner.h @@ -343,7 +343,7 @@ class nsScanner { * @param aCharsetSource- where the charset info came from * @return */ - nsresult SetDocumentCharset(const nsString& aCharset, PRInt32 aSource); + nsresult SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource); void BindSubstring(nsSlidingSubstring& aSubstring, const nsReadingIterator& aStart, const nsReadingIterator& aEnd); void CurrentPosition(nsReadingIterator& aPosition); diff --git a/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp b/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp index 0752c02900a..365f598170e 100644 --- a/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp +++ b/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp @@ -129,13 +129,10 @@ nsAddbookProtocolHandler::GenerateXMLOutputChannel( nsString &aOutput, nsresult rv = NS_OK; nsIChannel *channel; nsCOMPtr inStr; - nsCOMPtr s; - rv = NS_NewStringInputStream(getter_AddRefs(s), aOutput); + rv = NS_NewStringInputStream(getter_AddRefs(inStr), aOutput); NS_ENSURE_SUCCESS(rv, rv); - inStr = do_QueryInterface(s, &rv); - NS_ENSURE_SUCCESS(rv, rv); rv = NS_NewInputStreamChannel(&channel, aURI, inStr, "text/xml", aOutput.Length()); NS_ENSURE_SUCCESS(rv, rv); diff --git a/netwerk/base/public/nsNetUtil.h b/netwerk/base/public/nsNetUtil.h index 62bd88c87d5..346fcf02aeb 100644 --- a/netwerk/base/public/nsNetUtil.h +++ b/netwerk/base/public/nsNetUtil.h @@ -273,11 +273,7 @@ NS_NewPostDataStream(nsIInputStream **result, } // otherwise, create a string stream for the data - nsCOMPtr sup; - rv = NS_NewCStringInputStream(getter_AddRefs(sup), nsCAutoString(data)); - if (NS_FAILED(rv)) return rv; - - return CallQueryInterface(sup, result); + return NS_NewCStringInputStream(result, nsDependentCString(data)); } inline nsresult diff --git a/netwerk/protocol/about/src/nsAboutBlank.cpp b/netwerk/protocol/about/src/nsAboutBlank.cpp index 28af84f0371..a401b2bec00 100644 --- a/netwerk/protocol/about/src/nsAboutBlank.cpp +++ b/netwerk/protocol/about/src/nsAboutBlank.cpp @@ -51,18 +51,13 @@ nsAboutBlank::NewChannel(nsIURI *aURI, nsIChannel **result) { nsresult rv; nsIChannel* channel; - nsISupports* s; - rv = NS_NewCStringInputStream(&s, nsCAutoString(kBlankPage)); - if (NS_FAILED(rv)) return rv; - nsIInputStream* in; - rv = CallQueryInterface(s, &in); - NS_RELEASE(s); + nsCOMPtr in; + rv = NS_NewCStringInputStream(getter_AddRefs(in), nsDependentCString(kBlankPage)); if (NS_FAILED(rv)) return rv; rv = NS_NewInputStreamChannel(&channel, aURI, in, "text/html", nsCRT::strlen(kBlankPage)); - NS_RELEASE(in); if (NS_FAILED(rv)) return rv; *result = channel; diff --git a/netwerk/protocol/about/src/nsAboutBloat.cpp b/netwerk/protocol/about/src/nsAboutBloat.cpp index 7cbafc4ab25..3e99d150f95 100644 --- a/netwerk/protocol/about/src/nsAboutBloat.cpp +++ b/netwerk/protocol/about/src/nsAboutBloat.cpp @@ -86,29 +86,21 @@ nsAboutBloat::NewChannel(nsIURI *aURI, nsIChannel **result) if (clear) { nsTraceRefcnt::ResetStatistics(); - nsCOMPtr s; const char* msg = "Bloat statistics cleared."; - rv = NS_NewCStringInputStream(getter_AddRefs(s), nsCAutoString(msg)); + rv = NS_NewCStringInputStream(getter_AddRefs(inStr), nsDependentCString(msg)); if (NS_FAILED(rv)) return rv; size = nsCRT::strlen(msg); - - inStr = do_QueryInterface(s, &rv); - if (NS_FAILED(rv)) return rv; } else if (leaks) { // dump the current set of leaks. GC_gcollect(); - nsCOMPtr s; const char* msg = "Memory leaks dumped."; - rv = NS_NewCStringInputStream(getter_AddRefs(s), nsCAutoString(msg)); + rv = NS_NewCStringInputStream(getter_AddRefs(inStr), nsDependentCString(msg)); if (NS_FAILED(rv)) return rv; size = nsCRT::strlen(msg); - - inStr = do_QueryInterface(s, &rv); - if (NS_FAILED(rv)) return rv; } else { nsCOMPtr file; diff --git a/netwerk/protocol/http/src/nsHttpConnection.cpp b/netwerk/protocol/http/src/nsHttpConnection.cpp index da85f903b57..4e228eedb6c 100644 --- a/netwerk/protocol/http/src/nsHttpConnection.cpp +++ b/netwerk/protocol/http/src/nsHttpConnection.cpp @@ -516,11 +516,8 @@ nsHttpConnection::SetupSSLProxyConnect() request.Flatten(buf); buf.Append("\r\n"); - nsCOMPtr sup; - rv = NS_NewCStringInputStream(getter_AddRefs(sup), buf); - if (NS_FAILED(rv)) return rv; + rv = NS_NewCStringInputStream(getter_AddRefs(mSSLProxyConnectStream), buf); - mSSLProxyConnectStream = do_QueryInterface(sup, &rv); return rv; } diff --git a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp index 1d38a978698..450465da78a 100644 --- a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp +++ b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp @@ -186,20 +186,7 @@ nsFTPDirListingConv::Convert(nsIInputStream *aFromStream, #endif // DEBUG_valeski // send the converted data out. - nsCOMPtr inputData; - nsCOMPtr inputDataSup; - - rv = NS_NewCStringInputStream(getter_AddRefs(inputDataSup), convertedData); - if (NS_FAILED(rv)) return rv; - - inputData = do_QueryInterface(inputDataSup, &rv); - if (NS_FAILED(rv)) return rv; - - *_retval = inputData.get(); - NS_ADDREF(*_retval); - - return NS_OK; - + return NS_NewCStringInputStream(_retval, convertedData); } @@ -323,12 +310,8 @@ nsFTPDirListingConv::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, // send the converted data out. nsCOMPtr inputData; - nsCOMPtr inputDataSup; - rv = NS_NewCStringInputStream(getter_AddRefs(inputDataSup), indexFormat); - if (NS_FAILED(rv)) return rv; - - inputData = do_QueryInterface(inputDataSup, &rv); + rv = NS_NewCStringInputStream(getter_AddRefs(inputData), indexFormat); if (NS_FAILED(rv)) return rv; rv = mFinalListener->OnDataAvailable(mPartChannel, ctxt, inputData, 0, indexFormat.Length()); diff --git a/netwerk/streamconv/converters/nsGopherDirListingConv.cpp b/netwerk/streamconv/converters/nsGopherDirListingConv.cpp index 0fb7be39291..3a9aac1865e 100644 --- a/netwerk/streamconv/converters/nsGopherDirListingConv.cpp +++ b/netwerk/streamconv/converters/nsGopherDirListingConv.cpp @@ -109,19 +109,7 @@ nsGopherDirListingConv::Convert(nsIInputStream *aFromStream, } // send the converted data out. - nsCOMPtr inputData; - nsCOMPtr inputDataSup; - - rv = NS_NewCStringInputStream(getter_AddRefs(inputDataSup), convertedData); - if (NS_FAILED(rv)) return rv; - - inputData = do_QueryInterface(inputDataSup, &rv); - if (NS_FAILED(rv)) return rv; - - *_retval = inputData.get(); - NS_ADDREF(*_retval); - - return NS_OK; + return NS_NewCStringInputStream(_retval, convertedData); } // Stream converter service calls this to initialize the actual @@ -218,12 +206,8 @@ nsGopherDirListingConv::OnDataAvailable(nsIRequest *request, // send the converted data out. nsCOMPtr inputData; - nsCOMPtr inputDataSup; - rv = NS_NewCStringInputStream(getter_AddRefs(inputDataSup), indexFormat); - if (NS_FAILED(rv)) return rv; - - inputData = do_QueryInterface(inputDataSup, &rv); + rv = NS_NewCStringInputStream(getter_AddRefs(inputData), indexFormat); if (NS_FAILED(rv)) return rv; rv = mFinalListener->OnDataAvailable(mPartChannel, ctxt, inputData, diff --git a/netwerk/streamconv/converters/nsIndexedToHTML.cpp b/netwerk/streamconv/converters/nsIndexedToHTML.cpp index 99c11b595a3..e9a3b442782 100644 --- a/netwerk/streamconv/converters/nsIndexedToHTML.cpp +++ b/netwerk/streamconv/converters/nsIndexedToHTML.cpp @@ -238,12 +238,9 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) { if (NS_FAILED(rv)) return rv; nsCOMPtr inputData; - nsCOMPtr inputDataSup; - rv = NS_NewStringInputStream(getter_AddRefs(inputDataSup), buffer); + rv = NS_NewStringInputStream(getter_AddRefs(inputData), buffer); if (NS_FAILED(rv)) return rv; - inputData = do_QueryInterface(inputDataSup); - rv = mListener->OnDataAvailable(request, aContext, inputData, 0, buffer.Length()); return rv; @@ -257,13 +254,10 @@ nsIndexedToHTML::OnStopRequest(nsIRequest* request, nsISupports *aContext, buffer.Assign(NS_LITERAL_STRING("
\n")); nsCOMPtr inputData; - nsCOMPtr inputDataSup; - rv = NS_NewStringInputStream(getter_AddRefs(inputDataSup), buffer); + rv = NS_NewStringInputStream(getter_AddRefs(inputData), buffer); if (NS_FAILED(rv)) return rv; - inputData = do_QueryInterface(inputDataSup); - rv = mListener->OnDataAvailable(request, aContext, inputData, 0, buffer.Length()); if (NS_FAILED(rv)) return rv; @@ -384,15 +378,13 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest, } nsCOMPtr inputData; - nsCOMPtr inputDataSup; - nsresult rv = NS_NewStringInputStream(getter_AddRefs(inputDataSup), + + nsresult rv = NS_NewStringInputStream(getter_AddRefs(inputData), pushBuffer); if (NS_FAILED(rv)) return rv; - inputData = do_QueryInterface(inputDataSup); - rv = mListener->OnDataAvailable(aRequest, aCtxt, inputData, diff --git a/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp b/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp index 3c4e27b717b..d2269d1d818 100644 --- a/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp +++ b/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp @@ -85,11 +85,9 @@ nsTXTToHTMLConv::OnStartRequest(nsIRequest* request, nsISupports *aContext) { if (NS_FAILED(rv)) return rv; nsCOMPtr inputData; - nsCOMPtr inputDataSup; - rv = NS_NewStringInputStream(getter_AddRefs(inputDataSup), mBuffer); + rv = NS_NewStringInputStream(getter_AddRefs(inputData), mBuffer); if (NS_FAILED(rv)) return rv; - inputData = do_QueryInterface(inputDataSup); rv = mListener->OnDataAvailable(request, aContext, inputData, 0, mBuffer.Length()); if (NS_FAILED(rv)) return rv; @@ -113,13 +111,10 @@ nsTXTToHTMLConv::OnStopRequest(nsIRequest* request, nsISupports *aContext, mBuffer.Append(NS_LITERAL_STRING("\n")); nsCOMPtr inputData; - nsCOMPtr inputDataSup; - rv = NS_NewStringInputStream(getter_AddRefs(inputDataSup), mBuffer); + rv = NS_NewStringInputStream(getter_AddRefs(inputData), mBuffer); if (NS_FAILED(rv)) return rv; - inputData = do_QueryInterface(inputDataSup); - rv = mListener->OnDataAvailable(request, aContext, inputData, 0, mBuffer.Length()); if (NS_FAILED(rv)) return rv; @@ -186,15 +181,13 @@ nsTXTToHTMLConv::OnDataAvailable(nsIRequest* request, nsISupports *aContext, if (!pushBuffer.IsEmpty()) { nsCOMPtr inputData; - nsCOMPtr inputDataSup; - rv = NS_NewStringInputStream(getter_AddRefs(inputDataSup), pushBuffer); + + rv = NS_NewStringInputStream(getter_AddRefs(inputData), pushBuffer); if (NS_FAILED(rv)) { nsMemory::Free(buffer); return rv; } - inputData = do_QueryInterface(inputDataSup); - rv = mListener->OnDataAvailable(request, aContext, inputData, 0, pushBuffer.Length()); if (NS_FAILED(rv)) { diff --git a/netwerk/streamconv/test/Converters.cpp b/netwerk/streamconv/test/Converters.cpp index ce8d618f8b9..655af4f69bc 100644 --- a/netwerk/streamconv/test/Converters.cpp +++ b/netwerk/streamconv/test/Converters.cpp @@ -51,17 +51,7 @@ TestConverter::Convert(nsIInputStream *aFromStream, buf[read] = '\0'; - nsString convDataStr; - convDataStr.AssignWithConversion(buf); - nsCOMPtr inputDataSup; - - rv = NS_NewStringInputStream(getter_AddRefs(inputDataSup), convDataStr); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr inputData(do_QueryInterface(inputDataSup)); - *_retval = inputData; - NS_ADDREF(*_retval); - return NS_OK; + return NS_NewCStringInputStream(_retval, nsDependentCString(buf)); } /* This method initializes any internal state before the stream converter diff --git a/netwerk/streamconv/test/TestStreamConv.cpp b/netwerk/streamconv/test/TestStreamConv.cpp index 50f01a453c4..c56fb8d9d2e 100644 --- a/netwerk/streamconv/test/TestStreamConv.cpp +++ b/netwerk/streamconv/test/TestStreamConv.cpp @@ -127,11 +127,10 @@ NS_IMPL_ISUPPORTS1(EndListener, nsIStreamListener); nsresult SendData(const char * aData, nsIStreamListener* aListener, nsIRequest* request) { nsString data; data.AssignWithConversion(aData); - nsCOMPtr dataSup; - nsresult rv = NS_NewStringInputStream(getter_AddRefs(dataSup), data); + nsCOMPtr dataStream; + nsresult rv = NS_NewStringInputStream(getter_AddRefs(dataStream), data); if (NS_FAILED(rv)) return rv; - nsCOMPtr dataStream(do_QueryInterface(dataSup)); return aListener->OnDataAvailable(request, nsnull, dataStream, 0, -1); } #define SEND_DATA(x) SendData(x, converterListener, request) diff --git a/parser/htmlparser/public/nsIParser.h b/parser/htmlparser/public/nsIParser.h index 326ac77ffb6..134f805c425 100644 --- a/parser/htmlparser/public/nsIParser.h +++ b/parser/htmlparser/public/nsIParser.h @@ -187,8 +187,8 @@ class nsIParser : public nsISupports { * @param aCharsetSource- the soure of the chares * @return nada */ - virtual void SetDocumentCharset(nsString& aCharset, PRInt32 aSource)=0; - virtual void GetDocumentCharset(nsString& oCharset, PRInt32& oSource)=0; + virtual void SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource)=0; + virtual void GetDocumentCharset(nsAString& oCharset, PRInt32& oSource)=0; virtual nsIParserFilter* SetParserFilter(nsIParserFilter* aFilter) = 0; diff --git a/parser/htmlparser/src/nsParser.cpp b/parser/htmlparser/src/nsParser.cpp index 41977e5cf4f..b0fe39d5dfe 100644 --- a/parser/htmlparser/src/nsParser.cpp +++ b/parser/htmlparser/src/nsParser.cpp @@ -501,7 +501,7 @@ void nsParser::SetCommand(eParserCommands aParserCommand){ * @param aCharsetSource- the soure of the chares * @return nada */ -void nsParser::SetDocumentCharset(nsString& aCharset, PRInt32 aCharsetSource){ +void nsParser::SetDocumentCharset(const nsAString& aCharset, PRInt32 aCharsetSource){ mCharset = aCharset; mCharsetSource = aCharsetSource; if(mParserContext && mParserContext->mScanner) @@ -756,7 +756,7 @@ static PRBool ParseDocTypeDecl(const nsString &aBuffer, // The PI-skipping is a bit of a hack. PRInt32 theIndex = 0; do { - theIndex = aBuffer.FindChar('<', PR_FALSE, theIndex, -1); + theIndex = aBuffer.FindChar('<', theIndex); if (theIndex == kNotFound) break; PRUnichar nextChar = aBuffer.CharAt(theIndex+1); if (nextChar == PRUnichar('!')) { @@ -769,9 +769,9 @@ static PRBool ParseDocTypeDecl(const nsString &aBuffer, } theIndex = ParsePS(aBuffer,tmpIndex); // -1, not 0, in case it's another markup declaration - theIndex = aBuffer.FindChar('>', PR_FALSE, theIndex, -1); + theIndex = aBuffer.FindChar('>', theIndex); } else if (nextChar == PRUnichar('?')) { - theIndex = aBuffer.FindChar('>', PR_FALSE, theIndex, -1); + theIndex = aBuffer.FindChar('>', theIndex); } else { break; } @@ -806,7 +806,7 @@ static PRBool ParseDocTypeDecl(const nsString &aBuffer, PRInt32 PublicIDStart = theIndex + 1; PRInt32 PublicIDEnd = - aBuffer.FindChar(lit, PR_FALSE, PublicIDStart, -1); + aBuffer.FindChar(lit, PublicIDStart); if (kNotFound == PublicIDEnd) return PR_FALSE; theIndex = ParsePS(aBuffer, PublicIDEnd + 1); @@ -823,7 +823,7 @@ static PRBool ParseDocTypeDecl(const nsString &aBuffer, *aResultFlags |= PARSE_DTD_HAVE_SYSTEM_ID; PRInt32 SystemIDStart = theIndex + 1; PRInt32 SystemIDEnd = - aBuffer.FindChar(next, PR_FALSE, SystemIDStart, -1); + aBuffer.FindChar(next, SystemIDStart); if (kNotFound == SystemIDEnd) return PR_FALSE; } else if (next == PRUnichar('[')) { diff --git a/parser/htmlparser/src/nsParser.h b/parser/htmlparser/src/nsParser.h index 62a06186d54..a62a5440842 100644 --- a/parser/htmlparser/src/nsParser.h +++ b/parser/htmlparser/src/nsParser.h @@ -160,9 +160,9 @@ class nsParser : public nsIParser, * @param aCharsetSource- the soure of the chares * @return nada */ - virtual void SetDocumentCharset(nsString& aCharset, PRInt32 aSource); + virtual void SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource); - void GetDocumentCharset(nsString& aCharset, PRInt32& aSource) + void GetDocumentCharset(nsAString& aCharset, PRInt32& aSource) { aCharset = mCharset; aSource = mCharsetSource; diff --git a/parser/htmlparser/src/nsScanner.cpp b/parser/htmlparser/src/nsScanner.cpp index b72a3d9c29d..cb7f34e72a7 100644 --- a/parser/htmlparser/src/nsScanner.cpp +++ b/parser/htmlparser/src/nsScanner.cpp @@ -181,7 +181,7 @@ nsScanner::nsScanner(nsString& aFilename,nsInputStream& aStream,const nsString& } -nsresult nsScanner::SetDocumentCharset(const nsString& aCharset , PRInt32 aSource) { +nsresult nsScanner::SetDocumentCharset(const nsAString& aCharset , PRInt32 aSource) { nsresult res = NS_OK; diff --git a/parser/htmlparser/src/nsScanner.h b/parser/htmlparser/src/nsScanner.h index 6d46384ff63..dfbb57f0609 100644 --- a/parser/htmlparser/src/nsScanner.h +++ b/parser/htmlparser/src/nsScanner.h @@ -343,7 +343,7 @@ class nsScanner { * @param aCharsetSource- where the charset info came from * @return */ - nsresult SetDocumentCharset(const nsString& aCharset, PRInt32 aSource); + nsresult SetDocumentCharset(const nsAString& aCharset, PRInt32 aSource); void BindSubstring(nsSlidingSubstring& aSubstring, const nsReadingIterator& aStart, const nsReadingIterator& aEnd); void CurrentPosition(nsReadingIterator& aPosition); diff --git a/rdf/base/src/nsRDFXMLParser.cpp b/rdf/base/src/nsRDFXMLParser.cpp index 339022b7c12..925e0ee4a0c 100644 --- a/rdf/base/src/nsRDFXMLParser.cpp +++ b/rdf/base/src/nsRDFXMLParser.cpp @@ -80,8 +80,8 @@ nsRDFXMLParser::ParseAsync(nsIRDFDataSource* aSink, nsIURI* aBaseURI, nsIStreamL nsCOMPtr parser = do_CreateInstance(kParserCID, &rv); if (NS_FAILED(rv)) return rv; - nsAutoString charset(NS_LITERAL_STRING("UTF-8")); - parser->SetDocumentCharset(charset, kCharsetFromDocTypeDefault); + parser->SetDocumentCharset(NS_LITERAL_STRING("UTF-8"), + kCharsetFromDocTypeDefault); parser->SetContentSink(sink); rv = parser->Parse(aBaseURI); @@ -111,8 +111,8 @@ nsRDFXMLParser::ParseString(nsIRDFDataSource* aSink, nsIURI* aBaseURI, const nsA nsCOMPtr parser = do_CreateInstance(kParserCID, &rv); if (NS_FAILED(rv)) return rv; - nsAutoString charset(NS_LITERAL_STRING("UTF-8")); - parser->SetDocumentCharset(charset, kCharsetFromDocTypeDefault); + parser->SetDocumentCharset(NS_LITERAL_STRING("UTF-8"), + kCharsetFromDocTypeDefault); parser->SetContentSink(sink); rv = parser->Parse(aBaseURI); @@ -124,12 +124,8 @@ nsRDFXMLParser::ParseString(nsIRDFDataSource* aSink, nsIURI* aBaseURI, const nsA if (! listener) return NS_ERROR_FAILURE; - nsString copy(aString); // XXX sucks, but I ain't touchin' nsIStringStream! - - nsCOMPtr isupports; - rv = NS_NewStringInputStream(getter_AddRefs(isupports), copy); - if (NS_FAILED(rv)) return rv; - nsCOMPtr stream = do_QueryInterface(isupports, &rv); + nsCOMPtr stream; + rv = NS_NewStringInputStream(getter_AddRefs(stream), aString); if (NS_FAILED(rv)) return rv; nsCOMPtr channel; diff --git a/xpcom/io/nsFileStream.cpp b/xpcom/io/nsFileStream.cpp index dbc3b9641a5..ba3c3443cb2 100644 --- a/xpcom/io/nsFileStream.cpp +++ b/xpcom/io/nsFileStream.cpp @@ -261,12 +261,9 @@ nsInputStringStream::nsInputStringStream(const char* stringToRead) nsInputStringStream::nsInputStringStream(const nsString& stringToRead) //---------------------------------------------------------------------------------------- { - nsISupports* stream; - if (NS_FAILED(NS_NewStringInputStream(&stream, stringToRead))) + if (NS_FAILED(NS_NewStringInputStream(getter_AddRefs(mInputStream), stringToRead))) return; - mInputStream = do_QueryInterface(stream); - mStore = do_QueryInterface(stream); - NS_RELEASE(stream); + mStore = do_QueryInterface(mInputStream); } //======================================================================================== diff --git a/xpcom/io/nsIStringStream.idl b/xpcom/io/nsIStringStream.idl index 53aebdb7473..0567bba38b7 100644 --- a/xpcom/io/nsIStringStream.idl +++ b/xpcom/io/nsIStringStream.idl @@ -103,15 +103,15 @@ interface nsIStringInputStream : nsISupports //---------------------------------------------------------------------------------------- extern "C" NS_COM nsresult NS_NewStringInputStream( - nsISupports** aStreamResult, - const nsString& aStringToRead); + nsIInputStream** aStreamResult, + const nsAString& aStringToRead); // Factory method to get an nsInputStream from a string. Result will implement all the // file stream interfaces in nsIFileStream.h //---------------------------------------------------------------------------------------- extern "C" NS_COM nsresult NS_NewCStringInputStream( - nsISupports** aStreamResult, - const nsCString& aStringToRead); + nsIInputStream** aStreamResult, + const nsACString& aStringToRead); // Factory method to get an nsInputStream from a cstring. Result will implement all the // file stream interfaces in nsIFileStream.h diff --git a/xpcom/io/nsStringStream.cpp b/xpcom/io/nsStringStream.cpp index 4695be4dfae..8f962ebb033 100644 --- a/xpcom/io/nsStringStream.cpp +++ b/xpcom/io/nsStringStream.cpp @@ -446,13 +446,13 @@ class ConstStringImpl //======================================================================================== { public: - ConstStringImpl(const nsString& inString) + ConstStringImpl(const nsAString& inString) : ConstCharImpl(ToNewCString(inString), inString.Length()) { } - ConstStringImpl(const nsCString& inString) + ConstStringImpl(const nsACString& inString) : ConstCharImpl(ToNewCString(inString), inString.Length()) { @@ -525,8 +525,8 @@ NS_IMPL_QUERY_TAIL(nsIOutputStream) //---------------------------------------------------------------------------------------- extern "C" NS_COM nsresult NS_NewStringInputStream( - nsISupports** aStreamResult, - const nsString& aStringToRead) + nsIInputStream** aStreamResult, + const nsAString& aStringToRead) // Factory method to get an nsInputStream from a string. Result will implement all the // file stream interfaces in nsIFileStream.h //---------------------------------------------------------------------------------------- @@ -540,14 +540,14 @@ extern "C" NS_COM nsresult NS_NewStringInputStream( return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(stream); - *aStreamResult = (nsISupports*)(void*)stream; + *aStreamResult = NS_STATIC_CAST(nsIInputStream*,stream); return NS_OK; } //---------------------------------------------------------------------------------------- extern "C" NS_COM nsresult NS_NewCStringInputStream( - nsISupports** aStreamResult, - const nsCString& aStringToRead) + nsIInputStream** aStreamResult, + const nsACString& aStringToRead) // Factory method to get an nsInputStream from a cstring. Result will implement all the // file stream interfaces in nsIFileStream.h //---------------------------------------------------------------------------------------- @@ -561,7 +561,7 @@ extern "C" NS_COM nsresult NS_NewCStringInputStream( return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(stream); - *aStreamResult = (nsISupports*)(void*)stream; + *aStreamResult = NS_STATIC_CAST(nsIInputStream*,stream); return NS_OK; }