diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.cpp b/mozilla/content/base/src/nsGenericDOMDataNode.cpp index 7068c178796..bc7bd0aeaf0 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/content/base/src/nsGenericDOMDataNode.cpp @@ -353,7 +353,7 @@ nsGenericDOMDataNode::AppendData(nsIContent *aOuterContent, if (textLength) { mText.CopyTo(to, 0, textLength); } - CopyUnicodeTo(aData, to + textLength, dataLength); + CopyUnicodeTo(aData, 0, to + textLength, dataLength); // Null terminate the new buffer... to[newSize] = (PRUnichar)0; @@ -441,7 +441,7 @@ nsGenericDOMDataNode::ReplaceData(nsIContent *aOuterContent, PRUint32 aOffset, mText.CopyTo(to, 0, aOffset); } if (0 != dataLength) { - CopyUnicodeTo(aData, to+aOffset, dataLength); + CopyUnicodeTo(aData, 0, to+aOffset, dataLength); } if (endOffset != textLength) { mText.CopyTo(to + aOffset + dataLength, endOffset, textLength - endOffset); diff --git a/mozilla/content/base/src/nsPlainTextSerializer.cpp b/mozilla/content/base/src/nsPlainTextSerializer.cpp index b639f667bb7..3dc9048c526 100644 --- a/mozilla/content/base/src/nsPlainTextSerializer.cpp +++ b/mozilla/content/base/src/nsPlainTextSerializer.cpp @@ -341,7 +341,7 @@ NS_IMETHODIMP nsPlainTextSerializer::CloseContainer(const nsIParserNode& aNode) { PRInt32 type = aNode.GetNodeType(); - const nsString& namestr = aNode.GetText(); + const nsAReadableString& namestr = aNode.GetText(); nsCOMPtr name = dont_AddRef(NS_NewAtom(namestr)); mParserNode = NS_CONST_CAST(nsIParserNode *, &aNode); @@ -352,7 +352,7 @@ NS_IMETHODIMP nsPlainTextSerializer::AddLeaf(const nsIParserNode& aNode) { PRInt32 type = aNode.GetNodeType(); - const nsString& text = aNode.GetText(); + const nsAReadableString& text = aNode.GetText(); mParserNode = NS_CONST_CAST(nsIParserNode *, &aNode); return DoAddLeaf(type, text); @@ -819,7 +819,7 @@ nsPlainTextSerializer::DoCloseContainer(PRInt32 aTag) nsresult nsPlainTextSerializer::DoAddLeaf(PRInt32 aTag, - const nsString& aText) + const nsAReadableString& aText) { // If we don't want any output, just return if (!DoOutput()) { @@ -1259,10 +1259,10 @@ nsPlainTextSerializer::WriteQuotesAndIndent() // and so should be used for formatted output even if we're not wrapping. // void -nsPlainTextSerializer::Write(const nsString& aString) +nsPlainTextSerializer::Write(const nsAReadableString& aString) { #ifdef DEBUG_wrapping - char* foo = aString.ToNewCString(); + char* foo = ToNewCString(aString); printf("Write(%s): wrap col = %d, mColPos = %d\n", foo, mWrapColumn, mColPos); nsMemory::Free(foo); #endif @@ -1290,7 +1290,7 @@ nsPlainTextSerializer::Write(const nsString& aString) WriteQuotesAndIndent(); } - newline = aString.FindChar('\n',PR_FALSE,bol); + newline = aString.FindChar(PRUnichar('\n'),bol); // XXX should probably also look for \r even though they shouldn't happen if(newline < 0) { @@ -1333,6 +1333,10 @@ nsPlainTextSerializer::Write(const nsString& aString) return; } + // XXX Copy necessary to use nsString methods and gain + // access to underlying buffer + nsAutoString str(aString); + // Intelligent handling of text // If needed, strip out all "end of lines" // and multiple whitespace between words @@ -1342,10 +1346,10 @@ nsPlainTextSerializer::Write(const nsString& aString) while (bol < totLen) { // Loop over lines // Find a place where we may have to do whitespace compression - nextpos = aString.FindCharInSet(" \t\n\r", bol); + nextpos = str.FindCharInSet(" \t\n\r", bol); #ifdef DEBUG_wrapping - nsString remaining; - aString.Right(remaining, totLen - bol); + nsAutoString remaining; + str.Right(remaining, totLen - bol); foo = remaining.ToNewCString(); // printf("Next line: bol = %d, newlinepos = %d, totLen = %d, string = '%s'\n", // bol, nextpos, totLen, foo); @@ -1355,11 +1359,11 @@ nsPlainTextSerializer::Write(const nsString& aString) if(nextpos < 0) { // The rest of the string if(!mCacheLine) { - aString.Right(tempstr, totLen-bol); + str.Right(tempstr, totLen-bol); WriteSimple(tempstr); } else { - offsetIntoBuffer = aString.GetUnicode(); + offsetIntoBuffer = str.GetUnicode(); offsetIntoBuffer = &offsetIntoBuffer[bol]; AddToLine(offsetIntoBuffer, totLen-bol); } @@ -1381,11 +1385,11 @@ nsPlainTextSerializer::Write(const nsString& aString) // Note that we are in whitespace. mInWhitespace = PR_TRUE; if(!mCacheLine) { - nsAutoString whitestring(aString[nextpos]); + nsAutoString whitestring(str[nextpos]); WriteSimple(whitestring); } else { - offsetIntoBuffer = aString.GetUnicode(); + offsetIntoBuffer = str.GetUnicode(); offsetIntoBuffer = &offsetIntoBuffer[nextpos]; AddToLine(offsetIntoBuffer, 1); } @@ -1394,7 +1398,7 @@ nsPlainTextSerializer::Write(const nsString& aString) } if(!mCacheLine) { - aString.Mid(tempstr,bol,nextpos-bol); + str.Mid(tempstr,bol,nextpos-bol); if(mFlags & nsIDocumentEncoder::OutputPreformatted) { bol = nextpos; } @@ -1408,7 +1412,7 @@ nsPlainTextSerializer::Write(const nsString& aString) else { mInWhitespace = PR_TRUE; - offsetIntoBuffer = aString.GetUnicode(); + offsetIntoBuffer = str.GetUnicode(); offsetIntoBuffer = &offsetIntoBuffer[bol]; if(mPreFormatted || (mFlags & nsIDocumentEncoder::OutputPreformatted)) { // Preserve the real whitespace character @@ -1452,7 +1456,7 @@ nsPlainTextSerializer::GetAttributeValue(nsIAtom* aName, PRInt32 count = mParserNode->GetAttributeCount(); for (PRInt32 i=0;iGetKeyAt(i); + const nsAReadableString& key = mParserNode->GetKeyAt(i); if (key.Equals(name)) { aValueRet = mParserNode->GetValueAt(i); aValueRet.StripChars("\""); diff --git a/mozilla/content/base/src/nsPlainTextSerializer.h b/mozilla/content/base/src/nsPlainTextSerializer.h index 69fe23ddccb..802778de056 100644 --- a/mozilla/content/base/src/nsPlainTextSerializer.h +++ b/mozilla/content/base/src/nsPlainTextSerializer.h @@ -114,7 +114,7 @@ protected: void FlushLine(); void WriteQuotesAndIndent(); void WriteSimple(nsString& aString); - void Write(const nsString& aString); + void Write(const nsAReadableString& aString); PRBool DoOutput(); PRBool MayWrap(); PRBool IsBlockLevel(PRInt32 aId); @@ -125,7 +125,7 @@ protected: nsresult GetParserService(nsIParserService** aParserService); nsresult DoOpenContainer(PRInt32 aTag); nsresult DoCloseContainer(PRInt32 aTag); - nsresult DoAddLeaf(PRInt32 aTag, const nsString& aText); + nsresult DoAddLeaf(PRInt32 aTag, const nsAReadableString& aText); protected: nsString mCurrentLine; diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index e7eda37d6c5..12e5fc55bdf 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -110,6 +110,7 @@ #include "nsIScrollable.h" #include "nsContentPolicyUtils.h" +#include "nsReadableUtils.h" #include "nsWeakReference.h"//nshtmlelementfactory supports weak references #ifdef ALLOW_ASYNCH_STYLE_SHEETS @@ -437,7 +438,7 @@ public: nsresult End(); nsresult GrowStack(); - nsresult AddText(const nsString& aText); + nsresult AddText(const nsAReadableString& aText); nsresult FlushText(PRBool* aDidFlush = nsnull, PRBool aReleaseLast = PR_FALSE); nsresult FlushTextAndRelease(PRBool* aDidFlush = nsnull) { @@ -493,6 +494,7 @@ HTMLContentSink::SinkTraceNode(PRUint32 aBit, const char* cp; nsAutoString str; PRInt32 nt = aNode.GetNodeType(); + NS_ConvertUCS2toUTF8 flat(aNode.GetText()); if ((nt > PRInt32(eHTMLTag_unknown)) && (nt < PRInt32(eHTMLTag_text)) && mParser) { nsCOMPtr dtd; @@ -500,8 +502,7 @@ HTMLContentSink::SinkTraceNode(PRUint32 aBit, dtd->IntTagToStringTag(nsHTMLTag(aNode.GetNodeType()), str); cp = str.ToCString(cbuf, sizeof(cbuf)); } else { - aNode.GetText().ToCString(cbuf, sizeof(cbuf)); - cp = cbuf; + cp = (const char*)flat; } PR_LogPrint("%s: this=%p node='%s' stackPos=%d", aMsg, aThis, cp, aStackPos); } @@ -699,7 +700,7 @@ HTMLContentSink::AddAttributes(const nsIParserNode& aNode, PRInt32 ac = aNode.GetAttributeCount(); for (PRInt32 i = 0; i < ac; i++) { // Get upper-cased key - const nsString& key = aNode.GetKeyAt(i); + const nsAReadableString& key = aNode.GetKeyAt(i); k.Truncate(); k.Append(key); k.ToLowerCase(); @@ -1922,7 +1923,7 @@ SinkContext::GrowStack() */ // XXX If we get a giant string grow the buffer instead of chopping it up??? nsresult -SinkContext::AddText(const nsString& aText) +SinkContext::AddText(const nsAReadableString& aText) { PRInt32 addLen = aText.Length(); if (0 == addLen) { @@ -1954,8 +1955,7 @@ SinkContext::AddText(const nsString& aText) return rv; } } - memcpy(&mText[mTextLength], aText.GetUnicode() + offset, - sizeof(PRUnichar) * amount); + CopyUnicodeTo(aText, offset, &mText[mTextLength], amount); mTextLength += amount; offset += amount; addLen -= amount; @@ -3253,7 +3253,7 @@ HTMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode) if (!doc) return NS_OK; - const nsString& docTypeStr = aNode.GetText(); + nsAutoString docTypeStr(aNode.GetText()); PRInt32 publicStart = docTypeStr.Find("PUBLIC", PR_TRUE); PRInt32 systemStart = docTypeStr.Find("SYSTEM", PR_TRUE); @@ -4175,7 +4175,7 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode) nsAutoString media; for (i = 0; i < count; i++) { - const nsString& key = aNode.GetKeyAt(i); + nsAutoString key(aNode.GetKeyAt(i)); if (key.EqualsIgnoreCase("href")) { GetAttributeValueAt(aNode, i, href); href.StripWhitespace(); @@ -4837,7 +4837,7 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) // Look for SRC attribute and look for a LANGUAGE attribute nsAutoString src; for (i = 0; i < ac; i++) { - const nsString& key = aNode.GetKeyAt(i); + nsAutoString key(aNode.GetKeyAt(i)); if (key.EqualsIgnoreCase("src")) { GetAttributeValueAt(aNode, i, src); } @@ -5099,7 +5099,7 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode) nsAutoString media; for (i = 0; i < count; i++) { - const nsString& key = aNode.GetKeyAt(i); + nsAutoString key(aNode.GetKeyAt(i)); if (key.EqualsIgnoreCase("src")) { GetAttributeValueAt(aNode, i, src); src.StripWhitespace(); diff --git a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp index b6ff4618e9c..040d3e05e43 100644 --- a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp @@ -42,6 +42,7 @@ #include "nsIDocument.h" #include "nsINodeInfo.h" #include "prmem.h" +#include "nsReadableUtils.h" // // XXX THIS IS TEMPORARY CODE @@ -114,7 +115,7 @@ public: nsresult AddAttributes(const nsIParserNode& aNode, nsIContent* aContent); - nsresult AddText(const nsString& aString); + nsresult AddText(const nsAReadableString& aString); nsresult AddTextToContent(nsIHTMLContent* aContent,const nsString& aText); nsresult FlushText(); @@ -489,7 +490,7 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode) nsAutoString tmpName; if (nodeType == eHTMLTag_userdefined) { - tmpName = aNode.GetText(); + tmpName.Assign(aNode.GetText()); } else { result = parserService->HTMLIdToStringTag(nodeType, tmpName); NS_ENSURE_SUCCESS(result, result); @@ -567,7 +568,7 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode) nsAutoString tmpName; if (nodeType == eHTMLTag_userdefined) { - tmpName = aNode.GetText(); + tmpName.Assign(aNode.GetText()); } else { result = parserService->HTMLIdToStringTag(nodeType, tmpName); NS_ENSURE_SUCCESS(result, result); @@ -741,7 +742,7 @@ nsHTMLFragmentContentSink::PopContent() #define NS_ACCUMULATION_BUFFER_SIZE 4096 nsresult -nsHTMLFragmentContentSink::AddText(const nsString& aString) +nsHTMLFragmentContentSink::AddText(const nsAReadableString& aString) { PRInt32 addLen = aString.Length(); if (0 == addLen) { @@ -770,8 +771,7 @@ nsHTMLFragmentContentSink::AddText(const nsString& aString) return rv; } } - memcpy(&mText[mTextLength], aString.GetUnicode() + offset, - sizeof(PRUnichar) * amount); + CopyUnicodeTo(aString, offset, &mText[mTextLength], amount); mTextLength += amount; offset += amount; addLen -= amount; @@ -985,7 +985,7 @@ nsHTMLFragmentContentSink::AddAttributes(const nsIParserNode& aNode, PRInt32 ac = aNode.GetAttributeCount(); for (PRInt32 i = 0; i < ac; i++) { // Get upper-cased key - const nsString& key = aNode.GetKeyAt(i); + const nsAReadableString& key = aNode.GetKeyAt(i); k.Truncate(); k.Append(key); k.ToLowerCase(); diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 991b07d7a64..b30c706909f 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -422,7 +422,7 @@ nsXMLContentSink::AddAttributes(const nsIParserNode& aNode, PRInt32 ac = aNode.GetAttributeCount(); for (PRInt32 i = 0; i < ac; i++) { // Get upper-cased key - const nsString& key = aNode.GetKeyAt(i); + const nsAReadableString& key = aNode.GetKeyAt(i); name.Assign(key); nsCOMPtr nameSpacePrefix(dont_AddRef(CutNameSpacePrefix(name))); @@ -498,7 +498,7 @@ nsXMLContentSink::PushNameSpacesFrom(const nsIParserNode& aNode) if (nsnull != nameSpace) { for (PRInt32 i = 0; i < ac; i++) { - const nsString& key = aNode.GetKeyAt(i); + const nsAReadableString& key = aNode.GetKeyAt(i); k.Assign(key); // Look for "xmlns" at the start of the attribute name offset = k.Find(kNameSpaceDef); @@ -1225,7 +1225,7 @@ nsXMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode) if (!doc) return NS_OK; - const nsString& docTypeStr = aNode.GetText(); + nsAutoString docTypeStr(aNode.GetText()); nsAutoString str, name, publicId, systemId; if (docTypeStr.EqualsWithConversion("' detected at line %d\n", tagStr, aNode.GetSourceLineNumber())); @@ -924,7 +924,7 @@ XULContentSinkImpl::AddProcessingInstruction(const nsIParserNode& aNode) // XXX For now, we don't add the PI to the content model. // We just check for a style sheet PI - const nsString& text = aNode.GetText(); + nsAutoString text(aNode.GetText()); if (text.Find(kOverlayPI) == 0) { // Load a XUL overlay. @@ -1205,7 +1205,7 @@ nsresult XULContentSinkImpl::GetXULIDAttribute(const nsIParserNode& aNode, nsString& aID) { for (PRInt32 i = aNode.GetAttributeCount(); i >= 0; --i) { - if (aNode.GetKeyAt(i).EqualsWithConversion("id")) { + if (aNode.GetKeyAt(i).Equals(NS_LITERAL_STRING("id"))) { aID = aNode.GetValueAt(i); nsRDFParserUtils::StripAndConvert(aID); return NS_OK; @@ -1232,7 +1232,7 @@ XULContentSinkImpl::AddAttributes(const nsIParserNode& aNode, nsXULPrototypeElem generateIDAttr = PR_TRUE; for (PRInt32 i = 0; i < count; i++) { - if (aNode.GetKeyAt(i).EqualsWithConversion("id")) { + if (aNode.GetKeyAt(i).Equals(NS_LITERAL_STRING("id"))) { generateIDAttr = PR_FALSE; break; } @@ -1271,7 +1271,7 @@ XULContentSinkImpl::AddAttributes(const nsIParserNode& aNode, nsXULPrototypeElem // Copy the attributes into the prototype for (PRInt32 i = 0; i < count; i++) { - const nsString& qname = aNode.GetKeyAt(i); + const nsAReadableString& qname = aNode.GetKeyAt(i); rv = NormalizeAttributeString(qname, *getter_AddRefs(attrs->mNodeInfo)); @@ -1360,7 +1360,7 @@ XULContentSinkImpl::AddAttributes(const nsIParserNode& aNode, nsXULPrototypeElem nsresult -XULContentSinkImpl::ParseTag(const nsString& aText, nsINodeInfo*& aNodeInfo) +XULContentSinkImpl::ParseTag(const nsAReadableString& aText, nsINodeInfo*& aNodeInfo) { nsresult rv; @@ -1520,12 +1520,14 @@ XULContentSinkImpl::OpenTag(const nsIParserNode& aNode, nsINodeInfo *aNodeInfo) rv = CreateElement(aNodeInfo, &element); if (NS_FAILED(rv)) { +#ifdef PR_LOGGING nsCAutoString anodeC; anodeC.AssignWithConversion(aNode.GetText()); PR_LOG(gLog, PR_LOG_ALWAYS, ("xul: unable to create element '%s' at line %d", NS_STATIC_CAST(const char*, anodeC), aNode.GetSourceLineNumber())); +#endif return rv; } @@ -1565,7 +1567,7 @@ XULContentSinkImpl::OpenScript(const nsIParserNode& aNode) // Look for SRC attribute and look for a LANGUAGE attribute nsAutoString src; for (PRInt32 i = 0; i < ac; i++) { - const nsString& key = aNode.GetKeyAt(i); + nsAutoString key(aNode.GetKeyAt(i)); if (key.EqualsIgnoreCase("src")) { src.Assign(aNode.GetValueAt(i)); nsRDFParserUtils::StripAndConvert(src); diff --git a/mozilla/editor/base/nsEditorParserObserver.h b/mozilla/editor/base/nsEditorParserObserver.h index dbc2701c2ef..53d8d1f7d1c 100644 --- a/mozilla/editor/base/nsEditorParserObserver.h +++ b/mozilla/editor/base/nsEditorParserObserver.h @@ -26,6 +26,7 @@ #include "nsIObserverService.h" #include "nsWeakReference.h" +#include "nsString.h" #include "nsVoidArray.h" class nsEditorParserObserver : public nsSupportsWeakReference, diff --git a/mozilla/editor/composer/src/nsEditorParserObserver.h b/mozilla/editor/composer/src/nsEditorParserObserver.h index dbc2701c2ef..53d8d1f7d1c 100644 --- a/mozilla/editor/composer/src/nsEditorParserObserver.h +++ b/mozilla/editor/composer/src/nsEditorParserObserver.h @@ -26,6 +26,7 @@ #include "nsIObserverService.h" #include "nsWeakReference.h" +#include "nsString.h" #include "nsVoidArray.h" class nsEditorParserObserver : public nsSupportsWeakReference, diff --git a/mozilla/intl/chardet/src/nsDetectionAdaptor.cpp b/mozilla/intl/chardet/src/nsDetectionAdaptor.cpp index b35bb52819d..e4f3a7bdee4 100644 --- a/mozilla/intl/chardet/src/nsDetectionAdaptor.cpp +++ b/mozilla/intl/chardet/src/nsDetectionAdaptor.cpp @@ -161,7 +161,7 @@ class nsDetectionAdaptor : const char* aCommand=nsnull); // Methode to suppor nsIParserFilter - NS_IMETHOD RawBuffer(char * buffer, PRUint32 * buffer_length) ; + NS_IMETHOD RawBuffer(const char * buffer, PRUint32 * buffer_length) ; NS_IMETHOD Finish(); // really don't care the following two, only because they are defined @@ -267,7 +267,7 @@ NS_IMETHODIMP nsDetectionAdaptor::Init( } //-------------------------------------------------------------- NS_IMETHODIMP nsDetectionAdaptor::RawBuffer - (char * buffer, PRUint32 * buffer_length) + (const char * buffer, PRUint32 * buffer_length) { if((mDontFeedToDetector) || (nsnull == mDetector)) return NS_OK; diff --git a/mozilla/layout/base/src/nsGenericDOMDataNode.cpp b/mozilla/layout/base/src/nsGenericDOMDataNode.cpp index 7068c178796..bc7bd0aeaf0 100644 --- a/mozilla/layout/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/layout/base/src/nsGenericDOMDataNode.cpp @@ -353,7 +353,7 @@ nsGenericDOMDataNode::AppendData(nsIContent *aOuterContent, if (textLength) { mText.CopyTo(to, 0, textLength); } - CopyUnicodeTo(aData, to + textLength, dataLength); + CopyUnicodeTo(aData, 0, to + textLength, dataLength); // Null terminate the new buffer... to[newSize] = (PRUnichar)0; @@ -441,7 +441,7 @@ nsGenericDOMDataNode::ReplaceData(nsIContent *aOuterContent, PRUint32 aOffset, mText.CopyTo(to, 0, aOffset); } if (0 != dataLength) { - CopyUnicodeTo(aData, to+aOffset, dataLength); + CopyUnicodeTo(aData, 0, to+aOffset, dataLength); } if (endOffset != textLength) { mText.CopyTo(to + aOffset + dataLength, endOffset, textLength - endOffset); diff --git a/mozilla/layout/base/src/nsPlainTextSerializer.cpp b/mozilla/layout/base/src/nsPlainTextSerializer.cpp index b639f667bb7..3dc9048c526 100644 --- a/mozilla/layout/base/src/nsPlainTextSerializer.cpp +++ b/mozilla/layout/base/src/nsPlainTextSerializer.cpp @@ -341,7 +341,7 @@ NS_IMETHODIMP nsPlainTextSerializer::CloseContainer(const nsIParserNode& aNode) { PRInt32 type = aNode.GetNodeType(); - const nsString& namestr = aNode.GetText(); + const nsAReadableString& namestr = aNode.GetText(); nsCOMPtr name = dont_AddRef(NS_NewAtom(namestr)); mParserNode = NS_CONST_CAST(nsIParserNode *, &aNode); @@ -352,7 +352,7 @@ NS_IMETHODIMP nsPlainTextSerializer::AddLeaf(const nsIParserNode& aNode) { PRInt32 type = aNode.GetNodeType(); - const nsString& text = aNode.GetText(); + const nsAReadableString& text = aNode.GetText(); mParserNode = NS_CONST_CAST(nsIParserNode *, &aNode); return DoAddLeaf(type, text); @@ -819,7 +819,7 @@ nsPlainTextSerializer::DoCloseContainer(PRInt32 aTag) nsresult nsPlainTextSerializer::DoAddLeaf(PRInt32 aTag, - const nsString& aText) + const nsAReadableString& aText) { // If we don't want any output, just return if (!DoOutput()) { @@ -1259,10 +1259,10 @@ nsPlainTextSerializer::WriteQuotesAndIndent() // and so should be used for formatted output even if we're not wrapping. // void -nsPlainTextSerializer::Write(const nsString& aString) +nsPlainTextSerializer::Write(const nsAReadableString& aString) { #ifdef DEBUG_wrapping - char* foo = aString.ToNewCString(); + char* foo = ToNewCString(aString); printf("Write(%s): wrap col = %d, mColPos = %d\n", foo, mWrapColumn, mColPos); nsMemory::Free(foo); #endif @@ -1290,7 +1290,7 @@ nsPlainTextSerializer::Write(const nsString& aString) WriteQuotesAndIndent(); } - newline = aString.FindChar('\n',PR_FALSE,bol); + newline = aString.FindChar(PRUnichar('\n'),bol); // XXX should probably also look for \r even though they shouldn't happen if(newline < 0) { @@ -1333,6 +1333,10 @@ nsPlainTextSerializer::Write(const nsString& aString) return; } + // XXX Copy necessary to use nsString methods and gain + // access to underlying buffer + nsAutoString str(aString); + // Intelligent handling of text // If needed, strip out all "end of lines" // and multiple whitespace between words @@ -1342,10 +1346,10 @@ nsPlainTextSerializer::Write(const nsString& aString) while (bol < totLen) { // Loop over lines // Find a place where we may have to do whitespace compression - nextpos = aString.FindCharInSet(" \t\n\r", bol); + nextpos = str.FindCharInSet(" \t\n\r", bol); #ifdef DEBUG_wrapping - nsString remaining; - aString.Right(remaining, totLen - bol); + nsAutoString remaining; + str.Right(remaining, totLen - bol); foo = remaining.ToNewCString(); // printf("Next line: bol = %d, newlinepos = %d, totLen = %d, string = '%s'\n", // bol, nextpos, totLen, foo); @@ -1355,11 +1359,11 @@ nsPlainTextSerializer::Write(const nsString& aString) if(nextpos < 0) { // The rest of the string if(!mCacheLine) { - aString.Right(tempstr, totLen-bol); + str.Right(tempstr, totLen-bol); WriteSimple(tempstr); } else { - offsetIntoBuffer = aString.GetUnicode(); + offsetIntoBuffer = str.GetUnicode(); offsetIntoBuffer = &offsetIntoBuffer[bol]; AddToLine(offsetIntoBuffer, totLen-bol); } @@ -1381,11 +1385,11 @@ nsPlainTextSerializer::Write(const nsString& aString) // Note that we are in whitespace. mInWhitespace = PR_TRUE; if(!mCacheLine) { - nsAutoString whitestring(aString[nextpos]); + nsAutoString whitestring(str[nextpos]); WriteSimple(whitestring); } else { - offsetIntoBuffer = aString.GetUnicode(); + offsetIntoBuffer = str.GetUnicode(); offsetIntoBuffer = &offsetIntoBuffer[nextpos]; AddToLine(offsetIntoBuffer, 1); } @@ -1394,7 +1398,7 @@ nsPlainTextSerializer::Write(const nsString& aString) } if(!mCacheLine) { - aString.Mid(tempstr,bol,nextpos-bol); + str.Mid(tempstr,bol,nextpos-bol); if(mFlags & nsIDocumentEncoder::OutputPreformatted) { bol = nextpos; } @@ -1408,7 +1412,7 @@ nsPlainTextSerializer::Write(const nsString& aString) else { mInWhitespace = PR_TRUE; - offsetIntoBuffer = aString.GetUnicode(); + offsetIntoBuffer = str.GetUnicode(); offsetIntoBuffer = &offsetIntoBuffer[bol]; if(mPreFormatted || (mFlags & nsIDocumentEncoder::OutputPreformatted)) { // Preserve the real whitespace character @@ -1452,7 +1456,7 @@ nsPlainTextSerializer::GetAttributeValue(nsIAtom* aName, PRInt32 count = mParserNode->GetAttributeCount(); for (PRInt32 i=0;iGetKeyAt(i); + const nsAReadableString& key = mParserNode->GetKeyAt(i); if (key.Equals(name)) { aValueRet = mParserNode->GetValueAt(i); aValueRet.StripChars("\""); diff --git a/mozilla/layout/base/src/nsPlainTextSerializer.h b/mozilla/layout/base/src/nsPlainTextSerializer.h index 69fe23ddccb..802778de056 100644 --- a/mozilla/layout/base/src/nsPlainTextSerializer.h +++ b/mozilla/layout/base/src/nsPlainTextSerializer.h @@ -114,7 +114,7 @@ protected: void FlushLine(); void WriteQuotesAndIndent(); void WriteSimple(nsString& aString); - void Write(const nsString& aString); + void Write(const nsAReadableString& aString); PRBool DoOutput(); PRBool MayWrap(); PRBool IsBlockLevel(PRInt32 aId); @@ -125,7 +125,7 @@ protected: nsresult GetParserService(nsIParserService** aParserService); nsresult DoOpenContainer(PRInt32 aTag); nsresult DoCloseContainer(PRInt32 aTag); - nsresult DoAddLeaf(PRInt32 aTag, const nsString& aText); + nsresult DoAddLeaf(PRInt32 aTag, const nsAReadableString& aText); protected: nsString mCurrentLine; diff --git a/mozilla/layout/generic/nsTextTransformer.cpp b/mozilla/layout/generic/nsTextTransformer.cpp index 33849723a3f..84eac702719 100644 --- a/mozilla/layout/generic/nsTextTransformer.cpp +++ b/mozilla/layout/generic/nsTextTransformer.cpp @@ -106,11 +106,11 @@ nsTextTransformer::Shutdown() } } -// For now, we have only a single character to strip out. If we get +// For now, we have only a couple of characters to strip out. If we get // any more, change this to use a bitset to lookup into. // CH_SHY - soft hyphen (discretionary hyphen) #define IS_DISCARDED(_ch) \ - ((_ch) == CH_SHY) + (((_ch) == CH_SHY) || ((_ch) == '\r')) #define MAX_UNIBYTE 127 diff --git a/mozilla/layout/html/base/src/nsTextTransformer.cpp b/mozilla/layout/html/base/src/nsTextTransformer.cpp index 33849723a3f..84eac702719 100644 --- a/mozilla/layout/html/base/src/nsTextTransformer.cpp +++ b/mozilla/layout/html/base/src/nsTextTransformer.cpp @@ -106,11 +106,11 @@ nsTextTransformer::Shutdown() } } -// For now, we have only a single character to strip out. If we get +// For now, we have only a couple of characters to strip out. If we get // any more, change this to use a bitset to lookup into. // CH_SHY - soft hyphen (discretionary hyphen) #define IS_DISCARDED(_ch) \ - ((_ch) == CH_SHY) + (((_ch) == CH_SHY) || ((_ch) == '\r')) #define MAX_UNIBYTE 127 diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp index e7eda37d6c5..12e5fc55bdf 100644 --- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp @@ -110,6 +110,7 @@ #include "nsIScrollable.h" #include "nsContentPolicyUtils.h" +#include "nsReadableUtils.h" #include "nsWeakReference.h"//nshtmlelementfactory supports weak references #ifdef ALLOW_ASYNCH_STYLE_SHEETS @@ -437,7 +438,7 @@ public: nsresult End(); nsresult GrowStack(); - nsresult AddText(const nsString& aText); + nsresult AddText(const nsAReadableString& aText); nsresult FlushText(PRBool* aDidFlush = nsnull, PRBool aReleaseLast = PR_FALSE); nsresult FlushTextAndRelease(PRBool* aDidFlush = nsnull) { @@ -493,6 +494,7 @@ HTMLContentSink::SinkTraceNode(PRUint32 aBit, const char* cp; nsAutoString str; PRInt32 nt = aNode.GetNodeType(); + NS_ConvertUCS2toUTF8 flat(aNode.GetText()); if ((nt > PRInt32(eHTMLTag_unknown)) && (nt < PRInt32(eHTMLTag_text)) && mParser) { nsCOMPtr dtd; @@ -500,8 +502,7 @@ HTMLContentSink::SinkTraceNode(PRUint32 aBit, dtd->IntTagToStringTag(nsHTMLTag(aNode.GetNodeType()), str); cp = str.ToCString(cbuf, sizeof(cbuf)); } else { - aNode.GetText().ToCString(cbuf, sizeof(cbuf)); - cp = cbuf; + cp = (const char*)flat; } PR_LogPrint("%s: this=%p node='%s' stackPos=%d", aMsg, aThis, cp, aStackPos); } @@ -699,7 +700,7 @@ HTMLContentSink::AddAttributes(const nsIParserNode& aNode, PRInt32 ac = aNode.GetAttributeCount(); for (PRInt32 i = 0; i < ac; i++) { // Get upper-cased key - const nsString& key = aNode.GetKeyAt(i); + const nsAReadableString& key = aNode.GetKeyAt(i); k.Truncate(); k.Append(key); k.ToLowerCase(); @@ -1922,7 +1923,7 @@ SinkContext::GrowStack() */ // XXX If we get a giant string grow the buffer instead of chopping it up??? nsresult -SinkContext::AddText(const nsString& aText) +SinkContext::AddText(const nsAReadableString& aText) { PRInt32 addLen = aText.Length(); if (0 == addLen) { @@ -1954,8 +1955,7 @@ SinkContext::AddText(const nsString& aText) return rv; } } - memcpy(&mText[mTextLength], aText.GetUnicode() + offset, - sizeof(PRUnichar) * amount); + CopyUnicodeTo(aText, offset, &mText[mTextLength], amount); mTextLength += amount; offset += amount; addLen -= amount; @@ -3253,7 +3253,7 @@ HTMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode) if (!doc) return NS_OK; - const nsString& docTypeStr = aNode.GetText(); + nsAutoString docTypeStr(aNode.GetText()); PRInt32 publicStart = docTypeStr.Find("PUBLIC", PR_TRUE); PRInt32 systemStart = docTypeStr.Find("SYSTEM", PR_TRUE); @@ -4175,7 +4175,7 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode) nsAutoString media; for (i = 0; i < count; i++) { - const nsString& key = aNode.GetKeyAt(i); + nsAutoString key(aNode.GetKeyAt(i)); if (key.EqualsIgnoreCase("href")) { GetAttributeValueAt(aNode, i, href); href.StripWhitespace(); @@ -4837,7 +4837,7 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) // Look for SRC attribute and look for a LANGUAGE attribute nsAutoString src; for (i = 0; i < ac; i++) { - const nsString& key = aNode.GetKeyAt(i); + nsAutoString key(aNode.GetKeyAt(i)); if (key.EqualsIgnoreCase("src")) { GetAttributeValueAt(aNode, i, src); } @@ -5099,7 +5099,7 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode) nsAutoString media; for (i = 0; i < count; i++) { - const nsString& key = aNode.GetKeyAt(i); + nsAutoString key(aNode.GetKeyAt(i)); if (key.EqualsIgnoreCase("src")) { GetAttributeValueAt(aNode, i, src); src.StripWhitespace(); diff --git a/mozilla/layout/html/document/src/nsHTMLFragmentContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLFragmentContentSink.cpp index b6ff4618e9c..040d3e05e43 100644 --- a/mozilla/layout/html/document/src/nsHTMLFragmentContentSink.cpp +++ b/mozilla/layout/html/document/src/nsHTMLFragmentContentSink.cpp @@ -42,6 +42,7 @@ #include "nsIDocument.h" #include "nsINodeInfo.h" #include "prmem.h" +#include "nsReadableUtils.h" // // XXX THIS IS TEMPORARY CODE @@ -114,7 +115,7 @@ public: nsresult AddAttributes(const nsIParserNode& aNode, nsIContent* aContent); - nsresult AddText(const nsString& aString); + nsresult AddText(const nsAReadableString& aString); nsresult AddTextToContent(nsIHTMLContent* aContent,const nsString& aText); nsresult FlushText(); @@ -489,7 +490,7 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode) nsAutoString tmpName; if (nodeType == eHTMLTag_userdefined) { - tmpName = aNode.GetText(); + tmpName.Assign(aNode.GetText()); } else { result = parserService->HTMLIdToStringTag(nodeType, tmpName); NS_ENSURE_SUCCESS(result, result); @@ -567,7 +568,7 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode) nsAutoString tmpName; if (nodeType == eHTMLTag_userdefined) { - tmpName = aNode.GetText(); + tmpName.Assign(aNode.GetText()); } else { result = parserService->HTMLIdToStringTag(nodeType, tmpName); NS_ENSURE_SUCCESS(result, result); @@ -741,7 +742,7 @@ nsHTMLFragmentContentSink::PopContent() #define NS_ACCUMULATION_BUFFER_SIZE 4096 nsresult -nsHTMLFragmentContentSink::AddText(const nsString& aString) +nsHTMLFragmentContentSink::AddText(const nsAReadableString& aString) { PRInt32 addLen = aString.Length(); if (0 == addLen) { @@ -770,8 +771,7 @@ nsHTMLFragmentContentSink::AddText(const nsString& aString) return rv; } } - memcpy(&mText[mTextLength], aString.GetUnicode() + offset, - sizeof(PRUnichar) * amount); + CopyUnicodeTo(aString, offset, &mText[mTextLength], amount); mTextLength += amount; offset += amount; addLen -= amount; @@ -985,7 +985,7 @@ nsHTMLFragmentContentSink::AddAttributes(const nsIParserNode& aNode, PRInt32 ac = aNode.GetAttributeCount(); for (PRInt32 i = 0; i < ac; i++) { // Get upper-cased key - const nsString& key = aNode.GetKeyAt(i); + const nsAReadableString& key = aNode.GetKeyAt(i); k.Truncate(); k.Append(key); k.ToLowerCase(); diff --git a/mozilla/layout/xml/document/src/nsXMLContentSink.cpp b/mozilla/layout/xml/document/src/nsXMLContentSink.cpp index 991b07d7a64..b30c706909f 100644 --- a/mozilla/layout/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/layout/xml/document/src/nsXMLContentSink.cpp @@ -422,7 +422,7 @@ nsXMLContentSink::AddAttributes(const nsIParserNode& aNode, PRInt32 ac = aNode.GetAttributeCount(); for (PRInt32 i = 0; i < ac; i++) { // Get upper-cased key - const nsString& key = aNode.GetKeyAt(i); + const nsAReadableString& key = aNode.GetKeyAt(i); name.Assign(key); nsCOMPtr nameSpacePrefix(dont_AddRef(CutNameSpacePrefix(name))); @@ -498,7 +498,7 @@ nsXMLContentSink::PushNameSpacesFrom(const nsIParserNode& aNode) if (nsnull != nameSpace) { for (PRInt32 i = 0; i < ac; i++) { - const nsString& key = aNode.GetKeyAt(i); + const nsAReadableString& key = aNode.GetKeyAt(i); k.Assign(key); // Look for "xmlns" at the start of the attribute name offset = k.Find(kNameSpaceDef); @@ -1225,7 +1225,7 @@ nsXMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode) if (!doc) return NS_OK; - const nsString& docTypeStr = aNode.GetText(); + nsAutoString docTypeStr(aNode.GetText()); nsAutoString str, name, publicId, systemId; if (docTypeStr.EqualsWithConversion(" attr; @@ -1068,7 +1069,7 @@ RDFContentSinkImpl::GetResourceAttribute(const nsIParserNode& aNode, for (PRInt32 i = 0; i < ac; i++) { // Get upper-cased key - const nsString& key = aNode.GetKeyAt(i); + const nsAReadableString& key = aNode.GetKeyAt(i); const char* nameSpaceURI; nsCOMPtr attr; @@ -1117,7 +1118,7 @@ RDFContentSinkImpl::AddProperties(const nsIParserNode& aNode, for (PRInt32 i = 0; i < count; i++) { // Get upper-cased key - const nsString& key = aNode.GetKeyAt(i); + const nsAReadableString& key = aNode.GetKeyAt(i); // skip 'xmlns' directives, these are "meta" information if (IsXMLNSDirective(key)) @@ -1572,27 +1573,29 @@ RDFContentSinkImpl::PopContext(nsIRDFResource*& rResource, RDFContentSinkState& // Namespace management PRBool -RDFContentSinkImpl::IsXMLNSDirective(const nsString& aAttributeKey, nsIAtom** aPrefix) +RDFContentSinkImpl::IsXMLNSDirective(const nsAReadableString& aAttributeKey, nsIAtom** aPrefix) { + nsAutoString attr(aAttributeKey); + // Look for `xmlns' at the start of the attribute name - PRInt32 offset = aAttributeKey.Find(kNameSpaceDef); + PRInt32 offset = attr.Find(kNameSpaceDef); if (offset != 0) return PR_FALSE; - PRInt32 prefixLen = aAttributeKey.Length() - sizeof(kNameSpaceDef); + PRInt32 prefixLen = attr.Length() - sizeof(kNameSpaceDef); if (prefixLen <= 0) { // they're setting the default namespace; leave `prefix' // as nsnull. } else { // make sure there's a `:' character - if (aAttributeKey[sizeof(kNameSpaceDef) - 1] != kNameSpaceSeparator) + if (attr[sizeof(kNameSpaceDef) - 1] != kNameSpaceSeparator) return PR_FALSE; // if the caller wants the prefix back, compute it for them. if (aPrefix) { nsAutoString prefixStr; - aAttributeKey.Right(prefixStr, prefixLen); + attr.Right(prefixStr, prefixLen); *aPrefix = NS_NewAtom(prefixStr); } @@ -1611,7 +1614,7 @@ RDFContentSinkImpl::PushNameSpacesFrom(const nsIParserNode& aNode) PRInt32 count = aNode.GetAttributeCount(); for (PRInt32 i = 0; i < count; ++i) { - const nsString& key = aNode.GetKeyAt(i); + const nsAReadableString& key = aNode.GetKeyAt(i); nsCOMPtr prefix; if (! IsXMLNSDirective(key, getter_AddRefs(prefix))) diff --git a/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp b/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp index 8b2ff93350f..6a58baa9aba 100644 --- a/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp +++ b/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp @@ -153,21 +153,24 @@ public: } NS_IMETHOD Read(char* aBuf, PRUint32 aCount, PRUint32 *aReadCount) { - PRUint32 readCount = 0; - while (mIndex < mSize && aCount > 0) { - *aBuf = mBuffer[mIndex]; - aBuf++; - mIndex++; - readCount++; - aCount--; - } + PRUint32 readCount = PR_MIN(aCount, (mSize-mIndex)); + + nsCRT::memcpy(aBuf, mBuffer+mIndex, readCount); + mIndex += readCount; + *aReadCount = readCount; + return NS_OK; } NS_IMETHOD ReadSegments(nsWriteSegmentFun writer, void * closure, PRUint32 count, PRUint32 *_retval) { - NS_NOTREACHED("ReadSegments"); - return NS_ERROR_NOT_IMPLEMENTED; + PRUint32 readCount = PR_MIN(count, (mSize-mIndex)); + + *_retval = 0; + nsresult rv = writer (this, closure, mBuffer+mIndex, mIndex, readCount, _retval); + mIndex += *_retval; + + return rv; } NS_IMETHOD GetNonBlocking(PRBool *aNonBlocking) { diff --git a/mozilla/rdf/content/src/nsXULContentSink.cpp b/mozilla/rdf/content/src/nsXULContentSink.cpp index 036bdd2580b..d7221431929 100644 --- a/mozilla/rdf/content/src/nsXULContentSink.cpp +++ b/mozilla/rdf/content/src/nsXULContentSink.cpp @@ -178,7 +178,7 @@ protected: // RDF-specific parsing nsresult GetXULIDAttribute(const nsIParserNode& aNode, nsString& aID); nsresult AddAttributes(const nsIParserNode& aNode, nsXULPrototypeElement* aElement); - nsresult ParseTag(const nsString& aText, nsINodeInfo*& aNodeInfo); + nsresult ParseTag(const nsAReadableString& aText, nsINodeInfo*& aNodeInfo); nsresult NormalizeAttributeString(const nsAReadableString& aText, nsINodeInfo*& aNodeInfo); nsresult CreateElement(nsINodeInfo *aNodeInfo, nsXULPrototypeElement** aResult); @@ -591,7 +591,7 @@ XULContentSinkImpl::OpenContainer(const nsIParserNode& aNode) #ifdef PR_LOGGING if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) { - const nsString& text = aNode.GetText(); + const nsAReadableString& text = aNode.GetText(); nsCAutoString extraWhiteSpace; PRInt32 count = mContextStack.Depth(); @@ -668,7 +668,7 @@ XULContentSinkImpl::CloseContainer(const nsIParserNode& aNode) #ifdef PR_LOGGING if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) { - const nsString& text = aNode.GetText(); + const nsAReadableString& text = aNode.GetText(); nsCAutoString extraWhiteSpace; PRInt32 count = mContextStack.Depth(); @@ -692,7 +692,7 @@ XULContentSinkImpl::CloseContainer(const nsIParserNode& aNode) if (NS_FAILED(rv)) { #ifdef PR_LOGGING if (PR_LOG_TEST(gLog, PR_LOG_ALWAYS)) { - char* tagStr = aNode.GetText().ToNewCString(); + char* tagStr = ToNewCString(aNode.GetText()); PR_LOG(gLog, PR_LOG_ALWAYS, ("xul: extra close tag '' detected at line %d\n", tagStr, aNode.GetSourceLineNumber())); @@ -924,7 +924,7 @@ XULContentSinkImpl::AddProcessingInstruction(const nsIParserNode& aNode) // XXX For now, we don't add the PI to the content model. // We just check for a style sheet PI - const nsString& text = aNode.GetText(); + nsAutoString text(aNode.GetText()); if (text.Find(kOverlayPI) == 0) { // Load a XUL overlay. @@ -1205,7 +1205,7 @@ nsresult XULContentSinkImpl::GetXULIDAttribute(const nsIParserNode& aNode, nsString& aID) { for (PRInt32 i = aNode.GetAttributeCount(); i >= 0; --i) { - if (aNode.GetKeyAt(i).EqualsWithConversion("id")) { + if (aNode.GetKeyAt(i).Equals(NS_LITERAL_STRING("id"))) { aID = aNode.GetValueAt(i); nsRDFParserUtils::StripAndConvert(aID); return NS_OK; @@ -1232,7 +1232,7 @@ XULContentSinkImpl::AddAttributes(const nsIParserNode& aNode, nsXULPrototypeElem generateIDAttr = PR_TRUE; for (PRInt32 i = 0; i < count; i++) { - if (aNode.GetKeyAt(i).EqualsWithConversion("id")) { + if (aNode.GetKeyAt(i).Equals(NS_LITERAL_STRING("id"))) { generateIDAttr = PR_FALSE; break; } @@ -1271,7 +1271,7 @@ XULContentSinkImpl::AddAttributes(const nsIParserNode& aNode, nsXULPrototypeElem // Copy the attributes into the prototype for (PRInt32 i = 0; i < count; i++) { - const nsString& qname = aNode.GetKeyAt(i); + const nsAReadableString& qname = aNode.GetKeyAt(i); rv = NormalizeAttributeString(qname, *getter_AddRefs(attrs->mNodeInfo)); @@ -1360,7 +1360,7 @@ XULContentSinkImpl::AddAttributes(const nsIParserNode& aNode, nsXULPrototypeElem nsresult -XULContentSinkImpl::ParseTag(const nsString& aText, nsINodeInfo*& aNodeInfo) +XULContentSinkImpl::ParseTag(const nsAReadableString& aText, nsINodeInfo*& aNodeInfo) { nsresult rv; @@ -1520,12 +1520,14 @@ XULContentSinkImpl::OpenTag(const nsIParserNode& aNode, nsINodeInfo *aNodeInfo) rv = CreateElement(aNodeInfo, &element); if (NS_FAILED(rv)) { +#ifdef PR_LOGGING nsCAutoString anodeC; anodeC.AssignWithConversion(aNode.GetText()); PR_LOG(gLog, PR_LOG_ALWAYS, ("xul: unable to create element '%s' at line %d", NS_STATIC_CAST(const char*, anodeC), aNode.GetSourceLineNumber())); +#endif return rv; } @@ -1565,7 +1567,7 @@ XULContentSinkImpl::OpenScript(const nsIParserNode& aNode) // Look for SRC attribute and look for a LANGUAGE attribute nsAutoString src; for (PRInt32 i = 0; i < ac; i++) { - const nsString& key = aNode.GetKeyAt(i); + nsAutoString key(aNode.GetKeyAt(i)); if (key.EqualsIgnoreCase("src")) { src.Assign(aNode.GetValueAt(i)); nsRDFParserUtils::StripAndConvert(src);