diff --git a/mozilla/extensions/xmlterm/base/mozLineTerm.cpp b/mozilla/extensions/xmlterm/base/mozLineTerm.cpp index 92fde77828d..b70b82bea33 100644 --- a/mozilla/extensions/xmlterm/base/mozLineTerm.cpp +++ b/mozilla/extensions/xmlterm/base/mozLineTerm.cpp @@ -98,7 +98,7 @@ mozLineTerm::mozLineTerm() : mSuspended(PR_FALSE), mEchoFlag(PR_TRUE), mObserver(nsnull), - mCookie(""), + mCookie(nsAutoString()), mLastTime(LL_ZERO) { NS_INIT_REFCNT(); @@ -345,7 +345,7 @@ NS_IMETHODIMP mozLineTerm::OpenAux(const PRUnichar *command, return NS_ERROR_FAILURE; // Ensure that cookie attribute of document is defined - nsAutoString cookiePrefix ( "xmlterm=" ); + nsAutoString cookiePrefix ( NS_ConvertASCIItoUCS2("xmlterm=") ); nsAutoString cookieStr; result = domHTMLDoc->GetCookie(cookieStr); @@ -381,7 +381,8 @@ NS_IMETHODIMP mozLineTerm::OpenAux(const PRUnichar *command, XMLT_LOG(mozLineTerm::Open,22, ("mCookie=%s\n", cookieCStr)); // Convert initInput to CString - nsCAutoString initCStr (initInput); + nsCAutoString initCStr; + initCStr.AssignWithConversion(initInput); XMLT_LOG(mozLineTerm::Open,22, ("initInput=%s\n", initCStr.GetBuffer())); // List of prompt delimiters @@ -455,7 +456,7 @@ NS_IMETHODIMP mozLineTerm::SuspendAux(PRBool aSuspend) */ NS_IMETHODIMP mozLineTerm::Close(const PRUnichar* aCookie) { - if (!mCookie.Equals(aCookie)) { + if (!mCookie.EqualsWithConversion(aCookie)) { XMLT_ERROR("mozLineTerm::Close: Error - Cookie mismatch\n"); return NS_ERROR_FAILURE; } @@ -523,7 +524,7 @@ NS_IMETHODIMP mozLineTerm::ResizeAux(PRInt32 nRows, PRInt32 nCols) NS_IMETHODIMP mozLineTerm::Write(const PRUnichar *buf, const PRUnichar* aCookie) { - if (!mCookie.Equals(aCookie)) { + if (!mCookie.EqualsWithConversion(aCookie)) { XMLT_ERROR("mozLineTerm::Write: Error - Cookie mismatch\n"); return NS_ERROR_FAILURE; } @@ -592,7 +593,7 @@ NS_IMETHODIMP mozLineTerm::Read(PRInt32 *opcodes, PRInt32 *opvals, const PRUnichar* aCookie, PRUnichar **_retval) { - if (!mCookie.Equals(aCookie)) { + if (!mCookie.EqualsWithConversion(aCookie)) { XMLT_ERROR("mozLineTerm::Read: Error - Cookie mismatch\n"); return NS_ERROR_FAILURE; } diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermListeners.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermListeners.cpp index 2b8cc1e8560..6d903071ad2 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermListeners.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermListeners.cpp @@ -278,7 +278,7 @@ mozXMLTermKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) PRUint32 keyChar = 0; PRUint32 escPrefix = 0; - nsAutoString JSCommand = ""; + nsAutoString JSCommand; JSCommand.SetLength(0); PRBool screenMode = 0; result = mXMLTerminal->GetScreenMode(&screenMode); @@ -329,43 +329,43 @@ mozXMLTermKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) keyChar = U_ESCAPE; break; case nsIDOMKeyEvent::DOM_VK_HOME: - JSCommand = "ScrollHomeKey"; + JSCommand.AssignWithConversion("ScrollHomeKey"); break; case nsIDOMKeyEvent::DOM_VK_END: - JSCommand = "ScrollEndKey"; + JSCommand.AssignWithConversion("ScrollEndKey"); break; case nsIDOMKeyEvent::DOM_VK_PAGE_UP: - JSCommand = "ScrollPageUpKey"; + JSCommand.AssignWithConversion("ScrollPageUpKey"); break; case nsIDOMKeyEvent::DOM_VK_PAGE_DOWN: - JSCommand = "ScrollPageDownKey"; + JSCommand.AssignWithConversion("ScrollPageDownKey"); break; case nsIDOMKeyEvent::DOM_VK_F1: - JSCommand = "F1Key"; + JSCommand.AssignWithConversion("F1Key"); break; case nsIDOMKeyEvent::DOM_VK_F2: - JSCommand = "F2Key"; + JSCommand.AssignWithConversion("F2Key"); break; case nsIDOMKeyEvent::DOM_VK_F3: - JSCommand = "F3Key"; + JSCommand.AssignWithConversion("F3Key"); break; case nsIDOMKeyEvent::DOM_VK_F4: - JSCommand = "F4Key"; + JSCommand.AssignWithConversion("F4Key"); break; case nsIDOMKeyEvent::DOM_VK_F5: - JSCommand = "F5Key"; + JSCommand.AssignWithConversion("F5Key"); break; case nsIDOMKeyEvent::DOM_VK_F6: - JSCommand = "F6Key"; + JSCommand.AssignWithConversion("F6Key"); break; case nsIDOMKeyEvent::DOM_VK_F7: - JSCommand = "F7Key"; + JSCommand.AssignWithConversion("F7Key"); break; case nsIDOMKeyEvent::DOM_VK_F8: - JSCommand = "F8Key"; + JSCommand.AssignWithConversion("F8Key"); break; case nsIDOMKeyEvent::DOM_VK_F9: - JSCommand = "F9Key"; + JSCommand.AssignWithConversion("F9Key"); break; default: if ( (ctrlKey && (keyCode ==nsIDOMKeyEvent::DOM_VK_SPACE)) || @@ -396,12 +396,12 @@ mozXMLTermKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) if (NS_SUCCEEDED(result) && domDocument) { nsAutoString JSInput = JSCommand; - nsAutoString JSOutput = ""; - JSInput.Append("("); - JSInput.Append(shiftKey,10); - JSInput.Append(","); - JSInput.Append(ctrlKey,10); - JSInput.Append(");"); + nsAutoString JSOutput; JSOutput.SetLength(0); + JSInput.AppendWithConversion("("); + JSInput.AppendInt(shiftKey,10); + JSInput.AppendWithConversion(","); + JSInput.AppendInt(ctrlKey,10); + JSInput.AppendWithConversion(");"); result = mozXMLTermUtils::ExecuteScript(domDocument, JSInput, JSOutput); @@ -410,7 +410,7 @@ mozXMLTermKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) if (!mSuspend && (keyChar > 0) && (keyChar <= 0xFFFDU)) { // Transmit valid non-null Unicode character - nsAutoString keyString = ""; + nsAutoString keyString; keyString.SetLength(0); if (escPrefix) { keyString.Append((PRUnichar) U_ESCAPE); keyString.Append((PRUnichar) U_LBRACKET); @@ -638,7 +638,7 @@ mozXMLTermMouseListener::MouseClick(nsIDOMEvent* aMouseEvent) if (!selCon) return NS_ERROR_FAILURE; nsCOMPtr selection; - result = selCon->GetSelection(SELECTION_NORMAL, + result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); if (NS_FAILED(result) || !selection) diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp index d24cb1fc8ab..f24591b09ab 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp @@ -55,6 +55,7 @@ #include "mozIXMLTerminal.h" #include "mozXMLTermUtils.h" #include "mozXMLTermSession.h" +#include "nsISelectionController.h" ///////////////////////////////////////////////////////////////////////// // mozXMLTermSession definition @@ -144,9 +145,9 @@ mozXMLTermSession::mozXMLTermSession() : mEntryOutputLines(0), mPreTextBufferLines(0), - mPreTextIncomplete(""), - mPreTextBuffered(""), - mPreTextDisplayed(""), + mPreTextIncomplete(nsAutoString()), + mPreTextBuffered(nsAutoString()), + mPreTextDisplayed(nsAutoString()), mScreenNode(nsnull), mScreenRows(0), @@ -156,9 +157,9 @@ mozXMLTermSession::mozXMLTermSession() : mRestoreInputEcho(PR_FALSE), - mShellPrompt(""), - mPromptHTML(""), - mFragmentBuffer("") + mShellPrompt(nsAutoString()), + mPromptHTML(nsAutoString()), + mFragmentBuffer(nsAutoString()) { } @@ -204,7 +205,8 @@ NS_IMETHODIMP mozXMLTermSession::Init(mozIXMLTerminal* aXMLTerminal, // Locate document body node nsCOMPtr nodeList; - nsAutoString bodyTag = "body"; + nsAutoString bodyTag; + bodyTag.AssignWithConversion("body"); result = vDOMHTMLDocument->GetElementsByTagName(bodyTag, getter_AddRefs(nodeList)); if (NS_FAILED(result) || !nodeList) @@ -222,7 +224,8 @@ NS_IMETHODIMP mozXMLTermSession::Init(mozIXMLTerminal* aXMLTerminal, mSessionNode = mBodyNode; nsCOMPtr sessionElement; - nsAutoString sessionID = sessionElementNames[SESSION_ELEMENT]; + nsAutoString sessionID; + sessionID.AssignWithConversion(sessionElementNames[SESSION_ELEMENT]); result = vDOMHTMLDocument->GetElementById(sessionID, getter_AddRefs(sessionElement)); @@ -418,7 +421,8 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, PRUnichar *buf_str, *buf_style; PRBool newline, errorFlag, streamData, screenData; nsAutoString bufString, bufStyle; - nsAutoString abortCode = ""; + nsAutoString abortCode; + abortCode.SetLength(0); XMLT_LOG(mozXMLTermSession::ReadAll,60,("\n")); @@ -441,7 +445,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, result = lineTermAux->ReadAux(&opcodes, &opvals, &buf_row, &buf_col, &buf_str, &buf_style); if (NS_FAILED(result)) { - abortCode = "lineTermReadAux"; + abortCode.AssignWithConversion("lineTermReadAux"); break; } @@ -533,7 +537,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, if (streamIsSecure) { // Secure stream, i.e., prefixed with cookie; fragments allowed - streamURL = "chrome://xmlterm/content/xmltblank.html"; + streamURL.AssignWithConversion("chrome://xmlterm/content/xmltblank.html"); if (opcodes & LTERM_JSSTREAM_CODE) { // Javascript stream @@ -546,7 +550,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, } else { // Insecure stream; do not display - streamURL = "http://in.sec.ure"; + streamURL.AssignWithConversion("http://in.sec.ure"); streamMarkupType = INSECURE_FRAGMENT; } @@ -568,7 +572,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, } // Process stream output - bufStyle = ""; + bufStyle.SetLength(0); result = ProcessOutput(bufString, bufStyle, PR_FALSE, PR_TRUE); if (NS_FAILED(result)) break; @@ -732,8 +736,9 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, metaCommand = (opcodes & LTERM_META_CODE); completionRequested = (opcodes & LTERM_COMPLETION_CODE); - nsAutoString promptStr (""); + nsAutoString promptStr; PRInt32 promptLength = 0; + promptStr.SetLength(0); if (promptLine) { // Count prompt characters @@ -816,7 +821,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, PRInt32 j; for (j=NO_META_COMMAND+1; jSetEchoFlag(PR_FALSE); - nsAutoString lsCommand (""); + nsAutoString lsCommand; + lsCommand.SetLength(0); if (commandArgs.Length() > 0) { - lsCommand += "cd "; - lsCommand += commandArgs; - lsCommand += ";"; + lsCommand.AppendWithConversion("cd "); + lsCommand.Append(commandArgs); + lsCommand.AppendWithConversion(";"); } - lsCommand += "ls -dF `pwd`/*\n"; + lsCommand.AppendWithConversion("ls -dF `pwd`/*\n"); //mXMLTerminal->SendText(lsCommand); @@ -955,15 +966,16 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, XMLT_LOG(mozXMLTermSession::ReadAll,62,("metaCommandOutput\n")); // Ignore the string "false", if that's the only output - if (metaCommandOutput.Equals("false")) - metaCommandOutput = ""; + if (metaCommandOutput.EqualsWithConversion("false")) + metaCommandOutput.SetLength(0); // Check metacommand output for markup (secure) result = AutoDetectMarkup(metaCommandOutput, PR_TRUE, PR_TRUE); if (NS_FAILED(result)) break; - nsAutoString nullStyle (""); + nsAutoString nullStyle; + nullStyle.SetLength(0); result = ProcessOutput(metaCommandOutput, nullStyle, PR_TRUE, mOutputMarkupType != PLAIN_TEXT); if (NS_FAILED(result)) @@ -978,8 +990,8 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, } // Clear the meta command from the string nuffer - bufString = ""; - bufStyle = ""; + bufString.SetLength(0); + bufStyle.SetLength(0); } if (promptLine) { @@ -1049,7 +1061,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, } else if (newline) { // Process autodetected stream output (complete lines only) - bufStyle = ""; + bufStyle.SetLength(0); result = ProcessOutput(bufString, bufStyle, PR_TRUE, PR_TRUE); if (NS_FAILED(result)) break; @@ -1074,8 +1086,9 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, if (mEntryHasOutput) PositionOutputCursor(lineTermAux); - mPresShell->ScrollSelectionIntoView(SELECTION_NORMAL, - SELECTION_FOCUS_REGION); + nsCOMPtr selCon = do_QueryInterface(mPresShell); + selCon->ScrollSelectionIntoView(nsISelectionController::SELECTION_NORMAL, + nsISelectionController::SELECTION_FOCUS_REGION); } // Show caret @@ -1105,15 +1118,15 @@ NS_IMETHODIMP mozXMLTermSession::Abort(mozILineTermAux* lineTermAux, // Display error message using DIV node nsCOMPtr divNode, textNode; - nsAutoString tagName = "div"; - nsAutoString elementName = "errmsg"; + nsAutoString tagName; tagName.AssignWithConversion("div"); + nsAutoString elementName; elementName.AssignWithConversion("errmsg"); result = NewElementWithText(tagName, elementName, -1, mSessionNode, divNode, textNode); if (NS_SUCCEEDED(result) && divNode && textNode) { - nsAutoString errMsg = "Error in XMLterm (code "; + nsAutoString errMsg; errMsg.AssignWithConversion("Error in XMLterm (code "); errMsg.Append(abortCode); - errMsg.Append("); session closed."); + errMsg.AppendWithConversion("); session closed."); SetDOMText(textNode, errMsg); // Collapse selection and position cursor @@ -1122,13 +1135,13 @@ NS_IMETHODIMP mozXMLTermSession::Abort(mozILineTermAux* lineTermAux, if (!selCon) return NS_ERROR_FAILURE; nsCOMPtr selection; - result = selCon->GetSelection(SELECTION_NORMAL, + result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); if (NS_SUCCEEDED(result) && selection) { selection->Collapse(textNode, errMsg.Length()); if (NS_SUCCEEDED(result)) { - mPresShell->ScrollSelectionIntoView(SELECTION_NORMAL, - SELECTION_FOCUS_REGION); + selCon->ScrollSelectionIntoView(nsISelectionController::SELECTION_NORMAL, + nsISelectionController::SELECTION_FOCUS_REGION); } } } @@ -1166,7 +1179,7 @@ NS_IMETHODIMP mozXMLTermSession::DisplayInput(const nsString& aString, return NS_ERROR_FAILURE; nsCOMPtr selection; - result = selCon->GetSelection(SELECTION_NORMAL, + result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); if (NS_FAILED(result) || !selection) return NS_ERROR_FAILURE; @@ -1242,7 +1255,7 @@ NS_IMETHODIMP mozXMLTermSession::AutoDetectMarkup(const nsString& aString, if (str.First() == U_LESSTHAN) { // Markup tag detected str.CompressWhitespace(); - str.Append(" "); + str.AppendWithConversion(" "); if ( (str.Find("Open(outerDOMWindow, iframeName.GetBuffer(), url.GetBuffer(), contentType.GetBuffer(), 800); @@ -1421,8 +1434,8 @@ NS_IMETHODIMP mozXMLTermSession::BreakOutput(PRBool positionCursorBelow) { // Display text fragment using new SPAN node nsCOMPtr spanNode, textNode; - nsAutoString tagName = "span"; - nsAutoString elementName = "stream"; + nsAutoString tagName; tagName.AssignWithConversion("span"); + nsAutoString elementName; elementName.AssignWithConversion("stream"); result = NewElementWithText(tagName, elementName, -1, mOutputBlockNode, spanNode, textNode); @@ -1437,11 +1450,11 @@ NS_IMETHODIMP mozXMLTermSession::BreakOutput(PRBool positionCursorBelow) // Handle stream output error messages switch (mOutputMarkupType) { case INSECURE_FRAGMENT: - mFragmentBuffer = "XMLTerm: *Error* Insecure stream data; is LTERM_COOKIE set?"; + mFragmentBuffer.AssignWithConversion("XMLTerm: *Error* Insecure stream data; is LTERM_COOKIE set?"); break; case INCOMPLETE_FRAGMENT: - mFragmentBuffer = "XMLTerm: *Error* Incomplete stream data"; + mFragmentBuffer.AssignWithConversion("XMLTerm: *Error* Incomplete stream data"); break; default: @@ -1453,21 +1466,22 @@ NS_IMETHODIMP mozXMLTermSession::BreakOutput(PRBool positionCursorBelow) if (NS_FAILED(result)) return result; - mFragmentBuffer = ""; + mFragmentBuffer.SetLength(0); break; } case JS_FRAGMENT: { // Execute JS fragment - nsAutoString jsOutput = ""; + nsAutoString jsOutput; + jsOutput.SetLength(0); result = mozXMLTermUtils::ExecuteScript(mDOMDocument, mFragmentBuffer, jsOutput); if (NS_FAILED(result)) - jsOutput = "Error in JavaScript execution\n"; + jsOutput.AssignWithConversion("Error in JavaScript execution\n"); - mFragmentBuffer = ""; + mFragmentBuffer.SetLength(0); if (jsOutput.Length() > 0) { // Display JS output as HTML fragment @@ -1487,7 +1501,7 @@ NS_IMETHODIMP mozXMLTermSession::BreakOutput(PRBool positionCursorBelow) if (NS_FAILED(result)) return result; - mFragmentBuffer = ""; + mFragmentBuffer.SetLength(0); break; case HTML_DOCUMENT: @@ -1508,8 +1522,8 @@ NS_IMETHODIMP mozXMLTermSession::BreakOutput(PRBool positionCursorBelow) return result; mPreTextBufferLines = 0; - mPreTextBuffered = ""; - mPreTextDisplayed = ""; + mPreTextBuffered.SetLength(0); + mPreTextDisplayed.SetLength(0); mOutputDisplayNode = nsnull; mOutputDisplayType = NO_NODE; mOutputTextNode = nsnull; @@ -1577,9 +1591,9 @@ NS_IMETHODIMP mozXMLTermSession::ProcessOutput(const nsString& aString, } else { mOutputMarkupType = OVERFLOW_FRAGMENT; - mFragmentBuffer = "XMLTerm: *Error* Stream data overflow ("; - mFragmentBuffer.Append(strLen,10); - mFragmentBuffer.Append(" chars)"); + mFragmentBuffer.AssignWithConversion("XMLTerm: *Error* Stream data overflow ("); + mFragmentBuffer.AppendInt(strLen,10); + mFragmentBuffer.AppendWithConversion(" chars)"); break; } @@ -1594,7 +1608,7 @@ NS_IMETHODIMP mozXMLTermSession::ProcessOutput(const nsString& aString, if (newline || streamOutput) { nsAutoString str = aString; if (newline) - str.Append("\n"); + str.AppendWithConversion("\n"); result = mXMLTermStream->Write(str.GetUnicode()); if (NS_FAILED(result)) { @@ -1637,16 +1651,16 @@ NS_IMETHODIMP mozXMLTermSession::LimitOutputLines(PRBool deleteAllOld) if (NS_FAILED(result) || !firstChild) return NS_ERROR_FAILURE; - attValue = ""; + attValue.SetLength(0); result = mozXMLTermUtils::GetNodeAttribute(firstChild, "class", attValue); if (NS_FAILED(result)) return result; - if (!attValue.Equals(sessionElementNames[WARNING_ELEMENT])) { + if (!attValue.EqualsWithConversion(sessionElementNames[WARNING_ELEMENT])) { // Create warning message element nsCOMPtr divNode, textNode; - nsAutoString tagName = "div"; - nsAutoString elementName = sessionElementNames[WARNING_ELEMENT]; + nsAutoString tagName; tagName.AssignWithConversion("div"); + nsAutoString elementName; elementName.AssignWithConversion(sessionElementNames[WARNING_ELEMENT]); result = NewElementWithText(tagName, elementName, -1, mOutputBlockNode, divNode, textNode, firstChild); @@ -1655,9 +1669,10 @@ NS_IMETHODIMP mozXMLTermSession::LimitOutputLines(PRBool deleteAllOld) firstChild = divNode; - nsAutoString warningMsg ="XMLTerm: *WARNING* Command output truncated to "; - warningMsg.Append(300,10); - warningMsg.Append(" lines"); + nsAutoString warningMsg; + warningMsg.AssignWithConversion("XMLTerm: *WARNING* Command output truncated to "); + warningMsg.AppendInt(300,10); + warningMsg.AppendWithConversion(" lines"); result = SetDOMText(textNode, warningMsg); } @@ -1681,7 +1696,7 @@ NS_IMETHODIMP mozXMLTermSession::LimitOutputLines(PRBool deleteAllOld) deleteNode = 1; } else { - attValue = ""; + attValue.SetLength(0); result = mozXMLTermUtils::GetNodeAttribute(nextChild, "class", attValue); if (NS_FAILED(result)|| (attValue.Length() == 0)) { @@ -1689,7 +1704,7 @@ NS_IMETHODIMP mozXMLTermSession::LimitOutputLines(PRBool deleteAllOld) } else { - if (attValue.Equals(sessionElementNames[MIXED_ELEMENT])) { + if (attValue.EqualsWithConversion(sessionElementNames[MIXED_ELEMENT])) { // Delete single line containing mixed style output deleteNode = 1; decrementedLineCount = 1; @@ -1697,9 +1712,9 @@ NS_IMETHODIMP mozXMLTermSession::LimitOutputLines(PRBool deleteAllOld) XMLT_LOG(mozXMLTermSession::LimitOutputLines,79, ("deleted mixed line\n")); - } else if ( (attValue.Equals(sessionElementNames[STDIN_ELEMENT])) || - (attValue.Equals(sessionElementNames[STDOUT_ELEMENT])) || - (attValue.Equals(sessionElementNames[STDERR_ELEMENT]))) { + } else if ( (attValue.EqualsWithConversion(sessionElementNames[STDIN_ELEMENT])) || + (attValue.EqualsWithConversion(sessionElementNames[STDOUT_ELEMENT])) || + (attValue.EqualsWithConversion(sessionElementNames[STDERR_ELEMENT]))) { // Delete first line from STDIN/STDOUT/STDERR PRE output nsCOMPtr textNode; @@ -1814,21 +1829,22 @@ NS_IMETHODIMP mozXMLTermSession::AppendOutput(const nsString& aString, #endif // Uniform style data; display as preformatted block OutputDisplayType preDisplayType; - nsAutoString elementName = ""; + nsAutoString elementName; + elementName.SetLength(0); if (uniformStyle == LTERM_STDIN_STYLE) { preDisplayType = PRE_STDIN_NODE; - elementName = sessionElementNames[STDIN_ELEMENT]; + elementName.AssignWithConversion(sessionElementNames[STDIN_ELEMENT]); XMLT_LOG(mozXMLTermSession::AppendOutput,72, ("PRE_STDIN_NODE\n")); } else if (uniformStyle == LTERM_STDERR_STYLE) { preDisplayType = PRE_STDERR_NODE; - elementName = sessionElementNames[STDERR_ELEMENT]; + elementName.AssignWithConversion(sessionElementNames[STDERR_ELEMENT]); XMLT_LOG(mozXMLTermSession::AppendOutput,72, ("PRE_STDERR_NODE\n")); } else { preDisplayType = PRE_STDOUT_NODE; - elementName = sessionElementNames[STDOUT_ELEMENT]; + elementName.AssignWithConversion(sessionElementNames[STDOUT_ELEMENT]); XMLT_LOG(mozXMLTermSession::AppendOutput,72, ("PRE_STDOUT_NODE\n")); } @@ -1838,7 +1854,7 @@ NS_IMETHODIMP mozXMLTermSession::AppendOutput(const nsString& aString, // Create PRE display node nsCOMPtr preNode, textNode; - nsAutoString tagName = "pre"; + nsAutoString tagName; tagName.AssignWithConversion("pre"); result = NewElementWithText(tagName, elementName, -1, mOutputBlockNode, preNode, textNode); @@ -1866,7 +1882,7 @@ NS_IMETHODIMP mozXMLTermSession::AppendOutput(const nsString& aString, // Initialize PRE text string buffers mPreTextDisplayed = aString; - mPreTextBuffered = ""; + mPreTextBuffered.SetLength(0); mPreTextBufferLines = 0; } @@ -1880,7 +1896,7 @@ NS_IMETHODIMP mozXMLTermSession::AppendOutput(const nsString& aString, } mPreTextBufferLines++; mPreTextBuffered += mPreTextIncomplete; - mPreTextIncomplete = ""; + mPreTextIncomplete.SetLength(0); if (mPreTextBufferLines > 300) { // Delete all earlier PRE/mixed blocks and first line of current block @@ -1892,7 +1908,7 @@ NS_IMETHODIMP mozXMLTermSession::AppendOutput(const nsString& aString, // Delete first line from PRE text buffer PRInt32 offset = mPreTextBuffered.FindChar((PRUnichar) U_LINEFEED); if (offset < 0) { - mPreTextBuffered = ""; + mPreTextBuffered.SetLength(0); } else { mPreTextBuffered.Cut(0,offset+1); } @@ -1923,9 +1939,9 @@ NS_IMETHODIMP mozXMLTermSession::AppendOutput(const nsString& aString, return result; // Create new DIV node - nsAutoString elementName = sessionElementNames[MIXED_ELEMENT]; + nsAutoString elementName; elementName.AssignWithConversion(sessionElementNames[MIXED_ELEMENT]); nsCOMPtr divNode; - nsAutoString tagName = "div"; + nsAutoString tagName; tagName.AssignWithConversion("div"); result = NewElement(tagName, elementName, -1, mOutputBlockNode, divNode); @@ -1948,7 +1964,7 @@ NS_IMETHODIMP mozXMLTermSession::AppendOutput(const nsString& aString, currentStyle = strStyle[0]; mOutputTextOffset = 0; - tagName = "span"; + tagName.AssignWithConversion("span"); PR_ASSERT(strLength > 0); @@ -1958,13 +1974,13 @@ NS_IMETHODIMP mozXMLTermSession::AppendOutput(const nsString& aString, // Change of style or end of string switch (currentStyle) { case LTERM_STDIN_STYLE: - elementName = sessionElementNames[STDIN_ELEMENT]; + elementName.AssignWithConversion(sessionElementNames[STDIN_ELEMENT]); break; case LTERM_STDERR_STYLE: - elementName = sessionElementNames[STDERR_ELEMENT]; + elementName.AssignWithConversion(sessionElementNames[STDERR_ELEMENT]); break; default: - elementName = sessionElementNames[STDOUT_ELEMENT]; + elementName.AssignWithConversion(sessionElementNames[STDOUT_ELEMENT]); break; } @@ -2072,9 +2088,10 @@ NS_IMETHODIMP mozXMLTermSession::AppendLineLS(const nsString& aString, nsCRT::free(temCString); // Add markup to directory listing - nsAutoString markupString = ""; + nsAutoString markupString; PRInt32 lineLength = aString.Length(); PRInt32 wordBegin = 0; + markupString.SetLength(0); while (wordBegin < lineLength) { // Consume any leading spaces @@ -2138,26 +2155,26 @@ NS_IMETHODIMP mozXMLTermSession::AppendLineLS(const nsString& aString, aString.Mid(pathname, wordBegin, wordEnd-wordBegin+1-dropSuffix); // Append to markup string - markupString += ""); + markupString.Assign(filename); + markupString.AssignWithConversion(""); // Search for new word wordBegin = wordEnd+1; @@ -2165,7 +2182,7 @@ NS_IMETHODIMP mozXMLTermSession::AppendLineLS(const nsString& aString, if (mOutputDisplayType != PRE_STDOUT_NODE) { // Create PRE block - nsAutoString nullString(""); + nsAutoString nullString; nullString.SetLength(0); result = AppendOutput(nullString, nullString, PR_FALSE); } @@ -2177,7 +2194,7 @@ NS_IMETHODIMP mozXMLTermSession::AppendLineLS(const nsString& aString, // Insert text node containing newline only nsCOMPtr newText; - nsAutoString newlineStr ("\n"); + nsAutoString newlineStr; newlineStr.AssignWithConversion("\n"); result = mDOMDocument->CreateTextNode(newlineStr, getter_AddRefs(newText)); if (NS_FAILED(result) || !newText) return NS_ERROR_FAILURE; @@ -2234,7 +2251,7 @@ NS_IMETHODIMP mozXMLTermSession::AppendLineLS(const nsString& aString, selCon = do_QueryInterface(mPresShell); if (!selCon) return NS_ERROR_FAILURE; - result = selCon->GetSelection(SELECTION_NORMAL, + result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); if (NS_FAILED(result) || !selection) return NS_ERROR_FAILURE; @@ -2377,9 +2394,10 @@ void mozXMLTermSession::SubstituteCommandNumber(nsString& aString, return; PRInt32 numberOffset; - nsAutoString numberString = ""; + nsAutoString numberString; + numberString.SetLength(0); - numberString.Append(aNumber,10); + numberString.AppendInt(aNumber,10); for (;;) { // Search for '#' character @@ -2418,7 +2436,7 @@ void mozXMLTermSession::SanitizeAttribute(nsString& aAttrValue, XMLT_WARNING("mozXMLTermSession::SanitizeAttribute: Warning - deleted attribute on%s='%s'\n", aEventName, temCString); nsCRT::free(temCString); - aAttrValue = ""; + aAttrValue.SetLength(0); } return; @@ -2455,7 +2473,8 @@ NS_IMETHODIMP mozXMLTermSession::DeepSanitizeFragment( if (domElement) { // Check if this is a script element (IGNORE CASE) - nsAutoString tagName = ""; + nsAutoString tagName; + tagName.SetLength(0); result = domElement->GetTagName(tagName); if (NS_SUCCEEDED(result) && tagName.EqualsIgnoreCase("script")) { @@ -2478,15 +2497,15 @@ NS_IMETHODIMP mozXMLTermSession::DeepSanitizeFragment( nsAutoString eventAttrVals[SESSION_EVENT_TYPES]; for (j=0; jGetAttribute(attName, attValue); if (NS_SUCCEEDED(result) && (attValue.Length() > 0)) { // Save allowed event attribute value for re-insertion @@ -2506,7 +2525,7 @@ NS_IMETHODIMP mozXMLTermSession::DeepSanitizeFragment( nsCOMPtr attrNode; PRUint32 k; nsAutoString attrName, attrValue, prefix; - nsAutoString nullStr = ""; + nsAutoString nullStr; nullStr.SetLength(0); for (k=0; kItem(k, getter_AddRefs(attrNode)); @@ -2546,9 +2565,9 @@ NS_IMETHODIMP mozXMLTermSession::DeepSanitizeFragment( if (entryNumber >= 0) { // Process ID attribute - attName = "id"; + attName.AssignWithConversion("id"); - attValue = ""; + attValue.SetLength(0); result = domElement->GetAttribute(attName, attValue); if (NS_SUCCEEDED(result) && (attValue.Length() > 0)) { @@ -2560,8 +2579,8 @@ NS_IMETHODIMP mozXMLTermSession::DeepSanitizeFragment( for (j=0; j 0) { @@ -2616,13 +2635,13 @@ NS_IMETHODIMP mozXMLTermSession::DeepRefreshEventHandlers( // Refresh event attributes for (j=0; jGetAttribute(attName, attValue); if (NS_SUCCEEDED(result) && (attValue.Length() > 0)) { @@ -2672,7 +2691,7 @@ NS_IMETHODIMP mozXMLTermSession::FlushOutput(FlushActionType flushAction) if (preDisplay) { // PRE text display OutputDisplayType preDisplayType = mOutputDisplayType; - nsAutoString preTextSplit = ""; + nsAutoString preTextSplit; preTextSplit.SetLength(0); if (flushAction != DISPLAY_INCOMPLETE_FLUSH) { // Split/clear/close incomplete line @@ -2691,7 +2710,7 @@ NS_IMETHODIMP mozXMLTermSession::FlushOutput(FlushActionType flushAction) } // Clear incomplete PRE text - mPreTextIncomplete = ""; + mPreTextIncomplete.SetLength(0); if ((mPreTextBufferLines == 0) && (mPreTextBuffered.Length() == 0)) { // Remove lone text node @@ -2747,7 +2766,7 @@ NS_IMETHODIMP mozXMLTermSession::FlushOutput(FlushActionType flushAction) if ( (flushAction == SPLIT_INCOMPLETE_FLUSH) && (preTextSplit.Length() > 0) ) { // Create new PRE element with incomplete text - nsAutoString styleStr = ""; + nsAutoString styleStr; styleStr.SetLength(0); if (preDisplayType == PRE_STDIN_NODE) { styleStr += (PRUnichar) LTERM_STDIN_STYLE; @@ -2802,8 +2821,8 @@ void mozXMLTermSession::PositionOutputCursor(mozILineTermAux* lineTermAux) if (!mOutputTextNode) { // Append dummy output line nsCOMPtr spanNode, textNode; - nsAutoString tagName = "span"; - nsAutoString elementName = sessionElementNames[STDOUT_ELEMENT]; + nsAutoString tagName; tagName.AssignWithConversion("span"); + nsAutoString elementName; elementName.AssignWithConversion(sessionElementNames[STDOUT_ELEMENT]); result = NewElementWithText(tagName, elementName, -1, mOutputBlockNode, spanNode, textNode); @@ -2822,13 +2841,13 @@ void mozXMLTermSession::PositionOutputCursor(mozILineTermAux* lineTermAux) nsCOMPtr selCon; selCon = do_QueryInterface(mPresShell); if (!selCon) - return NS_ERROR_FAILURE; - result = selCon->GetSelection(SELECTION_NORMAL, + return ;; // NS_ERROR_FAILURE; + result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); if (NS_SUCCEEDED(result) && selection) { // Position cursor at end of line nsCOMPtr domText( do_QueryInterface(mOutputTextNode) ); - nsAutoString text = ""; + nsAutoString text; text.SetLength(0); domText->GetData(text); PRInt32 textOffset = text.Length(); @@ -2974,8 +2993,8 @@ NS_IMETHODIMP mozXMLTermSession::NewPreface(void) // Create preface element and append as child of session element nsCOMPtr divNode; - nsAutoString tagName = "div"; - nsAutoString name = "preface"; + nsAutoString tagName; tagName.AssignWithConversion("div"); + nsAutoString name; name.AssignWithConversion("preface"); result = NewElement(tagName, name, 0, mSessionNode, divNode); @@ -3020,7 +3039,8 @@ NS_IMETHODIMP mozXMLTermSession::NewEntry(const nsString& aPrompt) // Not first entry // Add event attributes to current command element - result = SetEventAttributes(sessionElementNames[COMMAND_ELEMENT], + nsAutoString cmdName; cmdName.AssignWithConversion(sessionElementNames[COMMAND_ELEMENT]); + result = SetEventAttributes(cmdName, mCurrentEntryNumber, mCommandSpanNode); if (NS_FAILED(result)) @@ -3058,8 +3078,8 @@ NS_IMETHODIMP mozXMLTermSession::NewEntry(const nsString& aPrompt) // Create "entry" element nsCOMPtr entryNode; - tagName = "div"; - name = sessionElementNames[ENTRY_ELEMENT]; + tagName.AssignWithConversion("div"); + name.AssignWithConversion(sessionElementNames[ENTRY_ELEMENT]); result = NewElement(tagName, name, mCurrentEntryNumber, mSessionNode, entryNode); if (NS_FAILED(result) || !entryNode) { @@ -3074,8 +3094,8 @@ NS_IMETHODIMP mozXMLTermSession::NewEntry(const nsString& aPrompt) // Create "input" element containing "prompt" and "command" elements nsCOMPtr inputNode; - tagName = "div"; - name = sessionElementNames[INPUT_ELEMENT]; + tagName.AssignWithConversion("div"); + name.AssignWithConversion(sessionElementNames[INPUT_ELEMENT]); result = NewElement(tagName, name, mCurrentEntryNumber, mCurrentEntryNode, inputNode); if (NS_FAILED(result) || !inputNode) { @@ -3086,8 +3106,8 @@ NS_IMETHODIMP mozXMLTermSession::NewEntry(const nsString& aPrompt) // Create prompt element nsCOMPtr newPromptSpanNode; - tagName = "span"; - name = sessionElementNames[PROMPT_ELEMENT]; + tagName.AssignWithConversion("span"); + name.AssignWithConversion(sessionElementNames[PROMPT_ELEMENT]); result = NewElement(tagName, name, mCurrentEntryNumber, inputNode, newPromptSpanNode); if (NS_FAILED(result) || !newPromptSpanNode) { @@ -3107,8 +3127,8 @@ NS_IMETHODIMP mozXMLTermSession::NewEntry(const nsString& aPrompt) // Create text node + image node as child of prompt element nsCOMPtr spanNode, textNode; - tagName = "span"; - name ="noicons"; + tagName.AssignWithConversion("span"); + name.AssignWithConversion("noicons"); result = NewElementWithText(tagName, name, -1, mPromptSpanNode, spanNode, textNode); if (NS_FAILED(result) || !spanNode || !textNode) { @@ -3121,23 +3141,23 @@ NS_IMETHODIMP mozXMLTermSession::NewEntry(const nsString& aPrompt) return NS_ERROR_FAILURE; // Create IMG element - tagName = "img"; + tagName.AssignWithConversion("img"); nsCOMPtr imgElement; result = mDOMDocument->CreateElement(tagName, getter_AddRefs(imgElement)); if (NS_FAILED(result) || !imgElement) return NS_ERROR_FAILURE; // Set attributes - nsAutoString attName("class"); - nsAutoString attValue("icons"); + nsAutoString attName; attName.AssignWithConversion("class"); + nsAutoString attValue; attValue.AssignWithConversion("icons"); imgElement->SetAttribute(attName, attValue); - attName = "src"; - attValue = "chrome://xmlterm/skin/wheel.gif"; + attName.AssignWithConversion("src"); + attValue.AssignWithConversion("chrome://xmlterm/skin/wheel.gif"); imgElement->SetAttribute(attName, attValue); - attName = "align"; - attValue = "middle"; + attName.AssignWithConversion("align"); + attValue.AssignWithConversion("middle"); imgElement->SetAttribute(attName, attValue); nsCOMPtr resultNode; @@ -3151,7 +3171,7 @@ NS_IMETHODIMP mozXMLTermSession::NewEntry(const nsString& aPrompt) // Append text node containing single space nsCOMPtr stubText; - nsAutoString spaceStr (" "); + nsAutoString spaceStr; spaceStr.AssignWithConversion(" "); result = mDOMDocument->CreateTextNode(spaceStr, getter_AddRefs(stubText)); if (NS_FAILED(result) || !stubText) return NS_ERROR_FAILURE; @@ -3184,8 +3204,8 @@ NS_IMETHODIMP mozXMLTermSession::NewEntry(const nsString& aPrompt) // Create command element nsCOMPtr newCommandSpanNode; - tagName = "span"; - name = sessionElementNames[COMMAND_ELEMENT]; + tagName.AssignWithConversion("span"); + name.AssignWithConversion(sessionElementNames[COMMAND_ELEMENT]); result = NewElement(tagName, name, mCurrentEntryNumber, inputNode, newCommandSpanNode); if (NS_FAILED(result) || !newCommandSpanNode) { @@ -3205,8 +3225,8 @@ NS_IMETHODIMP mozXMLTermSession::NewEntry(const nsString& aPrompt) // Create output element and append as child of current entry element nsCOMPtr divNode; - tagName = "div"; - name = sessionElementNames[OUTPUT_ELEMENT]; + tagName.AssignWithConversion("div"); + name.AssignWithConversion(sessionElementNames[OUTPUT_ELEMENT]); result = NewElement(tagName, name, mCurrentEntryNumber, mCurrentEntryNode, divNode); @@ -3240,8 +3260,8 @@ NS_IMETHODIMP mozXMLTermSession::NewScreen(void) // Create screen element and append as child of session element nsCOMPtr divNode; - nsAutoString tagName = "div"; - nsAutoString name = "screen"; + nsAutoString tagName; tagName.AssignWithConversion("div"); + nsAutoString name; name.AssignWithConversion("screen"); result = NewElement(tagName, name, 0, mSessionNode, divNode); @@ -3261,8 +3281,11 @@ NS_IMETHODIMP mozXMLTermSession::NewScreen(void) result = PositionScreenCursor(0, 0); if (NS_SUCCEEDED(result)) { - result = mPresShell->ScrollSelectionIntoView(SELECTION_NORMAL, - SELECTION_FOCUS_REGION); + nsCOMPtr selCon = do_QueryInterface(mPresShell); + if (!selCon) + return NS_ERROR_FAILURE; + result = selCon->ScrollSelectionIntoView(nsISelectionController::SELECTION_NORMAL, + nsISelectionController::SELECTION_FOCUS_REGION); } return NS_OK; @@ -3341,7 +3364,7 @@ NS_IMETHODIMP mozXMLTermSession::PositionScreenCursor(PRInt32 aRow, PRInt32 textOffset = 0; nsCOMPtr textNode = nsnull; nsCOMPtr childNode; - nsAutoString text = ""; + nsAutoString text; text.SetLength(0); for (j=0; jItem(j, getter_AddRefs(childNode)); @@ -3393,7 +3416,7 @@ NS_IMETHODIMP mozXMLTermSession::PositionScreenCursor(PRInt32 aRow, selCon = do_QueryInterface(mPresShell); if (!selCon) return NS_ERROR_FAILURE; - result = selCon->GetSelection(SELECTION_NORMAL, + result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); if (NS_SUCCEEDED(result) && selection) { @@ -3419,8 +3442,8 @@ NS_IMETHODIMP mozXMLTermSession::NewRow(nsIDOMNode* beforeRowNode, // Create PRE display node nsCOMPtr preNode, textNode; - nsAutoString tagName = "pre"; - nsAutoString elementName = "row"; + nsAutoString tagName; tagName.AssignWithConversion("pre"); + nsAutoString elementName; elementName.AssignWithConversion("row"); result = NewElementWithText(tagName, elementName, -1, mScreenNode, preNode, textNode); @@ -3430,13 +3453,13 @@ NS_IMETHODIMP mozXMLTermSession::NewRow(nsIDOMNode* beforeRowNode, // Set PRE element attributes nsCOMPtr preElement = do_QueryInterface(preNode); - nsAutoString att("cols"); - nsAutoString val(""); - val.Append(mScreenCols,10); + nsAutoString att; att.AssignWithConversion("cols"); + nsAutoString val; val.SetLength(0); + val.AppendInt(mScreenCols,10); preElement->SetAttribute(att, val); - att = "rows"; - val = "1"; + att.AssignWithConversion("rows"); + val.AssignWithConversion("1"); preElement->SetAttribute(att, val); if (beforeRowNode) { @@ -3537,7 +3560,7 @@ NS_IMETHODIMP mozXMLTermSession::DisplayRow(const nsString& aString, } nsCOMPtr spanNode, textNode; - nsAutoString tagName = "span"; + nsAutoString tagName; tagName.AssignWithConversion("span"); nsAutoString elementName; nsAutoString subString; PRInt32 k; @@ -3565,19 +3588,19 @@ NS_IMETHODIMP mozXMLTermSession::DisplayRow(const nsString& aString, switch (currentStyle) { case LTERM_STDOUT_STYLE | LTERM_BOLD_STYLE: - elementName = "boldstyle"; + elementName.AssignWithConversion("boldstyle"); break; case LTERM_STDOUT_STYLE | LTERM_ULINE_STYLE: - elementName = "underlinestyle"; + elementName.AssignWithConversion("underlinestyle"); break; case LTERM_STDOUT_STYLE | LTERM_BLINK_STYLE: - elementName = "blinkstyle"; + elementName.AssignWithConversion("blinkstyle"); break; case LTERM_STDOUT_STYLE | LTERM_INVERSE_STYLE: - elementName = "inversestyle"; + elementName.AssignWithConversion("inversestyle"); break; default: - elementName = "boldstyle"; + elementName.AssignWithConversion("boldstyle"); break; } @@ -3611,13 +3634,13 @@ NS_IMETHODIMP mozXMLTermSession::DisplayRow(const nsString& aString, NS_IMETHODIMP mozXMLTermSession::NewBreak(nsIDOMNode* parentNode) { nsresult result; - nsAutoString tagName = "br"; + nsAutoString tagName; tagName.AssignWithConversion("br"); XMLT_LOG(mozXMLTermSession::NewBreak,60,("\n")); // Create "br" element and append as child of specified parent nsCOMPtr brNode; - nsAutoString name = ""; + nsAutoString name; name.SetLength(0); result = NewElement(tagName, name, -1, parentNode, brNode); if (NS_FAILED(result) || !brNode) @@ -3686,7 +3709,7 @@ NS_IMETHODIMP mozXMLTermSession::NewAnchor(const nsString& classAttribute, nsCOMPtr& anchorNode) { nsresult result; - nsAutoString tagName("a"); + nsAutoString tagName; tagName.AssignWithConversion("a"); XMLT_LOG(mozXMLTermSession::NewAnchor,80,("\n")); @@ -3697,18 +3720,18 @@ NS_IMETHODIMP mozXMLTermSession::NewAnchor(const nsString& classAttribute, return NS_ERROR_FAILURE; // Set element attributes - nsAutoString hrefAtt("href"); - nsAutoString hrefVal("#"); + nsAutoString hrefAtt; hrefAtt.AssignWithConversion("href"); + nsAutoString hrefVal; hrefVal.AssignWithConversion("#"); newElement->SetAttribute(hrefAtt, hrefVal); if (classAttribute.Length() > 0) { - nsAutoString classStr("class"); + nsAutoString classStr; classStr.AssignWithConversion("class"); newElement->SetAttribute(classStr, classAttribute); if (number >= 0) { - nsAutoString idAtt("id"); + nsAutoString idAtt; idAtt.AssignWithConversion("id"); nsAutoString idVal(classAttribute); - idVal.Append(number,10); + idVal.AppendInt(number,10); newElement->SetAttribute(idAtt, idVal); } } @@ -3755,18 +3778,18 @@ NS_IMETHODIMP mozXMLTermSession::NewElement(const nsString& tagName, if (name.Length() > 0) { // Set attributes - nsAutoString classAtt("class"); + nsAutoString classAtt; classAtt.AssignWithConversion("class"); nsAutoString classVal(name); newElement->SetAttribute(classAtt, classVal); - nsAutoString nameAtt("name"); + nsAutoString nameAtt; nameAtt.AssignWithConversion("name"); nsAutoString nameVal(name); newElement->SetAttribute(nameAtt, nameVal); if (number >= 0) { - nsAutoString idAtt("id"); + nsAutoString idAtt; idAtt.AssignWithConversion("id"); nsAutoString idVal(name); - idVal.Append(number,10); + idVal.AppendInt(number,10); newElement->SetAttribute(idAtt, idVal); } } @@ -3805,7 +3828,7 @@ NS_IMETHODIMP mozXMLTermSession::NewTextNode( nsIDOMNode* parentNode, // Create text node nsCOMPtr newText; - nsAutoString nullStr(""); + nsAutoString nullStr; nullStr.SetLength(0); result = mDOMDocument->CreateTextNode(nullStr, getter_AddRefs(newText)); if (NS_FAILED(result) || !newText) return NS_ERROR_FAILURE; @@ -3859,7 +3882,7 @@ NS_IMETHODIMP mozXMLTermSession::NewIFrame(nsIDOMNode* parentNode, #else // Create IFRAME element nsCOMPtr newElement; - nsAutoString tagName = "iframe"; + nsAutoString tagName; tagName.AssignWithConversion("iframe"); result = mDOMDocument->CreateElement(tagName, getter_AddRefs(newElement)); if (NS_FAILED(result) || !newElement) return NS_ERROR_FAILURE; @@ -3868,32 +3891,32 @@ NS_IMETHODIMP mozXMLTermSession::NewIFrame(nsIDOMNode* parentNode, // Set attributes if (number >= 0) { - attName = "name"; - attValue = "iframe"; - attValue.Append(number,10); + attName.AssignWithConversion("name"); + attValue.AssignWithConversion("iframe"); + attValue.AppendInt(number,10); newElement->SetAttribute(attName, attValue); } - attName = "frameborder"; - attValue = ""; - attValue.Append(frameBorder,10); + attName.AssignWithConversion("frameborder"); + attValue.SetLength(0); + attValue.AppendInt(frameBorder,10); newElement->SetAttribute(attName, attValue); if (src.Length() > 0) { // Set SRC attribute - attName = "src"; + attName.AssignWithConversion("src"); newElement->SetAttribute(attName, src); } if (width.Length() > 0) { // Set WIDTH attribute - attName = "width"; + attName.AssignWithConversion("width"); newElement->SetAttribute(attName, width); } if (height.Length() > 0) { // Set HEIGHT attribute - attName = "height"; + attName.AssignWithConversion("height"); newElement->SetAttribute(attName, height); } @@ -3926,16 +3949,16 @@ NS_IMETHODIMP mozXMLTermSession::SetEventAttributes(const nsString& name, int j; for (j=0; jSetAttribute(attName, attValue); if (NS_FAILED(result)) @@ -4006,7 +4029,7 @@ PRBool mozXMLTermSession::IsPREInlineNode(nsIDOMNode* aNode) nsCOMPtr domElement = do_QueryInterface(aNode); if (domElement) { - nsAutoString tagName = ""; + nsAutoString tagName; tagName.SetLength(0); result = domElement->GetTagName(tagName); if (NS_SUCCEEDED(result)) { isPREInlineNode = tagName.EqualsIgnoreCase("span") || @@ -4040,9 +4063,9 @@ NS_IMETHODIMP mozXMLTermSession::ToHTMLString(nsIDOMNode* aNode, XMLT_LOG(mozXMLTermSession::ToHTMLString,80,("\n")); nsAutoString newIndentString (indentString); - newIndentString += " "; + newIndentString.AppendWithConversion(" "); - htmlString = ""; + htmlString.SetLength(0); nsCOMPtr domText( do_QueryInterface(aNode) ); @@ -4061,13 +4084,13 @@ NS_IMETHODIMP mozXMLTermSession::ToHTMLString(nsIDOMNode* aNode, nsCOMPtr domElement = do_QueryInterface(aNode); if (domElement) { - nsAutoString tagName = ""; + nsAutoString tagName; tagName.SetLength(0); domElement->GetTagName(tagName); if (!insidePRENode) { htmlString += indentString; } - htmlString += "<"; + htmlString.AppendWithConversion("<"); htmlString += tagName; PRBool isPRENode = tagName.EqualsIgnoreCase("pre"); @@ -4090,20 +4113,20 @@ NS_IMETHODIMP mozXMLTermSession::ToHTMLString(nsIDOMNode* aNode, nsCOMPtr attr = do_QueryInterface(attrNode); if (attr) { - nsAutoString attrName = ""; - nsAutoString attrValue = ""; + nsAutoString attrName; attrName.SetLength(0); + nsAutoString attrValue; attrValue.SetLength(0); result = attr->GetName(attrName); if (NS_SUCCEEDED(result)) { - htmlString += " "; - htmlString += attrName; + htmlString.AppendWithConversion(" "); + htmlString.Append(attrName); } result = attr->GetValue(attrValue); if (NS_SUCCEEDED(result) && (attrName.Length() > 0)) { - htmlString += "=\""; - htmlString += attrValue; - htmlString += "\""; + htmlString.AppendWithConversion("=\""); + htmlString.Append(attrValue); + htmlString.AppendWithConversion("\""); } } } @@ -4112,14 +4135,14 @@ NS_IMETHODIMP mozXMLTermSession::ToHTMLString(nsIDOMNode* aNode, } if (!deepContent) { - htmlString += ">"; + htmlString.AppendWithConversion(">"); } else { // Iterate over all child nodes to generate deep content nsCOMPtr child; result = aNode->GetFirstChild(getter_AddRefs(child)); - nsAutoString htmlInner (""); + nsAutoString htmlInner; htmlInner.AssignWithConversion(""); while (child) { nsAutoString innerString; ToHTMLString(child, newIndentString, innerString, deepContent, @@ -4135,27 +4158,27 @@ NS_IMETHODIMP mozXMLTermSession::ToHTMLString(nsIDOMNode* aNode, if (htmlInner.Length() > 0) { if (insidePRENode) - htmlString += "\n>"; + htmlString.AppendWithConversion("\n>"); else - htmlString += ">\n"; + htmlString.AppendWithConversion(">\n"); htmlString += htmlInner; if (!insidePRENode) htmlString += indentString; } else { - htmlString += ">"; + htmlString.AppendWithConversion(">"); } - htmlString += ""; + htmlString.AppendWithConversion("\n"); + htmlString.AppendWithConversion(">"); if (!insidePRENode) - htmlString += "\n"; + htmlString.AppendWithConversion("\n"); } } } @@ -4262,7 +4285,7 @@ void mozXMLTermSession::TraverseDOMTree(FILE* fileStream, case TREE_PRINT_ATTS: case TREE_PRINT_HTML: if (PR_TRUE) { - nsAutoString indentString (""); + nsAutoString indentString; indentString.SetLength(0); nsAutoString htmlString; ToHTMLString(currentNode, indentString, htmlString, (PRBool) (treeActionCode == TREE_PRINT_HTML) ); @@ -4292,7 +4315,7 @@ void mozXMLTermSession::TraverseDOMTree(FILE* fileStream, nsCOMPtr domElement; domElement = do_QueryInterface(moveNode); if (domElement) { - nsAutoString tagName = ""; + nsAutoString tagName; tagName.SetLength(0); result = domElement->GetTagName(tagName); if (NS_SUCCEEDED(result)) { @@ -4303,8 +4326,9 @@ void mozXMLTermSession::TraverseDOMTree(FILE* fileStream, // Print selected attribute values int j; for (j=0; jGetAttribute(attName, attValue); if (NS_SUCCEEDED(result) && (attValue.Length() > 0)) { diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermStream.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermStream.cpp index 2cee0191843..ca19d164bd4 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermStream.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermStream.cpp @@ -179,7 +179,7 @@ NS_IMETHODIMP mozXMLTermStream::Open(nsIDOMWindow* aDOMWindow, // Open stream in named subframe of current frame XMLT_LOG(mozXMLTermStream::Open,22,("frameName=%s\n", frameName)); - nsAutoString innerFrameName = frameName; + nsAutoString innerFrameName; innerFrameName.AssignWithConversion(frameName); // Get DOM IFRAME element nsCOMPtr domDoc; @@ -221,12 +221,12 @@ NS_IMETHODIMP mozXMLTermStream::Open(nsIDOMWindow* aDOMWindow, if (mMaxResizeHeight > 0) { // Set initial IFRAME size to be as wide as the window, but very short - nsAutoString attWidth = "width"; - nsAutoString valWidth = "100%"; + nsAutoString attWidth; attWidth.AssignWithConversion("width"); + nsAutoString valWidth; valWidth.AssignWithConversion("100%"); mDOMIFrameElement->SetAttribute(attWidth,valWidth); - nsAutoString attHeight = "height"; - nsAutoString valHeight = "10"; + nsAutoString attHeight; attHeight.AssignWithConversion("height"); + nsAutoString valHeight; valHeight.AssignWithConversion("10"); mDOMIFrameElement->SetAttribute(attHeight,valHeight); } @@ -472,9 +472,9 @@ NS_IMETHODIMP mozXMLTermStream::SizeToContentHeight(PRInt32 maxHeight) if ((pageHeight > shellHeight) || (pageWidth > shellWidth)) { // Page larger than docshell - nsAutoString attHeight = "height"; - nsAutoString attWidth = "width"; - nsAutoString attValue = ""; + nsAutoString attHeight; attHeight.AssignWithConversion("height"); + nsAutoString attWidth; attWidth.AssignWithConversion("width"); + nsAutoString attValue; attValue.SetLength(0); PRInt32 newPageHeight = pageHeight; PRInt32 excessWidth = (pageWidth+scrollBarWidth - shellWidth); @@ -484,7 +484,7 @@ NS_IMETHODIMP mozXMLTermStream::SizeToContentHeight(PRInt32 maxHeight) if (excessWidth > 0) { // Widen IFRAME beyond page width by scrollbar width - attValue = ""; + attValue.SetLength(0); attValue.Append(shellWidth+scrollBarWidth); mDOMIFrameElement->SetAttribute(attWidth,attValue); @@ -501,14 +501,14 @@ NS_IMETHODIMP mozXMLTermStream::SizeToContentHeight(PRInt32 maxHeight) pageWidth, pageHeight, newPageHeight); // Reset IFRAME width - attValue = ""; + attValue.SetLength(0); attValue.Append(shellWidth); mDOMIFrameElement->SetAttribute(attWidth,attValue); } // Resize IFRAME height to match page height (subject to a maximum) if (newPageHeight > maxHeight) newPageHeight = maxHeight; - attValue = ""; + attValue.SetLength(0); attValue.Append(newPageHeight); mDOMIFrameElement->SetAttribute(attHeight,attValue); } diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermUtils.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermUtils.cpp index 18e2a117373..7d836c40ed4 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermUtils.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermUtils.cpp @@ -293,11 +293,12 @@ mozXMLTermUtils::GetNodeAttribute(nsIDOMNode* aDOMNode, nsCOMPtr domElement = do_QueryInterface(aDOMNode); if (!domElement) { - aAttValue = ""; + aAttValue.SetLength(0); return NS_OK; } - nsAutoString attName = aAttName; + nsAutoString attName; + attName.AssignWithConversion(aAttName); return domElement->GetAttribute(attName, aAttValue); } @@ -324,7 +325,7 @@ NS_IMETHODIMP mozXMLTermUtils::TimeStamp(PRInt32 deltaSec, PRTime& lastTime, LL_I2L(deltaTime, deltaSec*1000000); if (LL_CMP(difTime, <, deltaTime)) { // Not enough time has elapsed for a new time stamp - aTimeStamp = ""; + aTimeStamp.SetLength(0); return NS_OK; } @@ -344,7 +345,7 @@ NS_IMETHODIMP mozXMLTermUtils::TimeStamp(PRInt32 deltaSec, PRTime& lastTime, XMLT_LOG(mozXMLTermUtils::LocalTime,99,("localTime=%s\n", dateStr)); - aTimeStamp = dateStr; + aTimeStamp.AssignWithConversion(dateStr); return NS_OK; } @@ -382,7 +383,7 @@ NS_IMETHODIMP mozXMLTermUtils::RandomCookie(nsString& aCookie) } cookie[11] = '\0'; - aCookie = cookie; + aCookie.AssignWithConversion(cookie); return NS_OK; } diff --git a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp index e340711b6aa..cb980f1dfd6 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp @@ -94,12 +94,12 @@ NS_NewXMLTerminal(mozIXMLTerminal** aXMLTerminal) mozXMLTerminal::mozXMLTerminal() : mInitialized(PR_FALSE), - mCookie(""), + mCookie(nsAutoString()), - mCommand(""), - mPromptExpr(""), + mCommand(nsAutoString()), + mPromptExpr(nsAutoString()), - mInitInput(""), + mInitInput(nsAutoString()), mXMLTermShell(nsnull), mDocShell(nsnull), @@ -244,8 +244,8 @@ NS_IMETHODIMP mozXMLTerminal::Init(nsIDocShell* aDocShell, result, (unsigned int) contViewer.get()); // NOTE: Need to parse args string!!! - mCommand = ""; - mPromptExpr = ""; + mCommand.SetLength(0); + mPromptExpr.SetLength(0); mInitInput = args; // Initialization completed @@ -263,7 +263,8 @@ NS_IMETHODIMP mozXMLTerminal::Init(nsIDocShell* aDocShell, XMLT_LOG(mozXMLTerminal::Init,22,("done setting DocLoaderObs\n")); // Load initial XMLterm background document - nsCAutoString urlCString(aURL); + nsCAutoString urlCString; + urlCString.AssignWithConversion(aURL); nsCOMPtr uri; result = uri->SetSpec(urlCString.GetBuffer()); @@ -691,7 +692,8 @@ NS_IMETHODIMP mozXMLTerminal::SendText(const nsString& aString, result = mLineTermAux->Write(sendStr.GetUnicode(), aCookie); if (NS_FAILED(result)) { // Abort XMLterm session - nsAutoString abortCode = "SendText"; + nsAutoString abortCode; + abortCode.AssignWithConversion("SendText"); mXMLTermSession->Abort(mLineTermAux, abortCode); return NS_ERROR_FAILURE; } @@ -713,7 +715,7 @@ NS_IMETHODIMP mozXMLTerminal::ShowCaret(void) if (!mPresShell) return NS_ERROR_FAILURE; - mPresShell->SetCaretEnabled(PR_TRUE); + //mPresShell->SetCaretEnabled(PR_TRUE); nsCOMPtr caret; if (NS_SUCCEEDED(mPresShell->GetCaret(getter_AddRefs(caret)))) { @@ -764,18 +766,19 @@ NS_IMETHODIMP mozXMLTerminal::Paste() if (NS_FAILED(result)) return result; - nsAutoString flavor ( bestFlavor ); + nsAutoString flavor; + flavor.AssignWithConversion(bestFlavor); char* temCStr = flavor.ToNewCString(); XMLT_LOG(mozXMLTerminal::Paste,20,("flavour=%s\n", temCStr)); nsAllocator::Free(temCStr); - if (flavor.Equals(kHTMLMime) || flavor.Equals(kUnicodeMime)) { + if (flavor.EqualsWithConversion(kHTMLMime) || flavor.EqualsWithConversion(kUnicodeMime)) { nsCOMPtr textDataObj ( do_QueryInterface(genericDataObj) ); if (textDataObj && objLen > 0) { PRUnichar* text = nsnull; textDataObj->ToString ( &text ); - pasteString.SetString ( text, objLen / 2 ); + pasteString.Assign( text, objLen / 2 ); result = SendTextAux(pasteString); } } @@ -890,7 +893,7 @@ NS_IMETHODIMP mozXMLTerminal::MatchesCookie(const PRUnichar* aCookie, return NS_ERROR_NULL_POINTER; // Check if supplied cookie matches XMLTerm cookie - *_retval = mCookie.Equals(aCookie); + *_retval = mCookie.EqualsWithConversion(aCookie); if (!(*_retval)) { XMLT_ERROR("mozXMLTerminal::MatchesCookie: Error - Cookie mismatch\n");