diff --git a/mozilla/editor/base/ChangeAttributeTxn.cpp b/mozilla/editor/base/ChangeAttributeTxn.cpp index dc950dff226..3c3ff7538db 100644 --- a/mozilla/editor/base/ChangeAttributeTxn.cpp +++ b/mozilla/editor/base/ChangeAttributeTxn.cpp @@ -35,8 +35,8 @@ ChangeAttributeTxn::~ChangeAttributeTxn() NS_IMETHODIMP ChangeAttributeTxn::Init(nsIEditor *aEditor, nsIDOMElement *aElement, - const nsString& aAttribute, - const nsString& aValue, + const nsAReadableString& aAttribute, + const nsAReadableString& aValue, PRBool aRemoveAttribute) { NS_ASSERTION(aEditor && aElement, "bad arg"); @@ -58,7 +58,7 @@ NS_IMETHODIMP ChangeAttributeTxn::DoTransaction(void) if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; } // need to get the current value of the attribute and save it, and set mAttributeWasSet - nsresult result = mEditor->GetAttributeValue(mElement, mAttribute, mUndoValue, mAttributeWasSet); + nsresult result = mEditor->GetAttributeValue(mElement, mAttribute, mUndoValue, &mAttributeWasSet); // XXX: hack until attribute-was-set code is implemented if (PR_FALSE==mUndoValue.IsEmpty()) mAttributeWasSet=PR_TRUE; diff --git a/mozilla/editor/base/ChangeAttributeTxn.h b/mozilla/editor/base/ChangeAttributeTxn.h index e9459b800f4..50eefa7f5e1 100644 --- a/mozilla/editor/base/ChangeAttributeTxn.h +++ b/mozilla/editor/base/ChangeAttributeTxn.h @@ -54,8 +54,8 @@ public: */ NS_IMETHOD Init(nsIEditor *aEditor, nsIDOMElement *aNode, - const nsString& aAttribute, - const nsString& aValue, + const nsAReadableString& aAttribute, + const nsAReadableString& aValue, PRBool aRemoveAttribute); private: diff --git a/mozilla/editor/base/CreateElementTxn.cpp b/mozilla/editor/base/CreateElementTxn.cpp index dabc508b114..45ed325d783 100644 --- a/mozilla/editor/base/CreateElementTxn.cpp +++ b/mozilla/editor/base/CreateElementTxn.cpp @@ -43,7 +43,7 @@ CreateElementTxn::CreateElementTxn() } NS_IMETHODIMP CreateElementTxn::Init(nsEditor *aEditor, - const nsString &aTag, + const nsAReadableString &aTag, nsIDOMNode *aParent, PRUint32 aOffsetInParent) { diff --git a/mozilla/editor/base/CreateElementTxn.h b/mozilla/editor/base/CreateElementTxn.h index 733921e0d34..fddf52b4c38 100644 --- a/mozilla/editor/base/CreateElementTxn.h +++ b/mozilla/editor/base/CreateElementTxn.h @@ -52,7 +52,7 @@ public: * if eAppend, the new element is appended as the last child */ NS_IMETHOD Init(nsEditor *aEditor, - const nsString& aTag, + const nsAReadableString& aTag, nsIDOMNode *aParent, PRUint32 aOffsetInParent); diff --git a/mozilla/editor/base/IMETextTxn.cpp b/mozilla/editor/base/IMETextTxn.cpp index fbb37087dab..246a730c2be 100644 --- a/mozilla/editor/base/IMETextTxn.cpp +++ b/mozilla/editor/base/IMETextTxn.cpp @@ -65,7 +65,7 @@ NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement, PRUint32 aOffset, PRUint32 aReplaceLength, nsIPrivateTextRangeList *aTextRangeList, - const nsString &aStringToInsert, + const nsAReadableString &aStringToInsert, nsWeakPtr aSelConWeak) { NS_ASSERTION(aElement, "illegal value- null ptr- aElement"); diff --git a/mozilla/editor/base/IMETextTxn.h b/mozilla/editor/base/IMETextTxn.h index 4b27f5770fa..5dc2c26d0ae 100644 --- a/mozilla/editor/base/IMETextTxn.h +++ b/mozilla/editor/base/IMETextTxn.h @@ -65,7 +65,7 @@ public: PRUint32 aOffset, PRUint32 aReplaceLength, nsIPrivateTextRangeList* aTextRangeList, - const nsString& aString, + const nsAReadableString& aString, nsWeakPtr aSelCon); private: diff --git a/mozilla/editor/base/InsertTextTxn.cpp b/mozilla/editor/base/InsertTextTxn.cpp index b60e46a451b..9e0e9979345 100644 --- a/mozilla/editor/base/InsertTextTxn.cpp +++ b/mozilla/editor/base/InsertTextTxn.cpp @@ -60,7 +60,7 @@ InsertTextTxn::~InsertTextTxn() NS_IMETHODIMP InsertTextTxn::Init(nsIDOMCharacterData *aElement, PRUint32 aOffset, - const nsString &aStringToInsert, + const nsAReadableString &aStringToInsert, nsIEditor *aEditor) { #if 0 //def DEBUG_cmanske diff --git a/mozilla/editor/base/InsertTextTxn.h b/mozilla/editor/base/InsertTextTxn.h index 577383db3a3..ce6680dbd15 100644 --- a/mozilla/editor/base/InsertTextTxn.h +++ b/mozilla/editor/base/InsertTextTxn.h @@ -59,7 +59,7 @@ public: */ NS_IMETHOD Init(nsIDOMCharacterData *aElement, PRUint32 aOffset, - const nsString& aString, + const nsAReadableString& aString, nsIEditor *aEditor); private: diff --git a/mozilla/editor/base/SetDocTitleTxn.cpp b/mozilla/editor/base/SetDocTitleTxn.cpp index 9d367d348a4..b7829e718d6 100644 --- a/mozilla/editor/base/SetDocTitleTxn.cpp +++ b/mozilla/editor/base/SetDocTitleTxn.cpp @@ -38,7 +38,7 @@ SetDocTitleTxn::SetDocTitleTxn() } NS_IMETHODIMP SetDocTitleTxn::Init(nsIHTMLEditor *aEditor, - const nsString *aValue) + const nsAReadableString *aValue) { NS_ASSERTION(aEditor && aValue, "null args"); @@ -72,7 +72,7 @@ NS_IMETHODIMP SetDocTitleTxn::RedoTransaction(void) return SetDocTitle(mValue); } -nsresult SetDocTitleTxn::SetDocTitle(nsString& aTitle) +nsresult SetDocTitleTxn::SetDocTitle(const nsAReadableString& aTitle) { NS_ASSERTION(mEditor, "bad state"); if (!mEditor) return NS_ERROR_NOT_INITIALIZED; @@ -89,7 +89,7 @@ nsresult SetDocTitleTxn::SetDocTitle(nsString& aTitle) return HTMLDoc->SetTitle(aTitle); } -nsresult SetDocTitleTxn::SetDomTitle(nsString& aTitle) +nsresult SetDocTitleTxn::SetDomTitle(const nsAReadableString& aTitle) { nsCOMPtr domDoc; nsCOMPtr editor = do_QueryInterface(mEditor); diff --git a/mozilla/editor/base/SetDocTitleTxn.h b/mozilla/editor/base/SetDocTitleTxn.h index 715e664e0e9..4451fe8d0ba 100644 --- a/mozilla/editor/base/SetDocTitleTxn.h +++ b/mozilla/editor/base/SetDocTitleTxn.h @@ -53,11 +53,11 @@ public: * @param aValue the new value for document title */ NS_IMETHOD Init(nsIHTMLEditor *aEditor, - const nsString *aValue); + const nsAReadableString *aValue); private: SetDocTitleTxn(); - nsresult SetDocTitle(nsString& aTitle); - nsresult SetDomTitle(nsString& aTitle); + nsresult SetDocTitle(const nsAReadableString& aTitle); + nsresult SetDomTitle(const nsAReadableString& aTitle); public: NS_IMETHOD DoTransaction(void); diff --git a/mozilla/editor/base/TextEditorTest.cpp b/mozilla/editor/base/TextEditorTest.cpp index 260cfc955b2..65afe166a91 100644 --- a/mozilla/editor/base/TextEditorTest.cpp +++ b/mozilla/editor/base/TextEditorTest.cpp @@ -71,13 +71,13 @@ nsresult TextEditorTest::RunUnitTest(PRInt32 *outNumTests, PRInt32 *outNumTestsF // shouldn't we just bail on error here? // insert some simple text - result = mTextEditor->InsertText(NS_LITERAL_STRING("1234567890abcdefghij1234567890").get()); + result = mTextEditor->InsertText(NS_LITERAL_STRING("1234567890abcdefghij1234567890")); TEST_RESULT(result); (*outNumTests)++; (*outNumTestsFailed) += (NS_FAILED(result) != NS_OK); // insert some more text - result = mTextEditor->InsertText(NS_LITERAL_STRING("Moreover, I am cognizant of the interrelatedness of all communities and states. I cannot sit idly by in Atlanta and not be concerned about what happens in Birmingham. Injustice anywhere is a threat to justice everywhere").get()); + result = mTextEditor->InsertText(NS_LITERAL_STRING("Moreover, I am cognizant of the interrelatedness of all communities and states. I cannot sit idly by in Atlanta and not be concerned about what happens in Birmingham. Injustice anywhere is a threat to justice everywhere")); TEST_RESULT(result); (*outNumTests)++; (*outNumTestsFailed) += (NS_FAILED(result) != NS_OK); @@ -174,14 +174,14 @@ nsresult TextEditorTest::TestTextProperties() PRBool all = PR_FALSE; PRBool first=PR_FALSE; - result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all); + result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all); TEST_RESULT(result); NS_ASSERTION(PR_FALSE==first, "first should be false"); NS_ASSERTION(PR_FALSE==any, "any should be false"); NS_ASSERTION(PR_FALSE==all, "all should be false"); - result = htmlEditor->SetInlineProperty(nsIEditProperty::b, nsnull, nsnull); + result = htmlEditor->SetInlineProperty(nsIEditProperty::b, nsString(), nsString()); TEST_RESULT(result); - result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all); + result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all); TEST_RESULT(result); NS_ASSERTION(PR_TRUE==first, "first should be true"); NS_ASSERTION(PR_TRUE==any, "any should be true"); @@ -190,9 +190,9 @@ nsresult TextEditorTest::TestTextProperties() // remove the bold we just set printf("set the whole first text node to not bold\n"); - result = htmlEditor->RemoveInlineProperty(nsIEditProperty::b, nsnull); + result = htmlEditor->RemoveInlineProperty(nsIEditProperty::b, nsString()); TEST_RESULT(result); - result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all); + result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all); TEST_RESULT(result); NS_ASSERTION(PR_FALSE==first, "first should be false"); NS_ASSERTION(PR_FALSE==any, "any should be false"); @@ -203,23 +203,23 @@ nsresult TextEditorTest::TestTextProperties() printf("set the first text node (1, length-1) to bold and italic, and (2, length-1) to underline.\n"); selection->Collapse(textNode, 1); selection->Extend(textNode, length-1); - result = htmlEditor->SetInlineProperty(nsIEditProperty::b, nsnull, nsnull); + result = htmlEditor->SetInlineProperty(nsIEditProperty::b, nsString(), nsString()); TEST_RESULT(result); - result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all); + result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all); TEST_RESULT(result); NS_ASSERTION(PR_TRUE==first, "first should be true"); NS_ASSERTION(PR_TRUE==any, "any should be true"); NS_ASSERTION(PR_TRUE==all, "all should be true"); mEditor->DebugDumpContent(); // make all that same text italic - result = htmlEditor->SetInlineProperty(nsIEditProperty::i, nsnull, nsnull); + result = htmlEditor->SetInlineProperty(nsIEditProperty::i, nsString(), nsString()); TEST_RESULT(result); - result = htmlEditor->GetInlineProperty(nsIEditProperty::i, nsnull, nsnull, first, any, all); + result = htmlEditor->GetInlineProperty(nsIEditProperty::i, nsString(), nsString(), &first, &any, &all); TEST_RESULT(result); NS_ASSERTION(PR_TRUE==first, "first should be true"); NS_ASSERTION(PR_TRUE==any, "any should be true"); NS_ASSERTION(PR_TRUE==all, "all should be true"); - result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all); + result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all); TEST_RESULT(result); NS_ASSERTION(PR_TRUE==first, "first should be true"); NS_ASSERTION(PR_TRUE==any, "any should be true"); @@ -240,9 +240,9 @@ nsresult TextEditorTest::TestTextProperties() NS_ASSERTION(length==915, "wrong text node"); selection->Collapse(textNode, 1); selection->Extend(textNode, length-2); - result = htmlEditor->SetInlineProperty(nsIEditProperty::u, nsnull, nsnull); + result = htmlEditor->SetInlineProperty(nsIEditProperty::u, nsString(), nsString()); TEST_RESULT(result); - result = htmlEditor->GetInlineProperty(nsIEditProperty::u, nsnull, nsnull, first, any, all); + result = htmlEditor->GetInlineProperty(nsIEditProperty::u, nsString(), nsString(), &first, &any, &all); TEST_RESULT(result); NS_ASSERTION(PR_TRUE==first, "first should be true"); NS_ASSERTION(PR_TRUE==any, "any should be true"); diff --git a/mozilla/editor/base/nsAOLCiter.cpp b/mozilla/editor/base/nsAOLCiter.cpp index 543b43d55a1..937b6ef9077 100644 --- a/mozilla/editor/base/nsAOLCiter.cpp +++ b/mozilla/editor/base/nsAOLCiter.cpp @@ -62,51 +62,53 @@ nsAOLCiter::QueryInterface(REFNSIID aIID, void** aInstancePtr) } NS_IMETHODIMP -nsAOLCiter::GetCiteString(const nsString& aInString, nsString& aOutString) +nsAOLCiter::GetCiteString(const nsAReadableString& aInString, nsAWritableString& aOutString) { - aOutString.AssignWithConversion("\n\n>> "); + aOutString = NS_LITERAL_STRING("\n\n>> "); aOutString += aInString; // See if the last char is a newline, and replace it if so PRUnichar newline ('\n'); if (aOutString.Last() == newline) { - aOutString.SetCharAt(' ',aOutString.Length()); - aOutString.AppendWithConversion("<<\n"); + aOutString.Append(PRUnichar(' ')); + aOutString.Append(NS_LITERAL_STRING("<<\n")); } else { - aOutString.AppendWithConversion(" <<\n"); + aOutString.Append(NS_LITERAL_STRING(" <<\n")); } return NS_OK; } NS_IMETHODIMP -nsAOLCiter::StripCites(const nsString& aInString, nsString& aOutString) +nsAOLCiter::StripCites(const nsAReadableString& aInString, nsAWritableString& aOutString) { // Remove the beginning cites, if any: - if (aInString.EqualsWithConversion(">>", PR_FALSE, 2)) + nsAutoString tInputString(aInString);//MJUDGE SCC NEED HELP + nsAutoString tOutputString; + if (tInputString.EqualsWithConversion(">>", PR_FALSE, 2)) { PRInt32 i = 3; - while (nsCRT::IsAsciiSpace(aInString[i])) + while (nsCRT::IsAsciiSpace(tInputString[i])) ++i; - aOutString.Append(aInString.GetUnicode(), i); + tOutputString.Append(tInputString.GetUnicode(), i); } else - aOutString = aInString; + tOutputString = tInputString; // Remove the end cites, if any: - aOutString.Trim("<", PR_FALSE, PR_TRUE, PR_FALSE); - + tOutputString.Trim("<", PR_FALSE, PR_TRUE, PR_FALSE); + aOutString.Assign(tOutputString); return NS_OK; } NS_IMETHODIMP -nsAOLCiter::Rewrap(const nsString& aInString, +nsAOLCiter::Rewrap(const nsAReadableString& aInString, PRUint32 aWrapCol, PRUint32 aFirstLineOffset, PRBool aRespectNewlines, - nsString& aOutString) + nsAWritableString& aOutString) { nsString citeString; return nsWrapUtils::Rewrap(aInString, aWrapCol, aFirstLineOffset, diff --git a/mozilla/editor/base/nsAOLCiter.h b/mozilla/editor/base/nsAOLCiter.h index a4edd83674e..a4086786963 100644 --- a/mozilla/editor/base/nsAOLCiter.h +++ b/mozilla/editor/base/nsAOLCiter.h @@ -23,9 +23,9 @@ #ifndef nsAOLCiter_h__ #define nsAOLCiter_h__ +#include "nsString.h" #include "nsICiter.h" -#include "nsString.h" /** Mail citations using the AOL style >> This is a citation << */ @@ -38,14 +38,14 @@ public: //NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor NS_DECL_ISUPPORTS - NS_IMETHOD GetCiteString(const nsString& aInString, nsString& aOutString); + NS_IMETHOD GetCiteString(const nsAReadableString & aInString, nsAWritableString & aOutString); - NS_IMETHOD StripCites(const nsString& aInString, nsString& aOutString); + NS_IMETHOD StripCites(const nsAReadableString & aInString, nsAWritableString & aOutString); - NS_IMETHOD Rewrap(const nsString& aInString, + NS_IMETHOD Rewrap(const nsAReadableString & aInString, PRUint32 aWrapCol, PRUint32 aFirstLineOffset, PRBool aRespectNewlines, - nsString& aOutString); + nsAWritableString & aOutString); }; #endif //nsAOLCiter_h__ diff --git a/mozilla/editor/base/nsComposerCommands.cpp b/mozilla/editor/base/nsComposerCommands.cpp index e1c598f0d3c..ee57e7c160b 100644 --- a/mozilla/editor/base/nsComposerCommands.cpp +++ b/mozilla/editor/base/nsComposerCommands.cpp @@ -274,7 +274,7 @@ nsPasteQuotationCommand::IsCommandEnabled(const nsAReadableString & aCommandName nsCOMPtr editor; editorShell->GetEditor(getter_AddRefs(editor)); if (editor) - editor->CanPaste(nsIClipboard::kGlobalClipboard, *outCmdEnabled); + editor->CanPaste(nsIClipboard::kGlobalClipboard, outCmdEnabled); } return NS_OK; @@ -322,7 +322,7 @@ nsStyleUpdatingCommand::GetCurrentState(nsIEditorShell *aEditorShell, const char if (!htmlEditor) return NS_ERROR_NOT_INITIALIZED; nsCOMPtr styleAtom = getter_AddRefs(NS_NewAtom(aTagName)); - rv = htmlEditor->GetInlineProperty(styleAtom, nsnull, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp); + rv = htmlEditor->GetInlineProperty(styleAtom, NS_LITERAL_STRING(""), NS_LITERAL_STRING(""), &firstOfSelectionHasProp, &anyOfSelectionHasProp, &allOfSelectionHasProp); outStyleSet = allOfSelectionHasProp; // change this to alter the behaviour return rv; @@ -442,8 +442,7 @@ nsListItemCommand::ToggleState(nsIEditorShell *aEditorShell, const char* aTagNam { if (!bMixed) { - nsAutoString listType(tagStr); - rv = htmlEditor->RemoveList(listType); + rv = htmlEditor->RemoveList(nsLiteralString(tagStr)); } nsCRT::free(tagStr); } @@ -554,7 +553,7 @@ nsOutdentCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISu if (htmlEditor) { PRBool canIndent, canOutdent; - htmlEditor->GetIndentState(canIndent, canOutdent); + htmlEditor->GetIndentState(&canIndent, &canOutdent); *outCmdEnabled = canOutdent; } @@ -690,7 +689,7 @@ nsParagraphStateCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsString& aEditorShell->GetEditor(getter_AddRefs(editor)); nsCOMPtr htmlEditor = do_QueryInterface(editor); if (!htmlEditor) return NS_ERROR_FAILURE; - return htmlEditor->GetParagraphState(outMixed, outStateString); + return htmlEditor->GetParagraphState(&outMixed, outStateString); } @@ -727,7 +726,7 @@ nsFontFaceStateCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsString& nsCOMPtr htmlEditor = do_QueryInterface(editor); if (!htmlEditor) return NS_ERROR_FAILURE; - return htmlEditor->GetFontFaceState(outMixed, outStateString); + return htmlEditor->GetFontFaceState(&outMixed, outStateString); } @@ -743,9 +742,6 @@ nsFontFaceStateCommand::SetState(nsIEditorShell *aEditorShell, nsString& newStat nsresult rv; - NS_ConvertASCIItoUCS2 emptyString(""); - NS_ConvertASCIItoUCS2 fontString("font"); - NS_ConvertASCIItoUCS2 faceString("face"); nsCOMPtr ttAtom = getter_AddRefs(NS_NewAtom("tt")); nsCOMPtr fontAtom = getter_AddRefs(NS_NewAtom("font")); @@ -753,19 +749,19 @@ nsFontFaceStateCommand::SetState(nsIEditorShell *aEditorShell, nsString& newStat if (newState.EqualsWithConversion("tt")) { // The old "teletype" attribute - rv = htmlEditor->SetInlineProperty(ttAtom, &emptyString, &emptyString); + rv = htmlEditor->SetInlineProperty(ttAtom, NS_LITERAL_STRING(""), NS_LITERAL_STRING("")); // Clear existing font face - rv = htmlEditor->RemoveInlineProperty(fontAtom, &faceString); + rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("face")); } else { // Remove any existing TT nodes - rv = htmlEditor->RemoveInlineProperty(ttAtom, &emptyString); + rv = htmlEditor->RemoveInlineProperty(ttAtom, NS_LITERAL_STRING("")); - if (newState == emptyString || newState.EqualsWithConversion("normal")) { - rv = htmlEditor->RemoveInlineProperty(fontAtom, &faceString); + if (!newState.Length() || newState.EqualsWithConversion("normal")) { + rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("face")); } else { - rv = htmlEditor->SetInlineProperty(fontAtom, &faceString, &newState); + rv = htmlEditor->SetInlineProperty(fontAtom, NS_LITERAL_STRING("face"), newState); } } @@ -791,7 +787,7 @@ nsFontColorStateCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsString& nsCOMPtr htmlEditor = do_QueryInterface(editor); if (!htmlEditor) return NS_ERROR_FAILURE; - return htmlEditor->GetFontColorState(outMixed, outStateString); + return htmlEditor->GetFontColorState(&outMixed, outStateString); } @@ -807,16 +803,13 @@ nsFontColorStateCommand::SetState(nsIEditorShell *aEditorShell, nsString& newSta nsresult rv; - NS_ConvertASCIItoUCS2 emptyString(""); - NS_ConvertASCIItoUCS2 fontString("font"); - NS_ConvertASCIItoUCS2 colorString("color"); nsCOMPtr fontAtom = getter_AddRefs(NS_NewAtom("font")); - if (newState == emptyString || newState.EqualsWithConversion("normal")) { - rv = htmlEditor->RemoveInlineProperty(fontAtom, &colorString); + if (!newState.Length() || newState.EqualsWithConversion("normal")) { + rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("color")); } else { - rv = htmlEditor->SetInlineProperty(fontAtom, &colorString, &newState); + rv = htmlEditor->SetInlineProperty(fontAtom, NS_LITERAL_STRING("color"), newState); } return rv; @@ -842,7 +835,7 @@ nsBackgroundColorStateCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsS if (!htmlEditor) return NS_ERROR_FAILURE; - return htmlEditor->GetBackgroundColorState(outMixed, outStateString); + return htmlEditor->GetBackgroundColorState(&outMixed, outStateString); } @@ -879,7 +872,7 @@ nsAlignCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsString& outState if (!htmlEditor) return NS_ERROR_FAILURE; nsIHTMLEditor::EAlignment firstAlign; - nsresult rv = htmlEditor->GetAlignment(outMixed, firstAlign); + nsresult rv = htmlEditor->GetAlignment(&outMixed, &firstAlign); if (NS_FAILED(rv)) return rv; switch (firstAlign) { diff --git a/mozilla/editor/base/nsEditor.cpp b/mozilla/editor/base/nsEditor.cpp index 80020203c3f..b963e8bf1a3 100644 --- a/mozilla/editor/base/nsEditor.cpp +++ b/mozilla/editor/base/nsEditor.cpp @@ -580,17 +580,19 @@ nsEditor::Undo(PRUint32 aCount) } -NS_IMETHODIMP nsEditor::CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo) +NS_IMETHODIMP nsEditor::CanUndo(PRBool *aIsEnabled, PRBool *aCanUndo) { - aIsEnabled = ((PRBool)((nsITransactionManager *)0!=mTxnMgr.get())); - if (aIsEnabled) + if (!aIsEnabled || !aCanUndo) + return NS_ERROR_NULL_POINTER; + *aIsEnabled = ((PRBool)((nsITransactionManager *)0!=mTxnMgr.get())); + if (*aIsEnabled) { PRInt32 numTxns=0; mTxnMgr->GetNumberOfUndoItems(&numTxns); - aCanUndo = ((PRBool)(0!=numTxns)); + *aCanUndo = ((PRBool)(0!=numTxns)); } else { - aCanUndo = PR_FALSE; + *aCanUndo = PR_FALSE; } return NS_OK; } @@ -624,17 +626,20 @@ nsEditor::Redo(PRUint32 aCount) } -NS_IMETHODIMP nsEditor::CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo) +NS_IMETHODIMP nsEditor::CanRedo(PRBool *aIsEnabled, PRBool *aCanRedo) { - aIsEnabled = ((PRBool)((nsITransactionManager *)0!=mTxnMgr.get())); - if (aIsEnabled) + if (!aIsEnabled || !aCanRedo) + return NS_ERROR_NULL_POINTER; + + *aIsEnabled = ((PRBool)((nsITransactionManager *)0!=mTxnMgr.get())); + if (*aIsEnabled) { PRInt32 numTxns=0; mTxnMgr->GetNumberOfRedoItems(&numTxns); - aCanRedo = ((PRBool)(0!=numTxns)); + *aCanRedo = ((PRBool)(0!=numTxns)); } else { - aCanRedo = PR_FALSE; + *aCanRedo = PR_FALSE; } return NS_OK; } @@ -891,24 +896,19 @@ nsEditor::GetDocumentModified(PRBool *outDocModified) } NS_IMETHODIMP -nsEditor::GetDocumentCharacterSet(PRUnichar** characterSet) +nsEditor::GetDocumentCharacterSet(nsAWritableString &characterSet) { nsresult rv; nsCOMPtr doc; nsCOMPtr presShell; - nsAutoString character_set; - - if (characterSet==nsnull) return NS_ERROR_NULL_POINTER; rv = GetPresShell(getter_AddRefs(presShell)); if (NS_SUCCEEDED(rv)) { presShell->GetDocument(getter_AddRefs(doc)); - if (doc ) { - rv = doc->GetDocumentCharacterSet(character_set); - if (NS_SUCCEEDED(rv)) *characterSet=character_set.ToNewUnicode(); - return rv; - } + if (doc ) + return doc->GetDocumentCharacterSet(characterSet); + rv = NS_ERROR_NULL_POINTER; } return rv; @@ -916,22 +916,20 @@ nsEditor::GetDocumentCharacterSet(PRUnichar** characterSet) } NS_IMETHODIMP -nsEditor::SetDocumentCharacterSet(const PRUnichar* characterSet) +nsEditor::SetDocumentCharacterSet(const nsAReadableString& characterSet) { nsresult rv; nsCOMPtr doc; nsCOMPtr presShell; - nsAutoString character_set(characterSet); - - if (characterSet==nsnull) return NS_ERROR_NULL_POINTER; rv = GetPresShell(getter_AddRefs(presShell)); if (NS_SUCCEEDED(rv)) { presShell->GetDocument(getter_AddRefs(doc)); if (doc) { - return doc->SetDocumentCharacterSet(character_set); + return doc->SetDocumentCharacterSet(characterSet); } + rv = NS_ERROR_NULL_POINTER; } return rv; @@ -957,7 +955,7 @@ nsEditor::GetWrapWidth(PRInt32 *aWrapColumn) NS_IMETHODIMP nsEditor::SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting, - PRBool aSaveCopy, const nsString& aFormat) + PRBool aSaveCopy, const nsAReadableString& aFormat) { if (!aFileSpec) return NS_ERROR_NULL_POINTER; @@ -997,8 +995,9 @@ nsEditor::SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting, GetWrapWidth(&wrapColumn); if (wrapColumn > 0) flags |= nsIDocumentEncoder::OutputWrap; + const nsPromiseFlatString &formatFlat = PromiseFlatString(aFormat); rv = diskDoc->SaveFile(aFileSpec, aReplaceExisting, aSaveCopy, - aFormat.GetUnicode(), NS_LITERAL_STRING("").get(), + formatFlat.get(), NS_LITERAL_STRING("").get(), flags, wrapColumn); if (NS_SUCCEEDED(rv)) DoAfterDocumentSave(); @@ -1015,7 +1014,7 @@ nsEditor::Cut() } NS_IMETHODIMP -nsEditor::CanCut(PRBool &aCanCut) +nsEditor::CanCut(PRBool *aCanCut) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -1027,7 +1026,7 @@ nsEditor::Copy() } NS_IMETHODIMP -nsEditor::CanCopy(PRBool &aCanCopy) +nsEditor::CanCopy(PRBool *aCanCut) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -1039,13 +1038,13 @@ nsEditor::Paste(PRInt32 aSelectionType) } NS_IMETHODIMP -nsEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste) +nsEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -nsEditor::CanDrag(nsIDOMEvent *aEvent, PRBool &aCanDrag) +nsEditor::CanDrag(nsIDOMEvent *aEvent, PRBool *aCanDrag) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -1064,7 +1063,7 @@ nsEditor::InsertFromDrop(nsIDOMEvent *aEvent) NS_IMETHODIMP -nsEditor::SetAttribute(nsIDOMElement *aElement, const nsString& aAttribute, const nsString& aValue) +nsEditor::SetAttribute(nsIDOMElement *aElement, const nsAReadableString & aAttribute, const nsAReadableString & aValue) { ChangeAttributeTxn *txn; nsresult result = CreateTxnForSetAttribute(aElement, aAttribute, aValue, &txn); @@ -1079,11 +1078,13 @@ nsEditor::SetAttribute(nsIDOMElement *aElement, const nsString& aAttribute, cons NS_IMETHODIMP nsEditor::GetAttributeValue(nsIDOMElement *aElement, - const nsString& aAttribute, - nsString& aResultValue, - PRBool& aResultIsSet) + const nsAReadableString & aAttribute, + nsAWritableString & aResultValue, + PRBool *aResultIsSet) { - aResultIsSet=PR_FALSE; + if (!aResultIsSet) + return NS_ERROR_NULL_POINTER; + *aResultIsSet=PR_FALSE; nsresult result=NS_OK; if (nsnull!=aElement) { @@ -1091,7 +1092,7 @@ nsEditor::GetAttributeValue(nsIDOMElement *aElement, result = aElement->GetAttributeNode(aAttribute, getter_AddRefs(attNode)); if ((NS_SUCCEEDED(result)) && attNode) { - attNode->GetSpecified(&aResultIsSet); + attNode->GetSpecified(aResultIsSet); attNode->GetValue(aResultValue); } } @@ -1099,7 +1100,7 @@ nsEditor::GetAttributeValue(nsIDOMElement *aElement, } NS_IMETHODIMP -nsEditor::RemoveAttribute(nsIDOMElement *aElement, const nsString& aAttribute) +nsEditor::RemoveAttribute(nsIDOMElement *aElement, const nsAReadableString& aAttribute) { ChangeAttributeTxn *txn; nsresult result = CreateTxnForRemoveAttribute(aElement, aAttribute, &txn); @@ -1129,7 +1130,7 @@ nsEditor::MarkNodeDirty(nsIDOMNode* aNode) #pragma mark - #endif -NS_IMETHODIMP nsEditor::CreateNode(const nsString& aTag, +NS_IMETHODIMP nsEditor::CreateNode(const nsAReadableString& aTag, nsIDOMNode * aParent, PRInt32 aPosition, nsIDOMNode ** aNewNode) @@ -1380,9 +1381,9 @@ NS_IMETHODIMP nsEditor::DeleteNode(nsIDOMNode * aElement) nsresult nsEditor::ReplaceContainer(nsIDOMNode *inNode, nsCOMPtr *outNode, - const nsString &aNodeType, - const nsString *aAttribute, - const nsString *aValue, + const nsAReadableString &aNodeType, + const nsAReadableString *aAttribute, + const nsAReadableString *aValue, PRBool aCloneAttributes) { if (!inNode || !outNode) @@ -1502,9 +1503,9 @@ nsEditor::RemoveContainer(nsIDOMNode *inNode) nsresult nsEditor::InsertContainerAbove( nsIDOMNode *inNode, nsCOMPtr *outNode, - const nsString &aNodeType, - const nsString *aAttribute, - const nsString *aValue) + const nsAReadableString &aNodeType, + const nsAReadableString *aAttribute, + const nsAReadableString *aValue) { if (!inNode || !outNode) return NS_ERROR_NULL_POINTER; @@ -1771,7 +1772,7 @@ NS_IMETHODIMP nsEditor::OutputToString(nsAWritableString& aOutputString, NS_IMETHODIMP nsEditor::OutputToStream(nsIOutputStream* aOutputStream, const nsAReadableString& aFormatType, - const nsAReadableString* aCharsetOverride, + const nsAReadableString& aCharsetOverride, PRUint32 aFlags) { // these should be implemented by derived classes. @@ -1788,7 +1789,7 @@ nsEditor::DumpContentTree() NS_IMETHODIMP -nsEditor::DebugDumpContent() const +nsEditor::DebugDumpContent() { nsCOMPtrcontent; nsCOMPtrnodeList; @@ -1935,7 +1936,7 @@ nsEditor::EndComposition(void) } NS_IMETHODIMP -nsEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply) +nsEditor::SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -2276,7 +2277,7 @@ NS_IMETHODIMP nsEditor::ScrollIntoView(PRBool aScrollToBegin) } /** static helper method */ -nsresult nsEditor::GetTextNodeTag(nsString& aOutString) +nsresult nsEditor::GetTextNodeTag(nsAWritableString& aOutString) { aOutString.SetLength(0); static nsString *gTextNodeTag=nsnull; @@ -2291,7 +2292,7 @@ nsresult nsEditor::GetTextNodeTag(nsString& aOutString) } -NS_IMETHODIMP nsEditor::InsertTextImpl(const nsString& aStringToInsert, +NS_IMETHODIMP nsEditor::InsertTextImpl(const nsAReadableString& aStringToInsert, nsCOMPtr *aInOutNode, PRInt32 *aInOutOffset, nsIDOMDocument *aDoc) @@ -2352,7 +2353,7 @@ NS_IMETHODIMP nsEditor::InsertTextImpl(const nsString& aStringToInsert, } -NS_IMETHODIMP nsEditor::InsertTextIntoTextNodeImpl(const nsString& aStringToInsert, +NS_IMETHODIMP nsEditor::InsertTextIntoTextNodeImpl(const nsAReadableString& aStringToInsert, nsIDOMCharacterData *aTextNode, PRInt32 aOffset) { @@ -2570,7 +2571,7 @@ nsEditor::NotifyDocumentListeners(TDocumentListenerNotification aNotificationTyp } -NS_IMETHODIMP nsEditor::CreateTxnForInsertText(const nsString & aStringToInsert, +NS_IMETHODIMP nsEditor::CreateTxnForInsertText(const nsAReadableString & aStringToInsert, nsIDOMCharacterData *aTextNode, PRInt32 aOffset, InsertTextTxn ** aTxn) @@ -3077,6 +3078,7 @@ nsEditor::GetLengthOfDOMNode(nsIDOMNode *aNode, PRUint32 &aCount) return result; } + nsresult nsEditor::GetPriorNode(nsIDOMNode *aParentNode, PRInt32 aOffset, @@ -3379,24 +3381,22 @@ nsEditor::NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag) } PRBool -nsEditor::NodeIsType(nsIDOMNode *aNode, const nsString &aTagStr) +nsEditor::NodeIsType(nsIDOMNode *aNode, const nsAReadableString &aTagStr) { nsCOMPtrelement; element = do_QueryInterface(aNode); if (element) { - nsAutoString tag; + nsAutoString tag, tagStr(aTagStr); element->GetTagName(tag); - if (tag.EqualsIgnoreCase(aTagStr)) - { + if (tag.EqualsIgnoreCase(tagStr)) return PR_TRUE; - } } return PR_FALSE; } PRBool -nsEditor::CanContainTag(nsIDOMNode* aParent, const nsString &aChildTag) +nsEditor::CanContainTag(nsIDOMNode* aParent, const nsAReadableString &aChildTag) { nsAutoString parentStringTag; @@ -3408,7 +3408,7 @@ nsEditor::CanContainTag(nsIDOMNode* aParent, const nsString &aChildTag) } PRBool -nsEditor::TagCanContain(const nsString &aParentTag, nsIDOMNode* aChild) +nsEditor::TagCanContain(const nsAReadableString &aParentTag, nsIDOMNode* aChild) { nsAutoString childStringTag; @@ -3426,7 +3426,7 @@ nsEditor::TagCanContain(const nsString &aParentTag, nsIDOMNode* aChild) } PRBool -nsEditor::TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag) +nsEditor::TagCanContainTag(const nsAReadableString &aParentTag, const nsAReadableString &aChildTag) { // if we don't have a dtd then assume we can insert whatever want if (!mDTD) return PR_TRUE; @@ -3680,7 +3680,7 @@ void nsEditor::HACKForceRedraw() nsresult nsEditor::GetFirstNodeOfType(nsIDOMNode *aStartNode, - const nsString &aTag, + const nsAReadableString &aTag, nsIDOMNode **aResult) { nsresult result=NS_OK; @@ -3697,11 +3697,11 @@ nsEditor::GetFirstNodeOfType(nsIDOMNode *aStartNode, while (childNode) { result = childNode->QueryInterface(NS_GET_IID(nsIDOMNode),getter_AddRefs(element)); - nsAutoString tag; if (NS_SUCCEEDED(result) && (element)) { + nsAutoString tag, tagStr(aTag); element->GetTagName(tag); - if (PR_TRUE==aTag.EqualsIgnoreCase(tag)) + if (tagStr.EqualsIgnoreCase(tag)) { return (childNode->QueryInterface(NS_GET_IID(nsIDOMNode),(void **) aResult)); // does the addref } @@ -3797,7 +3797,7 @@ nsEditor::GetTag(nsIDOMNode *aNode) // GetTagString: digs out string for the tag of this node // nsresult -nsEditor::GetTagString(nsIDOMNode *aNode, nsString& outString) +nsEditor::GetTagString(nsIDOMNode *aNode, nsAWritableString& outString) { nsCOMPtr atom; @@ -3840,7 +3840,6 @@ nsEditor::NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2) } -/////////////////////////////////////////////////////////////////////////// // IsTextOrElementNode: true if node of dom type element or text // PRBool @@ -4378,7 +4377,7 @@ nsEditor::DeleteSelectionImpl(nsIEditor::EDirection aAction) // XXX: error handling in this routine needs to be cleaned up! NS_IMETHODIMP -nsEditor::DeleteSelectionAndCreateNode(const nsString& aTag, +nsEditor::DeleteSelectionAndCreateNode(const nsAReadableString& aTag, nsIDOMNode ** aNewNode) { nsCOMPtr parentSelectedNode; @@ -4557,8 +4556,8 @@ nsEditor::DoAfterDocumentSave() NS_IMETHODIMP nsEditor::CreateTxnForSetAttribute(nsIDOMElement *aElement, - const nsString& aAttribute, - const nsString& aValue, + const nsAReadableString& aAttribute, + const nsAReadableString& aValue, ChangeAttributeTxn ** aTxn) { nsresult result = NS_ERROR_NULL_POINTER; @@ -4575,7 +4574,7 @@ nsEditor::CreateTxnForSetAttribute(nsIDOMElement *aElement, NS_IMETHODIMP nsEditor::CreateTxnForRemoveAttribute(nsIDOMElement *aElement, - const nsString& aAttribute, + const nsAReadableString& aAttribute, ChangeAttributeTxn ** aTxn) { nsresult result = NS_ERROR_NULL_POINTER; @@ -4592,7 +4591,7 @@ nsEditor::CreateTxnForRemoveAttribute(nsIDOMElement *aElement, } -NS_IMETHODIMP nsEditor::CreateTxnForCreateElement(const nsString& aTag, +NS_IMETHODIMP nsEditor::CreateTxnForCreateElement(const nsAReadableString& aTag, nsIDOMNode *aParent, PRInt32 aPosition, CreateElementTxn ** aTxn) @@ -4680,7 +4679,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteElement(nsIDOMNode * aElement, */ NS_IMETHODIMP -nsEditor::CreateTxnForIMEText(const nsString & aStringToInsert, +nsEditor::CreateTxnForIMEText(const nsAReadableString& aStringToInsert, IMETextTxn ** aTxn) { NS_ASSERTION(aTxn, "illegal value- null ptr- aTxn"); @@ -5085,7 +5084,7 @@ nsresult nsEditor::ClearSelection() } nsresult -nsEditor::CreateHTMLContent(const nsString& aTag, nsIContent** aContent) +nsEditor::CreateHTMLContent(const nsAReadableString& aTag, nsIContent** aContent) { nsresult rv; diff --git a/mozilla/editor/base/nsEditor.h b/mozilla/editor/base/nsEditor.h index c63be7c628f..ddf0db75bab 100644 --- a/mozilla/editor/base/nsEditor.h +++ b/mozilla/editor/base/nsEditor.h @@ -122,123 +122,16 @@ public: //NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor NS_DECL_ISUPPORTS - /* ------------ nsIEditor methods -------------- */ - NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags); - NS_IMETHOD PostCreate(); - NS_IMETHOD PreDestroy(); - NS_IMETHOD GetFlags(PRUint32 *aFlags); - NS_IMETHOD SetFlags(PRUint32 aFlags); - NS_IMETHOD GetDocument(nsIDOMDocument **aDoc); - NS_IMETHOD GetRootElement(nsIDOMElement **aElement); + /* ------------ utility methods -------------- */ NS_IMETHOD GetPresShell(nsIPresShell **aPS); - NS_IMETHOD GetSelectionController(nsISelectionController **aSel); - NS_IMETHOD GetSelection(nsISelection **aSelection); - NS_IMETHOD DeleteSelection(EDirection aAction); - - NS_IMETHOD EnableUndo(PRBool aEnable); - NS_IMETHOD GetTransactionManager(nsITransactionManager* *aTxnManager); - NS_IMETHOD Do(nsITransaction *aTxn); - NS_IMETHOD Undo(PRUint32 aCount); - NS_IMETHOD CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo); - NS_IMETHOD Redo(PRUint32 aCount); - NS_IMETHOD CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo); - - NS_IMETHOD BeginTransaction(); - NS_IMETHOD EndTransaction(); - - NS_IMETHOD BeginPlaceHolderTransaction(nsIAtom *aName); - NS_IMETHOD EndPlaceHolderTransaction(); - NS_IMETHOD ShouldTxnSetSelection(PRBool *aResult); - - NS_IMETHOD GetDocumentIsEmpty(PRBool *aDocumentIsEmpty); - - // file handling - NS_IMETHOD GetDocumentModified(PRBool *outDocModified); - NS_IMETHOD GetDocumentCharacterSet(PRUnichar** characterSet); - NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet); - NS_IMETHOD SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting, PRBool aSaveCopy, const nsString& aFormat); - - NS_IMETHOD Cut(); - NS_IMETHOD CanCut(PRBool &aCanCut); - NS_IMETHOD Copy(); - NS_IMETHOD CanCopy(PRBool &aCanCopy); - NS_IMETHOD Paste(PRInt32 aSelectionType); - NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste); - NS_IMETHOD CanDrag(nsIDOMEvent *aEvent, PRBool &aCanDrag); - NS_IMETHOD DoDrag(nsIDOMEvent *aEvent); - NS_IMETHOD InsertFromDrop(nsIDOMEvent *aEvent); - - NS_IMETHOD SelectAll(); - - NS_IMETHOD BeginningOfDocument(); - NS_IMETHOD EndOfDocument(); - - - /* Node and element manipulation */ - NS_IMETHOD SetAttribute(nsIDOMElement * aElement, - const nsString& aAttribute, - const nsString& aValue); - - NS_IMETHOD GetAttributeValue(nsIDOMElement * aElement, - const nsString& aAttribute, - nsString& aResultValue, - PRBool& aResultIsSet); - - NS_IMETHOD RemoveAttribute(nsIDOMElement *aElement, const nsString& aAttribute); - - NS_IMETHOD CreateNode(const nsString& aTag, - nsIDOMNode * aParent, - PRInt32 aPosition, - nsIDOMNode ** aNewNode); - - NS_IMETHOD InsertNode(nsIDOMNode * aNode, - nsIDOMNode * aParent, - PRInt32 aPosition); - - NS_IMETHOD SplitNode(nsIDOMNode * aExistingRightNode, - PRInt32 aOffset, - nsIDOMNode ** aNewLeftNode); - - NS_IMETHOD JoinNodes(nsIDOMNode * aLeftNode, - nsIDOMNode * aRightNode, - nsIDOMNode * aParent); - - NS_IMETHOD DeleteNode(nsIDOMNode * aChild); - - NS_IMETHOD MarkNodeDirty(nsIDOMNode* aNode); - - - /* output */ - NS_IMETHOD OutputToString(nsAWritableString& aOutputString, - const nsAReadableString& aFormatType, - PRUint32 aFlags); - - NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream, - const nsAReadableString& aFormatType, - const nsAReadableString* aCharsetOverride, - PRUint32 aFlags); - - /* Listeners */ - NS_IMETHOD AddEditorObserver(nsIEditorObserver *aObserver); - NS_IMETHOD RemoveEditorObserver(nsIEditorObserver *aObserver); - void NotifyEditorObservers(void); - - NS_IMETHOD AddEditActionListener(nsIEditActionListener *aListener); - NS_IMETHOD RemoveEditActionListener(nsIEditActionListener *aListener); - - NS_IMETHOD AddDocumentStateListener(nsIDocumentStateListener *aListener); - NS_IMETHOD RemoveDocumentStateListener(nsIDocumentStateListener *aListener); - - - NS_IMETHOD DumpContentTree(); - NS_IMETHOD DebugDumpContent() const; - NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed); - + void NotifyEditorObservers(void); + /* ------------ nsIEditor methods -------------- */ + NS_DECL_NSIEDITOR /* ------------ nsIEditorIMESupport methods -------------- */ NS_IMETHOD BeginComposition(nsTextEventReply* aReply); NS_IMETHOD QueryComposition(nsTextEventReply* aReply); - NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply); + NS_IMETHOD SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply); NS_IMETHOD EndComposition(void); NS_IMETHOD ForceCompositionEnd(void); NS_IMETHOD GetReconversionString(nsReconversionEventReply *aReply); @@ -246,31 +139,31 @@ public: public: - NS_IMETHOD InsertTextImpl(const nsString& aStringToInsert, + NS_IMETHOD InsertTextImpl(const nsAReadableString& aStringToInsert, nsCOMPtr *aInOutNode, PRInt32 *aInOutOffset, nsIDOMDocument *aDoc); - NS_IMETHOD InsertTextIntoTextNodeImpl(const nsString& aStringToInsert, + NS_IMETHOD InsertTextIntoTextNodeImpl(const nsAReadableString& aStringToInsert, nsIDOMCharacterData *aTextNode, PRInt32 aOffset); NS_IMETHOD DeleteSelectionImpl(EDirection aAction); - NS_IMETHOD DeleteSelectionAndCreateNode(const nsString& aTag, + NS_IMETHOD DeleteSelectionAndCreateNode(const nsAReadableString& aTag, nsIDOMNode ** aNewNode); /* helper routines for node/parent manipulations */ nsresult ReplaceContainer(nsIDOMNode *inNode, nsCOMPtr *outNode, - const nsString &aNodeType, - const nsString *aAttribute = nsnull, - const nsString *aValue = nsnull, + const nsAReadableString &aNodeType, + const nsAReadableString *aAttribute = nsnull, + const nsAReadableString *aValue = nsnull, PRBool aCloneAttributes = PR_FALSE); nsresult RemoveContainer(nsIDOMNode *inNode); nsresult InsertContainerAbove(nsIDOMNode *inNode, nsCOMPtr *outNode, - const nsString &aNodeType, - const nsString *aAttribute = nsnull, - const nsString *aValue = nsnull); + const nsAReadableString &aNodeType, + const nsAReadableString *aAttribute = nsnull, + const nsAReadableString *aValue = nsnull); nsresult MoveNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aOffset); /* Method to replace certain CreateElementNS() calls. @@ -278,15 +171,10 @@ public: nsString& aTag - tag you want nsIContent** aContent - returned Content that was created with above namespace. */ - nsresult CreateHTMLContent(const nsString& aTag, nsIContent** aContent); + nsresult CreateHTMLContent(const nsAReadableString& aTag, nsIContent** aContent); protected: - - - //NOTE: Most callers are dealing with Nodes, - // but these objects must supports nsIDOMElement - NS_IMETHOD CloneAttributes(nsIDOMNode *aDestNode, nsIDOMNode *aSourceNode); /* NS_IMETHOD SetProperties(nsVoidArray *aPropList); NS_IMETHOD GetProperties(nsVoidArray *aPropList); @@ -295,19 +183,19 @@ protected: /** create a transaction for setting aAttribute to aValue on aElement */ NS_IMETHOD CreateTxnForSetAttribute(nsIDOMElement *aElement, - const nsString& aAttribute, - const nsString& aValue, + const nsAReadableString & aAttribute, + const nsAReadableString & aValue, ChangeAttributeTxn ** aTxn); /** create a transaction for removing aAttribute on aElement */ NS_IMETHOD CreateTxnForRemoveAttribute(nsIDOMElement *aElement, - const nsString& aAttribute, + const nsAReadableString & aAttribute, ChangeAttributeTxn ** aTxn); /** create a transaction for creating a new child node of aParent of type aTag. */ - NS_IMETHOD CreateTxnForCreateElement(const nsString& aTag, + NS_IMETHOD CreateTxnForCreateElement(const nsAReadableString & aTag, nsIDOMNode *aParent, PRInt32 aPosition, CreateElementTxn ** aTxn); @@ -336,12 +224,12 @@ protected: /** create a transaction for inserting aStringToInsert into aTextNode * if aTextNode is null, the string is inserted at the current selection. */ - NS_IMETHOD CreateTxnForInsertText(const nsString & aStringToInsert, + NS_IMETHOD CreateTxnForInsertText(const nsAReadableString & aStringToInsert, nsIDOMCharacterData *aTextNode, PRInt32 aOffset, InsertTextTxn ** aTxn); - NS_IMETHOD CreateTxnForIMEText(const nsString & aStringToInsert, + NS_IMETHOD CreateTxnForIMEText(const nsAReadableString & aStringToInsert, IMETextTxn ** aTxn); /** create a transaction for adding a style sheet @@ -436,7 +324,7 @@ public: /** return the string that represents text nodes in the content tree */ - static nsresult GetTextNodeTag(nsString& aOutString); + static nsresult GetTextNodeTag(nsAWritableString& aOutString); /** * SplitNode() creates a new node identical to an existing node, and split the contents between the two nodes @@ -550,17 +438,17 @@ public: * @param aResult is the node we found, or nsnull if there is none */ static nsresult GetFirstNodeOfType(nsIDOMNode *aStartNode, - const nsString &aTag, + const nsAReadableString &aTag, nsIDOMNode **aResult); /** returns PR_TRUE if aNode is of the type implied by aTag */ static PRBool NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag); - static PRBool NodeIsType(nsIDOMNode *aNode, const nsString &aTag); + static PRBool NodeIsType(nsIDOMNode *aNode, const nsAReadableString &aTag); /** returns PR_TRUE if aParent can contain a child of type aTag */ - PRBool CanContainTag(nsIDOMNode* aParent, const nsString &aTag); - PRBool TagCanContain(const nsString &aParentTag, nsIDOMNode* aChild); - virtual PRBool TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag); + PRBool CanContainTag(nsIDOMNode* aParent, const nsAReadableString &aTag); + PRBool TagCanContain(const nsAReadableString &aParentTag, nsIDOMNode* aChild); + virtual PRBool TagCanContainTag(const nsAReadableString &aParentTag, const nsAReadableString &aChildTag); /** returns PR_TRUE if aNode is a descendant of our root node */ PRBool IsDescendantOfBody(nsIDOMNode *inNode); @@ -586,7 +474,7 @@ public: /** from html rules code - migration in progress */ - static nsresult GetTagString(nsIDOMNode *aNode, nsString& outString); + static nsresult GetTagString(nsIDOMNode *aNode, nsAWritableString& outString); static nsCOMPtr GetTag(nsIDOMNode *aNode); static PRBool NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2); static PRBool IsTextOrElementNode(nsIDOMNode *aNode); @@ -622,7 +510,7 @@ public: nsCOMPtr *outRightNode = 0); nsresult JoinNodeDeep(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsCOMPtr *aOutJoinNode, PRInt32 *outOffset); - nsresult GetString(const nsString& name, nsString& value); + nsresult GetString(const nsAReadableString& name, nsAWritableString& value); nsresult BeginUpdateViewBatch(void); nsresult EndUpdateViewBatch(void); diff --git a/mozilla/editor/base/nsEditorCommands.cpp b/mozilla/editor/base/nsEditorCommands.cpp index 0b3b470c8e3..03ea3054e86 100644 --- a/mozilla/editor/base/nsEditorCommands.cpp +++ b/mozilla/editor/base/nsEditorCommands.cpp @@ -53,7 +53,7 @@ nsUndoCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISuppo if (aEditor) { PRBool isEnabled; - return aEditor->CanUndo(isEnabled, *outCmdEnabled); + return aEditor->CanUndo(&isEnabled, outCmdEnabled); } return NS_OK; } @@ -78,7 +78,7 @@ nsRedoCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISuppo if (aEditor) { PRBool isEnabled; - return aEditor->CanRedo(isEnabled, *outCmdEnabled); + return aEditor->CanRedo(&isEnabled, outCmdEnabled); } return NS_OK; } @@ -101,7 +101,7 @@ nsCutCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISuppor nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; if (aEditor) - return aEditor->CanCut(*outCmdEnabled); + return aEditor->CanCut(outCmdEnabled); return NS_OK; } @@ -155,7 +155,7 @@ nsCopyCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISuppo nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; if (aEditor) - return aEditor->CanCopy(*outCmdEnabled); + return aEditor->CanCopy(outCmdEnabled); return NS_OK; } @@ -209,7 +209,7 @@ nsPasteCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupp nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; if (aEditor) - return aEditor->CanPaste(nsIClipboard::kGlobalClipboard, *outCmdEnabled); + return aEditor->CanPaste(nsIClipboard::kGlobalClipboard, outCmdEnabled); return NS_OK; } @@ -250,7 +250,7 @@ nsDeleteCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISup nsAutoString cmdString(aCommandName); if (cmdString.EqualsWithConversion("cmd_delete")) - rv = aEditor->CanCut(*outCmdEnabled); + rv = aEditor->CanCut(outCmdEnabled); else if (cmdString.EqualsWithConversion("cmd_deleteCharBackward")) *outCmdEnabled = PR_TRUE; else if (cmdString.EqualsWithConversion("cmd_deleteCharForward")) diff --git a/mozilla/editor/base/nsEditorEventListeners.cpp b/mozilla/editor/base/nsEditorEventListeners.cpp index bc6450b5ac2..3a041e8b4fd 100644 --- a/mozilla/editor/base/nsEditorEventListeners.cpp +++ b/mozilla/editor/base/nsEditorEventListeners.cpp @@ -615,7 +615,7 @@ nsTextEditorDragListener::DragGesture(nsIDOMEvent* aDragEvent) return NS_ERROR_NULL_POINTER; // ...figure out if a drag should be started... - nsresult rv = mEditor->CanDrag(aDragEvent, canDrag); + nsresult rv = mEditor->CanDrag(aDragEvent, &canDrag); if ( NS_SUCCEEDED(rv) && canDrag ) rv = mEditor->DoDrag(aDragEvent); diff --git a/mozilla/editor/base/nsEditorShell.cpp b/mozilla/editor/base/nsEditorShell.cpp index 11e29960ef6..b91e0a1f716 100644 --- a/mozilla/editor/base/nsEditorShell.cpp +++ b/mozilla/editor/base/nsEditorShell.cpp @@ -1061,9 +1061,7 @@ nsEditorShell::SetAttribute(nsIDOMElement *element, const PRUnichar *attr, const nsresult result = NS_NOINTERFACE; nsCOMPtr editor = do_QueryInterface(mEditor); if (editor) { - nsAutoString attributeStr(attr); - nsAutoString valueStr(value); - result = editor->SetAttribute(element, attributeStr, valueStr); + result = editor->SetAttribute(element, nsLiteralString(attr), nsLiteralString(value)); } return result; @@ -1078,8 +1076,7 @@ nsEditorShell::RemoveAttribute(nsIDOMElement *element, const PRUnichar *attr) nsresult result = NS_NOINTERFACE; nsCOMPtr editor = do_QueryInterface(mEditor); if (editor) { - nsAutoString attributeStr(attr); - result = editor->RemoveAttribute(element, attributeStr); + result = editor->RemoveAttribute(element, nsLiteralString(attr)); } return result; @@ -1094,16 +1091,13 @@ nsEditorShell::SetTextProperty(const PRUnichar *prop, const PRUnichar *attr, con nsCOMPtr styleAtom = getter_AddRefs(NS_NewAtom(prop)); /// XXX Hack alert! Look in nsIEditProperty.h for this if (! styleAtom) return NS_ERROR_OUT_OF_MEMORY; - - nsAutoString attributeStr(attr); - nsAutoString valueStr(value); - + switch (mEditorType) { case ePlainTextEditorType: // should we allow this? case eHTMLTextEditorType: - err = mEditor->SetInlineProperty(styleAtom, &attributeStr, &valueStr); + err = mEditor->SetInlineProperty(styleAtom, nsLiteralString(attr), nsLiteralString(value)); break; default: err = NS_ERROR_NOT_IMPLEMENTED; @@ -1127,7 +1121,7 @@ nsEditorShell::RemoveOneProperty(const nsString& aProp, const nsString &aAttr) case ePlainTextEditorType: // should we allow this? case eHTMLTextEditorType: - err = mEditor->RemoveInlineProperty(styleAtom, &aAttr); + err = mEditor->RemoveInlineProperty(styleAtom, aAttr); break; default: err = NS_ERROR_NOT_IMPLEMENTED; @@ -1172,15 +1166,12 @@ nsEditorShell::GetTextProperty(const PRUnichar *prop, const PRUnichar *attr, con styleAtom = NS_NewAtom(prop); /// XXX Hack alert! Look in nsIEditProperty.h for this - nsAutoString aAttr(attr); - nsAutoString aValue(value); - switch (mEditorType) { case ePlainTextEditorType: // should we allow this? case eHTMLTextEditorType: - err = mEditor->GetInlineProperty(styleAtom, &aAttr, &aValue, *firstHas, *anyHas, *allHas); + err = mEditor->GetInlineProperty(styleAtom, nsLiteralString(attr), nsLiteralString(value), firstHas, anyHas, allHas); break; default: err = NS_ERROR_NOT_IMPLEMENTED; @@ -1238,7 +1229,7 @@ nsEditorShell::GetParagraphState(PRBool *aMixed, PRUnichar **_retval) { PRBool bMixed; nsAutoString state; - err = htmlEditor->GetParagraphState(bMixed, state); + err = htmlEditor->GetParagraphState(&bMixed, state); if (!bMixed) *_retval = state.ToNewUnicode(); } @@ -1257,7 +1248,7 @@ nsEditorShell::GetListState(PRBool *aMixed, PRUnichar **_retval) if (htmlEditor) { PRBool bOL, bUL, bDL; - err = htmlEditor->GetListState(*aMixed, bOL, bUL, bDL); + err = htmlEditor->GetListState(aMixed, &bOL, &bUL, &bDL); if (NS_SUCCEEDED(err)) { if (!*aMixed) @@ -1285,7 +1276,7 @@ nsEditorShell::GetListItemState(PRBool *aMixed, PRUnichar **_retval) if (htmlEditor) { PRBool bLI,bDT,bDD; - err = htmlEditor->GetListItemState(*aMixed, bLI, bDT, bDD); + err = htmlEditor->GetListItemState(aMixed, &bLI, &bDT, &bDD); if (NS_SUCCEEDED(err)) { if (!*aMixed) @@ -1313,7 +1304,7 @@ nsEditorShell::GetAlignment(PRBool *aMixed, PRUnichar **_retval) if (htmlEditor) { nsIHTMLEditor::EAlignment firstAlign; - err = htmlEditor->GetAlignment(*aMixed, firstAlign); + err = htmlEditor->GetAlignment(aMixed, &firstAlign); if (NS_SUCCEEDED(err)) { nsAutoString tagStr; @@ -1777,7 +1768,7 @@ nsEditorShell::SaveDocument(PRBool aSaveAs, PRBool aSaveCopy, const PRUnichar* a return NS_OK; } // This sets title in HTML node - mEditor->SetDocumentTitle(titleUnicode); + mEditor->SetDocumentTitle(nsLiteralString(titleUnicode)); title = titleUnicode; nsCRT::free(titleUnicode); titleChanged = PR_TRUE; @@ -2240,7 +2231,7 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title) if (mEditorType != eHTMLTextEditorType) return NS_ERROR_NOT_IMPLEMENTED; - res = mEditor->SetDocumentTitle(title); + res = mEditor->SetDocumentTitle(nsLiteralString(title)); if (NS_FAILED(res)) return res; // PR_FALSE means don't save menu to prefs @@ -2283,7 +2274,7 @@ nsEditorShell::NodeIsBlock(nsIDOMNode *node, PRBool *_retval) case ePlainTextEditorType: case eHTMLTextEditorType: { - rv = mEditor->NodeIsBlock(node, *_retval); + rv = mEditor->NodeIsBlock(node, _retval); } break; @@ -2610,7 +2601,7 @@ nsEditorShell::InsertText(const PRUnichar *textToInsert) { nsCOMPtr textEditor (do_QueryInterface(mEditor)); if (textEditor) - err = textEditor->InsertText(textToInsert); + err = textEditor->InsertText(nsLiteralString(textToInsert)); } break; @@ -2953,11 +2944,19 @@ nsEditorShell::Alert(const nsString& aTitle, const nsString& aMsg) NS_IMETHODIMP nsEditorShell::GetDocumentCharacterSet(PRUnichar** characterSet) { + if (!characterSet) + return NS_ERROR_NULL_POINTER; nsCOMPtr editor = do_QueryInterface(mEditor); - + nsAutoString copiedData; + *characterSet = nsnull; if (editor) - return editor->GetDocumentCharacterSet(characterSet); - + { + if (NS_SUCCEEDED(editor->GetDocumentCharacterSet(copiedData))) + { + *characterSet = ToNewUnicode(copiedData); + return NS_OK; + } + } return NS_ERROR_FAILURE; } @@ -2968,7 +2967,7 @@ nsEditorShell::SetDocumentCharacterSet(const PRUnichar* characterSet) nsresult res = NS_OK; if (editor) - res = editor->SetDocumentCharacterSet(characterSet); + res = editor->SetDocumentCharacterSet(nsAutoString(characterSet)); if(NS_SUCCEEDED(res)) { nsCOMPtr globalObj( do_QueryReferent(mContentWindow)); diff --git a/mozilla/editor/base/nsHTMLDataTransfer.cpp b/mozilla/editor/base/nsHTMLDataTransfer.cpp index 217207bd770..76798a07f1c 100644 --- a/mozilla/editor/base/nsHTMLDataTransfer.cpp +++ b/mozilla/editor/base/nsHTMLDataTransfer.cpp @@ -160,29 +160,29 @@ static nsCOMPtr GetTableParent(nsIDOMNode* aNode) } -NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString) +NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsAReadableString & aInString) { nsAutoString charset; - return InsertHTMLWithCharset(aInputString, charset); + return InsertHTMLWithCharset(aInString, charset); } -nsresult nsHTMLEditor::InsertHTMLWithContext(const nsString& aInputString, const nsString& aContextStr, const nsString& aInfoStr) +nsresult nsHTMLEditor::InsertHTMLWithContext(const nsAReadableString & aInputString, const nsAReadableString & aContextStr, const nsAReadableString & aInfoStr) { nsAutoString charset; return InsertHTMLWithCharsetAndContext(aInputString, charset, aContextStr, aInfoStr); } -NS_IMETHODIMP nsHTMLEditor::InsertHTMLWithCharset(const nsString& aInputString, const nsString& aCharset) +NS_IMETHODIMP nsHTMLEditor::InsertHTMLWithCharset(const nsAReadableString & aInputString, const nsAReadableString & aCharset) { return InsertHTMLWithCharsetAndContext(aInputString, aCharset, nsAutoString(), nsAutoString()); } -nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputString, - const nsString& aCharset, - const nsString& aContextStr, - const nsString& aInfoStr) +nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsAReadableString & aInputString, + const nsAReadableString & aCharset, + const nsAReadableString & aContextStr, + const nsAReadableString & aInfoStr) { if (!mRules) return NS_ERROR_NOT_INITIALIZED; @@ -604,8 +604,8 @@ NS_IMETHODIMP nsHTMLEditor::PrepareTransferable(nsITransferable **transferable) } NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable, - const nsString& aContextStr, - const nsString& aInfoStr) + const nsAReadableString & aContextStr, + const nsAReadableString & aInfoStr) { nsresult rv = NS_OK; char* bestFlavor = nsnull; @@ -645,7 +645,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable nsAutoEditBatch beginBatching(this); // pasting does not inherit local inline styles RemoveAllInlineProperties(); - rv = InsertText(stuffToPaste.GetUnicode()); + rv = InsertText(stuffToPaste); if (text) nsMemory::Free(text); } @@ -906,12 +906,15 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent) return rv; } -NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag) +NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag) { + if (!aCanDrag) + return NS_ERROR_NULL_POINTER; + /* we really should be checking the XY coordinates of the mouseevent and ensure that * that particular point is actually within the selection (not just that there is a selection) */ - aCanDrag = PR_FALSE; + *aCanDrag = PR_FALSE; // KLUDGE to work around bug 50703 // After double click and object property editing, @@ -949,7 +952,7 @@ NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag) res = selection->ContainsNode(eventTargetDomNode, PR_FALSE, &amTargettedCorrectly); if (NS_FAILED(res)) return res; - aCanDrag = amTargettedCorrectly; + *aCanDrag = amTargettedCorrectly; } } @@ -1123,9 +1126,11 @@ NS_IMETHODIMP nsHTMLEditor::Paste(PRInt32 aSelectionType) } -NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste) +NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste) { - aCanPaste = PR_FALSE; + if (!aCanPaste) + return NS_ERROR_NULL_POINTER; + *aCanPaste = PR_FALSE; // can't paste if readonly if (!IsModifiable()) @@ -1180,7 +1185,7 @@ NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste) rv = clipboard->HasDataMatchingFlavors(flavorsList, aSelectionType, &haveFlavors); if (NS_FAILED(rv)) return rv; - aCanPaste = haveFlavors; + *aCanPaste = haveFlavors; return NS_OK; } @@ -1197,7 +1202,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsQuotation(PRInt32 aSelectionType) return PasteAsCitedQuotation(citation, aSelectionType); } -NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsString& aCitation, +NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsAReadableString & aCitation, PRInt32 aSelectionType) { nsAutoEditBatch beginBatching(this); @@ -1310,7 +1315,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation(PRInt32 aSelectionType) return rv; } -NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsString& aQuotedText, +NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsAReadableString & aQuotedText, nsIDOMNode **aNodeInserted) { if (mFlags & eEditorPlaintextMask) @@ -1327,7 +1332,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsString& aQuotedText, // in that here, quoted material is enclosed in a
 tag
 // in order to preserve the original line wrapping.
 NS_IMETHODIMP
-nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText,
+nsHTMLEditor::InsertAsPlaintextQuotation(const nsAReadableString & aQuotedText,
                                          nsIDOMNode **aNodeInserted)
 {
   nsresult rv;
@@ -1399,10 +1404,10 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText,
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
-                                     const nsString& aCitation,
+nsHTMLEditor::InsertAsCitedQuotation(const nsAReadableString & aQuotedText,
+                                     const nsAReadableString & aCitation,
                                      PRBool aInsertHTML,
-                                     const nsString& aCharset,
+                                     const nsAReadableString & aCharset,
                                      nsIDOMNode **aNodeInserted)
 {
   nsCOMPtr newNode;
@@ -1450,7 +1455,7 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
         res = InsertHTMLWithCharset(aQuotedText, aCharset);
 
       else
-        res = InsertText(aQuotedText.GetUnicode());  // XXX ignore charset
+        res = InsertText(aQuotedText);  // XXX ignore charset
 
       if (aNodeInserted)
       {
@@ -1475,9 +1480,9 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
 }
 
 nsresult nsHTMLEditor::CreateDOMFragmentFromPaste(nsIDOMNSRange *aNSRange,
-                                                  const nsString& aInputString,
-                                                  const nsString& aContextStr,
-                                                  const nsString& aInfoStr,
+                                                  const nsAReadableString & aInputString,
+                                                  const nsAReadableString & aContextStr,
+                                                  const nsAReadableString & aInfoStr,
                                                   nsCOMPtr *outFragNode,
                                                   PRInt32 *outRangeStartHint,
                                                   PRInt32 *outRangeEndHint)
diff --git a/mozilla/editor/base/nsHTMLEditRules.cpp b/mozilla/editor/base/nsHTMLEditRules.cpp
index 1d066339fd5..9ddf6e35da1 100644
--- a/mozilla/editor/base/nsHTMLEditRules.cpp
+++ b/mozilla/editor/base/nsHTMLEditRules.cpp
@@ -59,6 +59,8 @@
 
 #include "InsertTextTxn.h"
 #include "DeleteTextTxn.h"
+#include "nsReadableUtils.h"
+
 
 //const static char* kMOZEditorBogusNodeAttr="MOZ_EDITOR_BOGUS_NODE";
 //const static char* kMOZEditorBogusNodeValue="TRUE";
@@ -83,7 +85,7 @@ enum
 static PRBool IsBlockNode(nsIDOMNode* node)
 {
   PRBool isBlock (PR_FALSE);
-  nsHTMLEditor::NodeIsBlockStatic(node, isBlock);
+  nsHTMLEditor::NodeIsBlockStatic(node, &isBlock);
   return isBlock;
 }
 
@@ -500,12 +502,14 @@ nsHTMLEditRules::DidDoAction(nsISelection *aSelection,
  ********************************************************/
 
 NS_IMETHODIMP 
-nsHTMLEditRules::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL)
+nsHTMLEditRules::GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL)
 {
-  aMixed = PR_FALSE;
-  aOL = PR_FALSE;
-  aUL = PR_FALSE;
-  aDL = PR_FALSE;
+  if (!aMixed || !aOL || !aUL || !aDL)
+    return NS_ERROR_NULL_POINTER;
+  *aMixed = PR_FALSE;
+  *aOL = PR_FALSE;
+  *aUL = PR_FALSE;
+  *aDL = PR_FALSE;
   PRBool bNonList = PR_FALSE;
   
   nsCOMPtr arrayOfNodes;
@@ -522,9 +526,9 @@ nsHTMLEditRules::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &
     nsCOMPtr curNode( do_QueryInterface(isupports) );
     
     if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ul))
-      aUL = PR_TRUE;
+      *aUL = PR_TRUE;
     else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ol))
-      aOL = PR_TRUE;
+      *aOL = PR_TRUE;
     else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::li))
     {
       nsCOMPtr parent;
@@ -532,32 +536,34 @@ nsHTMLEditRules::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &
       res = nsEditor::GetNodeLocation(curNode, address_of(parent), &offset);
       if (NS_FAILED(res)) return res;
       if (nsHTMLEditUtils::IsUnorderedList(parent))
-        aUL = PR_TRUE;
+        *aUL = PR_TRUE;
       else if (nsHTMLEditUtils::IsOrderedList(parent))
-        aOL = PR_TRUE;
+        *aOL = PR_TRUE;
     }
     else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dl) ||
              mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dt) ||
              mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dd) )
     {
-      aDL = PR_TRUE;
+      *aDL = PR_TRUE;
     }
     else bNonList = PR_TRUE;
   }  
   
   // hokey arithmetic with booleans
-  if ( (aUL + aOL + aDL + bNonList) > 1) aMixed = PR_TRUE;
+  if ( (*aUL + *aOL + *aDL + bNonList) > 1) *aMixed = PR_TRUE;
   
   return res;
 }
 
 NS_IMETHODIMP 
-nsHTMLEditRules::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD)
+nsHTMLEditRules::GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD)
 {
-  aMixed = PR_FALSE;
-  aLI = PR_FALSE;
-  aDT = PR_FALSE;
-  aDD = PR_FALSE;
+  if (!aMixed || !aLI || !aDT || !aDD)
+    return NS_ERROR_NULL_POINTER;
+  *aMixed = PR_FALSE;
+  *aLI = PR_FALSE;
+  *aDT = PR_FALSE;
+  *aDD = PR_FALSE;
   PRBool bNonList = PR_FALSE;
   
   nsCOMPtr arrayOfNodes;
@@ -577,15 +583,15 @@ nsHTMLEditRules::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBo
         mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ol) ||
         mHTMLEditor->NodeIsType(curNode,nsIEditProperty::li) )
     {
-      aLI = PR_TRUE;
+      *aLI = PR_TRUE;
     }
     else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dt))
     {
-      aDT = PR_TRUE;
+      *aDT = PR_TRUE;
     }
     else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dd))
     {
-      aDD = PR_TRUE;
+      *aDD = PR_TRUE;
     }
     else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dl))
     {
@@ -593,20 +599,20 @@ nsHTMLEditRules::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBo
       PRBool bDT, bDD;
       res = GetDefinitionListItemTypes(curNode, bDT, bDD);
       if (NS_FAILED(res)) return res;
-      aDT |= bDT;
-      aDD |= bDD;
+      *aDT |= bDT;
+      *aDD |= bDD;
     }
     else bNonList = PR_TRUE;
   }  
   
   // hokey arithmetic with booleans
-  if ( (aDT + aDD + bNonList) > 1) aMixed = PR_TRUE;
+  if ( (*aDT + *aDD + bNonList) > 1) *aMixed = PR_TRUE;
   
   return res;
 }
 
 NS_IMETHODIMP 
-nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
+nsHTMLEditRules::GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
 {
   // for now, just return first alignment.  we'll lie about
   // if it's mixed.  This is for efficiency
@@ -617,8 +623,10 @@ nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
   // this routine assumes that alignment is done ONLY via divs
   
   // default alignment is left
-  aMixed = PR_FALSE;
-  aAlign = nsIHTMLEditor::eLeft;
+  if (!aMixed || !aAlign)
+    return NS_ERROR_NULL_POINTER;
+  *aMixed = PR_FALSE;
+  *aAlign = nsIHTMLEditor::eLeft;
   
   // get selection
   nsCOMPtrselection;
@@ -673,13 +681,13 @@ nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
         if (NS_SUCCEEDED(res) && typeAttrVal.Length())
         {
           if (typeAttrVal.EqualsWithConversion("center"))
-            aAlign = nsIHTMLEditor::eCenter;
+            *aAlign = nsIHTMLEditor::eCenter;
           else if (typeAttrVal.EqualsWithConversion("right"))
-            aAlign = nsIHTMLEditor::eRight;
+            *aAlign = nsIHTMLEditor::eRight;
           else if (typeAttrVal.EqualsWithConversion("justify"))
-            aAlign = nsIHTMLEditor::eJustify;
+            *aAlign = nsIHTMLEditor::eJustify;
           else
-            aAlign = nsIHTMLEditor::eLeft;
+            *aAlign = nsIHTMLEditor::eLeft;
           return res;
         }
       }
@@ -692,10 +700,12 @@ nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
 }
 
 NS_IMETHODIMP 
-nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
+nsHTMLEditRules::GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent)
 {
-  aCanIndent = PR_TRUE;    
-  aCanOutdent = PR_FALSE;
+  if (!aCanIndent || !aCanOutdent)
+      return NS_ERROR_FAILURE;
+  *aCanIndent = PR_TRUE;    
+  *aCanOutdent = PR_FALSE;
   
   nsCOMPtr arrayOfNodes;
   nsresult res = GetListActionNodes(address_of(arrayOfNodes), PR_FALSE, PR_TRUE);
@@ -716,7 +726,7 @@ nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
         nsHTMLEditUtils::IsListItem(curNode) ||
         nsHTMLEditUtils::IsBlockquote(curNode))
     {
-      aCanOutdent = PR_TRUE;
+      *aCanOutdent = PR_TRUE;
       break;
     }
   }  
@@ -726,17 +736,19 @@ nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
 
 
 NS_IMETHODIMP 
-nsHTMLEditRules::GetParagraphState(PRBool &aMixed, nsString &outFormat)
+nsHTMLEditRules::GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat)
 {
   // This routine is *heavily* tied to our ui choices in the paragraph
   // style popup.  I cant see a way around that.
-  aMixed = PR_TRUE;
-  outFormat.AssignWithConversion("");
+  if (!aMixed)
+    return NS_ERROR_NULL_POINTER;
+  *aMixed = PR_TRUE;
+  outFormat.Truncate(0);
   
   PRBool bMixed = PR_FALSE;
   nsAutoString formatStr; 
   // using "x" as an uninitialized value, since "" is meaningful
-  formatStr.AssignWithConversion("x");
+  formatStr.Assign(NS_LITERAL_STRING("x"));
   
   nsCOMPtr arrayOfNodes;
   nsresult res = GetParagraphFormatNodes(address_of(arrayOfNodes), PR_TRUE);
@@ -794,12 +806,12 @@ nsHTMLEditRules::GetParagraphState(PRBool &aMixed, nsString &outFormat)
         }
         else
         {
-          format.AssignWithConversion("");
+          format.Truncate(0);
         }
       }
       else
       {
-        format.AssignWithConversion("");
+        format.Truncate(0);
       }  
     }    
     else if (nsHTMLEditUtils::IsHeader(curNode))
@@ -828,7 +840,7 @@ nsHTMLEditRules::GetParagraphState(PRBool &aMixed, nsString &outFormat)
     }
   }  
   
-  aMixed = bMixed;
+  *aMixed = bMixed;
   outFormat = formatStr;
   return res;
 }
@@ -904,8 +916,8 @@ nsHTMLEditRules::WillInsertText(PRInt32          aAction,
                                 nsISelection *aSelection, 
                                 PRBool          *aCancel,
                                 PRBool          *aHandled,
-                                const nsString  *inString,
-                                nsString        *outString,
+                                const nsAReadableString  *inString,
+                                nsAWritableString        *outString,
                                 PRInt32          aMaxLength)
 {  
   if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
@@ -986,7 +998,8 @@ nsHTMLEditRules::WillInsertText(PRInt32          aAction,
     // dont spaz my selection in subtransactions
     nsAutoTxnsConserveSelection dontSpazMySelection(mHTMLEditor);
     nsSubsumeStr subStr;
-    const PRUnichar *unicodeBuf = inString->GetUnicode();
+    const nsPromiseFlatString &tString = PromiseFlatString(*inString);////MJUDGE SCC NEED HELP
+    const PRUnichar *unicodeBuf = tString.get();
     nsCOMPtr unused;
     PRInt32 pos = 0;
         
@@ -995,13 +1008,21 @@ nsHTMLEditRules::WillInsertText(PRInt32          aAction,
     // it is to search for both tabs and newlines.
     if (isPRE)
     {
-      char newlineChar = '\n';
-      while (unicodeBuf && (pos != -1) && (pos < (PRInt32)inString->Length()))
+      nsAutoString newlineChar(NS_LITERAL_STRING("\n"));
+      while (unicodeBuf && (pos != -1) && (pos < (PRInt32)(*inString).Length()))
       {
         PRInt32 oldPos = pos;
         PRInt32 subStrLen;
-        pos = inString->FindChar(newlineChar, PR_FALSE, oldPos);
-        
+        pos = -1;
+        nsReadingIterator beginFindIter, endFindIter, beginIter;
+        inString->BeginReading(beginIter);
+        beginFindIter = beginIter;
+        inString->EndReading(endFindIter);
+        beginFindIter.advance(oldPos);
+        if (FindInReadable(newlineChar,beginFindIter,endFindIter))
+        {
+          pos = Distance(beginIter,beginFindIter);
+        }
         if (pos != -1) 
         {
           subStrLen = pos - oldPos;
@@ -1011,8 +1032,8 @@ nsHTMLEditRules::WillInsertText(PRInt32          aAction,
         }
         else
         {
-          subStrLen = inString->Length() - oldPos;
-          pos = inString->Length();
+          subStrLen = (*inString).Length() - oldPos;
+          pos = (*inString).Length();
         }
 
         subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen);
@@ -1032,13 +1053,22 @@ nsHTMLEditRules::WillInsertText(PRInt32          aAction,
     }
     else
     {
-      char specialChars[] = {'\t','\n',0};
+      nsAutoString specialChars;
+      specialChars = NS_LITERAL_STRING("\t\n");
       nsAutoString tabString; tabString.AssignWithConversion("    ");
-      while (unicodeBuf && (pos != -1) && (pos < (PRInt32)inString->Length()))
+      while (unicodeBuf && (pos != -1) && (pos < (PRInt32)(*inString).Length()))
       {
         PRInt32 oldPos = pos;
         PRInt32 subStrLen;
-        pos = inString->FindCharInSet(specialChars, oldPos);
+        nsReadingIterator beginFindIter,endFindIter;
+        (*inString).BeginReading(beginFindIter);
+        beginFindIter.advance(oldPos);
+        (*inString).EndReading(endFindIter);
+        nsReadingIterator distanceIter;
+        (*inString).BeginReading(distanceIter);
+        pos = -1;
+        if (FindInReadable((const nsAString &)specialChars,beginFindIter,endFindIter))
+          pos = Distance(distanceIter,beginFindIter);
         
         if (pos != -1) 
         {
@@ -1049,8 +1079,8 @@ nsHTMLEditRules::WillInsertText(PRInt32          aAction,
         }
         else
         {
-          subStrLen = inString->Length() - oldPos;
-          pos = inString->Length();
+          subStrLen = (*inString).Length() - oldPos;
+          pos = (*inString).Length();
         }
 
         subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen);
@@ -1900,11 +1930,11 @@ nsHTMLEditRules::DeleteNonTableElements(nsIDOMNode *aNode)
 
 nsresult
 nsHTMLEditRules::WillMakeList(nsISelection *aSelection, 
-                              const nsString *aListType, 
+                              const nsAReadableString *aListType, 
                               PRBool aEntireList,
                               PRBool *aCancel,
                               PRBool *aHandled,
-                              const nsString *aItemType)
+                              const nsAReadableString *aItemType)
 {
   if (!aSelection || !aListType || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
 
@@ -1918,9 +1948,10 @@ nsHTMLEditRules::WillMakeList(nsISelection *aSelection,
 
   // deduce what tag to use for list items
   nsAutoString itemType;
+  nsString tString(*aListType);//MJUDGE SCC NEED HELP
   if (aItemType) 
     itemType = *aItemType;
-  else if (aListType->EqualsWithConversion("dl"))
+  else if (tString.EqualsWithConversion("dl"))
     itemType.AssignWithConversion("dd");
   else
     itemType.AssignWithConversion("li");
@@ -2316,7 +2347,7 @@ nsHTMLEditRules::WillRemoveList(nsISelection *aSelection,
 
 nsresult
 nsHTMLEditRules::WillMakeDefListItem(nsISelection *aSelection, 
-                                     const nsString *aItemType, 
+                                     const nsAReadableString *aItemType, 
                                      PRBool aEntireList, 
                                      PRBool *aCancel,
                                      PRBool *aHandled)
@@ -2329,7 +2360,7 @@ nsHTMLEditRules::WillMakeDefListItem(nsISelection *aSelection,
 
 nsresult
 nsHTMLEditRules::WillMakeBasicBlock(nsISelection *aSelection, 
-                                    const nsString *aBlockType, 
+                                    const nsAReadableString *aBlockType, 
                                     PRBool *aCancel,
                                     PRBool *aHandled)
 {
@@ -2384,7 +2415,8 @@ nsHTMLEditRules::WillMakeBasicBlock(nsISelection *aSelection,
     // Ok, now go through all the nodes and make the right kind of blocks, 
     // or whatever is approriate.  Wohoo! 
     // Note: blockquote is handled a little differently
-    if (aBlockType->EqualsWithConversion("blockquote"))
+    nsString tString(*aBlockType);
+    if (tString.EqualsWithConversion("blockquote"))
       res = MakeBlockquote(arrayOfNodes);
     else
       res = ApplyBlockStyle(arrayOfNodes, aBlockType);
@@ -2664,8 +2696,8 @@ nsHTMLEditRules::WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *
 nsresult 
 nsHTMLEditRules::ConvertListType(nsIDOMNode *aList, 
                                  nsCOMPtr *outList,
-                                 const nsString& aListType, 
-                                 const nsString& aItemType) 
+                                 const nsAReadableString& aListType, 
+                                 const nsAReadableString& aItemType) 
 {
   if (!aList || !outList) return NS_ERROR_NULL_POINTER;
   *outList = aList;  // we migvht not need to change the list
@@ -2879,7 +2911,7 @@ nsHTMLEditRules::IsEmptyBlock(nsIDOMNode *aNode,
 
 nsresult
 nsHTMLEditRules::WillAlign(nsISelection *aSelection, 
-                           const nsString *alignType, 
+                           const nsAReadableString *alignType, 
                            PRBool *aCancel,
                            PRBool *aHandled)
 {
@@ -3046,7 +3078,7 @@ nsHTMLEditRules::WillAlign(nsISelection *aSelection,
 // AlignInnerBlocks: align inside table cells or list items
 //       
 nsresult
-nsHTMLEditRules::AlignInnerBlocks(nsIDOMNode *aNode, const nsString *alignType)
+nsHTMLEditRules::AlignInnerBlocks(nsIDOMNode *aNode, const nsAReadableString *alignType)
 {
   if (!aNode || !alignType) return NS_ERROR_NULL_POINTER;
   nsresult res;
@@ -3084,7 +3116,7 @@ nsHTMLEditRules::AlignInnerBlocks(nsIDOMNode *aNode, const nsString *alignType)
 // AlignBlockContents: align contents of a block element
 //                  
 nsresult
-nsHTMLEditRules::AlignBlockContents(nsIDOMNode *aNode, const nsString *alignType)
+nsHTMLEditRules::AlignBlockContents(nsIDOMNode *aNode, const nsAReadableString *alignType)
 {
   if (!aNode || !alignType) return NS_ERROR_NULL_POINTER;
   nsresult res;
@@ -4149,7 +4181,7 @@ nsHTMLEditRules::MakeTransitionList(nsISupportsArray *inArrayOfNodes,
 //                       
 nsresult 
 nsHTMLEditRules::InsertTab(nsISelection *aSelection, 
-                           nsString *outString)
+                           nsAWritableString *outString)
 {
   nsCOMPtr parentNode;
   PRInt32 offset;
@@ -4165,14 +4197,14 @@ nsHTMLEditRules::InsertTab(nsISelection *aSelection,
     
   if (isPRE)
   {
-    outString->AssignWithConversion('\t');
+    outString->Assign(PRUnichar('\t'));
   }
   else
   {
     // number of spaces should be a pref?
     // note that we dont play around with nbsps here anymore.  
     // let the AfterEdit whitespace cleanup code handle it.
-    outString->AssignWithConversion("    ");
+    outString->Assign(NS_LITERAL_STRING("    "));
   }
   
   return NS_OK;
@@ -4566,7 +4598,7 @@ nsHTMLEditRules::MakeBlockquote(nsISupportsArray *arrayOfNodes)
 //                   one or more blocks of type blockTag.  
 //                       
 nsresult 
-nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString *aBlockTag)
+nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsAReadableString *aBlockTag)
 {
   // intent of this routine is to be used for converting to/from
   // headers, paragraphs, pre, and address.  Those blocks
@@ -4582,7 +4614,8 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString
   
   // we special case an empty tag name to mean "remove block parents".
   // This is used for the "normal" paragraph style in mail-compose
-  if (aBlockTag->IsEmpty() || aBlockTag->EqualsWithConversion("normal")) bNoParent = PR_TRUE;
+  nsString tString(*aBlockTag);////MJUDGE SCC NEED HELP
+  if (tString.IsEmpty() || tString.EqualsWithConversion("normal")) bNoParent = PR_TRUE;
   
   arrayOfNodes->Count(&listCount);
   
@@ -4674,7 +4707,8 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString
     else if (IsInlineNode(curNode) && !bNoParent)
     {
       // if curNode is a non editable, drop it if we are going to 
-      if ((aBlockTag->EqualsWithConversion("pre")) && (!mHTMLEditor->IsEditable(curNode)))
+      nsString tString(*aBlockTag); ////MJUDGE SCC NEED HELP
+      if ((tString.EqualsWithConversion("pre")) && (!mHTMLEditor->IsEditable(curNode)))
         continue; // do nothing to this block
       
       // if no curBlock, make one
@@ -4707,7 +4741,7 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString
 //                 where we can insert the tag.  Adjust inOutParent and
 //                 inOutOffset to pint to new location for tag.
 nsresult 
-nsHTMLEditRules::SplitAsNeeded(const nsString *aTag, 
+nsHTMLEditRules::SplitAsNeeded(const nsAReadableString *aTag, 
                                nsCOMPtr *inOutParent,
                                PRInt32 *inOutOffset)
 {
@@ -5443,47 +5477,48 @@ nsHTMLEditRules::DoTextNodeWhitespace(nsIDOMCharacterData *aTextNode, PRInt32 aS
 
 
 nsresult 
-nsHTMLEditRules::ConvertWhitespace(const nsString & inString, nsString & outString)
+nsHTMLEditRules::ConvertWhitespace(const nsAReadableString & inString, nsAWritableString & outString)
 {
   PRUint32 j,len = inString.Length();
+  nsString tString(inString);////MJUDGE SCC NEED HELP
   switch (len)
   {
     case 0:
       outString.SetLength(0);
       return NS_OK;
     case 1:
-      if (inString.EqualsWithConversion("\n"))   // a bit of a hack: don't convert single newlines that 
-        outString.AssignWithConversion("\n");     // dont have whitespace adjacent.  This is to preserve 
+      if (tString.EqualsWithConversion("\n"))   // a bit of a hack: don't convert single newlines that 
+        outString.Assign(NS_LITERAL_STRING("\n"));     // dont have whitespace adjacent.  This is to preserve 
       else                    // html source formatting to some degree.
-        outString.AssignWithConversion(" ");
+        outString.Assign(NS_LITERAL_STRING(" "));
       return NS_OK;
     case 2:
-      outString.Assign((PRUnichar)nbsp);
-      outString.AppendWithConversion(" ");
+      outString.Assign(PRUnichar(nbsp));
+      outString.Append(NS_LITERAL_STRING(" "));
       return NS_OK;
     case 3:
-      outString.AssignWithConversion(" ");
-      outString += (PRUnichar)nbsp;
-      outString.AppendWithConversion(" ");
+      outString.Assign(NS_LITERAL_STRING(" "));
+      outString += PRUnichar(nbsp);
+      outString.Append(NS_LITERAL_STRING(" "));
       return NS_OK;
   }
   if (len%2)  // length is odd
   {
     for (j=0;j *outList, const nsString& aListType, const nsString& aItemType);
+  nsresult ConvertListType(nsIDOMNode *aList, nsCOMPtr *outList, const nsAReadableString& aListType, const nsAReadableString& aItemType);
   nsresult CreateStyleForInsertText(nsISelection *aSelection, nsIDOMDocument *aDoc);
   nsresult IsEmptyBlock(nsIDOMNode *aNode, 
                         PRBool *outIsEmptyBlock, 
@@ -150,9 +151,9 @@ protected:
   nsCOMPtr GetHighestInlineParent(nsIDOMNode* aNode);
   nsresult MakeTransitionList(nsISupportsArray *inArrayOfNodes, 
                                    nsVoidArray *inTransitionArray);
-  nsresult ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString *aBlockTag);
+  nsresult ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsAReadableString *aBlockTag);
   nsresult MakeBlockquote(nsISupportsArray *arrayOfNodes);
-  nsresult SplitAsNeeded(const nsString *aTag, nsCOMPtr *inOutParent, PRInt32 *inOutOffset);
+  nsresult SplitAsNeeded(const nsAReadableString *aTag, nsCOMPtr *inOutParent, PRInt32 *inOutOffset);
   nsresult AddTerminatingBR(nsIDOMNode *aBlock);
   nsresult JoinNodesSmart( nsIDOMNode *aNodeLeft, 
                            nsIDOMNode *aNodeRight, 
@@ -172,7 +173,7 @@ protected:
   nsresult SelectionEndpointInNode(nsIDOMNode *aNode, PRBool *aResult);
   nsresult DoTextNodeWhitespace(nsIDOMCharacterData *aTextNode, PRInt32 aStart, PRInt32 aEnd);
   nsresult UpdateDocChangeRange(nsIDOMRange *aRange);
-  nsresult ConvertWhitespace(const nsString & inString, nsString & outString);
+  nsresult ConvertWhitespace(const nsAReadableString & inString, nsAWritableString & outString);
   nsresult ConfirmSelectionInBody();
   nsresult InsertMozBRIfNeeded(nsIDOMNode *aNode);
 
diff --git a/mozilla/editor/base/nsHTMLEditor.cpp b/mozilla/editor/base/nsHTMLEditor.cpp
index db2625e52d2..e272dcf7312 100644
--- a/mozilla/editor/base/nsHTMLEditor.cpp
+++ b/mozilla/editor/base/nsHTMLEditor.cpp
@@ -425,9 +425,9 @@ NS_IMETHODIMP nsHTMLEditor::InitRules()
  * Can be used to determine if a new paragraph should be started.
  */
 nsresult
-nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
+nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool *aIsBlock)
 {
-  if (!aNode) { return NS_ERROR_NULL_POINTER; }
+  if (!aNode || !aIsBlock) { return NS_ERROR_NULL_POINTER; }
 
 //#define USE_PARSER_FOR_BLOCKNESS 1
 #ifdef USE_PARSER_FOR_BLOCKNESS
@@ -443,11 +443,11 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
   if (!element)
   {
     // We don't have an element -- probably a text node
-    aIsBlock = PR_FALSE;
+    *aIsBlock = PR_FALSE;
     return NS_OK;
   }
 
-  aIsBlock = PR_FALSE;
+  *aIsBlock = PR_FALSE;
 
   // Get the node name and atom:
   nsAutoString tagName;
@@ -475,7 +475,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
       tagAtom==nsIEditProperty::td         ||
       tagAtom==nsIEditProperty::pre)
   {
-    aIsBlock = PR_TRUE;
+    *aIsBlock = PR_TRUE;
     return NS_OK;
   }
 
@@ -487,7 +487,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
   PRInt32 id;
   rv = sParserService->HTMLStringTagToId(tagName, &id);
   if (NS_FAILED(rv)) return rv;
-  rv = sParserService->IsBlock(id, aIsBlock);
+  rv = sParserService->IsBlock(id, *aIsBlock);
 
 #ifdef DEBUG
   // Check this against what we would have said with the old code:
@@ -517,12 +517,12 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
       tagAtom==nsIEditProperty::dd         ||
       tagAtom==nsIEditProperty::legend     )
   {
-    if (!aIsBlock)
+    if (!(*aIsBlock))
     {
       nsAutoString assertmsg (NS_LITERAL_STRING("Parser and editor disagree on blockness: "));
       assertmsg.Append(tagName);
       char* assertstr = assertmsg.ToNewCString();
-      NS_ASSERTION(aIsBlock, assertstr);
+      NS_ASSERTION(*aIsBlock, assertstr);
       Recycle(assertstr);
     }
   }
@@ -531,7 +531,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
   return rv;
 #else /* USE_PARSER_FOR_BLOCKNESS */
   nsresult result = NS_ERROR_FAILURE;
-  aIsBlock = PR_FALSE;
+  *aIsBlock = PR_FALSE;
   nsCOMPtrelement;
   element = do_QueryInterface(aNode);
   if (element)
@@ -578,7 +578,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
           tagAtom==nsIEditProperty::dd         ||
           tagAtom==nsIEditProperty::legend     )
       {
-        aIsBlock = PR_TRUE;
+        *aIsBlock = PR_TRUE;
       }
       NS_RELEASE(tagAtom);
       result = NS_OK;
@@ -588,7 +588,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
     nsCOMPtrnodeAsText = do_QueryInterface(aNode);
     if (nodeAsText)
     {
-      aIsBlock = PR_FALSE;
+      *aIsBlock = PR_FALSE;
       result = NS_OK;
     }
   }
@@ -597,22 +597,21 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
 #endif /* USE_PARSER_FOR_BLOCKNESS */
 }
 
-// Non-static version for the nsIEditor interface and JavaScript
-NS_IMETHODIMP 
-nsHTMLEditor::NodeIsBlock(nsIDOMNode *aNode, PRBool &aIsBlock)
+NS_IMETHODIMP
+nsHTMLEditor::NodeIsBlock(nsIDOMNode *aNode, PRBool *aIsBlock)
 {
   return NodeIsBlockStatic(aNode, aIsBlock);
 }
 
+// Non-static version for the nsIEditor interface and JavaScript
 NS_IMETHODIMP 
-nsHTMLEditor::SetDocumentTitle(const PRUnichar *aTitle)
+nsHTMLEditor::SetDocumentTitle(const nsAReadableString &aTitle)
 {
   SetDocTitleTxn *txn;
   nsresult result = TransactionFactory::GetNewTransaction(SetDocTitleTxn::GetCID(), (EditTxn **)&txn);
   if (NS_SUCCEEDED(result))  
   {
-    nsAutoString title(aTitle);
-    result = txn->Init(this, &title);
+    result = txn->Init(this, &aTitle);
 
     if (NS_SUCCEEDED(result)) 
     {
@@ -646,7 +645,7 @@ nsHTMLEditor::GetBlockNodeParent(nsIDOMNode *aNode)
   while (p)
   {
     PRBool isBlock;
-    if (NS_FAILED(NodeIsBlockStatic(p, isBlock)) || isBlock)
+    if (NS_FAILED(NodeIsBlockStatic(p, &isBlock)) || isBlock)
       break;
     if ( NS_FAILED(p->GetParentNode(getter_AddRefs(tmp))) || !tmp) // no parent, ran off top of tree
       return p;
@@ -697,7 +696,7 @@ nsHTMLEditor::GetBlockSection(nsIDOMNode *aChild,
   while ((NS_SUCCEEDED(result)) && sibling)
   {
     PRBool isBlock;
-    NodeIsBlockStatic(sibling, isBlock);
+    NodeIsBlockStatic(sibling, &isBlock);
     if (isBlock)
     {
       nsCOMPtrnodeAsText = do_QueryInterface(sibling);
@@ -715,7 +714,7 @@ nsHTMLEditor::GetBlockSection(nsIDOMNode *aChild,
   while ((NS_SUCCEEDED(result)) && sibling)
   {
     PRBool isBlock;
-    NodeIsBlockStatic(sibling, isBlock);
+    NodeIsBlockStatic(sibling, &isBlock);
     if (isBlock) 
     {
       nsCOMPtrnodeAsText = do_QueryInterface(sibling);
@@ -768,7 +767,7 @@ nsHTMLEditor::GetBlockSectionsForRange(nsIDOMRange *aRange,
         else
         {
           PRBool isNotInlineOrText;
-          result = NodeIsBlockStatic(currentNode, isNotInlineOrText);
+          result = NodeIsBlockStatic(currentNode, &isNotInlineOrText);
           if (isNotInlineOrText)
           {
             PRUint16 nodeType;
@@ -861,7 +860,7 @@ nsHTMLEditor::NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir)
   // much gnashing of teeth as we twit back and forth between content and domnode types
   content = do_QueryInterface(aNode);
   PRBool isBlock;
-  if (NS_SUCCEEDED(NodeIsBlockStatic(aNode, isBlock)) && isBlock)
+  if (NS_SUCCEEDED(NodeIsBlockStatic(aNode, &isBlock)) && isBlock)
   {
     blockParent = do_QueryInterface(aNode);
   }
@@ -936,7 +935,7 @@ nsHTMLEditor::IsNextCharWhitespace(nsIDOMNode *aParentNode,
   while (node) 
   {
     PRBool isBlock (PR_FALSE);
-    NodeIsBlock(node, isBlock);
+    NodeIsBlock(node, &isBlock);
     if (isBlock)  // skip over bold, italic, link, ect nodes
     {
       if (IsTextNode(node) && IsEditable(node))
@@ -1007,7 +1006,7 @@ nsHTMLEditor::IsPrevCharWhitespace(nsIDOMNode *aParentNode,
   while (node) 
   {
     PRBool isBlock (PR_FALSE);
-    NodeIsBlock(node, isBlock);
+    NodeIsBlock(node, &isBlock);
     if (isBlock)  // skip over bold, italic, link, ect nodes
     {
       if (IsTextNode(node) && IsEditable(node))
@@ -1093,7 +1092,7 @@ NS_IMETHODIMP nsHTMLEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
       if (!node) return NS_ERROR_FAILURE;
 
       PRBool isBlock (PR_FALSE);
-      NodeIsBlock(node, isBlock);
+      NodeIsBlock(node, &isBlock);
       if (isBlock) blockParent = node;
       else blockParent = GetBlockNodeParent(node);
       
@@ -1121,18 +1120,18 @@ NS_IMETHODIMP nsHTMLEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
       nsString empty;
       if (isShift && !(mFlags&eEditorPlaintextBit))
       {
-        return TypedText(empty.GetUnicode(), eTypedBR);  // only inserts a br node
+        return TypedText(empty, eTypedBR);  // only inserts a br node
       }
       else 
       {
-        return TypedText(empty.GetUnicode(), eTypedBreak);  // uses rules to figure out what to insert
+        return TypedText(empty, eTypedBreak);  // uses rules to figure out what to insert
       }
     }
     else if (keyCode == nsIDOMKeyEvent::DOM_VK_ESCAPE)
     {
       // pass escape keypresses through as empty strings: needed forime support
       nsString empty;
-      return TypedText(empty.GetUnicode(), eTypedText);
+      return TypedText(empty, eTypedText);
     }
     
     // if we got here we either fell out of the tab case or have a normal character.
@@ -1140,7 +1139,7 @@ NS_IMETHODIMP nsHTMLEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
     if (character && !altKey && !ctrlKey && !isShift && !metaKey)
     {
       nsAutoString key(character);
-      return TypedText(key.GetUnicode(), eTypedText);
+      return TypedText(key, eTypedText);
     }
   }
   return NS_ERROR_FAILURE;
@@ -1152,7 +1151,7 @@ NS_IMETHODIMP nsHTMLEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
    to TypedText() to determine what action to take, but without passing
    an event.
    */
-NS_IMETHODIMP nsHTMLEditor::TypedText(const PRUnichar* aString,
+NS_IMETHODIMP nsHTMLEditor::TypedText(const nsAReadableString& aString,
                                       PRInt32 aAction)
 {
   nsAutoPlaceHolderBatch batch(this, gTypingTxnName);
@@ -1491,7 +1490,7 @@ nsHTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(nsISelection *aSelect
 //  but we can't use that because it is selection-based and 
 //  the rules code won't let us edit under the  node
 NS_IMETHODIMP
-nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsString &aSourceToInsert)
+nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsAReadableString& aSourceToInsert)
 {
   nsCOMPtr selection;
   nsresult res = GetSelection(getter_AddRefs(selection));
@@ -1596,7 +1595,7 @@ nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsString &aSourceToInsert)
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::RebuildDocumentFromSource(const nsString& aSourceString)
+nsHTMLEditor::RebuildDocumentFromSource(const nsAReadableString& aSourceString)
 {
   ForceCompositionEnd();
 
@@ -1611,22 +1610,29 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsString& aSourceString)
 
   // Find where the  tag starts.
   // If user mangled that, then abort
-  PRInt32 bodyStart = aSourceString.Find(NS_ConvertASCIItoUCS2(" beginbody;
+  nsReadingIterator endbody;
+  aSourceString.BeginReading(beginbody);
+  aSourceString.EndReading(endbody);
+  if (!FindInReadable(NS_LITERAL_STRING(" beginhead;
+  nsReadingIterator endhead;
+  aSourceString.BeginReading(beginhead);
+  aSourceString.EndReading(endhead);
+  if (!FindInReadable(NS_LITERAL_STRING(" beginclosehead;
+  nsReadingIterator endclosehead;
+  aSourceString.BeginReading(beginclosehead);
+  aSourceString.EndReading(endclosehead);
 
   // Find the index after ""
-  PRInt32 headEnd = aSourceString.Find(NS_ConvertASCIItoUCS2(" endtotal;
+  aSourceString.EndReading(endtotal);
+
+  res = InsertHTML(Substring(beginbody,endtotal));
   if (NS_FAILED(res)) return res;
   selection->Collapse(bodyElement, 0);
 
-  res = ReplaceHeadContentsWithHTML(headString);
+  res = ReplaceHeadContentsWithHTML(Substring(beginhead,beginclosehead));
   if (NS_FAILED(res)) return res;
 
   // Now we must copy attributes user might have edited on the  tag
   //  because InsertHTML (actually, CreateContextualFragment()) 
   //  will never return a body node in the DOM fragment
-  nsAutoString bodyTag;
+  nsReadingIterator beginclosebody = endbody;// endclosebody;
+  aSourceString.BeginReading(beginclosebody);
+  aSourceString.EndReading(endclosebody);
+  if (!FindInReadable(NS_LITERAL_STRING(">"),beginclosebody,endclosebody))
+    return NS_ERROR_FAILURE;
+
+  nsAutoString bodyTag(Substring(beginbody,endclosebody));//
   // Truncate at the end of the body tag
-  PRInt32 bodyTagEnd = bodyString.FindChar((PRUnichar)'>', PR_FALSE, 5);
-  if (bodyTagEnd == -1) return NS_ERROR_FAILURE;
-  bodyString.Truncate(bodyTagEnd+1);
   
   // Kludge of the year: fool the parser by replacing "body" with "div" so we get a node
-  bodyString.ToLowerCase();
-  bodyString.ReplaceSubstring(NS_ConvertASCIItoUCS2("body"), NS_ConvertASCIItoUCS2("div"));
+  bodyTag.ToLowerCase();
+  bodyTag.ReplaceSubstring(NS_ConvertASCIItoUCS2("body"), NS_ConvertASCIItoUCS2("div"));
 
   nsCOMPtr range;
   res = selection->GetRangeAt(0, getter_AddRefs(range));
@@ -1663,7 +1676,7 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsString& aSourceString)
   if (!nsrange) return NS_ERROR_NO_INTERFACE;
 
   nsCOMPtr docfrag;
-  res = nsrange->CreateContextualFragment(bodyString, getter_AddRefs(docfrag));
+  res = nsrange->CreateContextualFragment(bodyTag, getter_AddRefs(docfrag));
   if (NS_FAILED(res)) return res;
 
   nsCOMPtr fragmentAsNode (do_QueryInterface(docfrag));
@@ -1876,7 +1889,7 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::SetParagraphFormat(const nsString& aParagraphFormat)
+nsHTMLEditor::SetParagraphFormat(const nsAReadableString& aParagraphFormat)
 {
   nsAutoString tag; tag.Assign(aParagraphFormat);
   tag.ToLowerCase();
@@ -1923,7 +1936,7 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists)
     else 
     {
       PRBool isBlock (PR_FALSE);
-      NodeIsBlock(node, isBlock);
+      NodeIsBlock(node, &isBlock);
       if (isBlock) blockParent = node;
       else blockParent = GetBlockNodeParent(node);
       blockParentElem = do_QueryInterface(blockParent);
@@ -2004,10 +2017,10 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists)
 
 
 NS_IMETHODIMP 
-nsHTMLEditor::GetParagraphState(PRBool &aMixed, nsString &outFormat)
+nsHTMLEditor::GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
-
+  if (!aMixed) return NS_ERROR_NULL_POINTER;
   nsCOMPtr htmlRules = do_QueryInterface(mRules);
   if (!htmlRules) return NS_ERROR_FAILURE;
   
@@ -2015,11 +2028,12 @@ nsHTMLEditor::GetParagraphState(PRBool &aMixed, nsString &outFormat)
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::GetBackgroundColorState(PRBool &aMixed, nsString &aOutColor)
+nsHTMLEditor::GetBackgroundColorState(PRBool *aMixed, nsAWritableString &aOutColor)
 {
   //TODO: We don't handle "mixed" correctly!
-  aMixed = PR_FALSE;
-  aOutColor.AssignWithConversion("");
+  if (!aMixed) return NS_ERROR_NULL_POINTER;
+  *aMixed = PR_FALSE;
+  aOutColor.Assign(NS_LITERAL_STRING(""));
   
   nsCOMPtr element;
   PRInt32 selectedCount;
@@ -2059,10 +2073,10 @@ nsHTMLEditor::GetBackgroundColorState(PRBool &aMixed, nsString &aOutColor)
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL)
+nsHTMLEditor::GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
-
+  if (!aMixed || !aOL || !aUL || !aDL) return NS_ERROR_NULL_POINTER;
   nsCOMPtr htmlRules = do_QueryInterface(mRules);
   if (!htmlRules) return NS_ERROR_FAILURE;
   
@@ -2070,9 +2084,10 @@ nsHTMLEditor::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD)
+nsHTMLEditor::GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
+  if (!aMixed || !aLI || !aDT || !aDD) return NS_ERROR_NULL_POINTER;
 
   nsCOMPtr htmlRules = do_QueryInterface(mRules);
   if (!htmlRules) return NS_ERROR_FAILURE;
@@ -2081,10 +2096,10 @@ nsHTMLEditor::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
+nsHTMLEditor::GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
-
+  if (!aMixed || !aAlign) return NS_ERROR_NULL_POINTER;
   nsCOMPtr htmlRules = do_QueryInterface(mRules);
   if (!htmlRules) return NS_ERROR_FAILURE;
   
@@ -2093,9 +2108,10 @@ nsHTMLEditor::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
 
 
 NS_IMETHODIMP 
-nsHTMLEditor::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
+nsHTMLEditor::GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
+  if (!aCanIndent || !aCanOutdent) return NS_ERROR_NULL_POINTER;
 
   nsCOMPtr htmlRules = do_QueryInterface(mRules);
   if (!htmlRules) return NS_ERROR_FAILURE;
@@ -2104,7 +2120,7 @@ nsHTMLEditor::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::MakeOrChangeList(const nsString& aListType, PRBool entireList)
+nsHTMLEditor::MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList)
 {
   nsresult res;
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@@ -2182,7 +2198,7 @@ nsHTMLEditor::MakeOrChangeList(const nsString& aListType, PRBool entireList)
 
 
 NS_IMETHODIMP
-nsHTMLEditor::RemoveList(const nsString& aListType)
+nsHTMLEditor::RemoveList(const nsAReadableString& aListType)
 {
   nsresult res;
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@@ -2199,7 +2215,8 @@ nsHTMLEditor::RemoveList(const nsString& aListType)
   if (!selection) return NS_ERROR_NULL_POINTER;
 
   nsTextRulesInfo ruleInfo(nsTextEditRules::kRemoveList);
-  if (aListType.EqualsWithConversion("ol")) ruleInfo.bOrdered = PR_TRUE;
+  nsString tString(aListType);//MJUDGE SCC NEED HELP
+  if (tString.EqualsWithConversion("ol")) ruleInfo.bOrdered = PR_TRUE;
   else  ruleInfo.bOrdered = PR_FALSE;
   res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   if (cancel || (NS_FAILED(res))) return res;
@@ -2211,7 +2228,7 @@ nsHTMLEditor::RemoveList(const nsString& aListType)
 }
 
 nsresult
-nsHTMLEditor::MakeDefinitionItem(const nsString& aItemType)
+nsHTMLEditor::MakeDefinitionItem(const nsAReadableString& aItemType)
 {
   nsresult res;
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@@ -2241,7 +2258,7 @@ nsHTMLEditor::MakeDefinitionItem(const nsString& aItemType)
 }
 
 nsresult
-nsHTMLEditor::InsertBasicBlock(const nsString& aBlockType)
+nsHTMLEditor::InsertBasicBlock(const nsAReadableString& aBlockType)
 {
   nsresult res;
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@@ -2313,7 +2330,7 @@ nsHTMLEditor::InsertBasicBlock(const nsString& aBlockType)
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::Indent(const nsString& aIndent)
+nsHTMLEditor::Indent(const nsAReadableString& aIndent)
 {
   nsresult res;
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@@ -2321,7 +2338,8 @@ nsHTMLEditor::Indent(const nsString& aIndent)
   PRBool cancel, handled;
   PRInt32 theAction = nsTextEditRules::kIndent;
   PRInt32 opID = kOpIndent;
-  if (aIndent.EqualsWithConversion("outdent"))
+  nsString tString(aIndent);//MJUDGE SCC NEED HELP
+  if (tString.EqualsWithConversion("outdent"))
   {
     theAction = nsTextEditRules::kOutdent;
     opID = kOpOutdent;
@@ -2384,7 +2402,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
         // put a space in it so layout will draw the list item
         res = selection->Collapse(newBQ,0);
         if (NS_FAILED(res)) return res;
-        res = InsertText(NS_LITERAL_STRING(" ").get());
+        res = InsertText(NS_LITERAL_STRING(" "));
         if (NS_FAILED(res)) return res;
         // reposition selection to before the space character
         res = GetStartNodeAndOffset(selection, address_of(node), &offset);
@@ -2401,7 +2419,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
 //TODO: IMPLEMENT ALIGNMENT!
 
 NS_IMETHODIMP
-nsHTMLEditor::Align(const nsString& aAlignType)
+nsHTMLEditor::Align(const nsAReadableString& aAlignType)
 {
   nsAutoEditBatch beginBatching(this);
   nsAutoRules beginRulesSniffing(this, kOpAlign, nsIEditor::eNext);
@@ -2547,7 +2565,7 @@ NODE_FOUND:
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aReturn)
+nsHTMLEditor::GetSelectedElement(const nsAReadableString& aTagName, nsIDOMElement** aReturn)
 {
   if (!aReturn )
     return NS_ERROR_NULL_POINTER;
@@ -2895,8 +2913,8 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
       if (href.GetUnicode() && href.Length() > 0)      
       {
         nsAutoEditBatch beginBatching(this);
-        nsString attribute; attribute.AssignWithConversion("href");
-        SetInlineProperty(nsIEditProperty::a, &attribute, &href);
+        nsString attribute(NS_LITERAL_STRING("href")); 
+        SetInlineProperty(nsIEditProperty::a, attribute, href);
         //TODO: Enumerate through other properties of the anchor tag
         // and set those as well. 
         // Optimization: Modify SetTextProperty to set all attributes at once?
@@ -2907,7 +2925,7 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::SetBackgroundColor(const nsString& aColor)
+nsHTMLEditor::SetBackgroundColor(const nsAReadableString& aColor)
 {
   NS_PRECONDITION(mDocWeak, "Missing Editor DOM Document");
   
@@ -2958,7 +2976,7 @@ nsHTMLEditor::SetBackgroundColor(const nsString& aColor)
   return res;
 }
 
-NS_IMETHODIMP nsHTMLEditor::SetBodyAttribute(const nsString& aAttribute, const nsString& aValue)
+NS_IMETHODIMP nsHTMLEditor::SetBodyAttribute(const nsAReadableString& aAttribute, const nsAReadableString& aValue)
 {
   nsresult res;
   // TODO: Check selection for Cell, Row, Column or table and do color on appropriate level
@@ -3056,20 +3074,20 @@ nsHTMLEditor::RemoveOverrideStyleSheet(nsICSSStyleSheet* aSheet)
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::ApplyOverrideStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)
+nsHTMLEditor::ApplyOverrideStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet)
 {
   return ApplyDocumentOrOverrideStyleSheet(aURL, PR_TRUE, aStyleSheet);
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)
+nsHTMLEditor::ApplyStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet)
 {
   return ApplyDocumentOrOverrideStyleSheet(aURL, PR_FALSE, aStyleSheet);
 }
 
 //Note: Loading a document style sheet is undoable, loading an override sheet is not
 nsresult 
-nsHTMLEditor::ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet)
+nsHTMLEditor::ApplyDocumentOrOverrideStyleSheet(const nsAReadableString& aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet)
 {
   nsresult rv   = NS_OK;
   nsCOMPtr uaURL;
@@ -3273,7 +3291,7 @@ static nsresult SetSelectionAroundHeadChildren(nsCOMPtr aSelection
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetHeadContentsAsHTML(nsString& aOutputString)
+nsHTMLEditor::GetHeadContentsAsHTML(nsAWritableString& aOutputString)
 {
   nsCOMPtr selection;
   nsresult res = GetSelection(getter_AddRefs(selection));
@@ -3292,15 +3310,27 @@ nsHTMLEditor::GetHeadContentsAsHTML(nsString& aOutputString)
   {
     // Selection always includes ,
     //  so terminate there
-    PRInt32 offset = aOutputString.Find(NS_ConvertASCIItoUCS2(" 0)
+    nsReadingIterator findIter,endFindIter;
+    aOutputString.BeginReading(findIter);
+    aOutputString.EndReading(endFindIter);
+    //counting on our parser to always lower case!!!
+    if (FindInReadable(NS_LITERAL_STRING(" beginIter;
+      aOutputString.BeginReading(beginIter);
+      PRInt32 offset = Distance(beginIter, findIter);//get the distance
+
+      nsWritingIterator writeIter;
+      aOutputString.BeginWriting(writeIter);
       // Ensure the string ends in a newline
       PRUnichar newline ('\n');
-      if (aOutputString.CharAt(offset-1) != newline)
-        aOutputString.SetCharAt(newline, offset++);
-
-      aOutputString.Truncate(offset);
+      findIter.advance(-1);
+      if (offset ==0 || (offset >0 &&  (*findIter) != newline)) //check for 0
+      {
+        writeIter.advance(offset);
+        *writeIter = newline;
+        aOutputString.Truncate(offset+1);
+      }
     }
   }
   return res;
@@ -3332,7 +3362,7 @@ nsHTMLEditor::DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed)
 #endif
 
 NS_IMETHODIMP
-nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
+nsHTMLEditor::SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
 {
   NS_ASSERTION(aTextRangeList, "null ptr");
   if(nsnull == aTextRangeList)
@@ -3355,7 +3385,7 @@ nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivat
   mIMETextRangeList = aTextRangeList;
   nsAutoPlaceHolderBatch batch(this, gIMETxnName);
 
-  result = InsertText(aCompositionString.GetUnicode());
+  result = InsertText(aCompositionString);
 
   mIMEBufferLength = aCompositionString.Length();
 
@@ -3492,28 +3522,29 @@ nsHTMLEditor::EndOperation()
 }  
 
 PRBool 
-nsHTMLEditor::TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag)
+nsHTMLEditor::TagCanContainTag(const nsAReadableString& aParentTag, const nsAReadableString& aChildTag)  
 {
   // COtherDTD gives some unwanted results.  We override them here.
   nsAutoString olStr, ulStr, liStr;
   olStr = NS_LITERAL_STRING("ol");
   ulStr = NS_LITERAL_STRING("ul");
   liStr = NS_LITERAL_STRING("li");
-  
-  if ( aParentTag.EqualsIgnoreCase(olStr) ||
-       aParentTag.EqualsIgnoreCase(ulStr) )
+  nsString tParent(aParentTag);//MJUDGE SCC NEED HELP
+  nsString tChild(aChildTag);//MJUDGE SCC NEED HELP
+  if ( tParent.EqualsIgnoreCase(olStr) ||
+       tParent.EqualsIgnoreCase(ulStr) )
   {
     // if parent is a list and tag is also a list, say "yes".
     // This is because the editor does sublists illegally for now. 
-    if (aChildTag.EqualsIgnoreCase(olStr) ||
-        aChildTag.EqualsIgnoreCase(ulStr) ) 
+    if (tChild.EqualsIgnoreCase(olStr) ||
+        tChild.EqualsIgnoreCase(ulStr) ) 
       return PR_TRUE;
   }
 
-  if ( aParentTag.EqualsIgnoreCase(liStr) )
+  if ( tParent.EqualsIgnoreCase(liStr) )
   {
     // list items cant contain list items
-    if (aChildTag.EqualsIgnoreCase(liStr) ) 
+    if (tChild.EqualsIgnoreCase(liStr) ) 
       return PR_FALSE;
   }
 
@@ -3607,8 +3638,8 @@ NS_IMETHODIMP nsHTMLEditor::GetLayoutObject(nsIDOMNode *aNode, nsISupports **aLa
 // so singleton attributes like  will not be matched!
 void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode     *aNode,
                                               nsIAtom        *aProperty, 
-                                              const nsString *aAttribute, 
-                                              const nsString *aValue, 
+                                              const nsAReadableString *aAttribute, 
+                                              const nsAReadableString *aValue, 
                                               PRBool         &aIsSet,
                                               nsIDOMNode    **aStyleNode,
                                               nsString       *outValue) const
@@ -3639,11 +3670,15 @@ void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode     *aNode,
             if (!aValue) {
               found = PR_TRUE;
             }
-            else if (aValue->EqualsIgnoreCase(value)) {
-              found = PR_TRUE;
-            }
-            else {  // we found the prop with the attribute, but the value doesn't match
-              break;
+            else
+            {
+              nsString tString(*aValue);
+              if (tString.EqualsIgnoreCase(value)) {
+                found = PR_TRUE;
+              }
+              else {  // we found the prop with the attribute, but the value doesn't match
+                break;
+              }
             }
           }
         }
@@ -3670,7 +3705,7 @@ void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode     *aNode,
 
 void nsHTMLEditor::IsTextStyleSet(nsIStyleContext *aSC, 
                                   nsIAtom *aProperty, 
-                                  const nsString *aAttribute,  
+                                  const nsAReadableString *aAttribute,  
                                   PRBool &aIsSet) const
 {
   aIsSet = PR_FALSE;
@@ -3969,7 +4004,7 @@ nsHTMLEditor::CollapseAdjacentTextNodes(nsIDOMRange *aInRange)
 
 NS_IMETHODIMP
 nsHTMLEditor::GetNextElementByTagName(nsIDOMElement    *aCurrentElement,
-                                      const nsString   *aTagName,
+                                      const nsAReadableString   *aTagName,
                                       nsIDOMElement   **aReturn)
 {
   nsresult res = NS_OK;
diff --git a/mozilla/editor/base/nsHTMLEditor.h b/mozilla/editor/base/nsHTMLEditor.h
index 481ccf5ee83..5434e6a96bd 100644
--- a/mozilla/editor/base/nsHTMLEditor.h
+++ b/mozilla/editor/base/nsHTMLEditor.h
@@ -99,72 +99,75 @@ public:
 
   /* ------------ nsIHTMLEditor methods -------------- */
   NS_IMETHOD SetInlineProperty(nsIAtom *aProperty, 
-                             const nsString *aAttribute,
-                             const nsString *aValue);
-
+                            const nsAReadableString & aAttribute, 
+                            const nsAReadableString & aValue);
+  
   NS_IMETHOD GetInlineProperty(nsIAtom *aProperty, 
-                             const nsString *aAttribute,
-                             const nsString *aValue,
-                             PRBool &aFirst, PRBool &aAny, PRBool &aAll);
+                             const nsAReadableString & aAttribute, 
+                             const nsAReadableString & aValue, 
+                             PRBool *aFirst, 
+                             PRBool *aAny, 
+                             PRBool *aAll);
   NS_IMETHOD GetInlinePropertyWithAttrValue(nsIAtom *aProperty, 
-                             const nsString *aAttribute,
-                             const nsString *aValue,
-                             PRBool &aFirst, PRBool &aAny, PRBool &aAll,
-                             nsString *outValue);
-
+                             const nsAReadableString &aAttribute,
+                             const nsAReadableString &aValue,
+                             PRBool *aFirst, 
+                             PRBool *aAny, 
+                             PRBool *aAll,
+                             nsAWritableString &outValue);
   NS_IMETHOD RemoveAllInlineProperties();
-  NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute);
+  NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsAReadableString & aAttribute);
   NS_IMETHOD IncreaseFontSize();
   NS_IMETHOD DecreaseFontSize();
 
-  NS_IMETHOD InsertHTML(const nsString &aInputString);
-  NS_IMETHOD InsertHTMLWithCharset(const nsString& aInputString,
-                                   const nsString& aCharset);
-  NS_IMETHOD RebuildDocumentFromSource(const nsString& aSourceString);
+  NS_IMETHOD InsertHTML(const nsAReadableString &aInputString);
+  NS_IMETHOD InsertHTMLWithCharset(const nsAReadableString& aInputString,
+                                   const nsAReadableString& aCharset);
+  NS_IMETHOD RebuildDocumentFromSource(const nsAReadableString& aSourceString);
   NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection);
   
   NS_IMETHOD SelectElement(nsIDOMElement* aElement);
   NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement);
 
-  NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat);
+  NS_IMETHOD SetParagraphFormat(const nsAReadableString& aParagraphFormat);
 
   NS_IMETHOD GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists);
 
-  NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat);
-  NS_IMETHOD GetFontFaceState(PRBool &aMixed, nsString &outFace);
-  NS_IMETHOD GetFontColorState(PRBool &aMixed, nsString &outColor);
-  NS_IMETHOD GetBackgroundColorState(PRBool &aMixed, nsString &outColor);
-  NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL);
-  NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD);
-  NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign);
-  NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent);
+  NS_IMETHOD GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat);
+  NS_IMETHOD GetFontFaceState(PRBool *aMixed, nsAWritableString &outFace);
+  NS_IMETHOD GetFontColorState(PRBool *aMixed, nsAWritableString &outColor);
+  NS_IMETHOD GetBackgroundColorState(PRBool *aMixed, nsAWritableString &outColor);
+  NS_IMETHOD GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL);
+  NS_IMETHOD GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD);
+  NS_IMETHOD GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign);
+  NS_IMETHOD GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent);
 
-  NS_IMETHOD MakeOrChangeList(const nsString& aListType, PRBool entireList);
-  NS_IMETHOD RemoveList(const nsString& aListType);
-  NS_IMETHOD Indent(const nsString& aIndent);
-  NS_IMETHOD Align(const nsString& aAlign);
+  NS_IMETHOD MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList);
+  NS_IMETHOD RemoveList(const nsAReadableString& aListType);
+  NS_IMETHOD Indent(const nsAReadableString& aIndent);
+  NS_IMETHOD Align(const nsAReadableString& aAlign);
 
   NS_IMETHOD GetElementOrParentByTagName(const nsAReadableString& aTagName, nsIDOMNode *aNode, nsIDOMElement** aReturn);
-  NS_IMETHOD GetSelectedElement(const nsString& aTagName, nsIDOMElement** aReturn);
+  NS_IMETHOD GetSelectedElement(const nsAReadableString& aTagName, nsIDOMElement** aReturn);
   NS_IMETHOD CreateElementWithDefaults(const nsAReadableString& aTagName, nsIDOMElement** aReturn);
-  NS_IMETHOD GetNextElementByTagName(nsIDOMElement *aCurrentElement, const nsString *aTagName, nsIDOMElement **aReturn);
+  NS_IMETHOD GetNextElementByTagName(nsIDOMElement *aCurrentElement, const nsAReadableString *aTagName, nsIDOMElement **aReturn);
 
 
   NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
 
   /* ------------ nsIEditorIMESupport overrides -------------- */
   
-  NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
+  NS_IMETHOD SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
   NS_IMETHOD GetReconversionString(nsReconversionEventReply* aReply);
 
   /* ------------ nsIEditorStyleSheets methods -------------- */
 
-  NS_IMETHOD ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet);
-  NS_IMETHOD ApplyOverrideStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet);
+  NS_IMETHOD ApplyStyleSheet(const nsAReadableString & aURL, nsICSSStyleSheet **aStyleSheet);
+  NS_IMETHOD ApplyOverrideStyleSheet(const nsAReadableString & aURL, nsICSSStyleSheet **aStyleSheet);
   /* Above 2 methods call this with appropriate aOverride value 
    * Not exposed to IDL interface 
   */
-  nsresult   ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet);
+  nsresult   ApplyDocumentOrOverrideStyleSheet(const nsAReadableString & aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet);
   NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet);
   NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet);
   NS_IMETHOD RemoveOverrideStyleSheet(nsICSSStyleSheet* aSheet);
@@ -172,13 +175,13 @@ public:
   /* ------------ nsIEditorMailSupport methods -------------- */
 
   NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType);
-  NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, nsIDOMNode **aNodeInserted);
-  NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation,
+  NS_IMETHOD InsertAsQuotation(const nsAReadableString & aQuotedText, nsIDOMNode **aNodeInserted);
+  NS_IMETHOD PasteAsCitedQuotation(const nsAReadableString & aCitation,
                                    PRInt32 aSelectionType);
-  NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText,
-                                    const nsString& aCitation,
+  NS_IMETHOD InsertAsCitedQuotation(const nsAReadableString & aQuotedText,
+                                    const nsAReadableString & aCitation,
                                     PRBool aInsertHTML,
-                                    const nsString& aCharset,
+                                    const nsAReadableString & aCharset,
                                     nsIDOMNode **aNodeInserted);
   NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
 
@@ -240,10 +243,11 @@ public:
   /* miscellaneous */
   // This sets background on the appropriate container element (table, cell,)
   //   or calls into nsTextEditor to set the page background
-  NS_IMETHOD SetBackgroundColor(const nsString& aColor);
-  NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue);
+  NS_IMETHOD SetBackgroundColor(const nsAReadableString& aColor);
+  NS_IMETHOD SetBodyAttribute(const nsAReadableString& aAttr, const nsAReadableString& aValue);
   // aTitle may be null or empty string to remove child contents of 
-  NS_IMETHOD SetDocumentTitle(const PRUnichar *aTitle);
+
+  NS_IMETHOD SetDocumentTitle(const nsAReadableString &aTitle);
 
   /* ------------ Block methods moved from nsEditor -------------- */
   static nsCOMPtr<nsIDOMNode> GetBlockNodeParent(nsIDOMNode *aNode);
@@ -301,10 +305,10 @@ public:
   NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell,  nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags);
   
   /** Internal, static version */
-  static nsresult NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock);
+  static nsresult NodeIsBlockStatic(nsIDOMNode *aNode, PRBool *aIsBlock);
 
   /** This version is for exposure to JavaScript */
-  NS_IMETHOD NodeIsBlock(nsIDOMNode *aNode, PRBool &aIsBlock);
+  NS_IMETHOD NodeIsBlock(nsIDOMNode *aNode, PRBool *aIsBlock);
 
   /** we override this here to install event listeners */
   NS_IMETHOD PostCreate();
@@ -313,14 +317,14 @@ public:
   NS_IMETHOD SetFlags(PRUint32 aFlags);
 
   NS_IMETHOD Paste(PRInt32 aSelectionType);
-  NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste);
+  NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste);
 
-  NS_IMETHOD CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag);
+  NS_IMETHOD CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag);
   NS_IMETHOD DoDrag(nsIDOMEvent *aDragEvent);
   NS_IMETHOD InsertFromDrop(nsIDOMEvent* aDropEvent);
 
-  NS_IMETHOD GetHeadContentsAsHTML(nsString& aOutputString);
-  NS_IMETHOD ReplaceHeadContentsWithHTML(const nsString &aSourceToInsert);
+  NS_IMETHOD GetHeadContentsAsHTML(nsAWritableString& aOutputString);
+  NS_IMETHOD ReplaceHeadContentsWithHTML(const nsAReadableString &aSourceToInsert);
 
   NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
 
@@ -333,7 +337,7 @@ public:
   NS_IMETHOD EndOperation();
 
   /** returns PR_TRUE if aParentTag can contain a child of type aChildTag */
-  virtual PRBool TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag);
+  virtual PRBool TagCanContainTag(const nsAReadableString& aParentTag, const nsAReadableString& aChildTag);
   
   /** make the given selection span the entire document */
   NS_IMETHOD SelectEntireDocument(nsISelection *aSelection);
@@ -345,7 +349,7 @@ public:
   NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify);
 
   /* ------------ Utility Routines, not part of public API -------------- */
-  NS_IMETHOD TypedText(const PRUnichar* aString, PRInt32 aAction);
+  NS_IMETHOD TypedText(const nsAReadableString& aString, PRInt32 aAction);
   nsresult InsertNodeAtPoint(nsIDOMNode *aNode, 
                                 nsIDOMNode *aParent, 
                                 PRInt32 aOffset, 
@@ -512,8 +516,8 @@ protected:
     */
   virtual void IsTextPropertySetByContent(nsIDOMNode     *aNode,
                                           nsIAtom        *aProperty, 
-                                          const nsString *aAttribute,
-                                          const nsString *aValue,
+                                          const nsAReadableString *aAttribute,
+                                          const nsAReadableString *aValue,
                                           PRBool         &aIsSet,
                                           nsIDOMNode    **aStyleNode,
                                           nsString       *outValue = nsnull) const;
@@ -523,7 +527,7 @@ protected:
     */
   virtual void IsTextStyleSet(nsIStyleContext *aSC, 
                               nsIAtom         *aProperty, 
-                              const nsString  *aAttributes, 
+                              const nsAReadableString  *aAttributes, 
                               PRBool          &aIsSet) const;
 
 
@@ -534,26 +538,26 @@ protected:
 
   // Methods for handling plaintext quotations
   NS_IMETHOD PasteAsPlaintextQuotation(PRInt32 aSelectionType);
-  NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText,
+  NS_IMETHOD InsertAsPlaintextQuotation(const nsAReadableString & aQuotedText,
                                         nsIDOMNode **aNodeInserted);
 
   // factored methods for handling insertion of data from transferables (drag&drop or clipboard)
   NS_IMETHOD PrepareTransferable(nsITransferable **transferable);
   NS_IMETHOD InsertFromTransferable(nsITransferable *transferable, 
-                                    const nsString& aContextStr,
-                                    const nsString& aInfoStr);
-  nsresult   InsertHTMLWithContext(const nsString& aInputString, 
-                                   const nsString& aContextStr, 
-                                   const nsString& aInfoStr);
-  nsresult   InsertHTMLWithCharsetAndContext(const nsString& aInputString,
-                                             const nsString& aCharset,
-                                             const nsString& aContextStr,
-                                             const nsString& aInfoStr);
+                                    const nsAReadableString & aContextStr,
+                                    const nsAReadableString & aInfoStr);
+  nsresult   InsertHTMLWithContext(const nsAReadableString & aInputString, 
+                                   const nsAReadableString & aContextStr, 
+                                   const nsAReadableString & aInfoStr);
+  nsresult   InsertHTMLWithCharsetAndContext(const nsAReadableString & aInputString,
+                                             const nsAReadableString & aCharset,
+                                             const nsAReadableString & aContextStr,
+                                             const nsAReadableString & aInfoStr);
   nsresult   StripFormattingNodes(nsIDOMNode *aNode);
   nsresult   CreateDOMFragmentFromPaste(nsIDOMNSRange *aNSRange,
-                                        const nsString& aInputString,
-                                        const nsString& aContextStr,
-                                        const nsString& aInfoStr,
+                                        const nsAReadableString & aInputString,
+                                        const nsAReadableString & aContextStr,
+                                        const nsAReadableString & aInfoStr,
                                         nsCOMPtr<nsIDOMNode> *outFragNode,
                                         PRInt32 *outRangeStartHint,
                                         PRInt32 *outRangeEndHint);
@@ -569,8 +573,8 @@ protected:
   PRBool IsModifiable();
 
   /* helpers for block transformations */
-  nsresult MakeDefinitionItem(const nsString& aItemType);
-  nsresult InsertBasicBlock(const nsString& aBlockType);
+  nsresult MakeDefinitionItem(const nsAReadableString & aItemType);
+  nsresult InsertBasicBlock(const nsAReadableString & aBlockType);
   
   /* increase/decrease the font size of selection */
   nsresult RelativeFontChange( PRInt32 aSizeChange);
@@ -588,35 +592,35 @@ protected:
                                         PRInt32 aStartOffset,
                                         PRInt32 aEndOffset,
                                         nsIAtom *aProperty, 
-                                        const nsString *aAttribute,
-                                        const nsString *aValue);
+                                        const nsAReadableString *aAttribute,
+                                        const nsAReadableString *aValue);
   nsresult SetInlinePropertyOnNode( nsIDOMNode *aNode,
                                     nsIAtom *aProperty, 
-                                    const nsString *aAttribute,
-                                    const nsString *aValue);
+                                    const nsAReadableString *aAttribute,
+                                    const nsAReadableString *aValue);
 
   nsresult PromoteInlineRange(nsIDOMRange *inRange);
   nsresult SplitStyleAboveRange(nsIDOMRange *aRange, 
                                 nsIAtom *aProperty, 
-                                const nsString *aAttribute);
+                                const nsAReadableString *aAttribute);
   nsresult SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode,
                                 PRInt32 *aOffset,
                                 nsIAtom *aProperty, 
-                                const nsString *aAttribute,
+                                const nsAReadableString *aAttribute,
                                 nsCOMPtr<nsIDOMNode> *outLeftNode = nsnull,
                                 nsCOMPtr<nsIDOMNode> *outRightNode = nsnull);
   nsresult RemoveStyleInside(nsIDOMNode *aNode, 
                              nsIAtom *aProperty, 
-                             const nsString *aAttribute, 
+                             const nsAReadableString *aAttribute, 
                              PRBool aChildrenOnly = PR_FALSE);
-  nsresult RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsString *aAttribute);
+  nsresult RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAReadableString *aAttribute);
   
   PRBool NodeIsProperty(nsIDOMNode *aNode);
-  PRBool HasAttr(nsIDOMNode *aNode, const nsString *aAttribute);
-  PRBool HasAttrVal(nsIDOMNode *aNode, const nsString *aAttribute, const nsString *aValue);
+  PRBool HasAttr(nsIDOMNode *aNode, const nsAReadableString *aAttribute);
+  PRBool HasAttrVal(nsIDOMNode *aNode, const nsAReadableString *aAttribute, const nsAReadableString *aValue);
   PRBool IsAtFrontOfNode(nsIDOMNode *aNode, PRInt32 aOffset);
   PRBool IsAtEndOfNode(nsIDOMNode *aNode, PRInt32 aOffset);
-  PRBool IsOnlyAttribute(nsIDOMNode *aElement, const nsString *aAttribute);
+  PRBool IsOnlyAttribute(nsIDOMNode *aElement, const nsAReadableString *aAttribute);
   PRBool HasMatchingAttributes(nsIDOMNode *aNode1, 
                                nsIDOMNode *aNode2);
 
@@ -642,6 +646,14 @@ protected:
   PRBool   mIgnoreSpuriousDragEvent;
   NS_IMETHOD IgnoreSpuriousDragEvent(PRBool aIgnoreSpuriousDragEvent) {mIgnoreSpuriousDragEvent = aIgnoreSpuriousDragEvent; return NS_OK;}
 
+  nsresult GetInlinePropertyBase(nsIAtom *aProperty, 
+                             const nsAReadableString *aAttribute,
+                             const nsAReadableString *aValue,
+                             PRBool *aFirst, 
+                             PRBool *aAny, 
+                             PRBool *aAll,
+                             nsAWritableString *outValue);
+
 // Data members
 protected:
 
diff --git a/mozilla/editor/base/nsHTMLEditorLog.cpp b/mozilla/editor/base/nsHTMLEditorLog.cpp
index 74c6b7fcfd8..c15926ff938 100644
--- a/mozilla/editor/base/nsHTMLEditorLog.cpp
+++ b/mozilla/editor/base/nsHTMLEditorLog.cpp
@@ -54,7 +54,7 @@ nsHTMLEditorLog::~nsHTMLEditorLog()
 NS_IMPL_ISUPPORTS_INHERITED(nsHTMLEditorLog, nsHTMLEditor, nsIEditorLogging);
 
 NS_IMETHODIMP
-nsHTMLEditorLog::SetInlineProperty(nsIAtom *aProperty, const nsString *aAttribute, const nsString *aValue)
+nsHTMLEditorLog::SetInlineProperty(nsIAtom *aProperty, const nsAReadableString &aAttribute, const nsAReadableString &aValue)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -68,11 +68,11 @@ nsHTMLEditorLog::SetInlineProperty(nsIAtom *aProperty, const nsString *aAttribut
     Write("window.editorShell.SetTextProperty(\"");
     PrintUnicode(propStr);
     Write("\", \"");
-    if (aAttribute)
-      PrintUnicode(*aAttribute);
+    if (aAttribute.Length())
+      PrintUnicode(aAttribute);
     Write("\", \"");
-    if (aValue)
-      PrintUnicode(*aValue);
+    if (aValue.Length())
+      PrintUnicode(aValue);
     Write("\");\n");
 
     Flush();
@@ -100,7 +100,7 @@ nsHTMLEditorLog::SetParagraphFormat(const nsString& aParagraphFormat)
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute)
+nsHTMLEditorLog::RemoveInlineProperty(nsIAtom *aProperty, const nsAReadableString &aAttribute)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -114,8 +114,8 @@ nsHTMLEditorLog::RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttri
     Write("window.editorShell.RemoveTextProperty(\"");
     PrintUnicode(propStr);
     Write("\", \"");
-    if (aAttribute)
-      PrintUnicode(*aAttribute);
+    if (aAttribute.Length())
+      PrintUnicode(aAttribute);
     Write("\");\n");
 
     Flush();
@@ -143,7 +143,7 @@ nsHTMLEditorLog::DeleteSelection(nsIEditor::EDirection aAction)
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::InsertText(const PRUnichar* aStringToInsert)
+nsHTMLEditorLog::InsertText(const nsAReadableString& aStringToInsert)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -351,7 +351,7 @@ nsHTMLEditorLog::PasteAsPlaintextQuotation(PRInt32 aSelectionType)
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::PasteAsCitedQuotation(const nsString& aCitation,
+nsHTMLEditorLog::PasteAsCitedQuotation(const nsAReadableString& aCitation,
                                        PRInt32 aSelectionType)
 {
   nsAutoHTMLEditorLogLock logLock(this);
@@ -369,7 +369,7 @@ nsHTMLEditorLog::PasteAsCitedQuotation(const nsString& aCitation,
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::InsertAsQuotation(const nsString& aQuotedText,
+nsHTMLEditorLog::InsertAsQuotation(const nsAReadableString& aQuotedText,
                                    nsIDOMNode **aNodeInserted)
 {
   nsAutoHTMLEditorLogLock logLock(this);
@@ -387,7 +387,7 @@ nsHTMLEditorLog::InsertAsQuotation(const nsString& aQuotedText,
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsString& aQuotedText,
+nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsAReadableString& aQuotedText,
                                             nsIDOMNode **aNodeInserted)
 {
   nsAutoHTMLEditorLogLock logLock(this);
@@ -405,10 +405,10 @@ nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsString& aQuotedText,
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText,
-                                        const nsString& aCitation,
+nsHTMLEditorLog::InsertAsCitedQuotation(const nsAReadableString& aQuotedText,
+                                        const nsAReadableString& aCitation,
                                         PRBool aInsertHTML,
-                                        const nsString& aCharset,
+                                        const nsAReadableString& aCharset,
                                         nsIDOMNode **aNodeInserted)
 {
   nsAutoHTMLEditorLogLock logLock(this);
@@ -429,7 +429,7 @@ nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText,
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::SetBackgroundColor(const nsString& aColor)
+nsHTMLEditorLog::SetBackgroundColor(const nsAReadableString& aColor)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -445,7 +445,7 @@ nsHTMLEditorLog::SetBackgroundColor(const nsString& aColor)
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::SetBodyAttribute(const nsString& aAttr, const nsString& aValue)
+nsHTMLEditorLog::SetBodyAttribute(const nsAReadableString& aAttr, const nsAReadableString& aValue)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -644,7 +644,7 @@ nsHTMLEditorLog::SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMEle
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::MakeOrChangeList(const nsString& aListType, PRBool entireList)
+nsHTMLEditorLog::MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -662,7 +662,7 @@ nsHTMLEditorLog::MakeOrChangeList(const nsString& aListType, PRBool entireList)
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::Indent(const nsString& aIndent)
+nsHTMLEditorLog::Indent(const nsAReadableString& aIndent)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -680,7 +680,7 @@ nsHTMLEditorLog::Indent(const nsString& aIndent)
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::Align(const nsString& aAlign)
+nsHTMLEditorLog::Align(const nsAReadableString& aAlign)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -748,7 +748,7 @@ nsHTMLEditorLog::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)
+nsHTMLEditorLog::ApplyStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -769,7 +769,7 @@ nsHTMLEditorLog::ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyle
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::SetDocumentTitle(const PRUnichar* aTitle)
+nsHTMLEditorLog::SetDocumentTitle(const nsAReadableString& aTitle)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -912,23 +912,25 @@ nsHTMLEditorLog::Flush()
 }
 
 nsresult
-nsHTMLEditorLog::PrintUnicode(const nsString &aString)
+nsHTMLEditorLog::PrintUnicode(const nsAReadableString &aString)
 {
-  const PRUnichar *uc = aString.GetUnicode();
-  PRInt32 i, len = aString.Length();
+  //const PRUnichar *uc = aString.GetUnicode();
   char buf[10];
-
-  for (i = 0; i < len; i++)
+  nsReadingIterator <PRUnichar> beginIter,endIter;
+  aString.BeginReading(beginIter);
+  aString.EndReading(endIter);
+  while(beginIter != endIter)
   {
-    if (nsCRT::IsAsciiAlpha(uc[i]) || nsCRT::IsAsciiDigit(uc[i]) || uc[i] == ' ')
-      sprintf(buf, "%c", uc[i]);
+    if (nsCRT::IsAsciiAlpha(*beginIter) || nsCRT::IsAsciiDigit(*beginIter) || *beginIter == ' ')
+      sprintf(buf, "%c", *beginIter);
     else
-      sprintf(buf, "\\u%.4x", uc[i]);
+      sprintf(buf, "\\u%.4x", *beginIter);
 
     nsresult result = Write(buf);
 
     if (NS_FAILED(result))
       return result;
+    ++beginIter;
   }
 
   return NS_OK;
diff --git a/mozilla/editor/base/nsHTMLEditorLog.h b/mozilla/editor/base/nsHTMLEditorLog.h
index e4dc06639ad..b37719356ff 100644
--- a/mozilla/editor/base/nsHTMLEditorLog.h
+++ b/mozilla/editor/base/nsHTMLEditorLog.h
@@ -54,12 +54,12 @@ public:
 
   /* nsIHTMLEditor method implementations. */
   NS_IMETHOD SetInlineProperty(nsIAtom *aProperty, 
-                               const nsString *aAttribute,
-                               const nsString *aValue);
+                            const nsAReadableString & aAttribute, 
+                            const nsAReadableString & aValue);
   NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat);
-  NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute);
+  NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsAReadableString& aAttribute);
   NS_IMETHOD DeleteSelection(nsIEditor::EDirection aAction);
-  NS_IMETHOD InsertText(const PRUnichar* aStringToInsert);
+  NS_IMETHOD InsertText(const nsAReadableString& aStringToInsert);
   NS_IMETHOD InsertLineBreak();
   NS_IMETHOD Undo(PRUint32 aCount);
   NS_IMETHOD Redo(PRUint32 aCount);
@@ -74,20 +74,22 @@ public:
   NS_IMETHOD Paste(PRInt32 aSelectionType);
   NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType);
   NS_IMETHOD PasteAsPlaintextQuotation(PRInt32 aSelectionType);
-  NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation,
+  NS_IMETHOD PasteAsCitedQuotation(const nsAReadableString& aCitation,
                                    PRInt32 aSelectionType);
-  NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted);
-  NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted);
-  NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation, PRBool aInsertHTML, const nsString& aCharset, nsIDOMNode** aNodeInserted);
+  NS_IMETHOD InsertAsQuotation(const nsAReadableString& aQuotedText, nsIDOMNode** aNodeInserted);
+  NS_IMETHOD InsertAsPlaintextQuotation(const nsAReadableString& aQuotedText, nsIDOMNode** aNodeInserted);
+  NS_IMETHOD InsertAsCitedQuotation(const nsAReadableString& aQuotedText, const nsAReadableString& aCitation, 
+                                    PRBool aInsertHTML, const nsAReadableString& aCharset, 
+                                    nsIDOMNode** aNodeInserted);
 
-  NS_IMETHOD ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet);
-  NS_IMETHOD SetDocumentTitle(const PRUnichar* aTitle);
+  NS_IMETHOD ApplyStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet);
+  NS_IMETHOD SetDocumentTitle(const nsAReadableString& aTitle);
 
-  NS_IMETHOD SetBackgroundColor(const nsString& aColor);
-  NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue);
-  NS_IMETHOD MakeOrChangeList(const nsString& aListType, PRBool entireList);
-  NS_IMETHOD Indent(const nsString& aIndent);
-  NS_IMETHOD Align(const nsString& aAlign);
+  NS_IMETHOD SetBackgroundColor(const nsAReadableString& aColor);
+  NS_IMETHOD SetBodyAttribute(const nsAReadableString& aAttr, const nsAReadableString& aValue);
+  NS_IMETHOD MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList);
+  NS_IMETHOD Indent(const nsAReadableString& aIndent);
+  NS_IMETHOD Align(const nsAReadableString& aAlign);
   NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection);
   NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
   
@@ -112,7 +114,7 @@ public:
   nsresult Write(const char *aBuffer);
   nsresult WriteInt(const char *aFormat, PRInt32 aInt);
   nsresult Flush();
-  nsresult PrintUnicode(const nsString &aString);
+  nsresult PrintUnicode(const nsAReadableString &aString);
   nsresult PrintSelection();
   nsresult PrintNode(nsIDOMNode *aNode, PRInt32 aDepth=0);
   nsresult PrintElementNode(nsIDOMNode *aNode, PRInt32 aDepth);
diff --git a/mozilla/editor/base/nsHTMLEditorStyle.cpp b/mozilla/editor/base/nsHTMLEditorStyle.cpp
index b17f5ff0e1b..fd4f1f45894 100644
--- a/mozilla/editor/base/nsHTMLEditorStyle.cpp
+++ b/mozilla/editor/base/nsHTMLEditorStyle.cpp
@@ -101,8 +101,8 @@ static const PRBool gNoisy = PR_FALSE;
 
 
 NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty, 
-                                            const nsString *aAttribute,
-                                            const nsString *aValue)
+                            const nsAReadableString & aAttribute, 
+                            const nsAReadableString & aValue)
 {
   if (!aProperty) { return NS_ERROR_NULL_POINTER; }
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@@ -120,7 +120,9 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
   if (isCollapsed)
   {
     // manipulating text attributes on a collapsed selection only sets state for the next text insertion
-    return mTypeInState->SetProp(aProperty, *aAttribute, *aValue);
+    nsString tAttr(aAttribute);//MJUDGE SCC NEED HELP
+    nsString tVal(aValue);//MJUDGE SCC NEED HELP
+    return mTypeInState->SetProp(aProperty, tAttr, tVal);
   }
   
   nsAutoEditBatch batchIt(this);
@@ -167,7 +169,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
         range->GetStartOffset(&startOffset);
         range->GetEndOffset(&endOffset);
         nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(startNode);
-        res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, endOffset, aProperty, aAttribute, aValue);
+        res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, endOffset, aProperty, &aAttribute, &aValue);
         if (NS_FAILED(res)) return res;
       }
       else
@@ -232,7 +234,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
           PRUint32 textLen;
           range->GetStartOffset(&startOffset);
           nodeAsText->GetLength(&textLen);
-          res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, textLen, aProperty, aAttribute, aValue);
+          res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, textLen, aProperty, &aAttribute, &aValue);
           if (NS_FAILED(res)) return res;
         }
         
@@ -244,7 +246,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
         {
           isupports = dont_AddRef(arrayOfNodes->ElementAt(0));
           node = do_QueryInterface(isupports);
-          res = SetInlinePropertyOnNode(node, aProperty, aAttribute, aValue);
+          res = SetInlinePropertyOnNode(node, aProperty, &aAttribute, &aValue);
           if (NS_FAILED(res)) return res;
           arrayOfNodes->RemoveElementAt(0);
         }
@@ -257,7 +259,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
           nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(endNode);
           PRInt32 endOffset;
           range->GetEndOffset(&endOffset);
-          res = SetInlinePropertyOnTextNode(nodeAsText, 0, endOffset, aProperty, aAttribute, aValue);
+          res = SetInlinePropertyOnTextNode(nodeAsText, 0, endOffset, aProperty, &aAttribute, &aValue);
           if (NS_FAILED(res)) return res;
         }
       }
@@ -279,8 +281,8 @@ nsHTMLEditor::SetInlinePropertyOnTextNode( nsIDOMCharacterData *aTextNode,
                                             PRInt32 aStartOffset,
                                             PRInt32 aEndOffset,
                                             nsIAtom *aProperty, 
-                                            const nsString *aAttribute,
-                                            const nsString *aValue)
+                                            const nsAReadableString *aAttribute,
+                                            const nsAReadableString *aValue)
 {
   if (!aTextNode) return NS_ERROR_NULL_POINTER;
   
@@ -323,8 +325,8 @@ nsHTMLEditor::SetInlinePropertyOnTextNode( nsIDOMCharacterData *aTextNode,
 nsresult
 nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode,
                                        nsIAtom *aProperty, 
-                                       const nsString *aAttribute,
-                                       const nsString *aValue)
+                                       const nsAReadableString *aAttribute,
+                                       const nsAReadableString *aValue)
 {
   if (!aNode || !aProperty) return NS_ERROR_NULL_POINTER;
 
@@ -430,7 +432,7 @@ nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode,
 
 nsresult nsHTMLEditor::SplitStyleAboveRange(nsIDOMRange *inRange, 
                                             nsIAtom *aProperty, 
-                                            const nsString *aAttribute)
+                                            const nsAReadableString *aAttribute)
 {
   if (!inRange) return NS_ERROR_NULL_POINTER;
   nsresult res;
@@ -474,7 +476,7 @@ nsresult nsHTMLEditor::SplitStyleAboveRange(nsIDOMRange *inRange,
 nsresult nsHTMLEditor::SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode,
                                            PRInt32 *aOffset,
                                            nsIAtom *aProperty,          // null here means we split all properties
-                                           const nsString *aAttribute,
+                                           const nsAReadableString *aAttribute,
                                            nsCOMPtr<nsIDOMNode> *outLeftNode,
                                            nsCOMPtr<nsIDOMNode> *outRightNode)
 {
@@ -508,7 +510,7 @@ PRBool nsHTMLEditor::NodeIsProperty(nsIDOMNode *aNode)
   if (!IsContainer(aNode))  return PR_FALSE;
   if (!IsEditable(aNode))   return PR_FALSE;
   PRBool isBlock (PR_FALSE);
-  NodeIsBlock(aNode, isBlock);
+  NodeIsBlock(aNode, &isBlock);
   if (isBlock) return PR_FALSE;
   if (NodeIsType(aNode, nsIEditProperty::a)) return PR_FALSE;
   return PR_TRUE;
@@ -516,7 +518,7 @@ PRBool nsHTMLEditor::NodeIsProperty(nsIDOMNode *aNode)
 
 nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode, 
                                    nsIAtom *aProperty,   // null here means remove all properties
-                                   const nsString *aAttribute, 
+                                   const nsAReadableString *aAttribute, 
                                    PRBool aChildrenOnly)
 {
   if (!aNode) return NS_ERROR_NULL_POINTER;
@@ -571,7 +573,7 @@ nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode,
 }
 
 PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode, 
-                                     const nsString *aAttribute)
+                                     const nsAReadableString *aAttribute)
 {
   if (!aNode || !aAttribute) return PR_FALSE;  // ooops
   nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
@@ -581,6 +583,7 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
   nsCOMPtr<nsIAtom> attrName, prefix;
   content->GetAttributeCount(attrCount);
   
+  nsString tString(*aAttribute);//MJUDGE SCC NEED HELP
   for (i=0; i<attrCount; i++)
   {
     content->GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attrName),
@@ -589,7 +592,7 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
     if (!attrName) continue;  // ooops
     attrName->ToString(attrString);
     // if it's the attribute we know about, keep looking
-    if (attrString.EqualsIgnoreCase(*aAttribute)) continue;
+    if (attrString.EqualsIgnoreCase(tString)) continue;
     // if it's a special _moz... attribute, keep looking
     attrString.Left(tmp,4);
     if (tmp.EqualsWithConversion("_moz")) continue;
@@ -656,7 +659,7 @@ nsHTMLEditor::HasMatchingAttributes(nsIDOMNode *aNode1,
 }
 
 PRBool nsHTMLEditor::HasAttr(nsIDOMNode *aNode, 
-                             const nsString *aAttribute)
+                             const nsAReadableString *aAttribute)
 {
   if (!aNode) return PR_FALSE;
   if (!aAttribute || aAttribute->IsEmpty()) return PR_TRUE;  // everybody has the 'null' attribute
@@ -674,8 +677,8 @@ PRBool nsHTMLEditor::HasAttr(nsIDOMNode *aNode,
 
 
 PRBool nsHTMLEditor::HasAttrVal(nsIDOMNode *aNode, 
-                                const nsString *aAttribute, 
-                                const nsString *aValue)
+                                const nsAReadableString *aAttribute, 
+                                const nsAReadableString *aValue)
 {
   if (!aNode) return PR_FALSE;
   if (!aAttribute || aAttribute->IsEmpty()) return PR_TRUE;  // everybody has the 'null' attribute
@@ -700,7 +703,8 @@ PRBool nsHTMLEditor::HasAttrVal(nsIDOMNode *aNode,
   attNode->GetValue(attrVal);
   
   // do values match?
-  if (attrVal.EqualsIgnoreCase(*aValue)) return PR_TRUE;
+  nsString tString(*aValue);//MJUDGE SCC NEED HELP
+  if (attrVal.EqualsIgnoreCase(tString)) return PR_TRUE;
   return PR_FALSE;
 }
 
@@ -792,23 +796,15 @@ PRBool nsHTMLEditor::IsAtEndOfNode(nsIDOMNode *aNode, PRInt32 aOffset)
   }
 }
 
-NS_IMETHODIMP nsHTMLEditor::GetInlineProperty(nsIAtom *aProperty, 
-                                              const nsString *aAttribute, 
-                                              const nsString *aValue,
-                                              PRBool &aFirst, 
-                                              PRBool &aAny, 
-                                              PRBool &aAll)
-{
-  return GetInlinePropertyWithAttrValue( aProperty, aAttribute, aValue, aFirst, aAny, aAll, nsnull);
-}
 
-NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty, 
-                                              const nsString *aAttribute, 
-                                              const nsString *aValue,
-                                              PRBool &aFirst, 
-                                              PRBool &aAny, 
-                                              PRBool &aAll,
-                                              nsString *outValue)
+nsresult
+nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty, 
+                             const nsAReadableString *aAttribute,
+                             const nsAReadableString *aValue,
+                             PRBool *aFirst, 
+                             PRBool *aAny, 
+                             PRBool *aAll,
+                             nsAWritableString *outValue)
 {
   if (!aProperty)
     return NS_ERROR_NULL_POINTER;
@@ -823,9 +819,9 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
   }
 */
   nsresult result;
-  aAny=PR_FALSE;
-  aAll=PR_TRUE;
-  aFirst=PR_FALSE;
+  *aAny=PR_FALSE;
+  *aAll=PR_TRUE;
+  *aFirst=PR_FALSE;
   PRBool first=PR_TRUE;
   nsCOMPtr<nsISelection>selection;
   result = GetSelection(getter_AddRefs(selection));
@@ -863,12 +859,21 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
       // cache now current, use it!  But override it with typeInState results if any...
       PRBool isSet, theSetting;
       if (aAttribute)
-        mTypeInState->GetTypingState(isSet, theSetting, aProperty, *aAttribute, outValue);
+      {
+        nsString tString(*aAttribute); //MJUDGE SCC NEED HELP
+        nsString tOutString;//MJUDGE SCC NEED HELP
+        nsString *tPassString=nsnull;
+        if (outValue)
+            tPassString = &tOutString;
+        mTypeInState->GetTypingState(isSet, theSetting, aProperty, tString, &tOutString);
+        if (outValue)
+          outValue->Assign(tOutString);
+      }
       else
         mTypeInState->GetTypingState(isSet, theSetting, aProperty);
       if (isSet) 
       {
-        aFirst = aAny = aAll = theSetting;
+        *aFirst = *aAny = *aAll = theSetting;
         return NS_OK;
       }
       /*
@@ -877,11 +882,11 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
         mTypeInState->GetTypingState(isSet, theSetting, aProperty);
         if (isSet) 
         {
-          aFirst = aAny = aAll = theSetting;
+          *aFirst = *aAny = *aAll = theSetting;
         }
         else
         {
-          aFirst = aAny = aAll = mCachedBoldStyle;
+          *aFirst = *aAny = *aAll = mCachedBoldStyle;
         }
         return NS_OK;
       }
@@ -890,11 +895,11 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
         mTypeInState->GetTypingState(isSet, theSetting, aProperty);
         if (isSet) 
         {
-          aFirst = aAny = aAll = theSetting;
+          *aFirst = *aAny = *aAll = theSetting;
         }
         else
         {
-          aFirst = aAny = aAll = mCachedItalicStyle;
+          *aFirst = *aAny = *aAll = mCachedItalicStyle;
         }
         return NS_OK;
       }
@@ -903,11 +908,11 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
         mTypeInState->GetTypingState(isSet, theSetting, aProperty);
         if (isSet) 
         {
-          aFirst = aAny = aAll = theSetting;
+          *aFirst = *aAny = *aAll = theSetting;
         }
         else
         {
-          aFirst = aAny = aAll = mCachedUnderlineStyle;
+          *aFirst = *aAny = *aAll = mCachedUnderlineStyle;
         }
         return NS_OK;
       } */
@@ -975,7 +980,7 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
           if (first)
           {
             IsTextPropertySetByContent(node, aProperty, aAttribute, aValue, isSet, getter_AddRefs(resultNode), &firstValue);
-            aFirst = isSet;
+            *aFirst = isSet;
             first = PR_FALSE;
             if (outValue) *outValue = firstValue;
           }
@@ -983,14 +988,14 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
           {
             IsTextPropertySetByContent(node, aProperty, aAttribute, aValue, isSet, getter_AddRefs(resultNode), &theValue);
             if (firstValue != theValue)
-              aAll = PR_FALSE;
+              *aAll = PR_FALSE;
           }
           
           if (isSet) {
-            aAny = PR_TRUE;
+            *aAny = PR_TRUE;
           }
           else {
-            aAll = PR_FALSE;
+            *aAll = PR_FALSE;
           }
         }
       }
@@ -1000,26 +1005,65 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
       iter->CurrentNode(getter_AddRefs(content));
     }
   }
-  if (!aAny) 
+  if (!*aAny) 
   { // make sure that if none of the selection is set, we don't report all is set
-    aAll = PR_FALSE;
+    *aAll = PR_FALSE;
   }
-  //if (gNoisy) { printf("  returning first=%d any=%d all=%d\n", aFirst, aAny, aAll); }
+  //if (gNoisy) { printf("  returning first=%d any=%d all=%d\n", *aFirst, *aAny, *aAll); }
   return result;
 }
 
 
+NS_IMETHODIMP nsHTMLEditor::GetInlineProperty(nsIAtom *aProperty, 
+                                              const nsAReadableString &aAttribute, 
+                                              const nsAReadableString &aValue,
+                                              PRBool *aFirst, 
+                                              PRBool *aAny, 
+                                              PRBool *aAll)
+{
+  if (!aProperty || !aFirst || !aAny || !aAll)
+    return NS_ERROR_NULL_POINTER;
+  const nsAReadableString *att = nsnull;
+  if (aAttribute.Length())
+    att = &aAttribute;
+  const nsAReadableString *val = nsnull;
+  if (aValue.Length())
+    val = &aValue;
+  return GetInlinePropertyBase( aProperty, att, val, aFirst, aAny, aAll, nsnull);
+}
+
+
+NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty, 
+                                              const nsAReadableString &aAttribute, 
+                                              const nsAReadableString &aValue,
+                                              PRBool *aFirst, 
+                                              PRBool *aAny, 
+                                              PRBool *aAll,
+                                              nsAWritableString &outValue)
+{
+  if (!aProperty || !aFirst || !aAny || !aAll)
+    return NS_ERROR_NULL_POINTER;
+  const nsAReadableString *att = nsnull;
+  if (aAttribute.Length())
+    att = &aAttribute;
+  const nsAReadableString *val = nsnull;
+  if (aValue.Length())
+    val = &aValue;
+  return GetInlinePropertyBase( aProperty, att, val, aFirst, aAny, aAll, &outValue);
+}
+
+
 NS_IMETHODIMP nsHTMLEditor::RemoveAllInlineProperties()
 {
   return RemoveInlinePropertyImpl(nsnull, nsnull);
 }
 
-NS_IMETHODIMP nsHTMLEditor::RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute)
+NS_IMETHODIMP nsHTMLEditor::RemoveInlineProperty(nsIAtom *aProperty, const nsAReadableString &aAttribute)
 {
-  return RemoveInlinePropertyImpl(aProperty, aAttribute);
+  return RemoveInlinePropertyImpl(aProperty, &aAttribute);
 }
 
-nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsString *aAttribute)
+nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAReadableString *aAttribute)
 {
   if (!mRules)    return NS_ERROR_NOT_INITIALIZED;
   ForceCompositionEnd();
@@ -1041,7 +1085,7 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsStri
     if (aProperty == nsIEditProperty::href)
       aProperty = nsIEditProperty::a;
 
-    if (aProperty) return mTypeInState->ClearProp(aProperty, *aAttribute);
+    if (aProperty) return mTypeInState->ClearProp(aProperty, nsAutoString(*aAttribute));
     else return mTypeInState->ClearAllProps();
   }
   nsAutoEditBatch batchIt(this);
@@ -1428,66 +1472,73 @@ nsHTMLEditor::RelativeFontChangeOnNode( PRInt32 aSizeChange,
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::GetFontFaceState(PRBool &aMixed, nsString &outFace)
+nsHTMLEditor::GetFontFaceState(PRBool *aMixed, nsAWritableString &outFace)
 {
-  aMixed = PR_TRUE;
-  outFace.AssignWithConversion("");
-  
+  if (!aMixed)
+      return NS_ERROR_FAILURE;
+  *aMixed = PR_TRUE;
+  //outFace.AssignWithConversion("");
+  outFace.SetLength(0);
+
   nsresult res;
-  nsAutoString faceStr; faceStr.AssignWithConversion("face");
+  nsAutoString faceStr;
+  faceStr.AssignWithConversion("face");
   PRBool first, any, all;
   
-  res = GetInlinePropertyWithAttrValue(nsIEditProperty::font, &faceStr, nsnull, first, any, all, &outFace);
+  
+  res = GetInlinePropertyBase(nsIEditProperty::font, &faceStr, nsnull, &first, &any, &all, &outFace);
   if (NS_FAILED(res)) return res;
   if (any && !all) return res; // mixed
   if (all)
   {
-    aMixed = PR_FALSE;
+    *aMixed = PR_FALSE;
     return res;
   }
   
-  res = GetInlineProperty(nsIEditProperty::tt, nsnull, nsnull, first, any, all);
+  res = GetInlinePropertyBase(nsIEditProperty::tt, nsnull, nsnull, &first, &any, &all,nsnull);
   if (NS_FAILED(res)) return res;
   if (any && !all) return res; // mixed
   if (all)
   {
-    aMixed = PR_FALSE;
+    *aMixed = PR_FALSE;
     nsIEditProperty::tt->ToString(outFace);
   }
   
   if (!any)
   {
     // there was no font face attrs of any kind.  We are in normal font.
-    outFace.AssignWithConversion("");
-    aMixed = PR_FALSE;
+    outFace.SetLength(0);
+    *aMixed = PR_FALSE;
   }
   return res;
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::GetFontColorState(PRBool &aMixed, nsString &aOutColor)
+nsHTMLEditor::GetFontColorState(PRBool *aMixed, nsAWritableString &aOutColor)
 {
-  aMixed = PR_TRUE;
-  aOutColor.AssignWithConversion("");
+  if (!aMixed)
+      return NS_ERROR_NULL_POINTER;
+  *aMixed = PR_TRUE;
+  aOutColor.SetLength(0);
   
   nsresult res;
   nsAutoString colorStr; colorStr.AssignWithConversion("color");
   PRBool first, any, all;
   
-  res = GetInlinePropertyWithAttrValue(nsIEditProperty::font, &colorStr, nsnull, first, any, all, &aOutColor);
+  res = GetInlinePropertyBase(nsIEditProperty::font, &colorStr, nsnull, &first, &any, &all, &aOutColor);
   if (NS_FAILED(res)) return res;
   if (any && !all) return res; // mixed
   if (all)
   {
-    aMixed = PR_FALSE;
+    *aMixed = PR_FALSE;
     return res;
   }
   
   if (!any)
   {
     // there was no font color attrs of any kind..
-    aOutColor.AssignWithConversion("");
-    aMixed = PR_FALSE;
+    aOutColor.SetLength(0);
+    *aMixed = PR_FALSE;
   }
   return res;
 }
diff --git a/mozilla/editor/base/nsIHTMLEditRules.h b/mozilla/editor/base/nsIHTMLEditRules.h
index 4289b52fbfe..f3454ac9189 100644
--- a/mozilla/editor/base/nsIHTMLEditRules.h
+++ b/mozilla/editor/base/nsIHTMLEditRules.h
@@ -35,11 +35,11 @@ class nsIHTMLEditRules : public nsISupports
 public:
   static const nsIID& GetIID() { static nsIID iid = NS_IHTMLEDITRULES_IID; return iid; }
   
-  NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL)=0;
-  NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD)=0;
-  NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)=0;
-  NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)=0;
-  NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat)=0;
+  NS_IMETHOD GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL)=0;
+  NS_IMETHOD GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD)=0;
+  NS_IMETHOD GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent)=0;
+  NS_IMETHOD GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign)=0;
+  NS_IMETHOD GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat)=0;
 };
 
 
diff --git a/mozilla/editor/base/nsInternetCiter.cpp b/mozilla/editor/base/nsInternetCiter.cpp
index 97fd76cdb09..1b629b15760 100644
--- a/mozilla/editor/base/nsInternetCiter.cpp
+++ b/mozilla/editor/base/nsInternetCiter.cpp
@@ -21,9 +21,9 @@
  *   Pierre Phaneuf <pp@ludusdesign.com>
  */
 
-#include "nsInternetCiter.h"
 
 #include "nsString.h"
+#include "nsInternetCiter.h"
 
 #include "nsCOMPtr.h"
 
@@ -76,7 +76,7 @@ nsInternetCiter::QueryInterface(REFNSIID aIID, void** aInstancePtr)
 }
 
 NS_IMETHODIMP
-nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
+nsInternetCiter::GetCiteString(const nsAReadableString& aInString, nsAWritableString& aOutString)
 {
   PRInt32 i = 0;
   PRInt32 length = aInString.Length();
@@ -85,9 +85,10 @@ nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
 
   // Strip trailing new lines which will otherwise turn up
   // as ugly quoted empty lines.
+  nsString tString(aInString); //CRAPCRAP
   while(length > 0 &&
-        (aInString[length-1] == cr ||
-         aInString[length-1] == nl))
+        (tString[length-1] == cr ||
+         tString[length-1] == nl))
   {
     --length;
   }
@@ -100,11 +101,11 @@ nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
       aOutString.Append(gt);
       // No space between >: this is ">>> " style quoting, for
       // compatability with RFC 2646 and format=flowed.
-      if (aInString[i] != gt)
+      if (tString[i] != gt)
         aOutString.Append(space);
     }
 
-    uch = aInString[i++];
+    uch = tString[i++];
 
     aOutString += uch;
   }
@@ -116,8 +117,8 @@ nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
 }
 
 nsresult
-nsInternetCiter::StripCitesAndLinebreaks(const nsString& aInString,
-                                         nsString& aOutString,
+nsInternetCiter::StripCitesAndLinebreaks(const nsAReadableString& aInString,
+                                         nsAWritableString& aOutString,
                                          PRBool aLinebreaksToo,
                                          PRInt32* aCiteLevel)
 {
@@ -126,36 +127,37 @@ nsInternetCiter::StripCitesAndLinebreaks(const nsString& aInString,
 
   aOutString.SetLength(0);
 
-  PRInt32 length = aInString.Length();
+  nsString tString(aInString);//CRAPCRAP
+  PRInt32 length = tString.Length();
   PRInt32 i = 0;
   while (i < length)  // loop over lines
   {
     // Clear out cites first, at the beginning of the line:
     PRInt32 thisLineCiteLevel = 0;
-    while (aInString[i] == gt || nsCRT::IsAsciiSpace(aInString[i]))
+    while (tString[i] == gt || nsCRT::IsAsciiSpace(tString[i]))
     {
-      if (aInString[i] == gt) ++thisLineCiteLevel;
+      if (tString[i] == gt) ++thisLineCiteLevel;
       ++i;
     }
 
     // Now copy characters until line end:
-    PRInt32 nextNewline = aInString.FindCharInSet("\r\n", i);
+    PRInt32 nextNewline = tString.FindCharInSet("\r\n", i);
     if (nextNewline > i)
     {
       while (i < nextNewline)
-        aOutString.Append(aInString[i++]);
+        aOutString.Append(tString[i++]);
       if (aLinebreaksToo)
-        aOutString.AppendWithConversion(' ');
+        aOutString.Append(PRUnichar(' '));
       else
-        aOutString.AppendWithConversion('\n');    // DOM linebreaks, not NS_LINEBREAK
+        aOutString.Append(PRUnichar('\n'));    // DOM linebreaks, not NS_LINEBREAK
       // Skip over any more consecutive linebreak-like characters:
-      while (i < length && (aInString[i] == '\r' || aInString[i] == '\n'))
+      while (i < length && (tString[i] == '\r' || tString[i] == '\n'))
         ++i;
     }
     else    // no more newlines
     {
       while (i < length)
-        aOutString.Append(aInString[i++]);
+        aOutString.Append(tString[i++]);
     }
 
     // Done with this line -- update cite level
@@ -166,24 +168,24 @@ nsInternetCiter::StripCitesAndLinebreaks(const nsString& aInString,
 }
 
 NS_IMETHODIMP
-nsInternetCiter::StripCites(const nsString& aInString, nsString& aOutString)
+nsInternetCiter::StripCites(const nsAReadableString& aInString, nsAWritableString& aOutString)
 {
   return StripCitesAndLinebreaks(aInString, aOutString, PR_FALSE, 0);
 }
 
-static void AddCite(nsString& aOutString, PRInt32 citeLevel)
+static void AddCite(nsAWritableString& aOutString, PRInt32 citeLevel)
 {
   for (PRInt32 i = 0; i < citeLevel; ++i)
-    aOutString.Append(gt);
+    aOutString.Append(PRUnichar(gt));
   if (citeLevel > 0)
-    aOutString.Append(space);
+    aOutString.Append(PRUnichar(space));
 }
 
 NS_IMETHODIMP
-nsInternetCiter::Rewrap(const nsString& aInString,
+nsInternetCiter::Rewrap(const nsAReadableString& aInString,
                         PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
                         PRBool aRespectNewlines,
-                        nsString& aOutString)
+                        nsAWritableString& aOutString)
 {
   nsCOMPtr<nsILineBreaker> lineBreaker;
   nsILineBreakerFactory *lf;
@@ -205,21 +207,21 @@ nsInternetCiter::Rewrap(const nsString& aInString,
   PRUint32 posInString = 0;
   PRUint32 outStringCol = 0;
   PRUint32 citeLevel = 0;
-  const PRUnichar* unicodeStr = aInString.GetUnicode();
+  const nsPromiseFlatString &tString = PromiseFlatString(aInString);//MJUDGE SCC NEED HELP
   while (posInString < length)
   {
 #ifdef DEBUG_wrapping
-    nsAutoString debug (nsPromiseSubstring<PRUnichar>(aInString, posInString, length-posInString));
+    nsAutoString debug (nsPromiseSubstring<PRUnichar>(tString, posInString, length-posInString));
     printf("Outer loop: '%s'\n", debug.ToNewCString());
 #endif
 
     // Get the new cite level here since we're at the beginning of a line
     PRUint32 newCiteLevel = 0;
-    while (posInString < length && aInString[posInString] == gt)
+    while (posInString < length && tString[posInString] == gt)
     {
       ++newCiteLevel;
       ++posInString;
-      while (posInString < length && aInString[posInString] == space)
+      while (posInString < length && tString[posInString] == space)
         ++posInString;
     }
     if (posInString >= length)
@@ -227,9 +229,12 @@ nsInternetCiter::Rewrap(const nsString& aInString,
 
     // Special case: if this is a blank line, maintain a blank line
     // (retain the original paragraph breaks)
-    if (aInString[posInString] == nl)
+    if (tString[posInString] == nl)
     {
-      if (aOutString.Length() > 0 && aOutString[aOutString.Length()-1] != nl)
+      nsReadingIterator <PRUnichar> outPeekIter;
+      aOutString.EndReading(outPeekIter);
+      outPeekIter.advance(-1);
+      if (aOutString.Length() > 0 && (*outPeekIter) != nl)
         aOutString.Append(nl);
       AddCite(aOutString, newCiteLevel);
       aOutString.Append(nl);
@@ -267,12 +272,12 @@ nsInternetCiter::Rewrap(const nsString& aInString,
       printf("Appending space; citeLevel=%d, outStringCol=%d\n", citeLevel,
              outStringCol);
 #endif
-      aOutString.Append(space);
+      aOutString.Append(PRUnichar(space));
       ++outStringCol;
     }
 
     // find the next newline -- don't want to go farther than that
-    PRInt32 nextNewline = aInString.FindChar(nl, PR_FALSE, posInString);
+    PRInt32 nextNewline = tString.FindChar(nl, posInString);
     if (nextNewline < 0) nextNewline = length;
 
     // For now, don't wrap unquoted lines at all.
@@ -285,11 +290,11 @@ nsInternetCiter::Rewrap(const nsString& aInString,
     if (citeLevel == 0)
     {
 #ifdef DEBUG_wrapping
-      nsAutoString debug (nsPromiseSubstring<PRUnichar>(aInString, posInString,
+      nsAutoString debug (nsPromiseSubstring<PRUnichar>(tString, posInString,
                                     nextNewline-posInString));
       printf("Unquoted: appending '%s'\n", debug.ToNewCString());
 #endif
-      aOutString.Append(nsPromiseSubstring(aInString, posInString,
+      aOutString.Append(nsPromiseSubstring(tString, posInString,
                                   nextNewline-posInString));
       outStringCol += nextNewline - posInString;
       if (nextNewline != (PRInt32)length)
@@ -309,7 +314,7 @@ nsInternetCiter::Rewrap(const nsString& aInString,
     while ((PRInt32)posInString < nextNewline)
     {
 #ifdef DEBUG_wrapping
-      nsAutoString debug (nsPromiseSubstring<PRUnichar>(aInString, posInString, nextNewline-posInString));
+      nsAutoString debug (nsPromiseSubstring<PRUnichar>(tString, posInString, nextNewline-posInString));
       printf("Inner loop: '%s'\n", debug.ToNewCString());
 #endif
 
@@ -318,13 +323,13 @@ nsInternetCiter::Rewrap(const nsString& aInString,
       {
         // If this short line is the final one in the in string,
         // then we need to include the final newline, if any:
-        if (nextNewline+1 == (PRInt32)length && aInString[nextNewline-1] == nl)
+        if (nextNewline+1 == (PRInt32)length && tString[nextNewline-1] == nl)
           ++nextNewline;
 #ifdef DEBUG_wrapping
-        nsAutoString debug (nsPromiseSubstring<PRUnichar>(aInString, posInString, nextNewline - posInString));
+        nsAutoString debug (nsPromiseSubstring<PRUnichar>(tString, posInString, nextNewline - posInString));
         printf("Short line: '%s'\n", debug.ToNewCString());
 #endif
-        aOutString += nsPromiseSubstring(aInString,
+        aOutString += nsPromiseSubstring(tString,
                                 posInString, nextNewline - posInString);
         outStringCol += nextNewline - posInString;
         posInString = nextNewline + 1;
@@ -339,13 +344,13 @@ nsInternetCiter::Rewrap(const nsString& aInString,
       rv = NS_ERROR_BASE;
       if (lineBreaker)
       {
-        rv = lineBreaker->Prev(unicodeStr + posInString, length - posInString,
+        rv = lineBreaker->Prev(tString.get() + posInString, length - posInString,
                                eol - posInString, &breakPt, &needMore);
         if (NS_FAILED(rv) || needMore)
         {
           // if we couldn't find a breakpoint looking backwards,
           // try looking forwards:
-          rv = lineBreaker->Next(unicodeStr + posInString,
+          rv = lineBreaker->Next(tString.get() + posInString,
                                  length - posInString,
                                  eol - posInString, &breakPt, &needMore);
           if (needMore) rv = NS_ERROR_BASE;
@@ -365,7 +370,7 @@ nsInternetCiter::Rewrap(const nsString& aInString,
       printf("breakPt = %d\n", breakPt);
 #endif
 
-      aOutString += nsPromiseSubstring(aInString, posInString, breakPt);
+      aOutString += nsPromiseSubstring(tString, posInString, breakPt);
       posInString += breakPt;
       outStringCol += breakPt;
 
diff --git a/mozilla/editor/base/nsInternetCiter.h b/mozilla/editor/base/nsInternetCiter.h
index 0ee7bc9a7b2..2fe6f8b0540 100644
--- a/mozilla/editor/base/nsInternetCiter.h
+++ b/mozilla/editor/base/nsInternetCiter.h
@@ -38,17 +38,17 @@ public:
 //NOTE: Use   NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
   NS_DECL_ISUPPORTS
 
-  NS_IMETHOD GetCiteString(const nsString& aInString, nsString& aOutString);
+  NS_IMETHOD GetCiteString(const nsAReadableString & aInString, nsAWritableString & aOutString);
 
-  NS_IMETHOD StripCites(const nsString& aInString, nsString& aOutString);
+  NS_IMETHOD StripCites(const nsAReadableString & aInString, nsAWritableString & aOutString);
 
-  NS_IMETHOD Rewrap(const nsString& aInString,
+  NS_IMETHOD Rewrap(const nsAReadableString & aInString,
                     PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
                     PRBool aRespectNewlines,
-                    nsString& aOutString);
+                    nsAWritableString & aOutString);
 
 protected:
-  nsresult StripCitesAndLinebreaks(const nsString& aInString, nsString& aOutString,
+  nsresult StripCitesAndLinebreaks(const nsAReadableString& aInString, nsAWritableString& aOutString,
                                    PRBool aLinebreaksToo, PRInt32* aCiteLevel);
 };
 
diff --git a/mozilla/editor/base/nsPlaintextDataTransfer.cpp b/mozilla/editor/base/nsPlaintextDataTransfer.cpp
index 227887e6e9b..39fa66f4104 100644
--- a/mozilla/editor/base/nsPlaintextDataTransfer.cpp
+++ b/mozilla/editor/base/nsPlaintextDataTransfer.cpp
@@ -160,7 +160,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertTextFromTransferable(nsITransferable *tra
         textDataObj->ToString ( &text );
         stuffToPaste.Assign ( text, len / 2 );
         nsAutoEditBatch beginBatching(this);
-        rv = InsertText(stuffToPaste.GetUnicode());
+        rv = InsertText(stuffToPaste);
         if (text)
           nsMemory::Free(text);
       }
@@ -355,12 +355,14 @@ NS_IMETHODIMP nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
   return rv;
 }
 
-NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag)
+NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag)
 {
+  if (!aCanDrag)
+    return NS_ERROR_NULL_POINTER;
   /* we really should be checking the XY coordinates of the mouseevent and ensure that
    * that particular point is actually within the selection (not just that there is a selection)
    */
-  aCanDrag = PR_FALSE;
+  *aCanDrag = PR_FALSE;
  
   // KLUDGE to work around bug 50703
   // After double click and object property editing, 
@@ -395,7 +397,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDr
       res = selection->ContainsNode(eventTargetDomNode, PR_FALSE, &amTargettedCorrectly);
       if (NS_FAILED(res)) return res;
 
-    	aCanDrag = amTargettedCorrectly;
+    	*aCanDrag = amTargettedCorrectly;
     }
   }
 
@@ -532,9 +534,11 @@ NS_IMETHODIMP nsPlaintextEditor::Paste(PRInt32 aSelectionType)
 }
 
 
-NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste)
+NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste)
 {
-  aCanPaste = PR_FALSE;
+  if (!aCanPaste)
+    return NS_ERROR_NULL_POINTER;
+  *aCanPaste = PR_FALSE;
   
   // can't paste if readonly
   if (!IsModifiable())
@@ -572,6 +576,6 @@ NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPa
   rv = clipboard->HasDataMatchingFlavors(flavorsList, aSelectionType, &haveFlavors);
   if (NS_FAILED(rv)) return rv;
   
-  aCanPaste = haveFlavors;
+  *aCanPaste = haveFlavors;
   return NS_OK;
 }
diff --git a/mozilla/editor/base/nsPlaintextEditor.cpp b/mozilla/editor/base/nsPlaintextEditor.cpp
index 507487a7e7f..99543dd594b 100644
--- a/mozilla/editor/base/nsPlaintextEditor.cpp
+++ b/mozilla/editor/base/nsPlaintextEditor.cpp
@@ -245,7 +245,7 @@ nsPlaintextEditor::EndEditorInit()
 }
 
 NS_IMETHODIMP 
-nsPlaintextEditor::SetDocumentCharacterSet(const PRUnichar* characterSet) 
+nsPlaintextEditor::SetDocumentCharacterSet(const nsAReadableString & characterSet) 
 { 
   nsresult result; 
 
@@ -312,7 +312,7 @@ nsPlaintextEditor::SetDocumentCharacterSet(const PRUnichar* characterSet)
               return NS_ERROR_FAILURE; 
 
             // Set attributes to the created element 
-            if (resultNode && nsCRT::strlen(characterSet) > 0) { 
+            if (resultNode && characterSet.Length() > 0) { 
               metaElement = do_QueryInterface(resultNode); 
               if (metaElement) { 
                 // not undoable, undo should undo CreateNode 
@@ -505,19 +505,19 @@ NS_IMETHODIMP nsPlaintextEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
      || keyCode == nsIDOMKeyEvent::DOM_VK_ENTER)
     {
       nsString empty;
-      return TypedText(empty.GetUnicode(), eTypedBreak);
+      return TypedText(empty, eTypedBreak);
     }
     else if (keyCode == nsIDOMKeyEvent::DOM_VK_ESCAPE)
     {
       // pass escape keypresses through as empty strings: needed for ime support
       nsString empty;
-      return TypedText(empty.GetUnicode(), eTypedText);
+      return TypedText(empty, eTypedText);
     }
     
     if (character && !altKey && !ctrlKey && !isShift && !metaKey)
     {
       nsAutoString key(character);
-      return TypedText(key.GetUnicode(), eTypedText);
+      return TypedText(key, eTypedText);
     }
   }
   return NS_ERROR_FAILURE;
@@ -529,7 +529,7 @@ NS_IMETHODIMP nsPlaintextEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
    to TypedText() to determine what action to take, but without passing
    an event.
    */
-NS_IMETHODIMP nsPlaintextEditor::TypedText(const PRUnichar* aString,
+NS_IMETHODIMP nsPlaintextEditor::TypedText(const nsAReadableString& aString,
                                       PRInt32 aAction)
 {
   nsAutoPlaceHolderBatch batch(this, gTypingTxnName);
@@ -944,7 +944,7 @@ NS_IMETHODIMP nsPlaintextEditor::DeleteSelection(nsIEditor::EDirection aAction)
   return result;
 }
 
-NS_IMETHODIMP nsPlaintextEditor::InsertText(const PRUnichar* aStringToInsert)
+NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAReadableString &aStringToInsert)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
@@ -967,9 +967,9 @@ NS_IMETHODIMP nsPlaintextEditor::InsertText(const PRUnichar* aStringToInsert)
   nsAutoString resultString;
   // XXX can we trust instring to outlive ruleInfo,
   // XXX and ruleInfo not to refer to instring in its dtor?
-  nsAutoString instring(aStringToInsert);
+  //nsAutoString instring(aStringToInsert);
   nsTextRulesInfo ruleInfo(theAction);
-  ruleInfo.inString = &instring;
+  ruleInfo.inString = &aStringToInsert;
   ruleInfo.outString = &resultString;
   ruleInfo.maxLength = mMaxTextLength;
 
@@ -1361,9 +1361,11 @@ NS_IMETHODIMP nsPlaintextEditor::Cut()
   return res;
 }
 
-NS_IMETHODIMP nsPlaintextEditor::CanCut(PRBool &aCanCut)
+NS_IMETHODIMP nsPlaintextEditor::CanCut(PRBool *aCanCut)
 {
-  aCanCut = PR_FALSE;
+  if (!aCanCut)
+    return NS_ERROR_NULL_POINTER;
+  *aCanCut = PR_FALSE;
   
   nsCOMPtr<nsISelection> selection;
   nsresult res = GetSelection(getter_AddRefs(selection));
@@ -1373,7 +1375,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanCut(PRBool &aCanCut)
   res = selection->GetIsCollapsed(&isCollapsed);
   if (NS_FAILED(res)) return res;
 
-  aCanCut = !isCollapsed && IsModifiable();
+  *aCanCut = !isCollapsed && IsModifiable();
   return NS_OK;
 }
 
@@ -1385,9 +1387,11 @@ NS_IMETHODIMP nsPlaintextEditor::Copy()
   return ps->DoCopy();
 }
 
-NS_IMETHODIMP nsPlaintextEditor::CanCopy(PRBool &aCanCopy)
+NS_IMETHODIMP nsPlaintextEditor::CanCopy(PRBool *aCanCopy)
 {
-  aCanCopy = PR_FALSE;
+  if (!aCanCopy)
+    return NS_ERROR_NULL_POINTER;
+  *aCanCopy = PR_FALSE;
   
   nsCOMPtr<nsISelection> selection;
   nsresult res = GetSelection(getter_AddRefs(selection));
@@ -1397,7 +1401,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanCopy(PRBool &aCanCopy)
   res = selection->GetIsCollapsed(&isCollapsed);
   if (NS_FAILED(res)) return res;
 
-  aCanCopy = !isCollapsed;
+  *aCanCopy = !isCollapsed;
   return NS_OK;
 }
 
@@ -1406,7 +1410,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanCopy(PRBool &aCanCopy)
 NS_IMETHODIMP
 nsPlaintextEditor::GetAndInitDocEncoder(const nsAReadableString& aFormatType,
                                         PRUint32 aFlags,
-                                        const nsAReadableString* aCharset,
+                                        const nsAReadableString& aCharset,
                                         nsIDocumentEncoder** encoder)
 {
   nsCOMPtr<nsIPresShell> presShell;
@@ -1426,9 +1430,9 @@ nsPlaintextEditor::GetAndInitDocEncoder(const nsAReadableString& aFormatType,
   rv = docEncoder->Init(doc, aFormatType, aFlags);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (aCharset && aCharset->Length() != 0
-      && !(aCharset->Equals(NS_LITERAL_STRING("null"))))
-    docEncoder->SetCharset(*aCharset);
+  if (aCharset.Length() != 0
+    && !(aCharset.Equals(NS_LITERAL_STRING("null"))))
+    docEncoder->SetCharset(aCharset);
 
   PRInt32 wc;
   (void) GetWrapWidth(&wc);
@@ -1512,7 +1516,7 @@ nsPlaintextEditor::OutputToString(nsAWritableString& aOutputString,
   }
 
   nsCOMPtr<nsIDocumentEncoder> encoder;
-  rv = GetAndInitDocEncoder(aFormatType, aFlags, 0, getter_AddRefs(encoder));
+  rv = GetAndInitDocEncoder(aFormatType, aFlags, NS_LITERAL_STRING(""), getter_AddRefs(encoder));
   if (NS_FAILED(rv))
     return rv;
   rv = encoder->EncodeToString(aOutputString);
@@ -1522,7 +1526,7 @@ nsPlaintextEditor::OutputToString(nsAWritableString& aOutputString,
 NS_IMETHODIMP
 nsPlaintextEditor::OutputToStream(nsIOutputStream* aOutputStream,
                              const nsAReadableString& aFormatType,
-                             const nsAReadableString* aCharset,
+                             const nsAReadableString& aCharset,
                              PRUint32 aFlags)
 {
   nsresult rv;
@@ -1647,7 +1651,7 @@ static nsICiter* MakeACiter()
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::InsertAsQuotation(const nsString& aQuotedText,
+nsPlaintextEditor::InsertAsQuotation(const nsAReadableString& aQuotedText,
                                      nsIDOMNode **aNodeInserted)
 {
   // We have the text.  Cite it appropriately:
@@ -1681,7 +1685,7 @@ nsPlaintextEditor::InsertAsQuotation(const nsString& aQuotedText,
   if (cancel) return NS_OK; // rules canceled the operation
   if (!handled)
   {
-    rv = InsertText(quotedStuff.GetUnicode());
+    rv = InsertText(quotedStuff);
 
     // XXX Should set *aNodeInserted to the first node inserted
     if (aNodeInserted && NS_SUCCEEDED(rv))
@@ -1694,17 +1698,17 @@ nsPlaintextEditor::InsertAsQuotation(const nsString& aQuotedText,
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::PasteAsCitedQuotation(const nsString& aCitation,
+nsPlaintextEditor::PasteAsCitedQuotation(const nsAReadableString& aCitation,
                                          PRInt32 aSelectionType)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
-                                          const nsString& aCitation,
+nsPlaintextEditor::InsertAsCitedQuotation(const nsAReadableString& aQuotedText,
+                                          const nsAReadableString& aCitation,
                                           PRBool aInsertHTML,
-                                          const nsString& aCharset,
+                                          const nsAReadableString& aCharset,
                                           nsIDOMNode **aNodeInserted)
 {
   return InsertAsQuotation(aQuotedText, aNodeInserted);
@@ -1752,7 +1756,7 @@ nsPlaintextEditor::Rewrap(PRBool aRespectNewlines)
     rv = SelectAll();
     if (NS_FAILED(rv)) return rv;
 
-    return InsertText(wrapped.GetUnicode());
+    return InsertText(wrapped);
   }
   else                // rewrap only the selection
   {
@@ -1770,7 +1774,7 @@ nsPlaintextEditor::Rewrap(PRBool aRespectNewlines)
                        wrapped);
     if (NS_FAILED(rv)) return rv;
 
-    return InsertText(wrapped.GetUnicode());
+    return InsertText(wrapped);
   }
   return NS_OK;
 }
@@ -1813,7 +1817,7 @@ nsPlaintextEditor::StripCites()
     rv = SelectAll();
     if (NS_FAILED(rv)) return rv;
 
-    return InsertText(stripped.GetUnicode());
+    return InsertText(stripped);
   }
   else                // rewrap only the selection
   {
@@ -1829,7 +1833,7 @@ nsPlaintextEditor::StripCites()
     rv = citer->StripCites(current, stripped);
     if (NS_FAILED(rv)) return rv;
 
-    return InsertText(stripped.GetUnicode());
+    return InsertText(stripped);
   }
   return NS_OK;
 }
@@ -1849,7 +1853,7 @@ nsPlaintextEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
 #endif
 
 NS_IMETHODIMP
-nsPlaintextEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
+nsPlaintextEditor::SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
 {
   NS_ASSERTION(aTextRangeList, "null ptr");
   if(nsnull == aTextRangeList)
@@ -1872,7 +1876,7 @@ nsPlaintextEditor::SetCompositionString(const nsString& aCompositionString, nsIP
   mIMETextRangeList = aTextRangeList;
   nsAutoPlaceHolderBatch batch(this, gIMETxnName);
 
-  result = InsertText(aCompositionString.GetUnicode());
+  result = InsertText(aCompositionString);
 
   mIMEBufferLength = aCompositionString.Length();
 
diff --git a/mozilla/editor/base/nsPlaintextEditor.h b/mozilla/editor/base/nsPlaintextEditor.h
index bfe586880ec..4cc4f6f0a49 100644
--- a/mozilla/editor/base/nsPlaintextEditor.h
+++ b/mozilla/editor/base/nsPlaintextEditor.h
@@ -70,14 +70,14 @@ public:
 
   /* ------------ nsIEditorMailSupport overrides -------------- */
   NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType);
-  NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText,
+  NS_IMETHOD InsertAsQuotation(const nsAReadableString& aQuotedText,
                                nsIDOMNode** aNodeInserted);
-  NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation,
+  NS_IMETHOD PasteAsCitedQuotation(const nsAReadableString& aCitation,
                                    PRInt32 aSelectionType);
-  NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText,
-                                    const nsString& aCitation,
+  NS_IMETHOD InsertAsCitedQuotation(const nsAReadableString& aQuotedText,
+                                    const nsAReadableString& aCitation,
                                     PRBool aInsertHTML,
-                                    const nsString& aCharset,
+                                    const nsAReadableString& aCharset,
                                     nsIDOMNode** aNodeInserted);
   NS_IMETHOD Rewrap(PRBool aRespectNewlines);
   NS_IMETHOD StripCites();
@@ -85,7 +85,7 @@ public:
 
   /* ------------ nsIEditorIMESupport overrides -------------- */
   
-  NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
+  NS_IMETHOD SetCompositionString(const nsAReadableString & aCompositionString, nsIPrivateTextRangeList * aTextRange, nsTextEventReply * aReply);
   NS_IMETHOD GetReconversionString(nsReconversionEventReply* aReply);
 
   /* ------------ Overrides of nsEditor interface methods -------------- */
@@ -97,7 +97,7 @@ public:
 
   NS_IMETHOD DeleteSelection(EDirection aAction);
 
-  NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet);
+  NS_IMETHOD SetDocumentCharacterSet(const nsAReadableString & characterSet);
 
   /** we override this here to install event listeners */
   NS_IMETHOD PostCreate();
@@ -109,13 +109,13 @@ public:
   NS_IMETHOD Redo(PRUint32 aCount);
 
   NS_IMETHOD Cut();
-  NS_IMETHOD CanCut(PRBool &aCanCut);
+  NS_IMETHOD CanCut(PRBool *aCanCut);
   NS_IMETHOD Copy();
-  NS_IMETHOD CanCopy(PRBool &aCanCopy);
+  NS_IMETHOD CanCopy(PRBool *aCanCopy);
   NS_IMETHOD Paste(PRInt32 aSelectionType);
-  NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste);
+  NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste);
 
-  NS_IMETHOD CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag);
+  NS_IMETHOD CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag);
   NS_IMETHOD DoDrag(nsIDOMEvent *aDragEvent);
   NS_IMETHOD InsertFromDrop(nsIDOMEvent* aDropEvent);
 
@@ -125,7 +125,7 @@ public:
                             
   NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
                             const nsAReadableString& aFormatType,
-                            const nsAReadableString* aCharsetOverride,
+                            const nsAReadableString& aCharsetOverride,
                             PRUint32 aFlags);
 
 
@@ -141,7 +141,7 @@ public:
   NS_IMETHOD SelectEntireDocument(nsISelection *aSelection);
 
   /* ------------ Utility Routines, not part of public API -------------- */
-  NS_IMETHOD TypedText(const PRUnichar* aString, PRInt32 aAction);
+  NS_IMETHOD TypedText(const nsAReadableString& aString, PRInt32 aAction);
 
   /** returns the absolute position of the end points of aSelection
     * in the document as a text stream.
@@ -183,7 +183,7 @@ protected:
   // Helpers for output routines
   NS_IMETHOD GetAndInitDocEncoder(const nsAReadableString& aFormatType,
                                   PRUint32 aFlags,
-                                  const nsAReadableString* aCharset,
+                                  const nsAReadableString& aCharset,
                                   nsIDocumentEncoder** encoder);
 
   // key event helpers
diff --git a/mozilla/editor/base/nsTableEditor.cpp b/mozilla/editor/base/nsTableEditor.cpp
index 426d1bfe361..804b61d162a 100644
--- a/mozilla/editor/base/nsTableEditor.cpp
+++ b/mozilla/editor/base/nsTableEditor.cpp
@@ -1885,7 +1885,7 @@ nsHTMLEditor::CopyCellBackgroundColor(nsIDOMElement *destCell, nsIDOMElement *so
   nsAutoString bgcolor; bgcolor.AssignWithConversion("bgcolor");
   nsAutoString color;
   PRBool isSet;
-  nsresult res = GetAttributeValue(sourceCell, bgcolor, color, isSet);
+  nsresult res = GetAttributeValue(sourceCell, bgcolor, color, &isSet);
 
   if (NS_SUCCEEDED(res) && isSet)
     res = SetAttribute(destCell, bgcolor, color);
diff --git a/mozilla/editor/base/nsTextEditRules.cpp b/mozilla/editor/base/nsTextEditRules.cpp
index 62b116eb4c3..a4dc1eec027 100644
--- a/mozilla/editor/base/nsTextEditRules.cpp
+++ b/mozilla/editor/base/nsTextEditRules.cpp
@@ -437,13 +437,14 @@ nsTextEditRules::DidInsertBreak(nsISelection *aSelection, nsresult aResult)
   return res;
 }
 
+
 nsresult
 nsTextEditRules::WillInsertText(PRInt32          aAction,
                                 nsISelection *aSelection, 
                                 PRBool          *aCancel,
                                 PRBool          *aHandled,
-                                const nsString  *inString,
-                                nsString        *outString,
+                                const nsAReadableString *inString,
+                                nsAWritableString *outString,
                                 PRInt32          aMaxLength)
 {  
   if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
@@ -528,17 +529,40 @@ nsTextEditRules::WillInsertText(PRInt32          aAction,
   if (nsIPlaintextEditor::eEditorSingleLineMask & mFlags)
   {
     if (singleLineNewlineBehavior == eReplaceWithSpaces)
-      outString->ReplaceChar(CRLF, ' ');
+    {
+      nsString tString;
+      tString.Assign(*outString);
+      //nsAWritableString destString;
+      //NormalizeCRLF(outString,destString);
+
+      tString.ReplaceChar(CRLF, ' ');
+      outString->Assign(tString);
+    }
     else if (singleLineNewlineBehavior == eStripNewlines)
-      outString->StripChars(CRLF);
+    {
+      nsString tString;
+      tString.Assign(*outString);
+      tString.StripChars(CRLF);
+      outString->Assign(tString);
+    }
     else if (singleLineNewlineBehavior == ePasteFirstLine)
     {
-      PRInt32 firstCRLF = outString->FindCharInSet(CRLF);
+      nsString tString;
+      tString.Assign(*outString);
+      PRInt32 firstCRLF = tString.FindCharInSet(CRLF);
       if (firstCRLF > 0)
-      outString->Truncate(firstCRLF);
+      {
+        tString.Truncate(firstCRLF);
+        outString->Assign(tString);
+      }
     }
     else // even if we're pasting newlines, don't paste leading/trailing ones
-      outString->Trim(CRLF, PR_TRUE, PR_TRUE);
+    {
+      nsString tString;
+      tString.Assign(*outString);
+      tString.Trim(CRLF, PR_TRUE, PR_TRUE);
+      outString->Assign(tString);
+    }
   }
 
   // get the (collapsed) selection location
@@ -576,7 +600,8 @@ nsTextEditRules::WillInsertText(PRInt32          aAction,
     // dont spaz my selection in subtransactions
     nsAutoTxnsConserveSelection dontSpazMySelection(mEditor);
     nsSubsumeStr subStr;
-    const PRUnichar *unicodeBuf = outString->GetUnicode();
+    nsString tString(*outString);
+    const PRUnichar *unicodeBuf = tString.GetUnicode();
     nsCOMPtr<nsIDOMNode> unused;
     PRInt32 pos = 0;
         
@@ -586,11 +611,11 @@ nsTextEditRules::WillInsertText(PRInt32          aAction,
     if (isPRE)
     {
       char newlineChar = '\n';
-      while (unicodeBuf && (pos != -1) && ((PRUint32)pos < outString->Length()))
+      while (unicodeBuf && (pos != -1) && ((PRUint32)pos < tString.Length()))
       {
         PRInt32 oldPos = pos;
         PRInt32 subStrLen;
-        pos = outString->FindChar(newlineChar, PR_FALSE, oldPos);
+        pos = tString.FindChar(newlineChar, PR_FALSE, oldPos);
         
         if (pos != -1) 
         {
@@ -601,8 +626,8 @@ nsTextEditRules::WillInsertText(PRInt32          aAction,
         }
         else
         {
-          subStrLen = outString->Length() - oldPos;
-          pos = outString->Length();
+          subStrLen = tString.Length() - oldPos;
+          pos = tString.Length();
         }
 
         subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen);
@@ -631,11 +656,11 @@ nsTextEditRules::WillInsertText(PRInt32          aAction,
     {
       char specialChars[] = {'\t','\n',0};
       nsAutoString tabString; tabString.AssignWithConversion("    ");
-      while (unicodeBuf && (pos != -1) && ((PRUint32)pos < outString->Length()))
+      while (unicodeBuf && (pos != -1) && ((PRUint32)pos < tString.Length()))
       {
         PRInt32 oldPos = pos;
         PRInt32 subStrLen;
-        pos = outString->FindCharInSet(specialChars, oldPos);
+        pos = tString.FindCharInSet(specialChars, oldPos);
         
         if (pos != -1) 
         {
@@ -646,8 +671,8 @@ nsTextEditRules::WillInsertText(PRInt32          aAction,
         }
         else
         {
-          subStrLen = outString->Length() - oldPos;
-          pos = outString->Length();
+          subStrLen = tString.Length() - oldPos;
+          pos = tString.Length();
         }
 
         subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen);
@@ -671,7 +696,10 @@ nsTextEditRules::WillInsertText(PRInt32          aAction,
         if (NS_FAILED(res)) return res;
       }
     }
-    if (curNode) aSelection->Collapse(curNode, curOffset);
+    outString->Assign(tString);
+
+    if (curNode) 
+      aSelection->Collapse(curNode, curOffset);
   }
   return res;
 }
@@ -1018,8 +1046,8 @@ nsTextEditRules::DidRedo(nsISelection *aSelection, nsresult aResult)
 
 nsresult
 nsTextEditRules::WillOutputText(nsISelection *aSelection, 
-                                const nsString  *aOutputFormat,
-                                nsString *aOutString,                                
+                                const nsAReadableString  *aOutputFormat,
+                                nsAWritableString *aOutString,                                
                                 PRBool   *aCancel,
                                 PRBool   *aHandled)
 {
@@ -1031,7 +1059,9 @@ nsTextEditRules::WillOutputText(nsISelection *aSelection,
   *aCancel = PR_FALSE;
   *aHandled = PR_FALSE;
 
-  if (PR_TRUE == aOutputFormat->EqualsWithConversion("text/plain"))
+  nsAutoString outputFormat(*aOutputFormat);
+  outputFormat.ToLowerCase();
+  if (outputFormat.Equals(NS_LITERAL_STRING("text/plain")))
   { // only use these rules for plain text output
     if (mFlags & nsIPlaintextEditor::eEditorPasswordMask)
     {
@@ -1214,8 +1244,8 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsISelection *aSelection)
 
 nsresult
 nsTextEditRules::TruncateInsertionIfNeeded(nsISelection *aSelection, 
-                                           const nsString  *aInString,
-                                           nsString        *aOutString,
+                                           const nsAReadableString  *aInString,
+                                           nsAWritableString  *aOutString,
                                            PRInt32          aMaxLength)
 {
   if (!aSelection || !aInString || !aOutString) {return NS_ERROR_NULL_POINTER;}
@@ -1263,7 +1293,7 @@ nsTextEditRules::TruncateInsertionIfNeeded(nsISelection *aSelection,
 
 
 nsresult
-nsTextEditRules::EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsString *aOutString)
+nsTextEditRules::EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsAWritableString *aOutString)
 {
   if (!aOutString) {return NS_ERROR_NULL_POINTER;}
 
@@ -1275,7 +1305,9 @@ nsTextEditRules::EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsString *a
   PRInt32 i;
   aOutString->SetLength(0);
   for (i=0; i<length; i++)
-    aOutString->AppendWithConversion('*');
+  {
+    aOutString->Append(PRUnichar('*'));
+  }
 
   return NS_OK;
 }
diff --git a/mozilla/editor/base/nsTextEditRules.h b/mozilla/editor/base/nsTextEditRules.h
index 8e295d7d14f..da3360aed00 100644
--- a/mozilla/editor/base/nsTextEditRules.h
+++ b/mozilla/editor/base/nsTextEditRules.h
@@ -92,8 +92,8 @@ protected:
                             nsISelection *aSelection, 
                             PRBool          *aCancel,
                             PRBool          *aHandled,
-                            const nsString  *inString,
-                            nsString        *outString,
+                            const nsAReadableString  *inString,
+                            nsAWritableString        *outString,
                             PRInt32          aMaxLength);
   nsresult DidInsertText(nsISelection *aSelection, nsresult aResult);
   nsresult GetTopEnclosingPre(nsIDOMNode *aNode, nsIDOMNode** aOutPreNode);
@@ -132,8 +132,8 @@ protected:
     *                   and use aOutText as the result.
     */
   nsresult WillOutputText(nsISelection *aSelection,
-                          const nsString  *aInFormat,
-                          nsString *aOutText, 
+                          const nsAReadableString  *aInFormat,
+                          nsAWritableString *aOutText, 
                           PRBool   *aOutCancel, 
                           PRBool *aHandled);
 
@@ -151,13 +151,13 @@ protected:
   /** returns a truncated insertion string if insertion would place us
       over aMaxLength */
   nsresult TruncateInsertionIfNeeded(nsISelection *aSelection, 
-                                           const nsString  *aInString,
-                                           nsString        *aOutString,
+                                           const nsAReadableString  *aInString,
+                                           nsAWritableString        *aOutString,
                                            PRInt32          aMaxLength);
   
   /** Echo's the insertion text into the password buffer, and converts
       insertion text to '*'s */                                        
-  nsresult EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsString *aOutString);
+  nsresult EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsAWritableString *aOutString);
 
   nsresult CreateMozBR(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outBRNode);
 
@@ -200,9 +200,9 @@ class nsTextRulesInfo : public nsRulesInfo
   virtual ~nsTextRulesInfo() {};
   
   // kInsertText
-  const nsString *inString;
-  nsString *outString;
-  const nsString *outputFormat;
+  const nsAReadableString *inString;
+  nsAWritableString *outString;
+  const nsAReadableString *outputFormat;
   PRInt32 maxLength;
   
   // kDeleteSelection
@@ -213,10 +213,10 @@ class nsTextRulesInfo : public nsRulesInfo
   PRBool entireList;
 
   // kAlign
-  const nsString *alignType;
+  const nsAReadableString *alignType;
   
   // kMakeBasicBlock
-  const nsString *blockType;
+  const nsAReadableString *blockType;
   
   // kInsertElement
   const nsIDOMElement* insertElement;
diff --git a/mozilla/editor/base/nsWrapUtils.cpp b/mozilla/editor/base/nsWrapUtils.cpp
index 59a74b964dc..e85449c1e58 100644
--- a/mozilla/editor/base/nsWrapUtils.cpp
+++ b/mozilla/editor/base/nsWrapUtils.cpp
@@ -35,11 +35,11 @@ static NS_DEFINE_CID(kLWBrkCID, NS_LWBRK_CID);
  * Rewrap the given section of string, putting the result in aOutString.
  */
 nsresult
-nsWrapUtils::Rewrap(const nsString& aInString,
-                    PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
-                    PRBool aRespectNewlines,
-                    nsString aLineStartStr,
-                    nsString& aOutString)
+nsWrapUtils::Rewrap(const nsAReadableString& aInString,
+                         PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
+                         PRBool aRespectNewlines,
+                         const nsAReadableString &aLineStartStr,
+                         nsAWritableString& aOutString)
 {
   PRInt32 i;
 
@@ -61,7 +61,8 @@ nsWrapUtils::Rewrap(const nsString& aInString,
 
   // Now we either have a line breaker, or we don't.
   PRInt32 length = aInString.Length();
-  const PRUnichar* unicodeStr = aInString.GetUnicode();
+  nsString tString(aInString);
+  const PRUnichar* unicodeStr = tString.GetUnicode();
   for (i = 0; i < length; )    // loop over lines
   {
     nsAutoString remaining(unicodeStr + i, length - i);
@@ -75,7 +76,7 @@ nsWrapUtils::Rewrap(const nsString& aInString,
     if (eol > length)
     {
       aOutString.Append(unicodeStr + i, length - i);
-      aOutString.AppendWithConversion('\n');  // DOM line breaks, not NS_LINEBREAK
+      aOutString.Append(PRUnichar('\n'));  // DOM line breaks, not NS_LINEBREAK
       break;
     }
     if (i > 0) aFirstLineOffset = 0;
@@ -108,7 +109,7 @@ nsWrapUtils::Rewrap(const nsString& aInString,
     else breakPt += i;
     nsAutoString appending(unicodeStr + i, breakPt - i);
     aOutString.Append(unicodeStr + i, breakPt - i);
-    aOutString.AppendWithConversion('\n');  // DOM line breaks, not NS_LINEBREAK
+    aOutString.Append(PRUnichar('\n'));  // DOM line breaks, not NS_LINEBREAK
 
     i = breakPt;
   } // continue looping over lines
diff --git a/mozilla/editor/base/nsWrapUtils.h b/mozilla/editor/base/nsWrapUtils.h
index 00ea2fdda28..ce3e34f1f9f 100644
--- a/mozilla/editor/base/nsWrapUtils.h
+++ b/mozilla/editor/base/nsWrapUtils.h
@@ -30,11 +30,11 @@
 class nsWrapUtils
 {
 public:
-  static nsresult Rewrap(const nsString& aInString,
+  static nsresult Rewrap(const nsAReadableString& aInString,
                          PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
                          PRBool aRespectNewlines,
-                         nsString aLineStartStr,
-                         nsString& aOutString);
+                         const nsAReadableString &aLineStartStr,
+                         nsAWritableString& aOutString);
 };
 
 #endif //nsWrapUtils_h__
diff --git a/mozilla/editor/composer/src/nsComposerCommands.cpp b/mozilla/editor/composer/src/nsComposerCommands.cpp
index e1c598f0d3c..ee57e7c160b 100644
--- a/mozilla/editor/composer/src/nsComposerCommands.cpp
+++ b/mozilla/editor/composer/src/nsComposerCommands.cpp
@@ -274,7 +274,7 @@ nsPasteQuotationCommand::IsCommandEnabled(const nsAReadableString & aCommandName
     nsCOMPtr<nsIEditor> editor;
     editorShell->GetEditor(getter_AddRefs(editor));
     if (editor)
-      editor->CanPaste(nsIClipboard::kGlobalClipboard, *outCmdEnabled);
+      editor->CanPaste(nsIClipboard::kGlobalClipboard, outCmdEnabled);
   }
   
   return NS_OK;
@@ -322,7 +322,7 @@ nsStyleUpdatingCommand::GetCurrentState(nsIEditorShell *aEditorShell, const char
   if (!htmlEditor) return NS_ERROR_NOT_INITIALIZED;
   
   nsCOMPtr<nsIAtom> styleAtom = getter_AddRefs(NS_NewAtom(aTagName));
-  rv = htmlEditor->GetInlineProperty(styleAtom, nsnull, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp);
+  rv = htmlEditor->GetInlineProperty(styleAtom, NS_LITERAL_STRING(""), NS_LITERAL_STRING(""), &firstOfSelectionHasProp, &anyOfSelectionHasProp, &allOfSelectionHasProp);
   outStyleSet = allOfSelectionHasProp;			// change this to alter the behaviour
 
   return rv;
@@ -442,8 +442,7 @@ nsListItemCommand::ToggleState(nsIEditorShell *aEditorShell, const char* aTagNam
     {
       if (!bMixed)
       {
-        nsAutoString listType(tagStr);
-        rv = htmlEditor->RemoveList(listType);    
+        rv = htmlEditor->RemoveList(nsLiteralString(tagStr));    
       }
       nsCRT::free(tagStr);
     }
@@ -554,7 +553,7 @@ nsOutdentCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISu
     if (htmlEditor)
     {
       PRBool canIndent, canOutdent;
-      htmlEditor->GetIndentState(canIndent, canOutdent);
+      htmlEditor->GetIndentState(&canIndent, &canOutdent);
       
       *outCmdEnabled = canOutdent;
     }
@@ -690,7 +689,7 @@ nsParagraphStateCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsString&
   aEditorShell->GetEditor(getter_AddRefs(editor));
   nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor);
   if (!htmlEditor) return NS_ERROR_FAILURE;
-  return htmlEditor->GetParagraphState(outMixed, outStateString);
+  return htmlEditor->GetParagraphState(&outMixed, outStateString);
 }
 
 
@@ -727,7 +726,7 @@ nsFontFaceStateCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsString&
   nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor);
   if (!htmlEditor) return NS_ERROR_FAILURE;
 
-  return htmlEditor->GetFontFaceState(outMixed, outStateString);
+  return htmlEditor->GetFontFaceState(&outMixed, outStateString);
 }
 
 
@@ -743,9 +742,6 @@ nsFontFaceStateCommand::SetState(nsIEditorShell *aEditorShell, nsString& newStat
   
   nsresult rv;
   
-  NS_ConvertASCIItoUCS2 emptyString("");
-  NS_ConvertASCIItoUCS2 fontString("font");
-  NS_ConvertASCIItoUCS2 faceString("face");
   
   nsCOMPtr<nsIAtom> ttAtom = getter_AddRefs(NS_NewAtom("tt"));
   nsCOMPtr<nsIAtom> fontAtom = getter_AddRefs(NS_NewAtom("font"));
@@ -753,19 +749,19 @@ nsFontFaceStateCommand::SetState(nsIEditorShell *aEditorShell, nsString& newStat
   if (newState.EqualsWithConversion("tt"))
   {
     // The old "teletype" attribute  
-    rv = htmlEditor->SetInlineProperty(ttAtom, &emptyString, &emptyString);  
+    rv = htmlEditor->SetInlineProperty(ttAtom, NS_LITERAL_STRING(""), NS_LITERAL_STRING(""));  
     // Clear existing font face
-    rv = htmlEditor->RemoveInlineProperty(fontAtom, &faceString);
+    rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("face"));
   }
   else
   {
     // Remove any existing TT nodes
-    rv = htmlEditor->RemoveInlineProperty(ttAtom, &emptyString);  
+    rv = htmlEditor->RemoveInlineProperty(ttAtom, NS_LITERAL_STRING(""));  
 
-    if (newState == emptyString || newState.EqualsWithConversion("normal")) {
-      rv = htmlEditor->RemoveInlineProperty(fontAtom, &faceString);
+    if (!newState.Length() || newState.EqualsWithConversion("normal")) {
+      rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("face"));
     } else {
-      rv = htmlEditor->SetInlineProperty(fontAtom, &faceString, &newState);
+      rv = htmlEditor->SetInlineProperty(fontAtom, NS_LITERAL_STRING("face"), newState);
     }
   }
   
@@ -791,7 +787,7 @@ nsFontColorStateCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsString&
   nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor);
   if (!htmlEditor) return NS_ERROR_FAILURE;
 
-  return htmlEditor->GetFontColorState(outMixed, outStateString);
+  return htmlEditor->GetFontColorState(&outMixed, outStateString);
 }
 
 
@@ -807,16 +803,13 @@ nsFontColorStateCommand::SetState(nsIEditorShell *aEditorShell, nsString& newSta
   
   nsresult rv;
   
-  NS_ConvertASCIItoUCS2 emptyString("");
-  NS_ConvertASCIItoUCS2 fontString("font");
-  NS_ConvertASCIItoUCS2 colorString("color");
   
   nsCOMPtr<nsIAtom> fontAtom = getter_AddRefs(NS_NewAtom("font"));
 
-  if (newState == emptyString || newState.EqualsWithConversion("normal")) {
-    rv = htmlEditor->RemoveInlineProperty(fontAtom, &colorString);
+  if (!newState.Length() || newState.EqualsWithConversion("normal")) {
+    rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("color"));
   } else {
-    rv = htmlEditor->SetInlineProperty(fontAtom, &colorString, &newState);
+    rv = htmlEditor->SetInlineProperty(fontAtom, NS_LITERAL_STRING("color"), newState);
   }
   
   return rv;
@@ -842,7 +835,7 @@ nsBackgroundColorStateCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsS
   if (!htmlEditor) return NS_ERROR_FAILURE;
 
 
-  return htmlEditor->GetBackgroundColorState(outMixed, outStateString);
+  return htmlEditor->GetBackgroundColorState(&outMixed, outStateString);
 }
 
 
@@ -879,7 +872,7 @@ nsAlignCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsString& outState
   if (!htmlEditor) return NS_ERROR_FAILURE;
  
   nsIHTMLEditor::EAlignment firstAlign;
-  nsresult rv = htmlEditor->GetAlignment(outMixed, firstAlign);
+  nsresult rv = htmlEditor->GetAlignment(&outMixed, &firstAlign);
   if (NS_FAILED(rv)) return rv;
   switch (firstAlign)
   {
diff --git a/mozilla/editor/composer/src/nsEditorShell.cpp b/mozilla/editor/composer/src/nsEditorShell.cpp
index 11e29960ef6..b91e0a1f716 100644
--- a/mozilla/editor/composer/src/nsEditorShell.cpp
+++ b/mozilla/editor/composer/src/nsEditorShell.cpp
@@ -1061,9 +1061,7 @@ nsEditorShell::SetAttribute(nsIDOMElement *element, const PRUnichar *attr, const
   nsresult  result = NS_NOINTERFACE;
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
   if (editor) {
-    nsAutoString attributeStr(attr);
-    nsAutoString valueStr(value);
-    result = editor->SetAttribute(element, attributeStr, valueStr); 
+    result = editor->SetAttribute(element, nsLiteralString(attr), nsLiteralString(value)); 
   }
 
   return result;
@@ -1078,8 +1076,7 @@ nsEditorShell::RemoveAttribute(nsIDOMElement *element, const PRUnichar *attr)
   nsresult  result = NS_NOINTERFACE;
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
   if (editor) {
-    nsAutoString attributeStr(attr);
-    result = editor->RemoveAttribute(element, attributeStr);
+    result = editor->RemoveAttribute(element, nsLiteralString(attr));
   }
 
   return result;
@@ -1094,16 +1091,13 @@ nsEditorShell::SetTextProperty(const PRUnichar *prop, const PRUnichar *attr, con
 
   nsCOMPtr<nsIAtom> styleAtom = getter_AddRefs(NS_NewAtom(prop));      /// XXX Hack alert! Look in nsIEditProperty.h for this
   if (! styleAtom) return NS_ERROR_OUT_OF_MEMORY;
-
-  nsAutoString    attributeStr(attr);
-  nsAutoString    valueStr(value);
-  
+ 
   switch (mEditorType)
   {
     case ePlainTextEditorType:
         // should we allow this?
     case eHTMLTextEditorType:
-      err = mEditor->SetInlineProperty(styleAtom, &attributeStr, &valueStr);
+      err = mEditor->SetInlineProperty(styleAtom, nsLiteralString(attr), nsLiteralString(value));
       break;
     default:
       err = NS_ERROR_NOT_IMPLEMENTED;
@@ -1127,7 +1121,7 @@ nsEditorShell::RemoveOneProperty(const nsString& aProp, const nsString &aAttr)
     case ePlainTextEditorType:
         // should we allow this?
     case eHTMLTextEditorType:
-      err = mEditor->RemoveInlineProperty(styleAtom, &aAttr);
+      err = mEditor->RemoveInlineProperty(styleAtom, aAttr);
       break;
     default:
       err = NS_ERROR_NOT_IMPLEMENTED;
@@ -1172,15 +1166,12 @@ nsEditorShell::GetTextProperty(const PRUnichar *prop, const PRUnichar *attr, con
 
   styleAtom = NS_NewAtom(prop);      /// XXX Hack alert! Look in nsIEditProperty.h for this
 
-  nsAutoString  aAttr(attr);
-  nsAutoString  aValue(value);
-  
   switch (mEditorType)
   {
     case ePlainTextEditorType:
         // should we allow this?
     case eHTMLTextEditorType:
-      err = mEditor->GetInlineProperty(styleAtom, &aAttr, &aValue, *firstHas, *anyHas, *allHas);
+      err = mEditor->GetInlineProperty(styleAtom, nsLiteralString(attr), nsLiteralString(value), firstHas, anyHas, allHas);
       break;
     default:
       err = NS_ERROR_NOT_IMPLEMENTED;
@@ -1238,7 +1229,7 @@ nsEditorShell::GetParagraphState(PRBool *aMixed, PRUnichar **_retval)
   {
     PRBool bMixed;
     nsAutoString state;
-    err = htmlEditor->GetParagraphState(bMixed, state);
+    err = htmlEditor->GetParagraphState(&bMixed, state);
     if (!bMixed)
       *_retval = state.ToNewUnicode();
   }
@@ -1257,7 +1248,7 @@ nsEditorShell::GetListState(PRBool *aMixed, PRUnichar **_retval)
   if (htmlEditor)
   {
     PRBool bOL, bUL, bDL;
-    err = htmlEditor->GetListState(*aMixed, bOL, bUL, bDL);
+    err = htmlEditor->GetListState(aMixed, &bOL, &bUL, &bDL);
     if (NS_SUCCEEDED(err))
     {
       if (!*aMixed)
@@ -1285,7 +1276,7 @@ nsEditorShell::GetListItemState(PRBool *aMixed, PRUnichar **_retval)
   if (htmlEditor)
   {
     PRBool bLI,bDT,bDD;
-    err = htmlEditor->GetListItemState(*aMixed, bLI, bDT, bDD);
+    err = htmlEditor->GetListItemState(aMixed, &bLI, &bDT, &bDD);
     if (NS_SUCCEEDED(err))
     {
       if (!*aMixed)
@@ -1313,7 +1304,7 @@ nsEditorShell::GetAlignment(PRBool *aMixed, PRUnichar **_retval)
   if (htmlEditor)
   {
     nsIHTMLEditor::EAlignment firstAlign;
-    err = htmlEditor->GetAlignment(*aMixed, firstAlign);
+    err = htmlEditor->GetAlignment(aMixed, &firstAlign);
     if (NS_SUCCEEDED(err))
     {
       nsAutoString tagStr;
@@ -1777,7 +1768,7 @@ nsEditorShell::SaveDocument(PRBool aSaveAs, PRBool aSaveCopy, const PRUnichar* a
                 return NS_OK;
               }
               // This sets title in HTML node
-              mEditor->SetDocumentTitle(titleUnicode);
+              mEditor->SetDocumentTitle(nsLiteralString(titleUnicode));
               title = titleUnicode;
               nsCRT::free(titleUnicode);
               titleChanged = PR_TRUE;
@@ -2240,7 +2231,7 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title)
   if (mEditorType != eHTMLTextEditorType)
     return NS_ERROR_NOT_IMPLEMENTED;
 
-  res = mEditor->SetDocumentTitle(title);
+  res = mEditor->SetDocumentTitle(nsLiteralString(title));
   if (NS_FAILED(res)) return res;
 
   // PR_FALSE means don't save menu to prefs
@@ -2283,7 +2274,7 @@ nsEditorShell::NodeIsBlock(nsIDOMNode *node, PRBool *_retval)
     case ePlainTextEditorType:
     case eHTMLTextEditorType:
       {
-        rv = mEditor->NodeIsBlock(node, *_retval);
+        rv = mEditor->NodeIsBlock(node, _retval);
       }
       break;
 
@@ -2610,7 +2601,7 @@ nsEditorShell::InsertText(const PRUnichar *textToInsert)
       {
         nsCOMPtr<nsIPlaintextEditor> textEditor (do_QueryInterface(mEditor));
         if (textEditor)
-          err = textEditor->InsertText(textToInsert);
+          err = textEditor->InsertText(nsLiteralString(textToInsert));
       }
       break;
 
@@ -2953,11 +2944,19 @@ nsEditorShell::Alert(const nsString& aTitle, const nsString& aMsg)
 NS_IMETHODIMP
 nsEditorShell::GetDocumentCharacterSet(PRUnichar** characterSet)
 {
+  if (!characterSet)
+      return NS_ERROR_NULL_POINTER;
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
-
+  nsAutoString copiedData;
+  *characterSet = nsnull;
   if (editor)
-    return editor->GetDocumentCharacterSet(characterSet);
-
+  {
+    if (NS_SUCCEEDED(editor->GetDocumentCharacterSet(copiedData)))
+    {
+      *characterSet = ToNewUnicode(copiedData);
+      return NS_OK;
+    }
+  }
   return NS_ERROR_FAILURE;
 }
 
@@ -2968,7 +2967,7 @@ nsEditorShell::SetDocumentCharacterSet(const PRUnichar* characterSet)
 
   nsresult res = NS_OK;
   if (editor)
-    res = editor->SetDocumentCharacterSet(characterSet);
+    res = editor->SetDocumentCharacterSet(nsAutoString(characterSet));
   
   if(NS_SUCCEEDED(res)) {
     nsCOMPtr<nsIScriptGlobalObject> globalObj( do_QueryReferent(mContentWindow));
diff --git a/mozilla/editor/idl/Makefile.in b/mozilla/editor/idl/Makefile.in
index c2b03e4b8ec..c757babb489 100644
--- a/mozilla/editor/idl/Makefile.in
+++ b/mozilla/editor/idl/Makefile.in
@@ -29,12 +29,18 @@ include $(DEPTH)/config/autoconf.mk
 MODULE		= editor
 
 XPIDLSRCS	= \
-		nsIPlaintextEditor.idl \
+		nsICiter.idl \
+		nsIDocumentStateListener.idl \
+		nsIEditActionListener.idl \
+		nsIEditorController.idl \
+		nsIEditor.idl \
+		nsIEditorIMESupport.idl \
+		nsIEditorObserver.idl \
+		nsIEditorService.idl \
 		nsIEditorShell.idl \
 		nsIEditorSpellCheck.idl \
-		nsIDocumentStateListener.idl \
-		nsIEditorService.idl \
-		nsIEditorController.idl \
+		nsIHTMLEditor.idl \
+		nsIPlaintextEditor.idl \
 		nsPIEditorTransaction.idl \
 		$(NULL)
 
diff --git a/mozilla/editor/idl/makefile.win b/mozilla/editor/idl/makefile.win
index 86eb8e1a1ae..6cfb45fcec7 100644
--- a/mozilla/editor/idl/makefile.win
+++ b/mozilla/editor/idl/makefile.win
@@ -26,13 +26,19 @@ DEPTH=..\..
 MODULE=editor
 XPIDL_MODULE=editor
 
-XPIDLSRCS = .\nsIEditorShell.idl           \
-            .\nsIPlaintextEditor.idl       \
-            .\nsIEditorSpellCheck.idl      \
-            .\nsIDocumentStateListener.idl \
-            .\nsIEditorService.idl         \
-            .\nsIEditorController.idl      \
-            .\nsPIEditorTransaction.idl    \
+XPIDLSRCS = .\nsICiter.idl \
+		.\nsIDocumentStateListener.idl \
+		.\nsIEditActionListener.idl \
+		.\nsIEditorController.idl \
+		.\nsIEditor.idl \
+		.\nsIEditorIMESupport.idl \
+		.\nsIEditorObserver.idl \
+		.\nsIEditorService.idl \
+		.\nsIEditorShell.idl \
+		.\nsIEditorSpellCheck.idl \
+		.\nsIHTMLEditor.idl \
+		.\nsIPlaintextEditor.idl \
+		.\nsPIEditorTransaction.idl \
             $(NULL)
 
 include <$(DEPTH)\config\rules.mak>
diff --git a/mozilla/editor/idl/nsICiter.idl b/mozilla/editor/idl/nsICiter.idl
index f005b912092..926994b0b19 100644
--- a/mozilla/editor/idl/nsICiter.idl
+++ b/mozilla/editor/idl/nsICiter.idl
@@ -25,7 +25,9 @@
 
 #include "nsISupports.idl"
 #include "domstubs.idl"
-
+%{C++
+#include "nsString.h"
+%}
 /** Handle plaintext citations, as in mail quoting.
   * Used by the editor but not dependant on it.
   */
diff --git a/mozilla/editor/idl/nsIEditor.idl b/mozilla/editor/idl/nsIEditor.idl
index ad971084358..ae8d726f5e6 100644
--- a/mozilla/editor/idl/nsIEditor.idl
+++ b/mozilla/editor/idl/nsIEditor.idl
@@ -326,14 +326,6 @@ interface nsIEditor  : nsISupports
 
   /* ------------ Node manipulation methods -------------- */
 
-  /**
-   * Tests if a node is a BLOCK element according the the HTML 4.0 DTD
-   *   This does NOT consider CSS effect on display type
-   *
-   * @param aNode      the node to test
-   */
-  void NodeIsBlock(in nsIDOMNode node, out boolean isBlock);
-
   /**
    * SetAttribute() sets the attribute of aElement.
    * No checking is done to see if aAttribute is a legal attribute of the node,
diff --git a/mozilla/editor/idl/nsIHTMLEditor.idl b/mozilla/editor/idl/nsIHTMLEditor.idl
index 1ce9672bf9c..e57afde8c0d 100644
--- a/mozilla/editor/idl/nsIHTMLEditor.idl
+++ b/mozilla/editor/idl/nsIHTMLEditor.idl
@@ -146,6 +146,14 @@ interface nsIHTMLEditor : nsISupports
 
   /* ------------ HTML content methods -------------- */
 
+  /**
+   * Tests if a node is a BLOCK element according the the HTML 4.0 DTD
+   *   This does NOT consider CSS effect on display type
+   *
+   * @param aNode      the node to test
+   */
+  void NodeIsBlock(in nsIDOMNode node, out boolean isBlock);
+
   /**
    * Insert some HTML source at the current location
    *
diff --git a/mozilla/editor/idl/nsIPlaintextEditor.idl b/mozilla/editor/idl/nsIPlaintextEditor.idl
index c40bbeae8cd..ab2a61f2ccd 100644
--- a/mozilla/editor/idl/nsIPlaintextEditor.idl
+++ b/mozilla/editor/idl/nsIPlaintextEditor.idl
@@ -89,7 +89,7 @@ interface nsIPlaintextEditor : nsISupports
    *
    * @param aString   the string to be inserted
    */
-   void insertText(in wstring aStringToInsert);
+   void insertText(in DOMString aStringToInsert);
 
   /**
    * Insert a line break into the content model.
diff --git a/mozilla/editor/libeditor/base/ChangeAttributeTxn.cpp b/mozilla/editor/libeditor/base/ChangeAttributeTxn.cpp
index dc950dff226..3c3ff7538db 100644
--- a/mozilla/editor/libeditor/base/ChangeAttributeTxn.cpp
+++ b/mozilla/editor/libeditor/base/ChangeAttributeTxn.cpp
@@ -35,8 +35,8 @@ ChangeAttributeTxn::~ChangeAttributeTxn()
 
 NS_IMETHODIMP ChangeAttributeTxn::Init(nsIEditor      *aEditor,
                                        nsIDOMElement  *aElement,
-                                       const nsString& aAttribute,
-                                       const nsString& aValue,
+                                       const nsAReadableString& aAttribute,
+                                       const nsAReadableString& aValue,
                                        PRBool aRemoveAttribute)
 {
 	NS_ASSERTION(aEditor && aElement, "bad arg");
@@ -58,7 +58,7 @@ NS_IMETHODIMP ChangeAttributeTxn::DoTransaction(void)
 	if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
 
   // need to get the current value of the attribute and save it, and set mAttributeWasSet
-  nsresult result = mEditor->GetAttributeValue(mElement, mAttribute, mUndoValue, mAttributeWasSet);
+  nsresult result = mEditor->GetAttributeValue(mElement, mAttribute, mUndoValue, &mAttributeWasSet);
   // XXX: hack until attribute-was-set code is implemented
       if (PR_FALSE==mUndoValue.IsEmpty())
         mAttributeWasSet=PR_TRUE;
diff --git a/mozilla/editor/libeditor/base/ChangeAttributeTxn.h b/mozilla/editor/libeditor/base/ChangeAttributeTxn.h
index e9459b800f4..50eefa7f5e1 100644
--- a/mozilla/editor/libeditor/base/ChangeAttributeTxn.h
+++ b/mozilla/editor/libeditor/base/ChangeAttributeTxn.h
@@ -54,8 +54,8 @@ public:
     */
   NS_IMETHOD Init(nsIEditor      *aEditor,
                   nsIDOMElement  *aNode,
-                  const nsString& aAttribute,
-                  const nsString& aValue,
+                  const nsAReadableString& aAttribute,
+                  const nsAReadableString& aValue,
                   PRBool aRemoveAttribute);
 
 private:
diff --git a/mozilla/editor/libeditor/base/CreateElementTxn.cpp b/mozilla/editor/libeditor/base/CreateElementTxn.cpp
index dabc508b114..45ed325d783 100644
--- a/mozilla/editor/libeditor/base/CreateElementTxn.cpp
+++ b/mozilla/editor/libeditor/base/CreateElementTxn.cpp
@@ -43,7 +43,7 @@ CreateElementTxn::CreateElementTxn()
 }
 
 NS_IMETHODIMP CreateElementTxn::Init(nsEditor      *aEditor,
-                                     const nsString &aTag,
+                                     const nsAReadableString &aTag,
                                      nsIDOMNode     *aParent,
                                      PRUint32        aOffsetInParent)
 {
diff --git a/mozilla/editor/libeditor/base/CreateElementTxn.h b/mozilla/editor/libeditor/base/CreateElementTxn.h
index 733921e0d34..fddf52b4c38 100644
--- a/mozilla/editor/libeditor/base/CreateElementTxn.h
+++ b/mozilla/editor/libeditor/base/CreateElementTxn.h
@@ -52,7 +52,7 @@ public:
     *                        if eAppend, the new element is appended as the last child
     */
   NS_IMETHOD Init(nsEditor *aEditor,
-                  const nsString& aTag,
+                  const nsAReadableString& aTag,
                   nsIDOMNode *aParent,
                   PRUint32 aOffsetInParent);
 
diff --git a/mozilla/editor/libeditor/base/IMETextTxn.cpp b/mozilla/editor/libeditor/base/IMETextTxn.cpp
index fbb37087dab..246a730c2be 100644
--- a/mozilla/editor/libeditor/base/IMETextTxn.cpp
+++ b/mozilla/editor/libeditor/base/IMETextTxn.cpp
@@ -65,7 +65,7 @@ NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData     *aElement,
                                PRUint32                 aOffset,
                                PRUint32                 aReplaceLength,
                                nsIPrivateTextRangeList *aTextRangeList,
-                               const nsString          &aStringToInsert,
+                               const nsAReadableString &aStringToInsert,
                                nsWeakPtr                aSelConWeak)
 {
   NS_ASSERTION(aElement, "illegal value- null ptr- aElement");
diff --git a/mozilla/editor/libeditor/base/IMETextTxn.h b/mozilla/editor/libeditor/base/IMETextTxn.h
index 4b27f5770fa..5dc2c26d0ae 100644
--- a/mozilla/editor/libeditor/base/IMETextTxn.h
+++ b/mozilla/editor/libeditor/base/IMETextTxn.h
@@ -65,7 +65,7 @@ public:
                   PRUint32 aOffset,
 				  PRUint32 aReplaceLength,
 				  nsIPrivateTextRangeList* aTextRangeList,
-                  const nsString& aString,
+                  const nsAReadableString& aString,
                   nsWeakPtr aSelCon);
 
 private:
diff --git a/mozilla/editor/libeditor/base/InsertTextTxn.cpp b/mozilla/editor/libeditor/base/InsertTextTxn.cpp
index b60e46a451b..9e0e9979345 100644
--- a/mozilla/editor/libeditor/base/InsertTextTxn.cpp
+++ b/mozilla/editor/libeditor/base/InsertTextTxn.cpp
@@ -60,7 +60,7 @@ InsertTextTxn::~InsertTextTxn()
 
 NS_IMETHODIMP InsertTextTxn::Init(nsIDOMCharacterData *aElement,
                                   PRUint32             aOffset,
-                                  const nsString      &aStringToInsert,
+                                  const nsAReadableString      &aStringToInsert,
                                   nsIEditor           *aEditor)
 {
 #if 0 //def DEBUG_cmanske
diff --git a/mozilla/editor/libeditor/base/InsertTextTxn.h b/mozilla/editor/libeditor/base/InsertTextTxn.h
index 577383db3a3..ce6680dbd15 100644
--- a/mozilla/editor/libeditor/base/InsertTextTxn.h
+++ b/mozilla/editor/libeditor/base/InsertTextTxn.h
@@ -59,7 +59,7 @@ public:
     */
   NS_IMETHOD Init(nsIDOMCharacterData *aElement,
                   PRUint32 aOffset,
-                  const nsString& aString,
+                  const nsAReadableString& aString,
                   nsIEditor *aEditor);
 
 private:
diff --git a/mozilla/editor/libeditor/base/SetDocTitleTxn.cpp b/mozilla/editor/libeditor/base/SetDocTitleTxn.cpp
index 9d367d348a4..b7829e718d6 100644
--- a/mozilla/editor/libeditor/base/SetDocTitleTxn.cpp
+++ b/mozilla/editor/libeditor/base/SetDocTitleTxn.cpp
@@ -38,7 +38,7 @@ SetDocTitleTxn::SetDocTitleTxn()
 }
 
 NS_IMETHODIMP SetDocTitleTxn::Init(nsIHTMLEditor *aEditor,
-                                   const nsString *aValue)
+                                   const nsAReadableString *aValue)
 
 {
   NS_ASSERTION(aEditor && aValue, "null args");
@@ -72,7 +72,7 @@ NS_IMETHODIMP SetDocTitleTxn::RedoTransaction(void)
   return SetDocTitle(mValue);
 }
 
-nsresult SetDocTitleTxn::SetDocTitle(nsString& aTitle)
+nsresult SetDocTitleTxn::SetDocTitle(const nsAReadableString& aTitle)
 {
   NS_ASSERTION(mEditor, "bad state");
   if (!mEditor) return NS_ERROR_NOT_INITIALIZED;
@@ -89,7 +89,7 @@ nsresult SetDocTitleTxn::SetDocTitle(nsString& aTitle)
   return HTMLDoc->SetTitle(aTitle);
 }
 
-nsresult SetDocTitleTxn::SetDomTitle(nsString& aTitle)
+nsresult SetDocTitleTxn::SetDomTitle(const nsAReadableString& aTitle)
 {
   nsCOMPtr<nsIDOMDocument>  domDoc;
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
diff --git a/mozilla/editor/libeditor/base/SetDocTitleTxn.h b/mozilla/editor/libeditor/base/SetDocTitleTxn.h
index 715e664e0e9..4451fe8d0ba 100644
--- a/mozilla/editor/libeditor/base/SetDocTitleTxn.h
+++ b/mozilla/editor/libeditor/base/SetDocTitleTxn.h
@@ -53,11 +53,11 @@ public:
     * @param aValue  the new value for document title
     */
   NS_IMETHOD Init(nsIHTMLEditor  *aEditor,
-                  const nsString *aValue);
+                  const nsAReadableString *aValue);
 private:
   SetDocTitleTxn();
-  nsresult SetDocTitle(nsString& aTitle);
-  nsresult SetDomTitle(nsString& aTitle);
+  nsresult SetDocTitle(const nsAReadableString& aTitle);
+  nsresult SetDomTitle(const nsAReadableString& aTitle);
 
 public:
   NS_IMETHOD DoTransaction(void);
diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp
index 80020203c3f..b963e8bf1a3 100644
--- a/mozilla/editor/libeditor/base/nsEditor.cpp
+++ b/mozilla/editor/libeditor/base/nsEditor.cpp
@@ -580,17 +580,19 @@ nsEditor::Undo(PRUint32 aCount)
 }
 
 
-NS_IMETHODIMP nsEditor::CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo)
+NS_IMETHODIMP nsEditor::CanUndo(PRBool *aIsEnabled, PRBool *aCanUndo)
 {
-  aIsEnabled = ((PRBool)((nsITransactionManager *)0!=mTxnMgr.get()));
-  if (aIsEnabled)
+  if (!aIsEnabled || !aCanUndo)
+     return NS_ERROR_NULL_POINTER;
+  *aIsEnabled = ((PRBool)((nsITransactionManager *)0!=mTxnMgr.get()));
+  if (*aIsEnabled)
   {
     PRInt32 numTxns=0;
     mTxnMgr->GetNumberOfUndoItems(&numTxns);
-    aCanUndo = ((PRBool)(0!=numTxns));
+    *aCanUndo = ((PRBool)(0!=numTxns));
   }
   else {
-    aCanUndo = PR_FALSE;
+    *aCanUndo = PR_FALSE;
   }
   return NS_OK;
 }
@@ -624,17 +626,20 @@ nsEditor::Redo(PRUint32 aCount)
 }
 
 
-NS_IMETHODIMP nsEditor::CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo)
+NS_IMETHODIMP nsEditor::CanRedo(PRBool *aIsEnabled, PRBool *aCanRedo)
 {
-  aIsEnabled = ((PRBool)((nsITransactionManager *)0!=mTxnMgr.get()));
-  if (aIsEnabled)
+  if (!aIsEnabled || !aCanRedo)
+     return NS_ERROR_NULL_POINTER;
+
+  *aIsEnabled = ((PRBool)((nsITransactionManager *)0!=mTxnMgr.get()));
+  if (*aIsEnabled)
   {
     PRInt32 numTxns=0;
     mTxnMgr->GetNumberOfRedoItems(&numTxns);
-    aCanRedo = ((PRBool)(0!=numTxns));
+    *aCanRedo = ((PRBool)(0!=numTxns));
   }
   else {
-    aCanRedo = PR_FALSE;
+    *aCanRedo = PR_FALSE;
   }
   return NS_OK;
 }
@@ -891,24 +896,19 @@ nsEditor::GetDocumentModified(PRBool *outDocModified)
 }
 
 NS_IMETHODIMP
-nsEditor::GetDocumentCharacterSet(PRUnichar** characterSet)
+nsEditor::GetDocumentCharacterSet(nsAWritableString &characterSet)
 {
   nsresult rv;
   nsCOMPtr<nsIDocument> doc;
   nsCOMPtr<nsIPresShell> presShell;
-  nsAutoString  character_set;
-
-  if (characterSet==nsnull) return NS_ERROR_NULL_POINTER;
 
   rv = GetPresShell(getter_AddRefs(presShell));
   if (NS_SUCCEEDED(rv))
   {
     presShell->GetDocument(getter_AddRefs(doc));
-    if (doc ) {
-    rv = doc->GetDocumentCharacterSet(character_set);
-    if (NS_SUCCEEDED(rv)) *characterSet=character_set.ToNewUnicode();
-    return rv;
-  }
+    if (doc )
+      return doc->GetDocumentCharacterSet(characterSet);
+    rv = NS_ERROR_NULL_POINTER;
   }
 
   return rv;
@@ -916,22 +916,20 @@ nsEditor::GetDocumentCharacterSet(PRUnichar** characterSet)
 }
 
 NS_IMETHODIMP
-nsEditor::SetDocumentCharacterSet(const PRUnichar* characterSet)
+nsEditor::SetDocumentCharacterSet(const nsAReadableString& characterSet)
 {
   nsresult rv;
   nsCOMPtr<nsIDocument> doc;
   nsCOMPtr<nsIPresShell> presShell;
-  nsAutoString character_set(characterSet);
-
-  if (characterSet==nsnull) return NS_ERROR_NULL_POINTER;
 
   rv = GetPresShell(getter_AddRefs(presShell));
   if (NS_SUCCEEDED(rv))
   {
     presShell->GetDocument(getter_AddRefs(doc));
     if (doc) {
-      return doc->SetDocumentCharacterSet(character_set);
+      return doc->SetDocumentCharacterSet(characterSet);
     }
+    rv = NS_ERROR_NULL_POINTER;
   }
 
   return rv;
@@ -957,7 +955,7 @@ nsEditor::GetWrapWidth(PRInt32 *aWrapColumn)
 
 NS_IMETHODIMP 
 nsEditor::SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting,
-                   PRBool aSaveCopy, const nsString& aFormat)
+                   PRBool aSaveCopy, const nsAReadableString& aFormat)
 {
   if (!aFileSpec)
     return NS_ERROR_NULL_POINTER;
@@ -997,8 +995,9 @@ nsEditor::SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting,
   GetWrapWidth(&wrapColumn);
   if (wrapColumn > 0)
     flags |= nsIDocumentEncoder::OutputWrap;
+  const nsPromiseFlatString &formatFlat = PromiseFlatString(aFormat);
   rv = diskDoc->SaveFile(aFileSpec, aReplaceExisting, aSaveCopy, 
-                         aFormat.GetUnicode(), NS_LITERAL_STRING("").get(),
+                         formatFlat.get(), NS_LITERAL_STRING("").get(),
                          flags, wrapColumn);
   if (NS_SUCCEEDED(rv))
     DoAfterDocumentSave();
@@ -1015,7 +1014,7 @@ nsEditor::Cut()
 }
 
 NS_IMETHODIMP
-nsEditor::CanCut(PRBool &aCanCut)
+nsEditor::CanCut(PRBool *aCanCut)
 {
   return NS_ERROR_NOT_IMPLEMENTED; 
 }
@@ -1027,7 +1026,7 @@ nsEditor::Copy()
 }
 
 NS_IMETHODIMP
-nsEditor::CanCopy(PRBool &aCanCopy)
+nsEditor::CanCopy(PRBool *aCanCut)
 {
   return NS_ERROR_NOT_IMPLEMENTED; 
 }
@@ -1039,13 +1038,13 @@ nsEditor::Paste(PRInt32 aSelectionType)
 }
 
 NS_IMETHODIMP
-nsEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste)
+nsEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste)
 {
   return NS_ERROR_NOT_IMPLEMENTED; 
 }
 
 NS_IMETHODIMP
-nsEditor::CanDrag(nsIDOMEvent *aEvent, PRBool &aCanDrag)
+nsEditor::CanDrag(nsIDOMEvent *aEvent, PRBool *aCanDrag)
 {
   return NS_ERROR_NOT_IMPLEMENTED; 
 }
@@ -1064,7 +1063,7 @@ nsEditor::InsertFromDrop(nsIDOMEvent *aEvent)
 
 
 NS_IMETHODIMP 
-nsEditor::SetAttribute(nsIDOMElement *aElement, const nsString& aAttribute, const nsString& aValue)
+nsEditor::SetAttribute(nsIDOMElement *aElement, const nsAReadableString & aAttribute, const nsAReadableString & aValue)
 {
   ChangeAttributeTxn *txn;
   nsresult result = CreateTxnForSetAttribute(aElement, aAttribute, aValue, &txn);
@@ -1079,11 +1078,13 @@ nsEditor::SetAttribute(nsIDOMElement *aElement, const nsString& aAttribute, cons
 
 NS_IMETHODIMP 
 nsEditor::GetAttributeValue(nsIDOMElement *aElement, 
-                            const nsString& aAttribute, 
-                            nsString& aResultValue, 
-                            PRBool&   aResultIsSet)
+                            const nsAReadableString & aAttribute, 
+                            nsAWritableString & aResultValue, 
+                            PRBool *aResultIsSet)
 {
-  aResultIsSet=PR_FALSE;
+  if (!aResultIsSet)
+    return NS_ERROR_NULL_POINTER;
+  *aResultIsSet=PR_FALSE;
   nsresult result=NS_OK;
   if (nsnull!=aElement)
   {
@@ -1091,7 +1092,7 @@ nsEditor::GetAttributeValue(nsIDOMElement *aElement,
     result = aElement->GetAttributeNode(aAttribute, getter_AddRefs(attNode));
     if ((NS_SUCCEEDED(result)) && attNode)
     {
-      attNode->GetSpecified(&aResultIsSet);
+      attNode->GetSpecified(aResultIsSet);
       attNode->GetValue(aResultValue);
     }
   }
@@ -1099,7 +1100,7 @@ nsEditor::GetAttributeValue(nsIDOMElement *aElement,
 }
 
 NS_IMETHODIMP 
-nsEditor::RemoveAttribute(nsIDOMElement *aElement, const nsString& aAttribute)
+nsEditor::RemoveAttribute(nsIDOMElement *aElement, const nsAReadableString& aAttribute)
 {
   ChangeAttributeTxn *txn;
   nsresult result = CreateTxnForRemoveAttribute(aElement, aAttribute, &txn);
@@ -1129,7 +1130,7 @@ nsEditor::MarkNodeDirty(nsIDOMNode* aNode)
 #pragma mark -
 #endif
 
-NS_IMETHODIMP nsEditor::CreateNode(const nsString& aTag,
+NS_IMETHODIMP nsEditor::CreateNode(const nsAReadableString& aTag,
                                    nsIDOMNode *    aParent,
                                    PRInt32         aPosition,
                                    nsIDOMNode **   aNewNode)
@@ -1380,9 +1381,9 @@ NS_IMETHODIMP nsEditor::DeleteNode(nsIDOMNode * aElement)
 nsresult
 nsEditor::ReplaceContainer(nsIDOMNode *inNode, 
                            nsCOMPtr<nsIDOMNode> *outNode, 
-                           const nsString &aNodeType,
-                           const nsString *aAttribute,
-                           const nsString *aValue,
+                           const nsAReadableString &aNodeType,
+                           const nsAReadableString *aAttribute,
+                           const nsAReadableString *aValue,
                            PRBool aCloneAttributes)
 {
   if (!inNode || !outNode)
@@ -1502,9 +1503,9 @@ nsEditor::RemoveContainer(nsIDOMNode *inNode)
 nsresult
 nsEditor::InsertContainerAbove( nsIDOMNode *inNode, 
                                 nsCOMPtr<nsIDOMNode> *outNode, 
-                                const nsString &aNodeType,
-                                const nsString *aAttribute,
-                                const nsString *aValue)
+                                const nsAReadableString &aNodeType,
+                                const nsAReadableString *aAttribute,
+                                const nsAReadableString *aValue)
 {
   if (!inNode || !outNode)
     return NS_ERROR_NULL_POINTER;
@@ -1771,7 +1772,7 @@ NS_IMETHODIMP nsEditor::OutputToString(nsAWritableString& aOutputString,
 NS_IMETHODIMP
 nsEditor::OutputToStream(nsIOutputStream* aOutputStream,
                          const nsAReadableString& aFormatType,
-                         const nsAReadableString* aCharsetOverride,
+                         const nsAReadableString& aCharsetOverride,
                          PRUint32 aFlags)
 {
   // these should be implemented by derived classes.
@@ -1788,7 +1789,7 @@ nsEditor::DumpContentTree()
 
 
 NS_IMETHODIMP
-nsEditor::DebugDumpContent() const
+nsEditor::DebugDumpContent()
 {
   nsCOMPtr<nsIContent>content;
   nsCOMPtr<nsIDOMNodeList>nodeList;
@@ -1935,7 +1936,7 @@ nsEditor::EndComposition(void)
 }
 
 NS_IMETHODIMP
-nsEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
+nsEditor::SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -2276,7 +2277,7 @@ NS_IMETHODIMP nsEditor::ScrollIntoView(PRBool aScrollToBegin)
 }
 
 /** static helper method */
-nsresult nsEditor::GetTextNodeTag(nsString& aOutString)
+nsresult nsEditor::GetTextNodeTag(nsAWritableString& aOutString)
 {
   aOutString.SetLength(0);
   static nsString *gTextNodeTag=nsnull;
@@ -2291,7 +2292,7 @@ nsresult nsEditor::GetTextNodeTag(nsString& aOutString)
 }
 
 
-NS_IMETHODIMP nsEditor::InsertTextImpl(const nsString& aStringToInsert, 
+NS_IMETHODIMP nsEditor::InsertTextImpl(const nsAReadableString& aStringToInsert, 
                                           nsCOMPtr<nsIDOMNode> *aInOutNode, 
                                           PRInt32 *aInOutOffset,
                                           nsIDOMDocument *aDoc)
@@ -2352,7 +2353,7 @@ NS_IMETHODIMP nsEditor::InsertTextImpl(const nsString& aStringToInsert,
 }
 
 
-NS_IMETHODIMP nsEditor::InsertTextIntoTextNodeImpl(const nsString& aStringToInsert, 
+NS_IMETHODIMP nsEditor::InsertTextIntoTextNodeImpl(const nsAReadableString& aStringToInsert, 
                                                      nsIDOMCharacterData *aTextNode, 
                                                      PRInt32 aOffset)
 {
@@ -2570,7 +2571,7 @@ nsEditor::NotifyDocumentListeners(TDocumentListenerNotification aNotificationTyp
 }
 
 
-NS_IMETHODIMP nsEditor::CreateTxnForInsertText(const nsString & aStringToInsert,
+NS_IMETHODIMP nsEditor::CreateTxnForInsertText(const nsAReadableString & aStringToInsert,
                                                nsIDOMCharacterData *aTextNode,
                                                PRInt32 aOffset,
                                                InsertTextTxn ** aTxn)
@@ -3077,6 +3078,7 @@ nsEditor::GetLengthOfDOMNode(nsIDOMNode *aNode, PRUint32 &aCount)
   return result;
 }
 
+
 nsresult 
 nsEditor::GetPriorNode(nsIDOMNode  *aParentNode, 
                        PRInt32      aOffset, 
@@ -3379,24 +3381,22 @@ nsEditor::NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag)
 }
 
 PRBool 
-nsEditor::NodeIsType(nsIDOMNode *aNode, const nsString &aTagStr)
+nsEditor::NodeIsType(nsIDOMNode *aNode, const nsAReadableString &aTagStr)
 {
   nsCOMPtr<nsIDOMElement>element;
   element = do_QueryInterface(aNode);
   if (element)
   {
-    nsAutoString tag;
+    nsAutoString tag, tagStr(aTagStr);
     element->GetTagName(tag);
-    if (tag.EqualsIgnoreCase(aTagStr))
-    {
+    if (tag.EqualsIgnoreCase(tagStr))
       return PR_TRUE;
-    }
   }
   return PR_FALSE;
 }
 
 PRBool 
-nsEditor::CanContainTag(nsIDOMNode* aParent, const nsString &aChildTag)
+nsEditor::CanContainTag(nsIDOMNode* aParent, const nsAReadableString &aChildTag)
 {
   nsAutoString parentStringTag;
   
@@ -3408,7 +3408,7 @@ nsEditor::CanContainTag(nsIDOMNode* aParent, const nsString &aChildTag)
 }
 
 PRBool 
-nsEditor::TagCanContain(const nsString &aParentTag, nsIDOMNode* aChild)
+nsEditor::TagCanContain(const nsAReadableString &aParentTag, nsIDOMNode* aChild)
 {
   nsAutoString childStringTag;
   
@@ -3426,7 +3426,7 @@ nsEditor::TagCanContain(const nsString &aParentTag, nsIDOMNode* aChild)
 }
 
 PRBool 
-nsEditor::TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag)
+nsEditor::TagCanContainTag(const nsAReadableString &aParentTag, const nsAReadableString &aChildTag)
 {
   // if we don't have a dtd then assume we can insert whatever want
   if (!mDTD) return PR_TRUE;
@@ -3680,7 +3680,7 @@ void nsEditor::HACKForceRedraw()
 
 nsresult
 nsEditor::GetFirstNodeOfType(nsIDOMNode     *aStartNode, 
-                             const nsString &aTag, 
+                             const nsAReadableString &aTag, 
                              nsIDOMNode    **aResult)
 {
   nsresult result=NS_OK;
@@ -3697,11 +3697,11 @@ nsEditor::GetFirstNodeOfType(nsIDOMNode     *aStartNode,
   while (childNode)
   {
     result = childNode->QueryInterface(NS_GET_IID(nsIDOMNode),getter_AddRefs(element));
-    nsAutoString tag;
     if (NS_SUCCEEDED(result) && (element))
     {    
+      nsAutoString tag, tagStr(aTag);
       element->GetTagName(tag);
-      if (PR_TRUE==aTag.EqualsIgnoreCase(tag))
+      if (tagStr.EqualsIgnoreCase(tag))
       {
         return (childNode->QueryInterface(NS_GET_IID(nsIDOMNode),(void **) aResult)); // does the addref
       }
@@ -3797,7 +3797,7 @@ nsEditor::GetTag(nsIDOMNode *aNode)
 // GetTagString: digs out string for the tag of this node
 //                    
 nsresult 
-nsEditor::GetTagString(nsIDOMNode *aNode, nsString& outString)
+nsEditor::GetTagString(nsIDOMNode *aNode, nsAWritableString& outString)
 {
   nsCOMPtr<nsIAtom> atom;
   
@@ -3840,7 +3840,6 @@ nsEditor::NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2)
 }
 
 
-///////////////////////////////////////////////////////////////////////////
 // IsTextOrElementNode: true if node of dom type element or text
 //               
 PRBool
@@ -4378,7 +4377,7 @@ nsEditor::DeleteSelectionImpl(nsIEditor::EDirection aAction)
 
 // XXX: error handling in this routine needs to be cleaned up!
 NS_IMETHODIMP
-nsEditor::DeleteSelectionAndCreateNode(const nsString& aTag,
+nsEditor::DeleteSelectionAndCreateNode(const nsAReadableString& aTag,
                                            nsIDOMNode ** aNewNode)
 {
   nsCOMPtr<nsIDOMNode> parentSelectedNode;
@@ -4557,8 +4556,8 @@ nsEditor::DoAfterDocumentSave()
 
 NS_IMETHODIMP 
 nsEditor::CreateTxnForSetAttribute(nsIDOMElement *aElement, 
-                                   const nsString& aAttribute, 
-                                   const nsString& aValue,
+                                   const nsAReadableString& aAttribute, 
+                                   const nsAReadableString& aValue,
                                    ChangeAttributeTxn ** aTxn)
 {
   nsresult result = NS_ERROR_NULL_POINTER;
@@ -4575,7 +4574,7 @@ nsEditor::CreateTxnForSetAttribute(nsIDOMElement *aElement,
 
 NS_IMETHODIMP 
 nsEditor::CreateTxnForRemoveAttribute(nsIDOMElement *aElement, 
-                                      const nsString& aAttribute,
+                                      const nsAReadableString& aAttribute,
                                       ChangeAttributeTxn ** aTxn)
 {
   nsresult result = NS_ERROR_NULL_POINTER;
@@ -4592,7 +4591,7 @@ nsEditor::CreateTxnForRemoveAttribute(nsIDOMElement *aElement,
 }
 
 
-NS_IMETHODIMP nsEditor::CreateTxnForCreateElement(const nsString& aTag,
+NS_IMETHODIMP nsEditor::CreateTxnForCreateElement(const nsAReadableString& aTag,
                                                   nsIDOMNode     *aParent,
                                                   PRInt32         aPosition,
                                                   CreateElementTxn ** aTxn)
@@ -4680,7 +4679,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteElement(nsIDOMNode * aElement,
 */
 
 NS_IMETHODIMP 
-nsEditor::CreateTxnForIMEText(const nsString & aStringToInsert,
+nsEditor::CreateTxnForIMEText(const nsAReadableString& aStringToInsert,
                               IMETextTxn ** aTxn)
 {
   NS_ASSERTION(aTxn, "illegal value- null ptr- aTxn");
@@ -5085,7 +5084,7 @@ nsresult nsEditor::ClearSelection()
 }
 
 nsresult
-nsEditor::CreateHTMLContent(const nsString& aTag, nsIContent** aContent)
+nsEditor::CreateHTMLContent(const nsAReadableString& aTag, nsIContent** aContent)
 {
   nsresult rv;
 
diff --git a/mozilla/editor/libeditor/base/nsEditor.h b/mozilla/editor/libeditor/base/nsEditor.h
index c63be7c628f..ddf0db75bab 100644
--- a/mozilla/editor/libeditor/base/nsEditor.h
+++ b/mozilla/editor/libeditor/base/nsEditor.h
@@ -122,123 +122,16 @@ public:
 //NOTE: Use   NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
   NS_DECL_ISUPPORTS
 
-  /* ------------ nsIEditor methods -------------- */
-  NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags);
-  NS_IMETHOD PostCreate();
-  NS_IMETHOD PreDestroy();
-  NS_IMETHOD GetFlags(PRUint32 *aFlags);
-  NS_IMETHOD SetFlags(PRUint32 aFlags);
-  NS_IMETHOD GetDocument(nsIDOMDocument **aDoc);
-  NS_IMETHOD GetRootElement(nsIDOMElement **aElement);
+  /* ------------ utility methods   -------------- */
   NS_IMETHOD GetPresShell(nsIPresShell **aPS);
-  NS_IMETHOD GetSelectionController(nsISelectionController **aSel);
-  NS_IMETHOD GetSelection(nsISelection **aSelection);
-  NS_IMETHOD DeleteSelection(EDirection aAction);
-  
-  NS_IMETHOD EnableUndo(PRBool aEnable);
-  NS_IMETHOD GetTransactionManager(nsITransactionManager* *aTxnManager);
-  NS_IMETHOD Do(nsITransaction *aTxn);
-  NS_IMETHOD Undo(PRUint32 aCount);
-  NS_IMETHOD CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo);
-  NS_IMETHOD Redo(PRUint32 aCount);
-  NS_IMETHOD CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo);
-
-  NS_IMETHOD BeginTransaction();
-  NS_IMETHOD EndTransaction();
-
-  NS_IMETHOD BeginPlaceHolderTransaction(nsIAtom *aName);
-  NS_IMETHOD EndPlaceHolderTransaction();
-  NS_IMETHOD ShouldTxnSetSelection(PRBool *aResult);
-
-  NS_IMETHOD GetDocumentIsEmpty(PRBool *aDocumentIsEmpty);
-
-  // file handling
-  NS_IMETHOD GetDocumentModified(PRBool *outDocModified);
-  NS_IMETHOD GetDocumentCharacterSet(PRUnichar** characterSet);
-  NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet);
-  NS_IMETHOD SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting, PRBool aSaveCopy, const nsString& aFormat);
-
-  NS_IMETHOD Cut();
-  NS_IMETHOD CanCut(PRBool &aCanCut);
-  NS_IMETHOD Copy();
-  NS_IMETHOD CanCopy(PRBool &aCanCopy);
-  NS_IMETHOD Paste(PRInt32 aSelectionType);
-  NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste);
-  NS_IMETHOD CanDrag(nsIDOMEvent *aEvent, PRBool &aCanDrag);
-  NS_IMETHOD DoDrag(nsIDOMEvent *aEvent);
-  NS_IMETHOD InsertFromDrop(nsIDOMEvent *aEvent);
-
-  NS_IMETHOD SelectAll();
-
-  NS_IMETHOD BeginningOfDocument();
-  NS_IMETHOD EndOfDocument();
-
-
-  /* Node and element manipulation */
-  NS_IMETHOD SetAttribute(nsIDOMElement * aElement, 
-                          const nsString& aAttribute, 
-                          const nsString& aValue);
-                          
-  NS_IMETHOD GetAttributeValue(nsIDOMElement * aElement, 
-                               const nsString& aAttribute, 
-                               nsString&       aResultValue, 
-                               PRBool&         aResultIsSet);
-                               
-  NS_IMETHOD RemoveAttribute(nsIDOMElement *aElement, const nsString& aAttribute);
-
-  NS_IMETHOD CreateNode(const nsString& aTag,
-                        nsIDOMNode *    aParent,
-                        PRInt32         aPosition,
-                        nsIDOMNode **   aNewNode);
-                        
-  NS_IMETHOD InsertNode(nsIDOMNode * aNode,
-                        nsIDOMNode * aParent,
-                        PRInt32      aPosition);
-
-  NS_IMETHOD SplitNode(nsIDOMNode * aExistingRightNode,
-                       PRInt32      aOffset,
-                       nsIDOMNode ** aNewLeftNode);
-
-  NS_IMETHOD JoinNodes(nsIDOMNode * aLeftNode,
-                       nsIDOMNode * aRightNode,
-                       nsIDOMNode * aParent);
-
-  NS_IMETHOD DeleteNode(nsIDOMNode * aChild);
-
-  NS_IMETHOD MarkNodeDirty(nsIDOMNode* aNode);
-
-
-  /* output */
-  NS_IMETHOD OutputToString(nsAWritableString& aOutputString,
-                            const nsAReadableString& aFormatType,
-                            PRUint32 aFlags);
-                            
-  NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
-                            const nsAReadableString& aFormatType,
-                            const nsAReadableString* aCharsetOverride,
-                            PRUint32 aFlags);
-
-  /* Listeners */
-  NS_IMETHOD AddEditorObserver(nsIEditorObserver *aObserver);
-  NS_IMETHOD RemoveEditorObserver(nsIEditorObserver *aObserver);
-  void  NotifyEditorObservers(void);
-
-  NS_IMETHOD AddEditActionListener(nsIEditActionListener *aListener);
-  NS_IMETHOD RemoveEditActionListener(nsIEditActionListener *aListener);
-
-  NS_IMETHOD AddDocumentStateListener(nsIDocumentStateListener *aListener);
-  NS_IMETHOD RemoveDocumentStateListener(nsIDocumentStateListener *aListener);
-
-
-  NS_IMETHOD DumpContentTree();
-  NS_IMETHOD DebugDumpContent() const;
-  NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
-
+  void NotifyEditorObservers(void);
+  /* ------------ nsIEditor methods -------------- */
+  NS_DECL_NSIEDITOR
   /* ------------ nsIEditorIMESupport methods -------------- */
   
   NS_IMETHOD BeginComposition(nsTextEventReply* aReply);
   NS_IMETHOD QueryComposition(nsTextEventReply* aReply);
-  NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
+  NS_IMETHOD SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
   NS_IMETHOD EndComposition(void);
   NS_IMETHOD ForceCompositionEnd(void);
   NS_IMETHOD GetReconversionString(nsReconversionEventReply *aReply);
@@ -246,31 +139,31 @@ public:
 public:
 
   
-  NS_IMETHOD InsertTextImpl(const nsString& aStringToInsert, 
+  NS_IMETHOD InsertTextImpl(const nsAReadableString& aStringToInsert, 
                                nsCOMPtr<nsIDOMNode> *aInOutNode, 
                                PRInt32 *aInOutOffset,
                                nsIDOMDocument *aDoc);
-  NS_IMETHOD InsertTextIntoTextNodeImpl(const nsString& aStringToInsert, 
+  NS_IMETHOD InsertTextIntoTextNodeImpl(const nsAReadableString& aStringToInsert, 
                                            nsIDOMCharacterData *aTextNode, 
                                            PRInt32 aOffset);
   NS_IMETHOD DeleteSelectionImpl(EDirection aAction);
-  NS_IMETHOD DeleteSelectionAndCreateNode(const nsString& aTag,
+  NS_IMETHOD DeleteSelectionAndCreateNode(const nsAReadableString& aTag,
                                            nsIDOMNode ** aNewNode);
 
   /* helper routines for node/parent manipulations */
   nsresult ReplaceContainer(nsIDOMNode *inNode, 
                             nsCOMPtr<nsIDOMNode> *outNode, 
-                            const nsString &aNodeType,
-                            const nsString *aAttribute = nsnull,
-                            const nsString *aValue = nsnull,
+                            const nsAReadableString &aNodeType,
+                            const nsAReadableString *aAttribute = nsnull,
+                            const nsAReadableString *aValue = nsnull,
                             PRBool aCloneAttributes = PR_FALSE);
 
   nsresult RemoveContainer(nsIDOMNode *inNode);
   nsresult InsertContainerAbove(nsIDOMNode *inNode, 
                                 nsCOMPtr<nsIDOMNode> *outNode, 
-                                const nsString &aNodeType,
-                                const nsString *aAttribute = nsnull,
-                                const nsString *aValue = nsnull);
+                                const nsAReadableString &aNodeType,
+                                const nsAReadableString *aAttribute = nsnull,
+                                const nsAReadableString *aValue = nsnull);
   nsresult MoveNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aOffset);
 
   /* Method to replace certain CreateElementNS() calls. 
@@ -278,15 +171,10 @@ public:
       nsString& aTag          - tag you want
       nsIContent** aContent   - returned Content that was created with above namespace.
   */
-  nsresult CreateHTMLContent(const nsString& aTag, nsIContent** aContent);
+  nsresult CreateHTMLContent(const nsAReadableString& aTag, nsIContent** aContent);
 
 protected:
 
-
-
-  //NOTE: Most callers are dealing with Nodes,
-  //  but these objects must supports nsIDOMElement
-  NS_IMETHOD CloneAttributes(nsIDOMNode *aDestNode, nsIDOMNode *aSourceNode);
   /*
   NS_IMETHOD SetProperties(nsVoidArray *aPropList);
   NS_IMETHOD GetProperties(nsVoidArray *aPropList);
@@ -295,19 +183,19 @@ protected:
   /** create a transaction for setting aAttribute to aValue on aElement
     */
   NS_IMETHOD CreateTxnForSetAttribute(nsIDOMElement *aElement, 
-                                      const nsString& aAttribute, 
-                                      const nsString& aValue,
+                                      const nsAReadableString &  aAttribute, 
+                                      const nsAReadableString &  aValue,
                                       ChangeAttributeTxn ** aTxn);
 
   /** create a transaction for removing aAttribute on aElement
     */
   NS_IMETHOD CreateTxnForRemoveAttribute(nsIDOMElement *aElement, 
-                                         const nsString& aAttribute,
+                                         const nsAReadableString &  aAttribute,
                                          ChangeAttributeTxn ** aTxn);
 
   /** create a transaction for creating a new child node of aParent of type aTag.
     */
-  NS_IMETHOD CreateTxnForCreateElement(const nsString& aTag,
+  NS_IMETHOD CreateTxnForCreateElement(const nsAReadableString & aTag,
                                        nsIDOMNode     *aParent,
                                        PRInt32         aPosition,
                                        CreateElementTxn ** aTxn);
@@ -336,12 +224,12 @@ protected:
   /** create a transaction for inserting aStringToInsert into aTextNode
     * if aTextNode is null, the string is inserted at the current selection.
     */
-  NS_IMETHOD CreateTxnForInsertText(const nsString & aStringToInsert,
+  NS_IMETHOD CreateTxnForInsertText(const nsAReadableString & aStringToInsert,
                                     nsIDOMCharacterData *aTextNode,
                                     PRInt32 aOffset,
                                     InsertTextTxn ** aTxn);
 
-  NS_IMETHOD CreateTxnForIMEText(const nsString & aStringToInsert,
+  NS_IMETHOD CreateTxnForIMEText(const nsAReadableString & aStringToInsert,
                                  IMETextTxn ** aTxn);
 
   /** create a transaction for adding a style sheet
@@ -436,7 +324,7 @@ public:
 
 
   /** return the string that represents text nodes in the content tree */
-  static nsresult GetTextNodeTag(nsString& aOutString);
+  static nsresult GetTextNodeTag(nsAWritableString& aOutString);
 
   /** 
    * SplitNode() creates a new node identical to an existing node, and split the contents between the two nodes
@@ -550,17 +438,17 @@ public:
    *  @param   aResult is the node we found, or nsnull if there is none
    */
   static nsresult GetFirstNodeOfType(nsIDOMNode     *aStartNode, 
-                                     const nsString &aTag, 
+                                     const nsAReadableString &aTag, 
                                      nsIDOMNode    **aResult);
 
   /** returns PR_TRUE if aNode is of the type implied by aTag */
   static PRBool NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag);
-  static PRBool NodeIsType(nsIDOMNode *aNode, const nsString &aTag);
+  static PRBool NodeIsType(nsIDOMNode *aNode, const nsAReadableString &aTag);
 
   /** returns PR_TRUE if aParent can contain a child of type aTag */
-  PRBool CanContainTag(nsIDOMNode* aParent, const nsString &aTag);
-  PRBool TagCanContain(const nsString &aParentTag, nsIDOMNode* aChild);
-  virtual PRBool TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag);
+  PRBool CanContainTag(nsIDOMNode* aParent, const nsAReadableString &aTag);
+  PRBool TagCanContain(const nsAReadableString &aParentTag, nsIDOMNode* aChild);
+  virtual PRBool TagCanContainTag(const nsAReadableString &aParentTag, const nsAReadableString &aChildTag);
 
   /** returns PR_TRUE if aNode is a descendant of our root node */
   PRBool IsDescendantOfBody(nsIDOMNode *inNode);
@@ -586,7 +474,7 @@ public:
 
 
   /** from html rules code - migration in progress */
-  static nsresult GetTagString(nsIDOMNode *aNode, nsString& outString);
+  static nsresult GetTagString(nsIDOMNode *aNode, nsAWritableString& outString);
   static nsCOMPtr<nsIAtom> GetTag(nsIDOMNode *aNode);
   static PRBool NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2);
   static PRBool IsTextOrElementNode(nsIDOMNode *aNode);
@@ -622,7 +510,7 @@ public:
                          nsCOMPtr<nsIDOMNode> *outRightNode = 0);
   nsresult JoinNodeDeep(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsCOMPtr<nsIDOMNode> *aOutJoinNode, PRInt32 *outOffset); 
 
-  nsresult GetString(const nsString& name, nsString& value);
+  nsresult GetString(const nsAReadableString& name, nsAWritableString& value);
 
   nsresult BeginUpdateViewBatch(void);
   nsresult EndUpdateViewBatch(void);
diff --git a/mozilla/editor/libeditor/base/nsEditorCommands.cpp b/mozilla/editor/libeditor/base/nsEditorCommands.cpp
index 0b3b470c8e3..03ea3054e86 100644
--- a/mozilla/editor/libeditor/base/nsEditorCommands.cpp
+++ b/mozilla/editor/libeditor/base/nsEditorCommands.cpp
@@ -53,7 +53,7 @@ nsUndoCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISuppo
   if (aEditor)
   {
     PRBool isEnabled;
-    return aEditor->CanUndo(isEnabled, *outCmdEnabled);
+    return aEditor->CanUndo(&isEnabled, outCmdEnabled);
   }
   return NS_OK;
 }
@@ -78,7 +78,7 @@ nsRedoCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISuppo
   if (aEditor)
   {
     PRBool isEnabled;
-    return aEditor->CanRedo(isEnabled, *outCmdEnabled);
+    return aEditor->CanRedo(&isEnabled, outCmdEnabled);
   }
   return NS_OK;
 }
@@ -101,7 +101,7 @@ nsCutCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISuppor
   nsCOMPtr<nsIEditor> aEditor = do_QueryInterface(aCommandRefCon);
   *outCmdEnabled = PR_FALSE;
   if (aEditor)
-    return aEditor->CanCut(*outCmdEnabled);
+    return aEditor->CanCut(outCmdEnabled);
 
   return NS_OK;
 }
@@ -155,7 +155,7 @@ nsCopyCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISuppo
   nsCOMPtr<nsIEditor> aEditor = do_QueryInterface(aCommandRefCon);
   *outCmdEnabled = PR_FALSE;
   if (aEditor)
-    return aEditor->CanCopy(*outCmdEnabled);
+    return aEditor->CanCopy(outCmdEnabled);
 
   return NS_OK;
 }
@@ -209,7 +209,7 @@ nsPasteCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupp
   nsCOMPtr<nsIEditor> aEditor = do_QueryInterface(aCommandRefCon);
   *outCmdEnabled = PR_FALSE;
   if (aEditor)
-    return aEditor->CanPaste(nsIClipboard::kGlobalClipboard, *outCmdEnabled);
+    return aEditor->CanPaste(nsIClipboard::kGlobalClipboard, outCmdEnabled);
 
   return NS_OK;
 }
@@ -250,7 +250,7 @@ nsDeleteCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISup
   nsAutoString cmdString(aCommandName);
 
   if (cmdString.EqualsWithConversion("cmd_delete"))
-    rv = aEditor->CanCut(*outCmdEnabled);
+    rv = aEditor->CanCut(outCmdEnabled);
   else if (cmdString.EqualsWithConversion("cmd_deleteCharBackward"))
     *outCmdEnabled = PR_TRUE;
   else if (cmdString.EqualsWithConversion("cmd_deleteCharForward"))
diff --git a/mozilla/editor/libeditor/html/TextEditorTest.cpp b/mozilla/editor/libeditor/html/TextEditorTest.cpp
index 260cfc955b2..65afe166a91 100644
--- a/mozilla/editor/libeditor/html/TextEditorTest.cpp
+++ b/mozilla/editor/libeditor/html/TextEditorTest.cpp
@@ -71,13 +71,13 @@ nsresult TextEditorTest::RunUnitTest(PRInt32 *outNumTests, PRInt32 *outNumTestsF
   // shouldn't we just bail on error here?
   
   // insert some simple text
-  result = mTextEditor->InsertText(NS_LITERAL_STRING("1234567890abcdefghij1234567890").get());
+  result = mTextEditor->InsertText(NS_LITERAL_STRING("1234567890abcdefghij1234567890"));
   TEST_RESULT(result);
   (*outNumTests)++;
   (*outNumTestsFailed) += (NS_FAILED(result) != NS_OK);
   
   // insert some more text
-  result = mTextEditor->InsertText(NS_LITERAL_STRING("Moreover, I am cognizant of the interrelatedness of all communities and states.  I cannot sit idly by in Atlanta and not be concerned about what happens in Birmingham.  Injustice anywhere is a threat to justice everywhere").get());
+  result = mTextEditor->InsertText(NS_LITERAL_STRING("Moreover, I am cognizant of the interrelatedness of all communities and states.  I cannot sit idly by in Atlanta and not be concerned about what happens in Birmingham.  Injustice anywhere is a threat to justice everywhere"));
   TEST_RESULT(result);
   (*outNumTests)++;
   (*outNumTestsFailed) += (NS_FAILED(result) != NS_OK);
@@ -174,14 +174,14 @@ nsresult TextEditorTest::TestTextProperties()
   PRBool all = PR_FALSE;
   PRBool first=PR_FALSE;
 
-  result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
+  result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all);
   TEST_RESULT(result);
   NS_ASSERTION(PR_FALSE==first, "first should be false");
   NS_ASSERTION(PR_FALSE==any, "any should be false");
   NS_ASSERTION(PR_FALSE==all, "all should be false");
-  result = htmlEditor->SetInlineProperty(nsIEditProperty::b, nsnull, nsnull);
+  result = htmlEditor->SetInlineProperty(nsIEditProperty::b, nsString(), nsString());
   TEST_RESULT(result);
-  result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
+  result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all);
   TEST_RESULT(result);
   NS_ASSERTION(PR_TRUE==first, "first should be true");
   NS_ASSERTION(PR_TRUE==any, "any should be true");
@@ -190,9 +190,9 @@ nsresult TextEditorTest::TestTextProperties()
 
   // remove the bold we just set
   printf("set the whole first text node to not bold\n");
-  result = htmlEditor->RemoveInlineProperty(nsIEditProperty::b, nsnull);
+  result = htmlEditor->RemoveInlineProperty(nsIEditProperty::b, nsString());
   TEST_RESULT(result);
-  result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
+  result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all);
   TEST_RESULT(result);
   NS_ASSERTION(PR_FALSE==first, "first should be false");
   NS_ASSERTION(PR_FALSE==any, "any should be false");
@@ -203,23 +203,23 @@ nsresult TextEditorTest::TestTextProperties()
   printf("set the first text node (1, length-1) to bold and italic, and (2, length-1) to underline.\n");
   selection->Collapse(textNode, 1);
   selection->Extend(textNode, length-1);
-  result = htmlEditor->SetInlineProperty(nsIEditProperty::b, nsnull, nsnull);
+  result = htmlEditor->SetInlineProperty(nsIEditProperty::b, nsString(), nsString());
   TEST_RESULT(result);
-  result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
+  result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all);
   TEST_RESULT(result);
   NS_ASSERTION(PR_TRUE==first, "first should be true");
   NS_ASSERTION(PR_TRUE==any, "any should be true");
   NS_ASSERTION(PR_TRUE==all, "all should be true");
   mEditor->DebugDumpContent();
   // make all that same text italic
-  result = htmlEditor->SetInlineProperty(nsIEditProperty::i, nsnull, nsnull);
+  result = htmlEditor->SetInlineProperty(nsIEditProperty::i, nsString(), nsString());
   TEST_RESULT(result);
-  result = htmlEditor->GetInlineProperty(nsIEditProperty::i, nsnull, nsnull, first, any, all);
+  result = htmlEditor->GetInlineProperty(nsIEditProperty::i, nsString(), nsString(), &first, &any, &all);
   TEST_RESULT(result);
   NS_ASSERTION(PR_TRUE==first, "first should be true");
   NS_ASSERTION(PR_TRUE==any, "any should be true");
   NS_ASSERTION(PR_TRUE==all, "all should be true");
-  result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
+  result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all);
   TEST_RESULT(result);
   NS_ASSERTION(PR_TRUE==first, "first should be true");
   NS_ASSERTION(PR_TRUE==any, "any should be true");
@@ -240,9 +240,9 @@ nsresult TextEditorTest::TestTextProperties()
   NS_ASSERTION(length==915, "wrong text node");
   selection->Collapse(textNode, 1);
   selection->Extend(textNode, length-2);
-  result = htmlEditor->SetInlineProperty(nsIEditProperty::u, nsnull, nsnull);
+  result = htmlEditor->SetInlineProperty(nsIEditProperty::u, nsString(), nsString());
   TEST_RESULT(result);
-  result = htmlEditor->GetInlineProperty(nsIEditProperty::u, nsnull, nsnull, first, any, all);
+  result = htmlEditor->GetInlineProperty(nsIEditProperty::u, nsString(), nsString(), &first, &any, &all);
   TEST_RESULT(result);
   NS_ASSERTION(PR_TRUE==first, "first should be true");
   NS_ASSERTION(PR_TRUE==any, "any should be true");
diff --git a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp
index 217207bd770..76798a07f1c 100644
--- a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp
+++ b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp
@@ -160,29 +160,29 @@ static nsCOMPtr<nsIDOMNode> GetTableParent(nsIDOMNode* aNode)
 }
 
 
-NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString)
+NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsAReadableString & aInString)
 {
   nsAutoString charset;
-  return InsertHTMLWithCharset(aInputString, charset);
+  return InsertHTMLWithCharset(aInString, charset);
 }
 
-nsresult nsHTMLEditor::InsertHTMLWithContext(const nsString& aInputString, const nsString& aContextStr, const nsString& aInfoStr)
+nsresult nsHTMLEditor::InsertHTMLWithContext(const nsAReadableString & aInputString, const nsAReadableString & aContextStr, const nsAReadableString & aInfoStr)
 {
   nsAutoString charset;
   return InsertHTMLWithCharsetAndContext(aInputString, charset, aContextStr, aInfoStr);
 }
 
 
-NS_IMETHODIMP nsHTMLEditor::InsertHTMLWithCharset(const nsString& aInputString, const nsString& aCharset)
+NS_IMETHODIMP nsHTMLEditor::InsertHTMLWithCharset(const nsAReadableString & aInputString, const nsAReadableString & aCharset)
 {
   return InsertHTMLWithCharsetAndContext(aInputString, aCharset, nsAutoString(), nsAutoString());
 }
 
 
-nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputString,
-                                                       const nsString& aCharset,
-                                                       const nsString& aContextStr,
-                                                       const nsString& aInfoStr)
+nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsAReadableString & aInputString,
+                                                       const nsAReadableString & aCharset,
+                                                       const nsAReadableString & aContextStr,
+                                                       const nsAReadableString & aInfoStr)
 {
   if (!mRules) return NS_ERROR_NOT_INITIALIZED;
 
@@ -604,8 +604,8 @@ NS_IMETHODIMP nsHTMLEditor::PrepareTransferable(nsITransferable **transferable)
 }
 
 NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable, 
-                                                   const nsString& aContextStr,
-                                                   const nsString& aInfoStr)
+                                                   const nsAReadableString & aContextStr,
+                                                   const nsAReadableString & aInfoStr)
 {
   nsresult rv = NS_OK;
   char* bestFlavor = nsnull;
@@ -645,7 +645,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable
         nsAutoEditBatch beginBatching(this);
         // pasting does not inherit local inline styles
         RemoveAllInlineProperties();
-        rv = InsertText(stuffToPaste.GetUnicode());
+        rv = InsertText(stuffToPaste);
         if (text)
           nsMemory::Free(text);
       }
@@ -906,12 +906,15 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
   return rv;
 }
 
-NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag)
+NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag)
 {
+  if (!aCanDrag)
+    return NS_ERROR_NULL_POINTER;
+
   /* we really should be checking the XY coordinates of the mouseevent and ensure that
    * that particular point is actually within the selection (not just that there is a selection)
    */
-  aCanDrag = PR_FALSE;
+  *aCanDrag = PR_FALSE;
  
   // KLUDGE to work around bug 50703
   // After double click and object property editing, 
@@ -949,7 +952,7 @@ NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag)
       res = selection->ContainsNode(eventTargetDomNode, PR_FALSE, &amTargettedCorrectly);
       if (NS_FAILED(res)) return res;
 
-    	aCanDrag = amTargettedCorrectly;
+    	*aCanDrag = amTargettedCorrectly;
     }
   }
 
@@ -1123,9 +1126,11 @@ NS_IMETHODIMP nsHTMLEditor::Paste(PRInt32 aSelectionType)
 }
 
 
-NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste)
+NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste)
 {
-  aCanPaste = PR_FALSE;
+  if (!aCanPaste)
+    return NS_ERROR_NULL_POINTER;
+  *aCanPaste = PR_FALSE;
   
   // can't paste if readonly
   if (!IsModifiable())
@@ -1180,7 +1185,7 @@ NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste)
   rv = clipboard->HasDataMatchingFlavors(flavorsList, aSelectionType, &haveFlavors);
   if (NS_FAILED(rv)) return rv;
   
-  aCanPaste = haveFlavors;
+  *aCanPaste = haveFlavors;
   return NS_OK;
 }
 
@@ -1197,7 +1202,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsQuotation(PRInt32 aSelectionType)
   return PasteAsCitedQuotation(citation, aSelectionType);
 }
 
-NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsString& aCitation,
+NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsAReadableString & aCitation,
                                                   PRInt32 aSelectionType)
 {
   nsAutoEditBatch beginBatching(this);
@@ -1310,7 +1315,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation(PRInt32 aSelectionType)
   return rv;
 }
 
-NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsString& aQuotedText,
+NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsAReadableString & aQuotedText,
                                               nsIDOMNode **aNodeInserted)
 {
   if (mFlags & eEditorPlaintextMask)
@@ -1327,7 +1332,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsString& aQuotedText,
 // in that here, quoted material is enclosed in a <pre> tag
 // in order to preserve the original line wrapping.
 NS_IMETHODIMP
-nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText,
+nsHTMLEditor::InsertAsPlaintextQuotation(const nsAReadableString & aQuotedText,
                                          nsIDOMNode **aNodeInserted)
 {
   nsresult rv;
@@ -1399,10 +1404,10 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText,
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
-                                     const nsString& aCitation,
+nsHTMLEditor::InsertAsCitedQuotation(const nsAReadableString & aQuotedText,
+                                     const nsAReadableString & aCitation,
                                      PRBool aInsertHTML,
-                                     const nsString& aCharset,
+                                     const nsAReadableString & aCharset,
                                      nsIDOMNode **aNodeInserted)
 {
   nsCOMPtr<nsIDOMNode> newNode;
@@ -1450,7 +1455,7 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
         res = InsertHTMLWithCharset(aQuotedText, aCharset);
 
       else
-        res = InsertText(aQuotedText.GetUnicode());  // XXX ignore charset
+        res = InsertText(aQuotedText);  // XXX ignore charset
 
       if (aNodeInserted)
       {
@@ -1475,9 +1480,9 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
 }
 
 nsresult nsHTMLEditor::CreateDOMFragmentFromPaste(nsIDOMNSRange *aNSRange,
-                                                  const nsString& aInputString,
-                                                  const nsString& aContextStr,
-                                                  const nsString& aInfoStr,
+                                                  const nsAReadableString & aInputString,
+                                                  const nsAReadableString & aContextStr,
+                                                  const nsAReadableString & aInfoStr,
                                                   nsCOMPtr<nsIDOMNode> *outFragNode,
                                                   PRInt32 *outRangeStartHint,
                                                   PRInt32 *outRangeEndHint)
diff --git a/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp b/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp
index 1d066339fd5..9ddf6e35da1 100644
--- a/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp
@@ -59,6 +59,8 @@
 
 #include "InsertTextTxn.h"
 #include "DeleteTextTxn.h"
+#include "nsReadableUtils.h"
+
 
 //const static char* kMOZEditorBogusNodeAttr="MOZ_EDITOR_BOGUS_NODE";
 //const static char* kMOZEditorBogusNodeValue="TRUE";
@@ -83,7 +85,7 @@ enum
 static PRBool IsBlockNode(nsIDOMNode* node)
 {
   PRBool isBlock (PR_FALSE);
-  nsHTMLEditor::NodeIsBlockStatic(node, isBlock);
+  nsHTMLEditor::NodeIsBlockStatic(node, &isBlock);
   return isBlock;
 }
 
@@ -500,12 +502,14 @@ nsHTMLEditRules::DidDoAction(nsISelection *aSelection,
  ********************************************************/
 
 NS_IMETHODIMP 
-nsHTMLEditRules::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL)
+nsHTMLEditRules::GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL)
 {
-  aMixed = PR_FALSE;
-  aOL = PR_FALSE;
-  aUL = PR_FALSE;
-  aDL = PR_FALSE;
+  if (!aMixed || !aOL || !aUL || !aDL)
+    return NS_ERROR_NULL_POINTER;
+  *aMixed = PR_FALSE;
+  *aOL = PR_FALSE;
+  *aUL = PR_FALSE;
+  *aDL = PR_FALSE;
   PRBool bNonList = PR_FALSE;
   
   nsCOMPtr<nsISupportsArray> arrayOfNodes;
@@ -522,9 +526,9 @@ nsHTMLEditRules::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &
     nsCOMPtr<nsIDOMNode> curNode( do_QueryInterface(isupports) );
     
     if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ul))
-      aUL = PR_TRUE;
+      *aUL = PR_TRUE;
     else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ol))
-      aOL = PR_TRUE;
+      *aOL = PR_TRUE;
     else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::li))
     {
       nsCOMPtr<nsIDOMNode> parent;
@@ -532,32 +536,34 @@ nsHTMLEditRules::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &
       res = nsEditor::GetNodeLocation(curNode, address_of(parent), &offset);
       if (NS_FAILED(res)) return res;
       if (nsHTMLEditUtils::IsUnorderedList(parent))
-        aUL = PR_TRUE;
+        *aUL = PR_TRUE;
       else if (nsHTMLEditUtils::IsOrderedList(parent))
-        aOL = PR_TRUE;
+        *aOL = PR_TRUE;
     }
     else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dl) ||
              mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dt) ||
              mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dd) )
     {
-      aDL = PR_TRUE;
+      *aDL = PR_TRUE;
     }
     else bNonList = PR_TRUE;
   }  
   
   // hokey arithmetic with booleans
-  if ( (aUL + aOL + aDL + bNonList) > 1) aMixed = PR_TRUE;
+  if ( (*aUL + *aOL + *aDL + bNonList) > 1) *aMixed = PR_TRUE;
   
   return res;
 }
 
 NS_IMETHODIMP 
-nsHTMLEditRules::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD)
+nsHTMLEditRules::GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD)
 {
-  aMixed = PR_FALSE;
-  aLI = PR_FALSE;
-  aDT = PR_FALSE;
-  aDD = PR_FALSE;
+  if (!aMixed || !aLI || !aDT || !aDD)
+    return NS_ERROR_NULL_POINTER;
+  *aMixed = PR_FALSE;
+  *aLI = PR_FALSE;
+  *aDT = PR_FALSE;
+  *aDD = PR_FALSE;
   PRBool bNonList = PR_FALSE;
   
   nsCOMPtr<nsISupportsArray> arrayOfNodes;
@@ -577,15 +583,15 @@ nsHTMLEditRules::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBo
         mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ol) ||
         mHTMLEditor->NodeIsType(curNode,nsIEditProperty::li) )
     {
-      aLI = PR_TRUE;
+      *aLI = PR_TRUE;
     }
     else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dt))
     {
-      aDT = PR_TRUE;
+      *aDT = PR_TRUE;
     }
     else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dd))
     {
-      aDD = PR_TRUE;
+      *aDD = PR_TRUE;
     }
     else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dl))
     {
@@ -593,20 +599,20 @@ nsHTMLEditRules::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBo
       PRBool bDT, bDD;
       res = GetDefinitionListItemTypes(curNode, bDT, bDD);
       if (NS_FAILED(res)) return res;
-      aDT |= bDT;
-      aDD |= bDD;
+      *aDT |= bDT;
+      *aDD |= bDD;
     }
     else bNonList = PR_TRUE;
   }  
   
   // hokey arithmetic with booleans
-  if ( (aDT + aDD + bNonList) > 1) aMixed = PR_TRUE;
+  if ( (*aDT + *aDD + bNonList) > 1) *aMixed = PR_TRUE;
   
   return res;
 }
 
 NS_IMETHODIMP 
-nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
+nsHTMLEditRules::GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
 {
   // for now, just return first alignment.  we'll lie about
   // if it's mixed.  This is for efficiency
@@ -617,8 +623,10 @@ nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
   // this routine assumes that alignment is done ONLY via divs
   
   // default alignment is left
-  aMixed = PR_FALSE;
-  aAlign = nsIHTMLEditor::eLeft;
+  if (!aMixed || !aAlign)
+    return NS_ERROR_NULL_POINTER;
+  *aMixed = PR_FALSE;
+  *aAlign = nsIHTMLEditor::eLeft;
   
   // get selection
   nsCOMPtr<nsISelection>selection;
@@ -673,13 +681,13 @@ nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
         if (NS_SUCCEEDED(res) && typeAttrVal.Length())
         {
           if (typeAttrVal.EqualsWithConversion("center"))
-            aAlign = nsIHTMLEditor::eCenter;
+            *aAlign = nsIHTMLEditor::eCenter;
           else if (typeAttrVal.EqualsWithConversion("right"))
-            aAlign = nsIHTMLEditor::eRight;
+            *aAlign = nsIHTMLEditor::eRight;
           else if (typeAttrVal.EqualsWithConversion("justify"))
-            aAlign = nsIHTMLEditor::eJustify;
+            *aAlign = nsIHTMLEditor::eJustify;
           else
-            aAlign = nsIHTMLEditor::eLeft;
+            *aAlign = nsIHTMLEditor::eLeft;
           return res;
         }
       }
@@ -692,10 +700,12 @@ nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
 }
 
 NS_IMETHODIMP 
-nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
+nsHTMLEditRules::GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent)
 {
-  aCanIndent = PR_TRUE;    
-  aCanOutdent = PR_FALSE;
+  if (!aCanIndent || !aCanOutdent)
+      return NS_ERROR_FAILURE;
+  *aCanIndent = PR_TRUE;    
+  *aCanOutdent = PR_FALSE;
   
   nsCOMPtr<nsISupportsArray> arrayOfNodes;
   nsresult res = GetListActionNodes(address_of(arrayOfNodes), PR_FALSE, PR_TRUE);
@@ -716,7 +726,7 @@ nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
         nsHTMLEditUtils::IsListItem(curNode) ||
         nsHTMLEditUtils::IsBlockquote(curNode))
     {
-      aCanOutdent = PR_TRUE;
+      *aCanOutdent = PR_TRUE;
       break;
     }
   }  
@@ -726,17 +736,19 @@ nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
 
 
 NS_IMETHODIMP 
-nsHTMLEditRules::GetParagraphState(PRBool &aMixed, nsString &outFormat)
+nsHTMLEditRules::GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat)
 {
   // This routine is *heavily* tied to our ui choices in the paragraph
   // style popup.  I cant see a way around that.
-  aMixed = PR_TRUE;
-  outFormat.AssignWithConversion("");
+  if (!aMixed)
+    return NS_ERROR_NULL_POINTER;
+  *aMixed = PR_TRUE;
+  outFormat.Truncate(0);
   
   PRBool bMixed = PR_FALSE;
   nsAutoString formatStr; 
   // using "x" as an uninitialized value, since "" is meaningful
-  formatStr.AssignWithConversion("x");
+  formatStr.Assign(NS_LITERAL_STRING("x"));
   
   nsCOMPtr<nsISupportsArray> arrayOfNodes;
   nsresult res = GetParagraphFormatNodes(address_of(arrayOfNodes), PR_TRUE);
@@ -794,12 +806,12 @@ nsHTMLEditRules::GetParagraphState(PRBool &aMixed, nsString &outFormat)
         }
         else
         {
-          format.AssignWithConversion("");
+          format.Truncate(0);
         }
       }
       else
       {
-        format.AssignWithConversion("");
+        format.Truncate(0);
       }  
     }    
     else if (nsHTMLEditUtils::IsHeader(curNode))
@@ -828,7 +840,7 @@ nsHTMLEditRules::GetParagraphState(PRBool &aMixed, nsString &outFormat)
     }
   }  
   
-  aMixed = bMixed;
+  *aMixed = bMixed;
   outFormat = formatStr;
   return res;
 }
@@ -904,8 +916,8 @@ nsHTMLEditRules::WillInsertText(PRInt32          aAction,
                                 nsISelection *aSelection, 
                                 PRBool          *aCancel,
                                 PRBool          *aHandled,
-                                const nsString  *inString,
-                                nsString        *outString,
+                                const nsAReadableString  *inString,
+                                nsAWritableString        *outString,
                                 PRInt32          aMaxLength)
 {  
   if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
@@ -986,7 +998,8 @@ nsHTMLEditRules::WillInsertText(PRInt32          aAction,
     // dont spaz my selection in subtransactions
     nsAutoTxnsConserveSelection dontSpazMySelection(mHTMLEditor);
     nsSubsumeStr subStr;
-    const PRUnichar *unicodeBuf = inString->GetUnicode();
+    const nsPromiseFlatString &tString = PromiseFlatString(*inString);////MJUDGE SCC NEED HELP
+    const PRUnichar *unicodeBuf = tString.get();
     nsCOMPtr<nsIDOMNode> unused;
     PRInt32 pos = 0;
         
@@ -995,13 +1008,21 @@ nsHTMLEditRules::WillInsertText(PRInt32          aAction,
     // it is to search for both tabs and newlines.
     if (isPRE)
     {
-      char newlineChar = '\n';
-      while (unicodeBuf && (pos != -1) && (pos < (PRInt32)inString->Length()))
+      nsAutoString newlineChar(NS_LITERAL_STRING("\n"));
+      while (unicodeBuf && (pos != -1) && (pos < (PRInt32)(*inString).Length()))
       {
         PRInt32 oldPos = pos;
         PRInt32 subStrLen;
-        pos = inString->FindChar(newlineChar, PR_FALSE, oldPos);
-        
+        pos = -1;
+        nsReadingIterator<PRUnichar> beginFindIter, endFindIter, beginIter;
+        inString->BeginReading(beginIter);
+        beginFindIter = beginIter;
+        inString->EndReading(endFindIter);
+        beginFindIter.advance(oldPos);
+        if (FindInReadable(newlineChar,beginFindIter,endFindIter))
+        {
+          pos = Distance(beginIter,beginFindIter);
+        }
         if (pos != -1) 
         {
           subStrLen = pos - oldPos;
@@ -1011,8 +1032,8 @@ nsHTMLEditRules::WillInsertText(PRInt32          aAction,
         }
         else
         {
-          subStrLen = inString->Length() - oldPos;
-          pos = inString->Length();
+          subStrLen = (*inString).Length() - oldPos;
+          pos = (*inString).Length();
         }
 
         subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen);
@@ -1032,13 +1053,22 @@ nsHTMLEditRules::WillInsertText(PRInt32          aAction,
     }
     else
     {
-      char specialChars[] = {'\t','\n',0};
+      nsAutoString specialChars;
+      specialChars = NS_LITERAL_STRING("\t\n");
       nsAutoString tabString; tabString.AssignWithConversion("    ");
-      while (unicodeBuf && (pos != -1) && (pos < (PRInt32)inString->Length()))
+      while (unicodeBuf && (pos != -1) && (pos < (PRInt32)(*inString).Length()))
       {
         PRInt32 oldPos = pos;
         PRInt32 subStrLen;
-        pos = inString->FindCharInSet(specialChars, oldPos);
+        nsReadingIterator<PRUnichar> beginFindIter,endFindIter;
+        (*inString).BeginReading(beginFindIter);
+        beginFindIter.advance(oldPos);
+        (*inString).EndReading(endFindIter);
+        nsReadingIterator<PRUnichar> distanceIter;
+        (*inString).BeginReading(distanceIter);
+        pos = -1;
+        if (FindInReadable((const nsAString &)specialChars,beginFindIter,endFindIter))
+          pos = Distance(distanceIter,beginFindIter);
         
         if (pos != -1) 
         {
@@ -1049,8 +1079,8 @@ nsHTMLEditRules::WillInsertText(PRInt32          aAction,
         }
         else
         {
-          subStrLen = inString->Length() - oldPos;
-          pos = inString->Length();
+          subStrLen = (*inString).Length() - oldPos;
+          pos = (*inString).Length();
         }
 
         subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen);
@@ -1900,11 +1930,11 @@ nsHTMLEditRules::DeleteNonTableElements(nsIDOMNode *aNode)
 
 nsresult
 nsHTMLEditRules::WillMakeList(nsISelection *aSelection, 
-                              const nsString *aListType, 
+                              const nsAReadableString *aListType, 
                               PRBool aEntireList,
                               PRBool *aCancel,
                               PRBool *aHandled,
-                              const nsString *aItemType)
+                              const nsAReadableString *aItemType)
 {
   if (!aSelection || !aListType || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
 
@@ -1918,9 +1948,10 @@ nsHTMLEditRules::WillMakeList(nsISelection *aSelection,
 
   // deduce what tag to use for list items
   nsAutoString itemType;
+  nsString tString(*aListType);//MJUDGE SCC NEED HELP
   if (aItemType) 
     itemType = *aItemType;
-  else if (aListType->EqualsWithConversion("dl"))
+  else if (tString.EqualsWithConversion("dl"))
     itemType.AssignWithConversion("dd");
   else
     itemType.AssignWithConversion("li");
@@ -2316,7 +2347,7 @@ nsHTMLEditRules::WillRemoveList(nsISelection *aSelection,
 
 nsresult
 nsHTMLEditRules::WillMakeDefListItem(nsISelection *aSelection, 
-                                     const nsString *aItemType, 
+                                     const nsAReadableString *aItemType, 
                                      PRBool aEntireList, 
                                      PRBool *aCancel,
                                      PRBool *aHandled)
@@ -2329,7 +2360,7 @@ nsHTMLEditRules::WillMakeDefListItem(nsISelection *aSelection,
 
 nsresult
 nsHTMLEditRules::WillMakeBasicBlock(nsISelection *aSelection, 
-                                    const nsString *aBlockType, 
+                                    const nsAReadableString *aBlockType, 
                                     PRBool *aCancel,
                                     PRBool *aHandled)
 {
@@ -2384,7 +2415,8 @@ nsHTMLEditRules::WillMakeBasicBlock(nsISelection *aSelection,
     // Ok, now go through all the nodes and make the right kind of blocks, 
     // or whatever is approriate.  Wohoo! 
     // Note: blockquote is handled a little differently
-    if (aBlockType->EqualsWithConversion("blockquote"))
+    nsString tString(*aBlockType);
+    if (tString.EqualsWithConversion("blockquote"))
       res = MakeBlockquote(arrayOfNodes);
     else
       res = ApplyBlockStyle(arrayOfNodes, aBlockType);
@@ -2664,8 +2696,8 @@ nsHTMLEditRules::WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *
 nsresult 
 nsHTMLEditRules::ConvertListType(nsIDOMNode *aList, 
                                  nsCOMPtr<nsIDOMNode> *outList,
-                                 const nsString& aListType, 
-                                 const nsString& aItemType) 
+                                 const nsAReadableString& aListType, 
+                                 const nsAReadableString& aItemType) 
 {
   if (!aList || !outList) return NS_ERROR_NULL_POINTER;
   *outList = aList;  // we migvht not need to change the list
@@ -2879,7 +2911,7 @@ nsHTMLEditRules::IsEmptyBlock(nsIDOMNode *aNode,
 
 nsresult
 nsHTMLEditRules::WillAlign(nsISelection *aSelection, 
-                           const nsString *alignType, 
+                           const nsAReadableString *alignType, 
                            PRBool *aCancel,
                            PRBool *aHandled)
 {
@@ -3046,7 +3078,7 @@ nsHTMLEditRules::WillAlign(nsISelection *aSelection,
 // AlignInnerBlocks: align inside table cells or list items
 //       
 nsresult
-nsHTMLEditRules::AlignInnerBlocks(nsIDOMNode *aNode, const nsString *alignType)
+nsHTMLEditRules::AlignInnerBlocks(nsIDOMNode *aNode, const nsAReadableString *alignType)
 {
   if (!aNode || !alignType) return NS_ERROR_NULL_POINTER;
   nsresult res;
@@ -3084,7 +3116,7 @@ nsHTMLEditRules::AlignInnerBlocks(nsIDOMNode *aNode, const nsString *alignType)
 // AlignBlockContents: align contents of a block element
 //                  
 nsresult
-nsHTMLEditRules::AlignBlockContents(nsIDOMNode *aNode, const nsString *alignType)
+nsHTMLEditRules::AlignBlockContents(nsIDOMNode *aNode, const nsAReadableString *alignType)
 {
   if (!aNode || !alignType) return NS_ERROR_NULL_POINTER;
   nsresult res;
@@ -4149,7 +4181,7 @@ nsHTMLEditRules::MakeTransitionList(nsISupportsArray *inArrayOfNodes,
 //                       
 nsresult 
 nsHTMLEditRules::InsertTab(nsISelection *aSelection, 
-                           nsString *outString)
+                           nsAWritableString *outString)
 {
   nsCOMPtr<nsIDOMNode> parentNode;
   PRInt32 offset;
@@ -4165,14 +4197,14 @@ nsHTMLEditRules::InsertTab(nsISelection *aSelection,
     
   if (isPRE)
   {
-    outString->AssignWithConversion('\t');
+    outString->Assign(PRUnichar('\t'));
   }
   else
   {
     // number of spaces should be a pref?
     // note that we dont play around with nbsps here anymore.  
     // let the AfterEdit whitespace cleanup code handle it.
-    outString->AssignWithConversion("    ");
+    outString->Assign(NS_LITERAL_STRING("    "));
   }
   
   return NS_OK;
@@ -4566,7 +4598,7 @@ nsHTMLEditRules::MakeBlockquote(nsISupportsArray *arrayOfNodes)
 //                   one or more blocks of type blockTag.  
 //                       
 nsresult 
-nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString *aBlockTag)
+nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsAReadableString *aBlockTag)
 {
   // intent of this routine is to be used for converting to/from
   // headers, paragraphs, pre, and address.  Those blocks
@@ -4582,7 +4614,8 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString
   
   // we special case an empty tag name to mean "remove block parents".
   // This is used for the "normal" paragraph style in mail-compose
-  if (aBlockTag->IsEmpty() || aBlockTag->EqualsWithConversion("normal")) bNoParent = PR_TRUE;
+  nsString tString(*aBlockTag);////MJUDGE SCC NEED HELP
+  if (tString.IsEmpty() || tString.EqualsWithConversion("normal")) bNoParent = PR_TRUE;
   
   arrayOfNodes->Count(&listCount);
   
@@ -4674,7 +4707,8 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString
     else if (IsInlineNode(curNode) && !bNoParent)
     {
       // if curNode is a non editable, drop it if we are going to <pre>
-      if ((aBlockTag->EqualsWithConversion("pre")) && (!mHTMLEditor->IsEditable(curNode)))
+      nsString tString(*aBlockTag); ////MJUDGE SCC NEED HELP
+      if ((tString.EqualsWithConversion("pre")) && (!mHTMLEditor->IsEditable(curNode)))
         continue; // do nothing to this block
       
       // if no curBlock, make one
@@ -4707,7 +4741,7 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString
 //                 where we can insert the tag.  Adjust inOutParent and
 //                 inOutOffset to pint to new location for tag.
 nsresult 
-nsHTMLEditRules::SplitAsNeeded(const nsString *aTag, 
+nsHTMLEditRules::SplitAsNeeded(const nsAReadableString *aTag, 
                                nsCOMPtr<nsIDOMNode> *inOutParent,
                                PRInt32 *inOutOffset)
 {
@@ -5443,47 +5477,48 @@ nsHTMLEditRules::DoTextNodeWhitespace(nsIDOMCharacterData *aTextNode, PRInt32 aS
 
 
 nsresult 
-nsHTMLEditRules::ConvertWhitespace(const nsString & inString, nsString & outString)
+nsHTMLEditRules::ConvertWhitespace(const nsAReadableString & inString, nsAWritableString & outString)
 {
   PRUint32 j,len = inString.Length();
+  nsString tString(inString);////MJUDGE SCC NEED HELP
   switch (len)
   {
     case 0:
       outString.SetLength(0);
       return NS_OK;
     case 1:
-      if (inString.EqualsWithConversion("\n"))   // a bit of a hack: don't convert single newlines that 
-        outString.AssignWithConversion("\n");     // dont have whitespace adjacent.  This is to preserve 
+      if (tString.EqualsWithConversion("\n"))   // a bit of a hack: don't convert single newlines that 
+        outString.Assign(NS_LITERAL_STRING("\n"));     // dont have whitespace adjacent.  This is to preserve 
       else                    // html source formatting to some degree.
-        outString.AssignWithConversion(" ");
+        outString.Assign(NS_LITERAL_STRING(" "));
       return NS_OK;
     case 2:
-      outString.Assign((PRUnichar)nbsp);
-      outString.AppendWithConversion(" ");
+      outString.Assign(PRUnichar(nbsp));
+      outString.Append(NS_LITERAL_STRING(" "));
       return NS_OK;
     case 3:
-      outString.AssignWithConversion(" ");
-      outString += (PRUnichar)nbsp;
-      outString.AppendWithConversion(" ");
+      outString.Assign(NS_LITERAL_STRING(" "));
+      outString += PRUnichar(nbsp);
+      outString.Append(NS_LITERAL_STRING(" "));
       return NS_OK;
   }
   if (len%2)  // length is odd
   {
     for (j=0;j<len;j++)
     {
-      if (!(j & 0x01)) outString.AppendWithConversion(" ");      // even char
-      else outString += (PRUnichar)nbsp; // odd char
+      if (!(j & 0x01)) outString.Append(NS_LITERAL_STRING(" "));      // even char
+      else outString += PRUnichar(nbsp); // odd char
     }
   }
   else
   {
-    outString.AssignWithConversion(" ");
-    outString += (PRUnichar)nbsp;
-    outString += (PRUnichar)nbsp;
+    outString.Assign(NS_LITERAL_STRING(" "));
+    outString += PRUnichar(nbsp);
+    outString += PRUnichar(nbsp);
     for (j=0;j<len-3;j++)
     {
-      if (!(j%2)) outString.AppendWithConversion(" ");      // even char
-      else outString += (PRUnichar)nbsp; // odd char
+      if (!(j%2)) outString.Append(NS_LITERAL_STRING(" "));      // even char
+      else outString += PRUnichar(nbsp); // odd char
     }
   }  
   return NS_OK;
@@ -5687,13 +5722,13 @@ nsHTMLEditRules::InsertMozBRIfNeeded(nsIDOMNode *aNode)
 #endif
 
 NS_IMETHODIMP 
-nsHTMLEditRules::WillCreateNode(const nsString& aTag, nsIDOMNode *aParent, PRInt32 aPosition)
+nsHTMLEditRules::WillCreateNode(const nsAReadableString& aTag, nsIDOMNode *aParent, PRInt32 aPosition)
 {
   return NS_OK;  
 }
 
 NS_IMETHODIMP 
-nsHTMLEditRules::DidCreateNode(const nsString& aTag, 
+nsHTMLEditRules::DidCreateNode(const nsAReadableString& aTag, 
                                nsIDOMNode *aNode, 
                                nsIDOMNode *aParent, 
                                PRInt32 aPosition, 
@@ -5798,7 +5833,7 @@ nsHTMLEditRules::DidJoinNodes(nsIDOMNode  *aLeftNode,
 
 
 NS_IMETHODIMP 
-nsHTMLEditRules::WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString)
+nsHTMLEditRules::WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString)
 {
   return NS_OK;  
 }
@@ -5807,7 +5842,7 @@ nsHTMLEditRules::WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset,
 NS_IMETHODIMP 
 nsHTMLEditRules::DidInsertText(nsIDOMCharacterData *aTextNode, 
                                   PRInt32 aOffset, 
-                                  const nsString &aString, 
+                                  const nsAReadableString &aString, 
                                   nsresult aResult)
 {
   if (!mListenerEnabled) return NS_OK;
diff --git a/mozilla/editor/libeditor/html/nsHTMLEditRules.h b/mozilla/editor/libeditor/html/nsHTMLEditRules.h
index 88fe713cd8d..077678895bf 100644
--- a/mozilla/editor/libeditor/html/nsHTMLEditRules.h
+++ b/mozilla/editor/libeditor/html/nsHTMLEditRules.h
@@ -54,16 +54,17 @@ public:
   NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult);
 
   // nsIHTMLEditRules methods
-  NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL);
-  NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD);
-  NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent);
-  NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign);
-  NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat);
+  
+  NS_IMETHOD GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL);
+  NS_IMETHOD GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD);
+  NS_IMETHOD GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent);
+  NS_IMETHOD GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign);
+  NS_IMETHOD GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat);
 
   // nsIEditActionListener methods
   
-  NS_IMETHOD WillCreateNode(const nsString& aTag, nsIDOMNode *aParent, PRInt32 aPosition);
-  NS_IMETHOD DidCreateNode(const nsString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult);
+  NS_IMETHOD WillCreateNode(const nsAReadableString& aTag, nsIDOMNode *aParent, PRInt32 aPosition);
+  NS_IMETHOD DidCreateNode(const nsAReadableString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult);
   NS_IMETHOD WillInsertNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition);
   NS_IMETHOD DidInsertNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult);
   NS_IMETHOD WillDeleteNode(nsIDOMNode *aChild);
@@ -72,8 +73,8 @@ public:
   NS_IMETHOD DidSplitNode(nsIDOMNode *aExistingRightNode, PRInt32 aOffset, nsIDOMNode *aNewLeftNode, nsresult aResult);
   NS_IMETHOD WillJoinNodes(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsIDOMNode *aParent);
   NS_IMETHOD DidJoinNodes(nsIDOMNode  *aLeftNode, nsIDOMNode *aRightNode, nsIDOMNode *aParent, nsresult aResult);
-  NS_IMETHOD WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString);
-  NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString, nsresult aResult);
+  NS_IMETHOD WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString);
+  NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString, nsresult aResult);
   NS_IMETHOD WillDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength);
   NS_IMETHOD DidDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength, nsresult aResult);
   NS_IMETHOD WillDeleteSelection(nsISelection *aSelection);
@@ -95,31 +96,31 @@ protected:
                             nsISelection *aSelection, 
                             PRBool          *aCancel,
                             PRBool          *aHandled,
-                            const nsString  *inString,
-                            nsString        *outString,
+                            const nsAReadableString  *inString,
+                            nsAWritableString        *outString,
                             PRInt32          aMaxLength);
   nsresult WillInsertBreak(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled);
   nsresult DidInsertBreak(nsISelection *aSelection, nsresult aResult);
   nsresult WillDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aAction, 
                                PRBool *aCancel, PRBool *aHandled);
   nsresult DeleteNonTableElements(nsIDOMNode *aNode);
-  nsresult WillMakeList(nsISelection *aSelection, const nsString *aListType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled, const nsString *aItemType=nsnull);
+  nsresult WillMakeList(nsISelection *aSelection, const nsAReadableString *aListType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled, const nsAReadableString *aItemType=nsnull);
   nsresult WillRemoveList(nsISelection *aSelection, PRBool aOrderd, PRBool *aCancel, PRBool *aHandled);
   nsresult WillIndent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled);
   nsresult WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled);
-  nsresult WillAlign(nsISelection *aSelection, const nsString *alignType, PRBool *aCancel, PRBool *aHandled);
-  nsresult WillMakeDefListItem(nsISelection *aSelection, const nsString *aBlockType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled);
-  nsresult WillMakeBasicBlock(nsISelection *aSelection, const nsString *aBlockType, PRBool *aCancel, PRBool *aHandled);
+  nsresult WillAlign(nsISelection *aSelection, const nsAReadableString *alignType, PRBool *aCancel, PRBool *aHandled);
+  nsresult WillMakeDefListItem(nsISelection *aSelection, const nsAReadableString *aBlockType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled);
+  nsresult WillMakeBasicBlock(nsISelection *aSelection, const nsAReadableString *aBlockType, PRBool *aCancel, PRBool *aHandled);
   nsresult DidMakeBasicBlock(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult);
-  nsresult AlignInnerBlocks(nsIDOMNode *aNode, const nsString *alignType);
-  nsresult AlignBlockContents(nsIDOMNode *aNode, const nsString *alignType);
+  nsresult AlignInnerBlocks(nsIDOMNode *aNode, const nsAReadableString *alignType);
+  nsresult AlignBlockContents(nsIDOMNode *aNode, const nsAReadableString *alignType);
   nsresult GetInnerContent(nsIDOMNode *aNode, nsISupportsArray *outArrayOfNodes, PRBool aList = PR_TRUE, PRBool aTble = PR_TRUE);
-  nsresult InsertTab(nsISelection *aSelection, nsString *outString);
+  nsresult InsertTab(nsISelection *aSelection, nsAWritableString *outString);
   nsresult ReturnInHeader(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset);
   nsresult ReturnInParagraph(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset, PRBool *aCancel, PRBool *aHandled);
   nsresult ReturnInListItem(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset);
   nsresult AfterEditInner(PRInt32 action, nsIEditor::EDirection aDirection);
-  nsresult ConvertListType(nsIDOMNode *aList, nsCOMPtr<nsIDOMNode> *outList, const nsString& aListType, const nsString& aItemType);
+  nsresult ConvertListType(nsIDOMNode *aList, nsCOMPtr<nsIDOMNode> *outList, const nsAReadableString& aListType, const nsAReadableString& aItemType);
   nsresult CreateStyleForInsertText(nsISelection *aSelection, nsIDOMDocument *aDoc);
   nsresult IsEmptyBlock(nsIDOMNode *aNode, 
                         PRBool *outIsEmptyBlock, 
@@ -150,9 +151,9 @@ protected:
   nsCOMPtr<nsIDOMNode> GetHighestInlineParent(nsIDOMNode* aNode);
   nsresult MakeTransitionList(nsISupportsArray *inArrayOfNodes, 
                                    nsVoidArray *inTransitionArray);
-  nsresult ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString *aBlockTag);
+  nsresult ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsAReadableString *aBlockTag);
   nsresult MakeBlockquote(nsISupportsArray *arrayOfNodes);
-  nsresult SplitAsNeeded(const nsString *aTag, nsCOMPtr<nsIDOMNode> *inOutParent, PRInt32 *inOutOffset);
+  nsresult SplitAsNeeded(const nsAReadableString *aTag, nsCOMPtr<nsIDOMNode> *inOutParent, PRInt32 *inOutOffset);
   nsresult AddTerminatingBR(nsIDOMNode *aBlock);
   nsresult JoinNodesSmart( nsIDOMNode *aNodeLeft, 
                            nsIDOMNode *aNodeRight, 
@@ -172,7 +173,7 @@ protected:
   nsresult SelectionEndpointInNode(nsIDOMNode *aNode, PRBool *aResult);
   nsresult DoTextNodeWhitespace(nsIDOMCharacterData *aTextNode, PRInt32 aStart, PRInt32 aEnd);
   nsresult UpdateDocChangeRange(nsIDOMRange *aRange);
-  nsresult ConvertWhitespace(const nsString & inString, nsString & outString);
+  nsresult ConvertWhitespace(const nsAReadableString & inString, nsAWritableString & outString);
   nsresult ConfirmSelectionInBody();
   nsresult InsertMozBRIfNeeded(nsIDOMNode *aNode);
 
diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp
index db2625e52d2..e272dcf7312 100644
--- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp
@@ -425,9 +425,9 @@ NS_IMETHODIMP nsHTMLEditor::InitRules()
  * Can be used to determine if a new paragraph should be started.
  */
 nsresult
-nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
+nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool *aIsBlock)
 {
-  if (!aNode) { return NS_ERROR_NULL_POINTER; }
+  if (!aNode || !aIsBlock) { return NS_ERROR_NULL_POINTER; }
 
 //#define USE_PARSER_FOR_BLOCKNESS 1
 #ifdef USE_PARSER_FOR_BLOCKNESS
@@ -443,11 +443,11 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
   if (!element)
   {
     // We don't have an element -- probably a text node
-    aIsBlock = PR_FALSE;
+    *aIsBlock = PR_FALSE;
     return NS_OK;
   }
 
-  aIsBlock = PR_FALSE;
+  *aIsBlock = PR_FALSE;
 
   // Get the node name and atom:
   nsAutoString tagName;
@@ -475,7 +475,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
       tagAtom==nsIEditProperty::td         ||
       tagAtom==nsIEditProperty::pre)
   {
-    aIsBlock = PR_TRUE;
+    *aIsBlock = PR_TRUE;
     return NS_OK;
   }
 
@@ -487,7 +487,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
   PRInt32 id;
   rv = sParserService->HTMLStringTagToId(tagName, &id);
   if (NS_FAILED(rv)) return rv;
-  rv = sParserService->IsBlock(id, aIsBlock);
+  rv = sParserService->IsBlock(id, *aIsBlock);
 
 #ifdef DEBUG
   // Check this against what we would have said with the old code:
@@ -517,12 +517,12 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
       tagAtom==nsIEditProperty::dd         ||
       tagAtom==nsIEditProperty::legend     )
   {
-    if (!aIsBlock)
+    if (!(*aIsBlock))
     {
       nsAutoString assertmsg (NS_LITERAL_STRING("Parser and editor disagree on blockness: "));
       assertmsg.Append(tagName);
       char* assertstr = assertmsg.ToNewCString();
-      NS_ASSERTION(aIsBlock, assertstr);
+      NS_ASSERTION(*aIsBlock, assertstr);
       Recycle(assertstr);
     }
   }
@@ -531,7 +531,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
   return rv;
 #else /* USE_PARSER_FOR_BLOCKNESS */
   nsresult result = NS_ERROR_FAILURE;
-  aIsBlock = PR_FALSE;
+  *aIsBlock = PR_FALSE;
   nsCOMPtr<nsIDOMElement>element;
   element = do_QueryInterface(aNode);
   if (element)
@@ -578,7 +578,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
           tagAtom==nsIEditProperty::dd         ||
           tagAtom==nsIEditProperty::legend     )
       {
-        aIsBlock = PR_TRUE;
+        *aIsBlock = PR_TRUE;
       }
       NS_RELEASE(tagAtom);
       result = NS_OK;
@@ -588,7 +588,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
     nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(aNode);
     if (nodeAsText)
     {
-      aIsBlock = PR_FALSE;
+      *aIsBlock = PR_FALSE;
       result = NS_OK;
     }
   }
@@ -597,22 +597,21 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
 #endif /* USE_PARSER_FOR_BLOCKNESS */
 }
 
-// Non-static version for the nsIEditor interface and JavaScript
-NS_IMETHODIMP 
-nsHTMLEditor::NodeIsBlock(nsIDOMNode *aNode, PRBool &aIsBlock)
+NS_IMETHODIMP
+nsHTMLEditor::NodeIsBlock(nsIDOMNode *aNode, PRBool *aIsBlock)
 {
   return NodeIsBlockStatic(aNode, aIsBlock);
 }
 
+// Non-static version for the nsIEditor interface and JavaScript
 NS_IMETHODIMP 
-nsHTMLEditor::SetDocumentTitle(const PRUnichar *aTitle)
+nsHTMLEditor::SetDocumentTitle(const nsAReadableString &aTitle)
 {
   SetDocTitleTxn *txn;
   nsresult result = TransactionFactory::GetNewTransaction(SetDocTitleTxn::GetCID(), (EditTxn **)&txn);
   if (NS_SUCCEEDED(result))  
   {
-    nsAutoString title(aTitle);
-    result = txn->Init(this, &title);
+    result = txn->Init(this, &aTitle);
 
     if (NS_SUCCEEDED(result)) 
     {
@@ -646,7 +645,7 @@ nsHTMLEditor::GetBlockNodeParent(nsIDOMNode *aNode)
   while (p)
   {
     PRBool isBlock;
-    if (NS_FAILED(NodeIsBlockStatic(p, isBlock)) || isBlock)
+    if (NS_FAILED(NodeIsBlockStatic(p, &isBlock)) || isBlock)
       break;
     if ( NS_FAILED(p->GetParentNode(getter_AddRefs(tmp))) || !tmp) // no parent, ran off top of tree
       return p;
@@ -697,7 +696,7 @@ nsHTMLEditor::GetBlockSection(nsIDOMNode *aChild,
   while ((NS_SUCCEEDED(result)) && sibling)
   {
     PRBool isBlock;
-    NodeIsBlockStatic(sibling, isBlock);
+    NodeIsBlockStatic(sibling, &isBlock);
     if (isBlock)
     {
       nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(sibling);
@@ -715,7 +714,7 @@ nsHTMLEditor::GetBlockSection(nsIDOMNode *aChild,
   while ((NS_SUCCEEDED(result)) && sibling)
   {
     PRBool isBlock;
-    NodeIsBlockStatic(sibling, isBlock);
+    NodeIsBlockStatic(sibling, &isBlock);
     if (isBlock) 
     {
       nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(sibling);
@@ -768,7 +767,7 @@ nsHTMLEditor::GetBlockSectionsForRange(nsIDOMRange *aRange,
         else
         {
           PRBool isNotInlineOrText;
-          result = NodeIsBlockStatic(currentNode, isNotInlineOrText);
+          result = NodeIsBlockStatic(currentNode, &isNotInlineOrText);
           if (isNotInlineOrText)
           {
             PRUint16 nodeType;
@@ -861,7 +860,7 @@ nsHTMLEditor::NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir)
   // much gnashing of teeth as we twit back and forth between content and domnode types
   content = do_QueryInterface(aNode);
   PRBool isBlock;
-  if (NS_SUCCEEDED(NodeIsBlockStatic(aNode, isBlock)) && isBlock)
+  if (NS_SUCCEEDED(NodeIsBlockStatic(aNode, &isBlock)) && isBlock)
   {
     blockParent = do_QueryInterface(aNode);
   }
@@ -936,7 +935,7 @@ nsHTMLEditor::IsNextCharWhitespace(nsIDOMNode *aParentNode,
   while (node) 
   {
     PRBool isBlock (PR_FALSE);
-    NodeIsBlock(node, isBlock);
+    NodeIsBlock(node, &isBlock);
     if (isBlock)  // skip over bold, italic, link, ect nodes
     {
       if (IsTextNode(node) && IsEditable(node))
@@ -1007,7 +1006,7 @@ nsHTMLEditor::IsPrevCharWhitespace(nsIDOMNode *aParentNode,
   while (node) 
   {
     PRBool isBlock (PR_FALSE);
-    NodeIsBlock(node, isBlock);
+    NodeIsBlock(node, &isBlock);
     if (isBlock)  // skip over bold, italic, link, ect nodes
     {
       if (IsTextNode(node) && IsEditable(node))
@@ -1093,7 +1092,7 @@ NS_IMETHODIMP nsHTMLEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
       if (!node) return NS_ERROR_FAILURE;
 
       PRBool isBlock (PR_FALSE);
-      NodeIsBlock(node, isBlock);
+      NodeIsBlock(node, &isBlock);
       if (isBlock) blockParent = node;
       else blockParent = GetBlockNodeParent(node);
       
@@ -1121,18 +1120,18 @@ NS_IMETHODIMP nsHTMLEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
       nsString empty;
       if (isShift && !(mFlags&eEditorPlaintextBit))
       {
-        return TypedText(empty.GetUnicode(), eTypedBR);  // only inserts a br node
+        return TypedText(empty, eTypedBR);  // only inserts a br node
       }
       else 
       {
-        return TypedText(empty.GetUnicode(), eTypedBreak);  // uses rules to figure out what to insert
+        return TypedText(empty, eTypedBreak);  // uses rules to figure out what to insert
       }
     }
     else if (keyCode == nsIDOMKeyEvent::DOM_VK_ESCAPE)
     {
       // pass escape keypresses through as empty strings: needed forime support
       nsString empty;
-      return TypedText(empty.GetUnicode(), eTypedText);
+      return TypedText(empty, eTypedText);
     }
     
     // if we got here we either fell out of the tab case or have a normal character.
@@ -1140,7 +1139,7 @@ NS_IMETHODIMP nsHTMLEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
     if (character && !altKey && !ctrlKey && !isShift && !metaKey)
     {
       nsAutoString key(character);
-      return TypedText(key.GetUnicode(), eTypedText);
+      return TypedText(key, eTypedText);
     }
   }
   return NS_ERROR_FAILURE;
@@ -1152,7 +1151,7 @@ NS_IMETHODIMP nsHTMLEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
    to TypedText() to determine what action to take, but without passing
    an event.
    */
-NS_IMETHODIMP nsHTMLEditor::TypedText(const PRUnichar* aString,
+NS_IMETHODIMP nsHTMLEditor::TypedText(const nsAReadableString& aString,
                                       PRInt32 aAction)
 {
   nsAutoPlaceHolderBatch batch(this, gTypingTxnName);
@@ -1491,7 +1490,7 @@ nsHTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(nsISelection *aSelect
 //  but we can't use that because it is selection-based and 
 //  the rules code won't let us edit under the <head> node
 NS_IMETHODIMP
-nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsString &aSourceToInsert)
+nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsAReadableString& aSourceToInsert)
 {
   nsCOMPtr<nsISelection> selection;
   nsresult res = GetSelection(getter_AddRefs(selection));
@@ -1596,7 +1595,7 @@ nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsString &aSourceToInsert)
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::RebuildDocumentFromSource(const nsString& aSourceString)
+nsHTMLEditor::RebuildDocumentFromSource(const nsAReadableString& aSourceString)
 {
   ForceCompositionEnd();
 
@@ -1611,22 +1610,29 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsString& aSourceString)
 
   // Find where the <body> tag starts.
   // If user mangled that, then abort
-  PRInt32 bodyStart = aSourceString.Find(NS_ConvertASCIItoUCS2("<body"), PR_TRUE);
-  if (bodyStart == -1) return NS_ERROR_FAILURE;
+  nsReadingIterator<PRUnichar> beginbody;
+  nsReadingIterator<PRUnichar> endbody;
+  aSourceString.BeginReading(beginbody);
+  aSourceString.EndReading(endbody);
+  if (!FindInReadable(NS_LITERAL_STRING("<body"),beginbody,endbody))
+    return NS_ERROR_FAILURE;
 
-  PRInt32 headStart = aSourceString.Find(NS_ConvertASCIItoUCS2("<head"), PR_TRUE);
-  if (headStart == -1) return NS_ERROR_FAILURE;
+  nsReadingIterator<PRUnichar> beginhead;
+  nsReadingIterator<PRUnichar> endhead;
+  aSourceString.BeginReading(beginhead);
+  aSourceString.EndReading(endhead);
+  if (!FindInReadable(NS_LITERAL_STRING("<head"),beginhead,endhead))
+    return NS_ERROR_FAILURE;
+
+  nsReadingIterator<PRUnichar> beginclosehead;
+  nsReadingIterator<PRUnichar> endclosehead;
+  aSourceString.BeginReading(beginclosehead);
+  aSourceString.EndReading(endclosehead);
 
   // Find the index after "<head>"
-  PRInt32 headEnd = aSourceString.Find(NS_ConvertASCIItoUCS2("</head"), PR_TRUE);
-
+  if (!FindInReadable(NS_LITERAL_STRING("</head"),beginclosehead,endclosehead))
+    beginclosehead = beginbody;
   // We'll be forgiving and assume head ends before body
-  if (headEnd == -1) headEnd = bodyStart;
-  nsAutoString headString;
-  aSourceString.Mid(headString, headStart, (headEnd - headStart));
-  
-  nsAutoString bodyString;
-  aSourceString.Mid(bodyString, bodyStart, (aSourceString.Length() - bodyStart - 1));
   
   // Time to change the document
   nsAutoEditBatch beginBatching(this);
@@ -1635,25 +1641,32 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsString& aSourceString)
   res = SelectAll();
   if (NS_FAILED(res)) return res;
 
-  res = InsertHTML(bodyString);
+  nsReadingIterator<PRUnichar> endtotal;
+  aSourceString.EndReading(endtotal);
+
+  res = InsertHTML(Substring(beginbody,endtotal));
   if (NS_FAILED(res)) return res;
   selection->Collapse(bodyElement, 0);
 
-  res = ReplaceHeadContentsWithHTML(headString);
+  res = ReplaceHeadContentsWithHTML(Substring(beginhead,beginclosehead));
   if (NS_FAILED(res)) return res;
 
   // Now we must copy attributes user might have edited on the <body> tag
   //  because InsertHTML (actually, CreateContextualFragment()) 
   //  will never return a body node in the DOM fragment
-  nsAutoString bodyTag;
+  nsReadingIterator<PRUnichar> beginclosebody = endbody;//<bodyX
+  nsReadingIterator<PRUnichar> endclosebody;
+  aSourceString.BeginReading(beginclosebody);
+  aSourceString.EndReading(endclosebody);
+  if (!FindInReadable(NS_LITERAL_STRING(">"),beginclosebody,endclosebody))
+    return NS_ERROR_FAILURE;
+
+  nsAutoString bodyTag(Substring(beginbody,endclosebody));//<bodyXXXX >
   // Truncate at the end of the body tag
-  PRInt32 bodyTagEnd = bodyString.FindChar((PRUnichar)'>', PR_FALSE, 5);
-  if (bodyTagEnd == -1) return NS_ERROR_FAILURE;
-  bodyString.Truncate(bodyTagEnd+1);
   
   // Kludge of the year: fool the parser by replacing "body" with "div" so we get a node
-  bodyString.ToLowerCase();
-  bodyString.ReplaceSubstring(NS_ConvertASCIItoUCS2("body"), NS_ConvertASCIItoUCS2("div"));
+  bodyTag.ToLowerCase();
+  bodyTag.ReplaceSubstring(NS_ConvertASCIItoUCS2("body"), NS_ConvertASCIItoUCS2("div"));
 
   nsCOMPtr<nsIDOMRange> range;
   res = selection->GetRangeAt(0, getter_AddRefs(range));
@@ -1663,7 +1676,7 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsString& aSourceString)
   if (!nsrange) return NS_ERROR_NO_INTERFACE;
 
   nsCOMPtr<nsIDOMDocumentFragment> docfrag;
-  res = nsrange->CreateContextualFragment(bodyString, getter_AddRefs(docfrag));
+  res = nsrange->CreateContextualFragment(bodyTag, getter_AddRefs(docfrag));
   if (NS_FAILED(res)) return res;
 
   nsCOMPtr<nsIDOMNode> fragmentAsNode (do_QueryInterface(docfrag));
@@ -1876,7 +1889,7 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::SetParagraphFormat(const nsString& aParagraphFormat)
+nsHTMLEditor::SetParagraphFormat(const nsAReadableString& aParagraphFormat)
 {
   nsAutoString tag; tag.Assign(aParagraphFormat);
   tag.ToLowerCase();
@@ -1923,7 +1936,7 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists)
     else 
     {
       PRBool isBlock (PR_FALSE);
-      NodeIsBlock(node, isBlock);
+      NodeIsBlock(node, &isBlock);
       if (isBlock) blockParent = node;
       else blockParent = GetBlockNodeParent(node);
       blockParentElem = do_QueryInterface(blockParent);
@@ -2004,10 +2017,10 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists)
 
 
 NS_IMETHODIMP 
-nsHTMLEditor::GetParagraphState(PRBool &aMixed, nsString &outFormat)
+nsHTMLEditor::GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
-
+  if (!aMixed) return NS_ERROR_NULL_POINTER;
   nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
   if (!htmlRules) return NS_ERROR_FAILURE;
   
@@ -2015,11 +2028,12 @@ nsHTMLEditor::GetParagraphState(PRBool &aMixed, nsString &outFormat)
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::GetBackgroundColorState(PRBool &aMixed, nsString &aOutColor)
+nsHTMLEditor::GetBackgroundColorState(PRBool *aMixed, nsAWritableString &aOutColor)
 {
   //TODO: We don't handle "mixed" correctly!
-  aMixed = PR_FALSE;
-  aOutColor.AssignWithConversion("");
+  if (!aMixed) return NS_ERROR_NULL_POINTER;
+  *aMixed = PR_FALSE;
+  aOutColor.Assign(NS_LITERAL_STRING(""));
   
   nsCOMPtr<nsIDOMElement> element;
   PRInt32 selectedCount;
@@ -2059,10 +2073,10 @@ nsHTMLEditor::GetBackgroundColorState(PRBool &aMixed, nsString &aOutColor)
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL)
+nsHTMLEditor::GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
-
+  if (!aMixed || !aOL || !aUL || !aDL) return NS_ERROR_NULL_POINTER;
   nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
   if (!htmlRules) return NS_ERROR_FAILURE;
   
@@ -2070,9 +2084,10 @@ nsHTMLEditor::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD)
+nsHTMLEditor::GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
+  if (!aMixed || !aLI || !aDT || !aDD) return NS_ERROR_NULL_POINTER;
 
   nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
   if (!htmlRules) return NS_ERROR_FAILURE;
@@ -2081,10 +2096,10 @@ nsHTMLEditor::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
+nsHTMLEditor::GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
-
+  if (!aMixed || !aAlign) return NS_ERROR_NULL_POINTER;
   nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
   if (!htmlRules) return NS_ERROR_FAILURE;
   
@@ -2093,9 +2108,10 @@ nsHTMLEditor::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
 
 
 NS_IMETHODIMP 
-nsHTMLEditor::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
+nsHTMLEditor::GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
+  if (!aCanIndent || !aCanOutdent) return NS_ERROR_NULL_POINTER;
 
   nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
   if (!htmlRules) return NS_ERROR_FAILURE;
@@ -2104,7 +2120,7 @@ nsHTMLEditor::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::MakeOrChangeList(const nsString& aListType, PRBool entireList)
+nsHTMLEditor::MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList)
 {
   nsresult res;
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@@ -2182,7 +2198,7 @@ nsHTMLEditor::MakeOrChangeList(const nsString& aListType, PRBool entireList)
 
 
 NS_IMETHODIMP
-nsHTMLEditor::RemoveList(const nsString& aListType)
+nsHTMLEditor::RemoveList(const nsAReadableString& aListType)
 {
   nsresult res;
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@@ -2199,7 +2215,8 @@ nsHTMLEditor::RemoveList(const nsString& aListType)
   if (!selection) return NS_ERROR_NULL_POINTER;
 
   nsTextRulesInfo ruleInfo(nsTextEditRules::kRemoveList);
-  if (aListType.EqualsWithConversion("ol")) ruleInfo.bOrdered = PR_TRUE;
+  nsString tString(aListType);//MJUDGE SCC NEED HELP
+  if (tString.EqualsWithConversion("ol")) ruleInfo.bOrdered = PR_TRUE;
   else  ruleInfo.bOrdered = PR_FALSE;
   res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   if (cancel || (NS_FAILED(res))) return res;
@@ -2211,7 +2228,7 @@ nsHTMLEditor::RemoveList(const nsString& aListType)
 }
 
 nsresult
-nsHTMLEditor::MakeDefinitionItem(const nsString& aItemType)
+nsHTMLEditor::MakeDefinitionItem(const nsAReadableString& aItemType)
 {
   nsresult res;
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@@ -2241,7 +2258,7 @@ nsHTMLEditor::MakeDefinitionItem(const nsString& aItemType)
 }
 
 nsresult
-nsHTMLEditor::InsertBasicBlock(const nsString& aBlockType)
+nsHTMLEditor::InsertBasicBlock(const nsAReadableString& aBlockType)
 {
   nsresult res;
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@@ -2313,7 +2330,7 @@ nsHTMLEditor::InsertBasicBlock(const nsString& aBlockType)
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::Indent(const nsString& aIndent)
+nsHTMLEditor::Indent(const nsAReadableString& aIndent)
 {
   nsresult res;
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@@ -2321,7 +2338,8 @@ nsHTMLEditor::Indent(const nsString& aIndent)
   PRBool cancel, handled;
   PRInt32 theAction = nsTextEditRules::kIndent;
   PRInt32 opID = kOpIndent;
-  if (aIndent.EqualsWithConversion("outdent"))
+  nsString tString(aIndent);//MJUDGE SCC NEED HELP
+  if (tString.EqualsWithConversion("outdent"))
   {
     theAction = nsTextEditRules::kOutdent;
     opID = kOpOutdent;
@@ -2384,7 +2402,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
         // put a space in it so layout will draw the list item
         res = selection->Collapse(newBQ,0);
         if (NS_FAILED(res)) return res;
-        res = InsertText(NS_LITERAL_STRING(" ").get());
+        res = InsertText(NS_LITERAL_STRING(" "));
         if (NS_FAILED(res)) return res;
         // reposition selection to before the space character
         res = GetStartNodeAndOffset(selection, address_of(node), &offset);
@@ -2401,7 +2419,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
 //TODO: IMPLEMENT ALIGNMENT!
 
 NS_IMETHODIMP
-nsHTMLEditor::Align(const nsString& aAlignType)
+nsHTMLEditor::Align(const nsAReadableString& aAlignType)
 {
   nsAutoEditBatch beginBatching(this);
   nsAutoRules beginRulesSniffing(this, kOpAlign, nsIEditor::eNext);
@@ -2547,7 +2565,7 @@ NODE_FOUND:
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aReturn)
+nsHTMLEditor::GetSelectedElement(const nsAReadableString& aTagName, nsIDOMElement** aReturn)
 {
   if (!aReturn )
     return NS_ERROR_NULL_POINTER;
@@ -2895,8 +2913,8 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
       if (href.GetUnicode() && href.Length() > 0)      
       {
         nsAutoEditBatch beginBatching(this);
-        nsString attribute; attribute.AssignWithConversion("href");
-        SetInlineProperty(nsIEditProperty::a, &attribute, &href);
+        nsString attribute(NS_LITERAL_STRING("href")); 
+        SetInlineProperty(nsIEditProperty::a, attribute, href);
         //TODO: Enumerate through other properties of the anchor tag
         // and set those as well. 
         // Optimization: Modify SetTextProperty to set all attributes at once?
@@ -2907,7 +2925,7 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::SetBackgroundColor(const nsString& aColor)
+nsHTMLEditor::SetBackgroundColor(const nsAReadableString& aColor)
 {
   NS_PRECONDITION(mDocWeak, "Missing Editor DOM Document");
   
@@ -2958,7 +2976,7 @@ nsHTMLEditor::SetBackgroundColor(const nsString& aColor)
   return res;
 }
 
-NS_IMETHODIMP nsHTMLEditor::SetBodyAttribute(const nsString& aAttribute, const nsString& aValue)
+NS_IMETHODIMP nsHTMLEditor::SetBodyAttribute(const nsAReadableString& aAttribute, const nsAReadableString& aValue)
 {
   nsresult res;
   // TODO: Check selection for Cell, Row, Column or table and do color on appropriate level
@@ -3056,20 +3074,20 @@ nsHTMLEditor::RemoveOverrideStyleSheet(nsICSSStyleSheet* aSheet)
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::ApplyOverrideStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)
+nsHTMLEditor::ApplyOverrideStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet)
 {
   return ApplyDocumentOrOverrideStyleSheet(aURL, PR_TRUE, aStyleSheet);
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)
+nsHTMLEditor::ApplyStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet)
 {
   return ApplyDocumentOrOverrideStyleSheet(aURL, PR_FALSE, aStyleSheet);
 }
 
 //Note: Loading a document style sheet is undoable, loading an override sheet is not
 nsresult 
-nsHTMLEditor::ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet)
+nsHTMLEditor::ApplyDocumentOrOverrideStyleSheet(const nsAReadableString& aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet)
 {
   nsresult rv   = NS_OK;
   nsCOMPtr<nsIURI> uaURL;
@@ -3273,7 +3291,7 @@ static nsresult SetSelectionAroundHeadChildren(nsCOMPtr<nsISelection> aSelection
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetHeadContentsAsHTML(nsString& aOutputString)
+nsHTMLEditor::GetHeadContentsAsHTML(nsAWritableString& aOutputString)
 {
   nsCOMPtr<nsISelection> selection;
   nsresult res = GetSelection(getter_AddRefs(selection));
@@ -3292,15 +3310,27 @@ nsHTMLEditor::GetHeadContentsAsHTML(nsString& aOutputString)
   {
     // Selection always includes <body></body>,
     //  so terminate there
-    PRInt32 offset = aOutputString.Find(NS_ConvertASCIItoUCS2("<body"), PR_TRUE);
-    if (offset > 0)
+    nsReadingIterator<PRUnichar> findIter,endFindIter;
+    aOutputString.BeginReading(findIter);
+    aOutputString.EndReading(endFindIter);
+    //counting on our parser to always lower case!!!
+    if (FindInReadable(NS_LITERAL_STRING("<body"),findIter,endFindIter))
     {
+      nsReadingIterator<PRUnichar> beginIter;
+      aOutputString.BeginReading(beginIter);
+      PRInt32 offset = Distance(beginIter, findIter);//get the distance
+
+      nsWritingIterator<PRUnichar> writeIter;
+      aOutputString.BeginWriting(writeIter);
       // Ensure the string ends in a newline
       PRUnichar newline ('\n');
-      if (aOutputString.CharAt(offset-1) != newline)
-        aOutputString.SetCharAt(newline, offset++);
-
-      aOutputString.Truncate(offset);
+      findIter.advance(-1);
+      if (offset ==0 || (offset >0 &&  (*findIter) != newline)) //check for 0
+      {
+        writeIter.advance(offset);
+        *writeIter = newline;
+        aOutputString.Truncate(offset+1);
+      }
     }
   }
   return res;
@@ -3332,7 +3362,7 @@ nsHTMLEditor::DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed)
 #endif
 
 NS_IMETHODIMP
-nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
+nsHTMLEditor::SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
 {
   NS_ASSERTION(aTextRangeList, "null ptr");
   if(nsnull == aTextRangeList)
@@ -3355,7 +3385,7 @@ nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivat
   mIMETextRangeList = aTextRangeList;
   nsAutoPlaceHolderBatch batch(this, gIMETxnName);
 
-  result = InsertText(aCompositionString.GetUnicode());
+  result = InsertText(aCompositionString);
 
   mIMEBufferLength = aCompositionString.Length();
 
@@ -3492,28 +3522,29 @@ nsHTMLEditor::EndOperation()
 }  
 
 PRBool 
-nsHTMLEditor::TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag)
+nsHTMLEditor::TagCanContainTag(const nsAReadableString& aParentTag, const nsAReadableString& aChildTag)  
 {
   // COtherDTD gives some unwanted results.  We override them here.
   nsAutoString olStr, ulStr, liStr;
   olStr = NS_LITERAL_STRING("ol");
   ulStr = NS_LITERAL_STRING("ul");
   liStr = NS_LITERAL_STRING("li");
-  
-  if ( aParentTag.EqualsIgnoreCase(olStr) ||
-       aParentTag.EqualsIgnoreCase(ulStr) )
+  nsString tParent(aParentTag);//MJUDGE SCC NEED HELP
+  nsString tChild(aChildTag);//MJUDGE SCC NEED HELP
+  if ( tParent.EqualsIgnoreCase(olStr) ||
+       tParent.EqualsIgnoreCase(ulStr) )
   {
     // if parent is a list and tag is also a list, say "yes".
     // This is because the editor does sublists illegally for now. 
-    if (aChildTag.EqualsIgnoreCase(olStr) ||
-        aChildTag.EqualsIgnoreCase(ulStr) ) 
+    if (tChild.EqualsIgnoreCase(olStr) ||
+        tChild.EqualsIgnoreCase(ulStr) ) 
       return PR_TRUE;
   }
 
-  if ( aParentTag.EqualsIgnoreCase(liStr) )
+  if ( tParent.EqualsIgnoreCase(liStr) )
   {
     // list items cant contain list items
-    if (aChildTag.EqualsIgnoreCase(liStr) ) 
+    if (tChild.EqualsIgnoreCase(liStr) ) 
       return PR_FALSE;
   }
 
@@ -3607,8 +3638,8 @@ NS_IMETHODIMP nsHTMLEditor::GetLayoutObject(nsIDOMNode *aNode, nsISupports **aLa
 // so singleton attributes like <Table border> will not be matched!
 void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode     *aNode,
                                               nsIAtom        *aProperty, 
-                                              const nsString *aAttribute, 
-                                              const nsString *aValue, 
+                                              const nsAReadableString *aAttribute, 
+                                              const nsAReadableString *aValue, 
                                               PRBool         &aIsSet,
                                               nsIDOMNode    **aStyleNode,
                                               nsString       *outValue) const
@@ -3639,11 +3670,15 @@ void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode     *aNode,
             if (!aValue) {
               found = PR_TRUE;
             }
-            else if (aValue->EqualsIgnoreCase(value)) {
-              found = PR_TRUE;
-            }
-            else {  // we found the prop with the attribute, but the value doesn't match
-              break;
+            else
+            {
+              nsString tString(*aValue);
+              if (tString.EqualsIgnoreCase(value)) {
+                found = PR_TRUE;
+              }
+              else {  // we found the prop with the attribute, but the value doesn't match
+                break;
+              }
             }
           }
         }
@@ -3670,7 +3705,7 @@ void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode     *aNode,
 
 void nsHTMLEditor::IsTextStyleSet(nsIStyleContext *aSC, 
                                   nsIAtom *aProperty, 
-                                  const nsString *aAttribute,  
+                                  const nsAReadableString *aAttribute,  
                                   PRBool &aIsSet) const
 {
   aIsSet = PR_FALSE;
@@ -3969,7 +4004,7 @@ nsHTMLEditor::CollapseAdjacentTextNodes(nsIDOMRange *aInRange)
 
 NS_IMETHODIMP
 nsHTMLEditor::GetNextElementByTagName(nsIDOMElement    *aCurrentElement,
-                                      const nsString   *aTagName,
+                                      const nsAReadableString   *aTagName,
                                       nsIDOMElement   **aReturn)
 {
   nsresult res = NS_OK;
diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.h b/mozilla/editor/libeditor/html/nsHTMLEditor.h
index 481ccf5ee83..5434e6a96bd 100644
--- a/mozilla/editor/libeditor/html/nsHTMLEditor.h
+++ b/mozilla/editor/libeditor/html/nsHTMLEditor.h
@@ -99,72 +99,75 @@ public:
 
   /* ------------ nsIHTMLEditor methods -------------- */
   NS_IMETHOD SetInlineProperty(nsIAtom *aProperty, 
-                             const nsString *aAttribute,
-                             const nsString *aValue);
-
+                            const nsAReadableString & aAttribute, 
+                            const nsAReadableString & aValue);
+  
   NS_IMETHOD GetInlineProperty(nsIAtom *aProperty, 
-                             const nsString *aAttribute,
-                             const nsString *aValue,
-                             PRBool &aFirst, PRBool &aAny, PRBool &aAll);
+                             const nsAReadableString & aAttribute, 
+                             const nsAReadableString & aValue, 
+                             PRBool *aFirst, 
+                             PRBool *aAny, 
+                             PRBool *aAll);
   NS_IMETHOD GetInlinePropertyWithAttrValue(nsIAtom *aProperty, 
-                             const nsString *aAttribute,
-                             const nsString *aValue,
-                             PRBool &aFirst, PRBool &aAny, PRBool &aAll,
-                             nsString *outValue);
-
+                             const nsAReadableString &aAttribute,
+                             const nsAReadableString &aValue,
+                             PRBool *aFirst, 
+                             PRBool *aAny, 
+                             PRBool *aAll,
+                             nsAWritableString &outValue);
   NS_IMETHOD RemoveAllInlineProperties();
-  NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute);
+  NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsAReadableString & aAttribute);
   NS_IMETHOD IncreaseFontSize();
   NS_IMETHOD DecreaseFontSize();
 
-  NS_IMETHOD InsertHTML(const nsString &aInputString);
-  NS_IMETHOD InsertHTMLWithCharset(const nsString& aInputString,
-                                   const nsString& aCharset);
-  NS_IMETHOD RebuildDocumentFromSource(const nsString& aSourceString);
+  NS_IMETHOD InsertHTML(const nsAReadableString &aInputString);
+  NS_IMETHOD InsertHTMLWithCharset(const nsAReadableString& aInputString,
+                                   const nsAReadableString& aCharset);
+  NS_IMETHOD RebuildDocumentFromSource(const nsAReadableString& aSourceString);
   NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection);
   
   NS_IMETHOD SelectElement(nsIDOMElement* aElement);
   NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement);
 
-  NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat);
+  NS_IMETHOD SetParagraphFormat(const nsAReadableString& aParagraphFormat);
 
   NS_IMETHOD GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists);
 
-  NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat);
-  NS_IMETHOD GetFontFaceState(PRBool &aMixed, nsString &outFace);
-  NS_IMETHOD GetFontColorState(PRBool &aMixed, nsString &outColor);
-  NS_IMETHOD GetBackgroundColorState(PRBool &aMixed, nsString &outColor);
-  NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL);
-  NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD);
-  NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign);
-  NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent);
+  NS_IMETHOD GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat);
+  NS_IMETHOD GetFontFaceState(PRBool *aMixed, nsAWritableString &outFace);
+  NS_IMETHOD GetFontColorState(PRBool *aMixed, nsAWritableString &outColor);
+  NS_IMETHOD GetBackgroundColorState(PRBool *aMixed, nsAWritableString &outColor);
+  NS_IMETHOD GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL);
+  NS_IMETHOD GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD);
+  NS_IMETHOD GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign);
+  NS_IMETHOD GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent);
 
-  NS_IMETHOD MakeOrChangeList(const nsString& aListType, PRBool entireList);
-  NS_IMETHOD RemoveList(const nsString& aListType);
-  NS_IMETHOD Indent(const nsString& aIndent);
-  NS_IMETHOD Align(const nsString& aAlign);
+  NS_IMETHOD MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList);
+  NS_IMETHOD RemoveList(const nsAReadableString& aListType);
+  NS_IMETHOD Indent(const nsAReadableString& aIndent);
+  NS_IMETHOD Align(const nsAReadableString& aAlign);
 
   NS_IMETHOD GetElementOrParentByTagName(const nsAReadableString& aTagName, nsIDOMNode *aNode, nsIDOMElement** aReturn);
-  NS_IMETHOD GetSelectedElement(const nsString& aTagName, nsIDOMElement** aReturn);
+  NS_IMETHOD GetSelectedElement(const nsAReadableString& aTagName, nsIDOMElement** aReturn);
   NS_IMETHOD CreateElementWithDefaults(const nsAReadableString& aTagName, nsIDOMElement** aReturn);
-  NS_IMETHOD GetNextElementByTagName(nsIDOMElement *aCurrentElement, const nsString *aTagName, nsIDOMElement **aReturn);
+  NS_IMETHOD GetNextElementByTagName(nsIDOMElement *aCurrentElement, const nsAReadableString *aTagName, nsIDOMElement **aReturn);
 
 
   NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
 
   /* ------------ nsIEditorIMESupport overrides -------------- */
   
-  NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
+  NS_IMETHOD SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
   NS_IMETHOD GetReconversionString(nsReconversionEventReply* aReply);
 
   /* ------------ nsIEditorStyleSheets methods -------------- */
 
-  NS_IMETHOD ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet);
-  NS_IMETHOD ApplyOverrideStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet);
+  NS_IMETHOD ApplyStyleSheet(const nsAReadableString & aURL, nsICSSStyleSheet **aStyleSheet);
+  NS_IMETHOD ApplyOverrideStyleSheet(const nsAReadableString & aURL, nsICSSStyleSheet **aStyleSheet);
   /* Above 2 methods call this with appropriate aOverride value 
    * Not exposed to IDL interface 
   */
-  nsresult   ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet);
+  nsresult   ApplyDocumentOrOverrideStyleSheet(const nsAReadableString & aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet);
   NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet);
   NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet);
   NS_IMETHOD RemoveOverrideStyleSheet(nsICSSStyleSheet* aSheet);
@@ -172,13 +175,13 @@ public:
   /* ------------ nsIEditorMailSupport methods -------------- */
 
   NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType);
-  NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, nsIDOMNode **aNodeInserted);
-  NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation,
+  NS_IMETHOD InsertAsQuotation(const nsAReadableString & aQuotedText, nsIDOMNode **aNodeInserted);
+  NS_IMETHOD PasteAsCitedQuotation(const nsAReadableString & aCitation,
                                    PRInt32 aSelectionType);
-  NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText,
-                                    const nsString& aCitation,
+  NS_IMETHOD InsertAsCitedQuotation(const nsAReadableString & aQuotedText,
+                                    const nsAReadableString & aCitation,
                                     PRBool aInsertHTML,
-                                    const nsString& aCharset,
+                                    const nsAReadableString & aCharset,
                                     nsIDOMNode **aNodeInserted);
   NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
 
@@ -240,10 +243,11 @@ public:
   /* miscellaneous */
   // This sets background on the appropriate container element (table, cell,)
   //   or calls into nsTextEditor to set the page background
-  NS_IMETHOD SetBackgroundColor(const nsString& aColor);
-  NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue);
+  NS_IMETHOD SetBackgroundColor(const nsAReadableString& aColor);
+  NS_IMETHOD SetBodyAttribute(const nsAReadableString& aAttr, const nsAReadableString& aValue);
   // aTitle may be null or empty string to remove child contents of <title>
-  NS_IMETHOD SetDocumentTitle(const PRUnichar *aTitle);
+
+  NS_IMETHOD SetDocumentTitle(const nsAReadableString &aTitle);
 
   /* ------------ Block methods moved from nsEditor -------------- */
   static nsCOMPtr<nsIDOMNode> GetBlockNodeParent(nsIDOMNode *aNode);
@@ -301,10 +305,10 @@ public:
   NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell,  nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags);
   
   /** Internal, static version */
-  static nsresult NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock);
+  static nsresult NodeIsBlockStatic(nsIDOMNode *aNode, PRBool *aIsBlock);
 
   /** This version is for exposure to JavaScript */
-  NS_IMETHOD NodeIsBlock(nsIDOMNode *aNode, PRBool &aIsBlock);
+  NS_IMETHOD NodeIsBlock(nsIDOMNode *aNode, PRBool *aIsBlock);
 
   /** we override this here to install event listeners */
   NS_IMETHOD PostCreate();
@@ -313,14 +317,14 @@ public:
   NS_IMETHOD SetFlags(PRUint32 aFlags);
 
   NS_IMETHOD Paste(PRInt32 aSelectionType);
-  NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste);
+  NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste);
 
-  NS_IMETHOD CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag);
+  NS_IMETHOD CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag);
   NS_IMETHOD DoDrag(nsIDOMEvent *aDragEvent);
   NS_IMETHOD InsertFromDrop(nsIDOMEvent* aDropEvent);
 
-  NS_IMETHOD GetHeadContentsAsHTML(nsString& aOutputString);
-  NS_IMETHOD ReplaceHeadContentsWithHTML(const nsString &aSourceToInsert);
+  NS_IMETHOD GetHeadContentsAsHTML(nsAWritableString& aOutputString);
+  NS_IMETHOD ReplaceHeadContentsWithHTML(const nsAReadableString &aSourceToInsert);
 
   NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
 
@@ -333,7 +337,7 @@ public:
   NS_IMETHOD EndOperation();
 
   /** returns PR_TRUE if aParentTag can contain a child of type aChildTag */
-  virtual PRBool TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag);
+  virtual PRBool TagCanContainTag(const nsAReadableString& aParentTag, const nsAReadableString& aChildTag);
   
   /** make the given selection span the entire document */
   NS_IMETHOD SelectEntireDocument(nsISelection *aSelection);
@@ -345,7 +349,7 @@ public:
   NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify);
 
   /* ------------ Utility Routines, not part of public API -------------- */
-  NS_IMETHOD TypedText(const PRUnichar* aString, PRInt32 aAction);
+  NS_IMETHOD TypedText(const nsAReadableString& aString, PRInt32 aAction);
   nsresult InsertNodeAtPoint(nsIDOMNode *aNode, 
                                 nsIDOMNode *aParent, 
                                 PRInt32 aOffset, 
@@ -512,8 +516,8 @@ protected:
     */
   virtual void IsTextPropertySetByContent(nsIDOMNode     *aNode,
                                           nsIAtom        *aProperty, 
-                                          const nsString *aAttribute,
-                                          const nsString *aValue,
+                                          const nsAReadableString *aAttribute,
+                                          const nsAReadableString *aValue,
                                           PRBool         &aIsSet,
                                           nsIDOMNode    **aStyleNode,
                                           nsString       *outValue = nsnull) const;
@@ -523,7 +527,7 @@ protected:
     */
   virtual void IsTextStyleSet(nsIStyleContext *aSC, 
                               nsIAtom         *aProperty, 
-                              const nsString  *aAttributes, 
+                              const nsAReadableString  *aAttributes, 
                               PRBool          &aIsSet) const;
 
 
@@ -534,26 +538,26 @@ protected:
 
   // Methods for handling plaintext quotations
   NS_IMETHOD PasteAsPlaintextQuotation(PRInt32 aSelectionType);
-  NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText,
+  NS_IMETHOD InsertAsPlaintextQuotation(const nsAReadableString & aQuotedText,
                                         nsIDOMNode **aNodeInserted);
 
   // factored methods for handling insertion of data from transferables (drag&drop or clipboard)
   NS_IMETHOD PrepareTransferable(nsITransferable **transferable);
   NS_IMETHOD InsertFromTransferable(nsITransferable *transferable, 
-                                    const nsString& aContextStr,
-                                    const nsString& aInfoStr);
-  nsresult   InsertHTMLWithContext(const nsString& aInputString, 
-                                   const nsString& aContextStr, 
-                                   const nsString& aInfoStr);
-  nsresult   InsertHTMLWithCharsetAndContext(const nsString& aInputString,
-                                             const nsString& aCharset,
-                                             const nsString& aContextStr,
-                                             const nsString& aInfoStr);
+                                    const nsAReadableString & aContextStr,
+                                    const nsAReadableString & aInfoStr);
+  nsresult   InsertHTMLWithContext(const nsAReadableString & aInputString, 
+                                   const nsAReadableString & aContextStr, 
+                                   const nsAReadableString & aInfoStr);
+  nsresult   InsertHTMLWithCharsetAndContext(const nsAReadableString & aInputString,
+                                             const nsAReadableString & aCharset,
+                                             const nsAReadableString & aContextStr,
+                                             const nsAReadableString & aInfoStr);
   nsresult   StripFormattingNodes(nsIDOMNode *aNode);
   nsresult   CreateDOMFragmentFromPaste(nsIDOMNSRange *aNSRange,
-                                        const nsString& aInputString,
-                                        const nsString& aContextStr,
-                                        const nsString& aInfoStr,
+                                        const nsAReadableString & aInputString,
+                                        const nsAReadableString & aContextStr,
+                                        const nsAReadableString & aInfoStr,
                                         nsCOMPtr<nsIDOMNode> *outFragNode,
                                         PRInt32 *outRangeStartHint,
                                         PRInt32 *outRangeEndHint);
@@ -569,8 +573,8 @@ protected:
   PRBool IsModifiable();
 
   /* helpers for block transformations */
-  nsresult MakeDefinitionItem(const nsString& aItemType);
-  nsresult InsertBasicBlock(const nsString& aBlockType);
+  nsresult MakeDefinitionItem(const nsAReadableString & aItemType);
+  nsresult InsertBasicBlock(const nsAReadableString & aBlockType);
   
   /* increase/decrease the font size of selection */
   nsresult RelativeFontChange( PRInt32 aSizeChange);
@@ -588,35 +592,35 @@ protected:
                                         PRInt32 aStartOffset,
                                         PRInt32 aEndOffset,
                                         nsIAtom *aProperty, 
-                                        const nsString *aAttribute,
-                                        const nsString *aValue);
+                                        const nsAReadableString *aAttribute,
+                                        const nsAReadableString *aValue);
   nsresult SetInlinePropertyOnNode( nsIDOMNode *aNode,
                                     nsIAtom *aProperty, 
-                                    const nsString *aAttribute,
-                                    const nsString *aValue);
+                                    const nsAReadableString *aAttribute,
+                                    const nsAReadableString *aValue);
 
   nsresult PromoteInlineRange(nsIDOMRange *inRange);
   nsresult SplitStyleAboveRange(nsIDOMRange *aRange, 
                                 nsIAtom *aProperty, 
-                                const nsString *aAttribute);
+                                const nsAReadableString *aAttribute);
   nsresult SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode,
                                 PRInt32 *aOffset,
                                 nsIAtom *aProperty, 
-                                const nsString *aAttribute,
+                                const nsAReadableString *aAttribute,
                                 nsCOMPtr<nsIDOMNode> *outLeftNode = nsnull,
                                 nsCOMPtr<nsIDOMNode> *outRightNode = nsnull);
   nsresult RemoveStyleInside(nsIDOMNode *aNode, 
                              nsIAtom *aProperty, 
-                             const nsString *aAttribute, 
+                             const nsAReadableString *aAttribute, 
                              PRBool aChildrenOnly = PR_FALSE);
-  nsresult RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsString *aAttribute);
+  nsresult RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAReadableString *aAttribute);
   
   PRBool NodeIsProperty(nsIDOMNode *aNode);
-  PRBool HasAttr(nsIDOMNode *aNode, const nsString *aAttribute);
-  PRBool HasAttrVal(nsIDOMNode *aNode, const nsString *aAttribute, const nsString *aValue);
+  PRBool HasAttr(nsIDOMNode *aNode, const nsAReadableString *aAttribute);
+  PRBool HasAttrVal(nsIDOMNode *aNode, const nsAReadableString *aAttribute, const nsAReadableString *aValue);
   PRBool IsAtFrontOfNode(nsIDOMNode *aNode, PRInt32 aOffset);
   PRBool IsAtEndOfNode(nsIDOMNode *aNode, PRInt32 aOffset);
-  PRBool IsOnlyAttribute(nsIDOMNode *aElement, const nsString *aAttribute);
+  PRBool IsOnlyAttribute(nsIDOMNode *aElement, const nsAReadableString *aAttribute);
   PRBool HasMatchingAttributes(nsIDOMNode *aNode1, 
                                nsIDOMNode *aNode2);
 
@@ -642,6 +646,14 @@ protected:
   PRBool   mIgnoreSpuriousDragEvent;
   NS_IMETHOD IgnoreSpuriousDragEvent(PRBool aIgnoreSpuriousDragEvent) {mIgnoreSpuriousDragEvent = aIgnoreSpuriousDragEvent; return NS_OK;}
 
+  nsresult GetInlinePropertyBase(nsIAtom *aProperty, 
+                             const nsAReadableString *aAttribute,
+                             const nsAReadableString *aValue,
+                             PRBool *aFirst, 
+                             PRBool *aAny, 
+                             PRBool *aAll,
+                             nsAWritableString *outValue);
+
 // Data members
 protected:
 
diff --git a/mozilla/editor/libeditor/html/nsHTMLEditorLog.cpp b/mozilla/editor/libeditor/html/nsHTMLEditorLog.cpp
index 74c6b7fcfd8..c15926ff938 100644
--- a/mozilla/editor/libeditor/html/nsHTMLEditorLog.cpp
+++ b/mozilla/editor/libeditor/html/nsHTMLEditorLog.cpp
@@ -54,7 +54,7 @@ nsHTMLEditorLog::~nsHTMLEditorLog()
 NS_IMPL_ISUPPORTS_INHERITED(nsHTMLEditorLog, nsHTMLEditor, nsIEditorLogging);
 
 NS_IMETHODIMP
-nsHTMLEditorLog::SetInlineProperty(nsIAtom *aProperty, const nsString *aAttribute, const nsString *aValue)
+nsHTMLEditorLog::SetInlineProperty(nsIAtom *aProperty, const nsAReadableString &aAttribute, const nsAReadableString &aValue)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -68,11 +68,11 @@ nsHTMLEditorLog::SetInlineProperty(nsIAtom *aProperty, const nsString *aAttribut
     Write("window.editorShell.SetTextProperty(\"");
     PrintUnicode(propStr);
     Write("\", \"");
-    if (aAttribute)
-      PrintUnicode(*aAttribute);
+    if (aAttribute.Length())
+      PrintUnicode(aAttribute);
     Write("\", \"");
-    if (aValue)
-      PrintUnicode(*aValue);
+    if (aValue.Length())
+      PrintUnicode(aValue);
     Write("\");\n");
 
     Flush();
@@ -100,7 +100,7 @@ nsHTMLEditorLog::SetParagraphFormat(const nsString& aParagraphFormat)
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute)
+nsHTMLEditorLog::RemoveInlineProperty(nsIAtom *aProperty, const nsAReadableString &aAttribute)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -114,8 +114,8 @@ nsHTMLEditorLog::RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttri
     Write("window.editorShell.RemoveTextProperty(\"");
     PrintUnicode(propStr);
     Write("\", \"");
-    if (aAttribute)
-      PrintUnicode(*aAttribute);
+    if (aAttribute.Length())
+      PrintUnicode(aAttribute);
     Write("\");\n");
 
     Flush();
@@ -143,7 +143,7 @@ nsHTMLEditorLog::DeleteSelection(nsIEditor::EDirection aAction)
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::InsertText(const PRUnichar* aStringToInsert)
+nsHTMLEditorLog::InsertText(const nsAReadableString& aStringToInsert)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -351,7 +351,7 @@ nsHTMLEditorLog::PasteAsPlaintextQuotation(PRInt32 aSelectionType)
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::PasteAsCitedQuotation(const nsString& aCitation,
+nsHTMLEditorLog::PasteAsCitedQuotation(const nsAReadableString& aCitation,
                                        PRInt32 aSelectionType)
 {
   nsAutoHTMLEditorLogLock logLock(this);
@@ -369,7 +369,7 @@ nsHTMLEditorLog::PasteAsCitedQuotation(const nsString& aCitation,
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::InsertAsQuotation(const nsString& aQuotedText,
+nsHTMLEditorLog::InsertAsQuotation(const nsAReadableString& aQuotedText,
                                    nsIDOMNode **aNodeInserted)
 {
   nsAutoHTMLEditorLogLock logLock(this);
@@ -387,7 +387,7 @@ nsHTMLEditorLog::InsertAsQuotation(const nsString& aQuotedText,
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsString& aQuotedText,
+nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsAReadableString& aQuotedText,
                                             nsIDOMNode **aNodeInserted)
 {
   nsAutoHTMLEditorLogLock logLock(this);
@@ -405,10 +405,10 @@ nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsString& aQuotedText,
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText,
-                                        const nsString& aCitation,
+nsHTMLEditorLog::InsertAsCitedQuotation(const nsAReadableString& aQuotedText,
+                                        const nsAReadableString& aCitation,
                                         PRBool aInsertHTML,
-                                        const nsString& aCharset,
+                                        const nsAReadableString& aCharset,
                                         nsIDOMNode **aNodeInserted)
 {
   nsAutoHTMLEditorLogLock logLock(this);
@@ -429,7 +429,7 @@ nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText,
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::SetBackgroundColor(const nsString& aColor)
+nsHTMLEditorLog::SetBackgroundColor(const nsAReadableString& aColor)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -445,7 +445,7 @@ nsHTMLEditorLog::SetBackgroundColor(const nsString& aColor)
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::SetBodyAttribute(const nsString& aAttr, const nsString& aValue)
+nsHTMLEditorLog::SetBodyAttribute(const nsAReadableString& aAttr, const nsAReadableString& aValue)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -644,7 +644,7 @@ nsHTMLEditorLog::SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMEle
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::MakeOrChangeList(const nsString& aListType, PRBool entireList)
+nsHTMLEditorLog::MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -662,7 +662,7 @@ nsHTMLEditorLog::MakeOrChangeList(const nsString& aListType, PRBool entireList)
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::Indent(const nsString& aIndent)
+nsHTMLEditorLog::Indent(const nsAReadableString& aIndent)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -680,7 +680,7 @@ nsHTMLEditorLog::Indent(const nsString& aIndent)
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::Align(const nsString& aAlign)
+nsHTMLEditorLog::Align(const nsAReadableString& aAlign)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -748,7 +748,7 @@ nsHTMLEditorLog::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)
+nsHTMLEditorLog::ApplyStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -769,7 +769,7 @@ nsHTMLEditorLog::ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyle
 }
 
 NS_IMETHODIMP
-nsHTMLEditorLog::SetDocumentTitle(const PRUnichar* aTitle)
+nsHTMLEditorLog::SetDocumentTitle(const nsAReadableString& aTitle)
 {
   nsAutoHTMLEditorLogLock logLock(this);
 
@@ -912,23 +912,25 @@ nsHTMLEditorLog::Flush()
 }
 
 nsresult
-nsHTMLEditorLog::PrintUnicode(const nsString &aString)
+nsHTMLEditorLog::PrintUnicode(const nsAReadableString &aString)
 {
-  const PRUnichar *uc = aString.GetUnicode();
-  PRInt32 i, len = aString.Length();
+  //const PRUnichar *uc = aString.GetUnicode();
   char buf[10];
-
-  for (i = 0; i < len; i++)
+  nsReadingIterator <PRUnichar> beginIter,endIter;
+  aString.BeginReading(beginIter);
+  aString.EndReading(endIter);
+  while(beginIter != endIter)
   {
-    if (nsCRT::IsAsciiAlpha(uc[i]) || nsCRT::IsAsciiDigit(uc[i]) || uc[i] == ' ')
-      sprintf(buf, "%c", uc[i]);
+    if (nsCRT::IsAsciiAlpha(*beginIter) || nsCRT::IsAsciiDigit(*beginIter) || *beginIter == ' ')
+      sprintf(buf, "%c", *beginIter);
     else
-      sprintf(buf, "\\u%.4x", uc[i]);
+      sprintf(buf, "\\u%.4x", *beginIter);
 
     nsresult result = Write(buf);
 
     if (NS_FAILED(result))
       return result;
+    ++beginIter;
   }
 
   return NS_OK;
diff --git a/mozilla/editor/libeditor/html/nsHTMLEditorLog.h b/mozilla/editor/libeditor/html/nsHTMLEditorLog.h
index e4dc06639ad..b37719356ff 100644
--- a/mozilla/editor/libeditor/html/nsHTMLEditorLog.h
+++ b/mozilla/editor/libeditor/html/nsHTMLEditorLog.h
@@ -54,12 +54,12 @@ public:
 
   /* nsIHTMLEditor method implementations. */
   NS_IMETHOD SetInlineProperty(nsIAtom *aProperty, 
-                               const nsString *aAttribute,
-                               const nsString *aValue);
+                            const nsAReadableString & aAttribute, 
+                            const nsAReadableString & aValue);
   NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat);
-  NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute);
+  NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsAReadableString& aAttribute);
   NS_IMETHOD DeleteSelection(nsIEditor::EDirection aAction);
-  NS_IMETHOD InsertText(const PRUnichar* aStringToInsert);
+  NS_IMETHOD InsertText(const nsAReadableString& aStringToInsert);
   NS_IMETHOD InsertLineBreak();
   NS_IMETHOD Undo(PRUint32 aCount);
   NS_IMETHOD Redo(PRUint32 aCount);
@@ -74,20 +74,22 @@ public:
   NS_IMETHOD Paste(PRInt32 aSelectionType);
   NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType);
   NS_IMETHOD PasteAsPlaintextQuotation(PRInt32 aSelectionType);
-  NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation,
+  NS_IMETHOD PasteAsCitedQuotation(const nsAReadableString& aCitation,
                                    PRInt32 aSelectionType);
-  NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted);
-  NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted);
-  NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation, PRBool aInsertHTML, const nsString& aCharset, nsIDOMNode** aNodeInserted);
+  NS_IMETHOD InsertAsQuotation(const nsAReadableString& aQuotedText, nsIDOMNode** aNodeInserted);
+  NS_IMETHOD InsertAsPlaintextQuotation(const nsAReadableString& aQuotedText, nsIDOMNode** aNodeInserted);
+  NS_IMETHOD InsertAsCitedQuotation(const nsAReadableString& aQuotedText, const nsAReadableString& aCitation, 
+                                    PRBool aInsertHTML, const nsAReadableString& aCharset, 
+                                    nsIDOMNode** aNodeInserted);
 
-  NS_IMETHOD ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet);
-  NS_IMETHOD SetDocumentTitle(const PRUnichar* aTitle);
+  NS_IMETHOD ApplyStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet);
+  NS_IMETHOD SetDocumentTitle(const nsAReadableString& aTitle);
 
-  NS_IMETHOD SetBackgroundColor(const nsString& aColor);
-  NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue);
-  NS_IMETHOD MakeOrChangeList(const nsString& aListType, PRBool entireList);
-  NS_IMETHOD Indent(const nsString& aIndent);
-  NS_IMETHOD Align(const nsString& aAlign);
+  NS_IMETHOD SetBackgroundColor(const nsAReadableString& aColor);
+  NS_IMETHOD SetBodyAttribute(const nsAReadableString& aAttr, const nsAReadableString& aValue);
+  NS_IMETHOD MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList);
+  NS_IMETHOD Indent(const nsAReadableString& aIndent);
+  NS_IMETHOD Align(const nsAReadableString& aAlign);
   NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection);
   NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
   
@@ -112,7 +114,7 @@ public:
   nsresult Write(const char *aBuffer);
   nsresult WriteInt(const char *aFormat, PRInt32 aInt);
   nsresult Flush();
-  nsresult PrintUnicode(const nsString &aString);
+  nsresult PrintUnicode(const nsAReadableString &aString);
   nsresult PrintSelection();
   nsresult PrintNode(nsIDOMNode *aNode, PRInt32 aDepth=0);
   nsresult PrintElementNode(nsIDOMNode *aNode, PRInt32 aDepth);
diff --git a/mozilla/editor/libeditor/html/nsHTMLEditorStyle.cpp b/mozilla/editor/libeditor/html/nsHTMLEditorStyle.cpp
index b17f5ff0e1b..fd4f1f45894 100644
--- a/mozilla/editor/libeditor/html/nsHTMLEditorStyle.cpp
+++ b/mozilla/editor/libeditor/html/nsHTMLEditorStyle.cpp
@@ -101,8 +101,8 @@ static const PRBool gNoisy = PR_FALSE;
 
 
 NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty, 
-                                            const nsString *aAttribute,
-                                            const nsString *aValue)
+                            const nsAReadableString & aAttribute, 
+                            const nsAReadableString & aValue)
 {
   if (!aProperty) { return NS_ERROR_NULL_POINTER; }
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@@ -120,7 +120,9 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
   if (isCollapsed)
   {
     // manipulating text attributes on a collapsed selection only sets state for the next text insertion
-    return mTypeInState->SetProp(aProperty, *aAttribute, *aValue);
+    nsString tAttr(aAttribute);//MJUDGE SCC NEED HELP
+    nsString tVal(aValue);//MJUDGE SCC NEED HELP
+    return mTypeInState->SetProp(aProperty, tAttr, tVal);
   }
   
   nsAutoEditBatch batchIt(this);
@@ -167,7 +169,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
         range->GetStartOffset(&startOffset);
         range->GetEndOffset(&endOffset);
         nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(startNode);
-        res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, endOffset, aProperty, aAttribute, aValue);
+        res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, endOffset, aProperty, &aAttribute, &aValue);
         if (NS_FAILED(res)) return res;
       }
       else
@@ -232,7 +234,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
           PRUint32 textLen;
           range->GetStartOffset(&startOffset);
           nodeAsText->GetLength(&textLen);
-          res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, textLen, aProperty, aAttribute, aValue);
+          res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, textLen, aProperty, &aAttribute, &aValue);
           if (NS_FAILED(res)) return res;
         }
         
@@ -244,7 +246,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
         {
           isupports = dont_AddRef(arrayOfNodes->ElementAt(0));
           node = do_QueryInterface(isupports);
-          res = SetInlinePropertyOnNode(node, aProperty, aAttribute, aValue);
+          res = SetInlinePropertyOnNode(node, aProperty, &aAttribute, &aValue);
           if (NS_FAILED(res)) return res;
           arrayOfNodes->RemoveElementAt(0);
         }
@@ -257,7 +259,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
           nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(endNode);
           PRInt32 endOffset;
           range->GetEndOffset(&endOffset);
-          res = SetInlinePropertyOnTextNode(nodeAsText, 0, endOffset, aProperty, aAttribute, aValue);
+          res = SetInlinePropertyOnTextNode(nodeAsText, 0, endOffset, aProperty, &aAttribute, &aValue);
           if (NS_FAILED(res)) return res;
         }
       }
@@ -279,8 +281,8 @@ nsHTMLEditor::SetInlinePropertyOnTextNode( nsIDOMCharacterData *aTextNode,
                                             PRInt32 aStartOffset,
                                             PRInt32 aEndOffset,
                                             nsIAtom *aProperty, 
-                                            const nsString *aAttribute,
-                                            const nsString *aValue)
+                                            const nsAReadableString *aAttribute,
+                                            const nsAReadableString *aValue)
 {
   if (!aTextNode) return NS_ERROR_NULL_POINTER;
   
@@ -323,8 +325,8 @@ nsHTMLEditor::SetInlinePropertyOnTextNode( nsIDOMCharacterData *aTextNode,
 nsresult
 nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode,
                                        nsIAtom *aProperty, 
-                                       const nsString *aAttribute,
-                                       const nsString *aValue)
+                                       const nsAReadableString *aAttribute,
+                                       const nsAReadableString *aValue)
 {
   if (!aNode || !aProperty) return NS_ERROR_NULL_POINTER;
 
@@ -430,7 +432,7 @@ nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode,
 
 nsresult nsHTMLEditor::SplitStyleAboveRange(nsIDOMRange *inRange, 
                                             nsIAtom *aProperty, 
-                                            const nsString *aAttribute)
+                                            const nsAReadableString *aAttribute)
 {
   if (!inRange) return NS_ERROR_NULL_POINTER;
   nsresult res;
@@ -474,7 +476,7 @@ nsresult nsHTMLEditor::SplitStyleAboveRange(nsIDOMRange *inRange,
 nsresult nsHTMLEditor::SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode,
                                            PRInt32 *aOffset,
                                            nsIAtom *aProperty,          // null here means we split all properties
-                                           const nsString *aAttribute,
+                                           const nsAReadableString *aAttribute,
                                            nsCOMPtr<nsIDOMNode> *outLeftNode,
                                            nsCOMPtr<nsIDOMNode> *outRightNode)
 {
@@ -508,7 +510,7 @@ PRBool nsHTMLEditor::NodeIsProperty(nsIDOMNode *aNode)
   if (!IsContainer(aNode))  return PR_FALSE;
   if (!IsEditable(aNode))   return PR_FALSE;
   PRBool isBlock (PR_FALSE);
-  NodeIsBlock(aNode, isBlock);
+  NodeIsBlock(aNode, &isBlock);
   if (isBlock) return PR_FALSE;
   if (NodeIsType(aNode, nsIEditProperty::a)) return PR_FALSE;
   return PR_TRUE;
@@ -516,7 +518,7 @@ PRBool nsHTMLEditor::NodeIsProperty(nsIDOMNode *aNode)
 
 nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode, 
                                    nsIAtom *aProperty,   // null here means remove all properties
-                                   const nsString *aAttribute, 
+                                   const nsAReadableString *aAttribute, 
                                    PRBool aChildrenOnly)
 {
   if (!aNode) return NS_ERROR_NULL_POINTER;
@@ -571,7 +573,7 @@ nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode,
 }
 
 PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode, 
-                                     const nsString *aAttribute)
+                                     const nsAReadableString *aAttribute)
 {
   if (!aNode || !aAttribute) return PR_FALSE;  // ooops
   nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
@@ -581,6 +583,7 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
   nsCOMPtr<nsIAtom> attrName, prefix;
   content->GetAttributeCount(attrCount);
   
+  nsString tString(*aAttribute);//MJUDGE SCC NEED HELP
   for (i=0; i<attrCount; i++)
   {
     content->GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attrName),
@@ -589,7 +592,7 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
     if (!attrName) continue;  // ooops
     attrName->ToString(attrString);
     // if it's the attribute we know about, keep looking
-    if (attrString.EqualsIgnoreCase(*aAttribute)) continue;
+    if (attrString.EqualsIgnoreCase(tString)) continue;
     // if it's a special _moz... attribute, keep looking
     attrString.Left(tmp,4);
     if (tmp.EqualsWithConversion("_moz")) continue;
@@ -656,7 +659,7 @@ nsHTMLEditor::HasMatchingAttributes(nsIDOMNode *aNode1,
 }
 
 PRBool nsHTMLEditor::HasAttr(nsIDOMNode *aNode, 
-                             const nsString *aAttribute)
+                             const nsAReadableString *aAttribute)
 {
   if (!aNode) return PR_FALSE;
   if (!aAttribute || aAttribute->IsEmpty()) return PR_TRUE;  // everybody has the 'null' attribute
@@ -674,8 +677,8 @@ PRBool nsHTMLEditor::HasAttr(nsIDOMNode *aNode,
 
 
 PRBool nsHTMLEditor::HasAttrVal(nsIDOMNode *aNode, 
-                                const nsString *aAttribute, 
-                                const nsString *aValue)
+                                const nsAReadableString *aAttribute, 
+                                const nsAReadableString *aValue)
 {
   if (!aNode) return PR_FALSE;
   if (!aAttribute || aAttribute->IsEmpty()) return PR_TRUE;  // everybody has the 'null' attribute
@@ -700,7 +703,8 @@ PRBool nsHTMLEditor::HasAttrVal(nsIDOMNode *aNode,
   attNode->GetValue(attrVal);
   
   // do values match?
-  if (attrVal.EqualsIgnoreCase(*aValue)) return PR_TRUE;
+  nsString tString(*aValue);//MJUDGE SCC NEED HELP
+  if (attrVal.EqualsIgnoreCase(tString)) return PR_TRUE;
   return PR_FALSE;
 }
 
@@ -792,23 +796,15 @@ PRBool nsHTMLEditor::IsAtEndOfNode(nsIDOMNode *aNode, PRInt32 aOffset)
   }
 }
 
-NS_IMETHODIMP nsHTMLEditor::GetInlineProperty(nsIAtom *aProperty, 
-                                              const nsString *aAttribute, 
-                                              const nsString *aValue,
-                                              PRBool &aFirst, 
-                                              PRBool &aAny, 
-                                              PRBool &aAll)
-{
-  return GetInlinePropertyWithAttrValue( aProperty, aAttribute, aValue, aFirst, aAny, aAll, nsnull);
-}
 
-NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty, 
-                                              const nsString *aAttribute, 
-                                              const nsString *aValue,
-                                              PRBool &aFirst, 
-                                              PRBool &aAny, 
-                                              PRBool &aAll,
-                                              nsString *outValue)
+nsresult
+nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty, 
+                             const nsAReadableString *aAttribute,
+                             const nsAReadableString *aValue,
+                             PRBool *aFirst, 
+                             PRBool *aAny, 
+                             PRBool *aAll,
+                             nsAWritableString *outValue)
 {
   if (!aProperty)
     return NS_ERROR_NULL_POINTER;
@@ -823,9 +819,9 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
   }
 */
   nsresult result;
-  aAny=PR_FALSE;
-  aAll=PR_TRUE;
-  aFirst=PR_FALSE;
+  *aAny=PR_FALSE;
+  *aAll=PR_TRUE;
+  *aFirst=PR_FALSE;
   PRBool first=PR_TRUE;
   nsCOMPtr<nsISelection>selection;
   result = GetSelection(getter_AddRefs(selection));
@@ -863,12 +859,21 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
       // cache now current, use it!  But override it with typeInState results if any...
       PRBool isSet, theSetting;
       if (aAttribute)
-        mTypeInState->GetTypingState(isSet, theSetting, aProperty, *aAttribute, outValue);
+      {
+        nsString tString(*aAttribute); //MJUDGE SCC NEED HELP
+        nsString tOutString;//MJUDGE SCC NEED HELP
+        nsString *tPassString=nsnull;
+        if (outValue)
+            tPassString = &tOutString;
+        mTypeInState->GetTypingState(isSet, theSetting, aProperty, tString, &tOutString);
+        if (outValue)
+          outValue->Assign(tOutString);
+      }
       else
         mTypeInState->GetTypingState(isSet, theSetting, aProperty);
       if (isSet) 
       {
-        aFirst = aAny = aAll = theSetting;
+        *aFirst = *aAny = *aAll = theSetting;
         return NS_OK;
       }
       /*
@@ -877,11 +882,11 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
         mTypeInState->GetTypingState(isSet, theSetting, aProperty);
         if (isSet) 
         {
-          aFirst = aAny = aAll = theSetting;
+          *aFirst = *aAny = *aAll = theSetting;
         }
         else
         {
-          aFirst = aAny = aAll = mCachedBoldStyle;
+          *aFirst = *aAny = *aAll = mCachedBoldStyle;
         }
         return NS_OK;
       }
@@ -890,11 +895,11 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
         mTypeInState->GetTypingState(isSet, theSetting, aProperty);
         if (isSet) 
         {
-          aFirst = aAny = aAll = theSetting;
+          *aFirst = *aAny = *aAll = theSetting;
         }
         else
         {
-          aFirst = aAny = aAll = mCachedItalicStyle;
+          *aFirst = *aAny = *aAll = mCachedItalicStyle;
         }
         return NS_OK;
       }
@@ -903,11 +908,11 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
         mTypeInState->GetTypingState(isSet, theSetting, aProperty);
         if (isSet) 
         {
-          aFirst = aAny = aAll = theSetting;
+          *aFirst = *aAny = *aAll = theSetting;
         }
         else
         {
-          aFirst = aAny = aAll = mCachedUnderlineStyle;
+          *aFirst = *aAny = *aAll = mCachedUnderlineStyle;
         }
         return NS_OK;
       } */
@@ -975,7 +980,7 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
           if (first)
           {
             IsTextPropertySetByContent(node, aProperty, aAttribute, aValue, isSet, getter_AddRefs(resultNode), &firstValue);
-            aFirst = isSet;
+            *aFirst = isSet;
             first = PR_FALSE;
             if (outValue) *outValue = firstValue;
           }
@@ -983,14 +988,14 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
           {
             IsTextPropertySetByContent(node, aProperty, aAttribute, aValue, isSet, getter_AddRefs(resultNode), &theValue);
             if (firstValue != theValue)
-              aAll = PR_FALSE;
+              *aAll = PR_FALSE;
           }
           
           if (isSet) {
-            aAny = PR_TRUE;
+            *aAny = PR_TRUE;
           }
           else {
-            aAll = PR_FALSE;
+            *aAll = PR_FALSE;
           }
         }
       }
@@ -1000,26 +1005,65 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
       iter->CurrentNode(getter_AddRefs(content));
     }
   }
-  if (!aAny) 
+  if (!*aAny) 
   { // make sure that if none of the selection is set, we don't report all is set
-    aAll = PR_FALSE;
+    *aAll = PR_FALSE;
   }
-  //if (gNoisy) { printf("  returning first=%d any=%d all=%d\n", aFirst, aAny, aAll); }
+  //if (gNoisy) { printf("  returning first=%d any=%d all=%d\n", *aFirst, *aAny, *aAll); }
   return result;
 }
 
 
+NS_IMETHODIMP nsHTMLEditor::GetInlineProperty(nsIAtom *aProperty, 
+                                              const nsAReadableString &aAttribute, 
+                                              const nsAReadableString &aValue,
+                                              PRBool *aFirst, 
+                                              PRBool *aAny, 
+                                              PRBool *aAll)
+{
+  if (!aProperty || !aFirst || !aAny || !aAll)
+    return NS_ERROR_NULL_POINTER;
+  const nsAReadableString *att = nsnull;
+  if (aAttribute.Length())
+    att = &aAttribute;
+  const nsAReadableString *val = nsnull;
+  if (aValue.Length())
+    val = &aValue;
+  return GetInlinePropertyBase( aProperty, att, val, aFirst, aAny, aAll, nsnull);
+}
+
+
+NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty, 
+                                              const nsAReadableString &aAttribute, 
+                                              const nsAReadableString &aValue,
+                                              PRBool *aFirst, 
+                                              PRBool *aAny, 
+                                              PRBool *aAll,
+                                              nsAWritableString &outValue)
+{
+  if (!aProperty || !aFirst || !aAny || !aAll)
+    return NS_ERROR_NULL_POINTER;
+  const nsAReadableString *att = nsnull;
+  if (aAttribute.Length())
+    att = &aAttribute;
+  const nsAReadableString *val = nsnull;
+  if (aValue.Length())
+    val = &aValue;
+  return GetInlinePropertyBase( aProperty, att, val, aFirst, aAny, aAll, &outValue);
+}
+
+
 NS_IMETHODIMP nsHTMLEditor::RemoveAllInlineProperties()
 {
   return RemoveInlinePropertyImpl(nsnull, nsnull);
 }
 
-NS_IMETHODIMP nsHTMLEditor::RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute)
+NS_IMETHODIMP nsHTMLEditor::RemoveInlineProperty(nsIAtom *aProperty, const nsAReadableString &aAttribute)
 {
-  return RemoveInlinePropertyImpl(aProperty, aAttribute);
+  return RemoveInlinePropertyImpl(aProperty, &aAttribute);
 }
 
-nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsString *aAttribute)
+nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAReadableString *aAttribute)
 {
   if (!mRules)    return NS_ERROR_NOT_INITIALIZED;
   ForceCompositionEnd();
@@ -1041,7 +1085,7 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsStri
     if (aProperty == nsIEditProperty::href)
       aProperty = nsIEditProperty::a;
 
-    if (aProperty) return mTypeInState->ClearProp(aProperty, *aAttribute);
+    if (aProperty) return mTypeInState->ClearProp(aProperty, nsAutoString(*aAttribute));
     else return mTypeInState->ClearAllProps();
   }
   nsAutoEditBatch batchIt(this);
@@ -1428,66 +1472,73 @@ nsHTMLEditor::RelativeFontChangeOnNode( PRInt32 aSizeChange,
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::GetFontFaceState(PRBool &aMixed, nsString &outFace)
+nsHTMLEditor::GetFontFaceState(PRBool *aMixed, nsAWritableString &outFace)
 {
-  aMixed = PR_TRUE;
-  outFace.AssignWithConversion("");
-  
+  if (!aMixed)
+      return NS_ERROR_FAILURE;
+  *aMixed = PR_TRUE;
+  //outFace.AssignWithConversion("");
+  outFace.SetLength(0);
+
   nsresult res;
-  nsAutoString faceStr; faceStr.AssignWithConversion("face");
+  nsAutoString faceStr;
+  faceStr.AssignWithConversion("face");
   PRBool first, any, all;
   
-  res = GetInlinePropertyWithAttrValue(nsIEditProperty::font, &faceStr, nsnull, first, any, all, &outFace);
+  
+  res = GetInlinePropertyBase(nsIEditProperty::font, &faceStr, nsnull, &first, &any, &all, &outFace);
   if (NS_FAILED(res)) return res;
   if (any && !all) return res; // mixed
   if (all)
   {
-    aMixed = PR_FALSE;
+    *aMixed = PR_FALSE;
     return res;
   }
   
-  res = GetInlineProperty(nsIEditProperty::tt, nsnull, nsnull, first, any, all);
+  res = GetInlinePropertyBase(nsIEditProperty::tt, nsnull, nsnull, &first, &any, &all,nsnull);
   if (NS_FAILED(res)) return res;
   if (any && !all) return res; // mixed
   if (all)
   {
-    aMixed = PR_FALSE;
+    *aMixed = PR_FALSE;
     nsIEditProperty::tt->ToString(outFace);
   }
   
   if (!any)
   {
     // there was no font face attrs of any kind.  We are in normal font.
-    outFace.AssignWithConversion("");
-    aMixed = PR_FALSE;
+    outFace.SetLength(0);
+    *aMixed = PR_FALSE;
   }
   return res;
 }
 
 NS_IMETHODIMP 
-nsHTMLEditor::GetFontColorState(PRBool &aMixed, nsString &aOutColor)
+nsHTMLEditor::GetFontColorState(PRBool *aMixed, nsAWritableString &aOutColor)
 {
-  aMixed = PR_TRUE;
-  aOutColor.AssignWithConversion("");
+  if (!aMixed)
+      return NS_ERROR_NULL_POINTER;
+  *aMixed = PR_TRUE;
+  aOutColor.SetLength(0);
   
   nsresult res;
   nsAutoString colorStr; colorStr.AssignWithConversion("color");
   PRBool first, any, all;
   
-  res = GetInlinePropertyWithAttrValue(nsIEditProperty::font, &colorStr, nsnull, first, any, all, &aOutColor);
+  res = GetInlinePropertyBase(nsIEditProperty::font, &colorStr, nsnull, &first, &any, &all, &aOutColor);
   if (NS_FAILED(res)) return res;
   if (any && !all) return res; // mixed
   if (all)
   {
-    aMixed = PR_FALSE;
+    *aMixed = PR_FALSE;
     return res;
   }
   
   if (!any)
   {
     // there was no font color attrs of any kind..
-    aOutColor.AssignWithConversion("");
-    aMixed = PR_FALSE;
+    aOutColor.SetLength(0);
+    *aMixed = PR_FALSE;
   }
   return res;
 }
diff --git a/mozilla/editor/libeditor/html/nsIHTMLEditRules.h b/mozilla/editor/libeditor/html/nsIHTMLEditRules.h
index 4289b52fbfe..f3454ac9189 100644
--- a/mozilla/editor/libeditor/html/nsIHTMLEditRules.h
+++ b/mozilla/editor/libeditor/html/nsIHTMLEditRules.h
@@ -35,11 +35,11 @@ class nsIHTMLEditRules : public nsISupports
 public:
   static const nsIID& GetIID() { static nsIID iid = NS_IHTMLEDITRULES_IID; return iid; }
   
-  NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL)=0;
-  NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD)=0;
-  NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)=0;
-  NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)=0;
-  NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat)=0;
+  NS_IMETHOD GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL)=0;
+  NS_IMETHOD GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD)=0;
+  NS_IMETHOD GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent)=0;
+  NS_IMETHOD GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign)=0;
+  NS_IMETHOD GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat)=0;
 };
 
 
diff --git a/mozilla/editor/libeditor/html/nsTableEditor.cpp b/mozilla/editor/libeditor/html/nsTableEditor.cpp
index 426d1bfe361..804b61d162a 100644
--- a/mozilla/editor/libeditor/html/nsTableEditor.cpp
+++ b/mozilla/editor/libeditor/html/nsTableEditor.cpp
@@ -1885,7 +1885,7 @@ nsHTMLEditor::CopyCellBackgroundColor(nsIDOMElement *destCell, nsIDOMElement *so
   nsAutoString bgcolor; bgcolor.AssignWithConversion("bgcolor");
   nsAutoString color;
   PRBool isSet;
-  nsresult res = GetAttributeValue(sourceCell, bgcolor, color, isSet);
+  nsresult res = GetAttributeValue(sourceCell, bgcolor, color, &isSet);
 
   if (NS_SUCCEEDED(res) && isSet)
     res = SetAttribute(destCell, bgcolor, color);
diff --git a/mozilla/editor/libeditor/text/nsAOLCiter.cpp b/mozilla/editor/libeditor/text/nsAOLCiter.cpp
index 543b43d55a1..937b6ef9077 100644
--- a/mozilla/editor/libeditor/text/nsAOLCiter.cpp
+++ b/mozilla/editor/libeditor/text/nsAOLCiter.cpp
@@ -62,51 +62,53 @@ nsAOLCiter::QueryInterface(REFNSIID aIID, void** aInstancePtr)
 }
 
 NS_IMETHODIMP
-nsAOLCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
+nsAOLCiter::GetCiteString(const nsAReadableString& aInString, nsAWritableString& aOutString)
 {
-  aOutString.AssignWithConversion("\n\n>> ");
+  aOutString = NS_LITERAL_STRING("\n\n>> ");
   aOutString += aInString;
 
   // See if the last char is a newline, and replace it if so
   PRUnichar newline ('\n');
   if (aOutString.Last() == newline)
   {
-    aOutString.SetCharAt(' ',aOutString.Length());
-    aOutString.AppendWithConversion("<<\n");
+    aOutString.Append(PRUnichar(' '));
+    aOutString.Append(NS_LITERAL_STRING("<<\n"));
   }
   else
   {
-    aOutString.AppendWithConversion(" <<\n");
+    aOutString.Append(NS_LITERAL_STRING(" <<\n"));
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsAOLCiter::StripCites(const nsString& aInString, nsString& aOutString)
+nsAOLCiter::StripCites(const nsAReadableString& aInString, nsAWritableString& aOutString)
 {
   // Remove the beginning cites, if any:
-  if (aInString.EqualsWithConversion(">>", PR_FALSE, 2))
+  nsAutoString tInputString(aInString);//MJUDGE SCC NEED HELP
+  nsAutoString tOutputString;
+  if (tInputString.EqualsWithConversion(">>", PR_FALSE, 2))
   {
     PRInt32 i = 3;
-    while (nsCRT::IsAsciiSpace(aInString[i]))
+    while (nsCRT::IsAsciiSpace(tInputString[i]))
       ++i;
-    aOutString.Append(aInString.GetUnicode(), i);
+    tOutputString.Append(tInputString.GetUnicode(), i);
   }
   else
-    aOutString = aInString;
+    tOutputString = tInputString;
 
   // Remove the end cites, if any:
-  aOutString.Trim("<", PR_FALSE, PR_TRUE, PR_FALSE);
-
+  tOutputString.Trim("<", PR_FALSE, PR_TRUE, PR_FALSE);
+  aOutString.Assign(tOutputString);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsAOLCiter::Rewrap(const nsString& aInString,
+nsAOLCiter::Rewrap(const nsAReadableString& aInString,
                    PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
                    PRBool aRespectNewlines,
-                   nsString& aOutString)
+                   nsAWritableString& aOutString)
 {
   nsString citeString;
   return nsWrapUtils::Rewrap(aInString, aWrapCol, aFirstLineOffset,
diff --git a/mozilla/editor/libeditor/text/nsAOLCiter.h b/mozilla/editor/libeditor/text/nsAOLCiter.h
index a4edd83674e..a4086786963 100644
--- a/mozilla/editor/libeditor/text/nsAOLCiter.h
+++ b/mozilla/editor/libeditor/text/nsAOLCiter.h
@@ -23,9 +23,9 @@
 #ifndef nsAOLCiter_h__
 #define nsAOLCiter_h__
 
+#include "nsString.h"
 #include "nsICiter.h"
 
-#include "nsString.h"
 
 /** Mail citations using the AOL style >> This is a citation <<
   */
@@ -38,14 +38,14 @@ public:
 //NOTE: Use   NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
   NS_DECL_ISUPPORTS
 
-  NS_IMETHOD GetCiteString(const nsString& aInString, nsString& aOutString);
+  NS_IMETHOD GetCiteString(const nsAReadableString & aInString, nsAWritableString & aOutString);
 
-  NS_IMETHOD StripCites(const nsString& aInString, nsString& aOutString);
+  NS_IMETHOD StripCites(const nsAReadableString & aInString, nsAWritableString & aOutString);
 
-  NS_IMETHOD Rewrap(const nsString& aInString,
+  NS_IMETHOD Rewrap(const nsAReadableString & aInString,
                     PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
                     PRBool aRespectNewlines,
-                    nsString& aOutString);
+                    nsAWritableString & aOutString);
 };
 
 #endif //nsAOLCiter_h__
diff --git a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp
index bc6450b5ac2..3a041e8b4fd 100644
--- a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp
+++ b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp
@@ -615,7 +615,7 @@ nsTextEditorDragListener::DragGesture(nsIDOMEvent* aDragEvent)
     return NS_ERROR_NULL_POINTER;
   
   // ...figure out if a drag should be started...
-  nsresult rv = mEditor->CanDrag(aDragEvent, canDrag);
+  nsresult rv = mEditor->CanDrag(aDragEvent, &canDrag);
   if ( NS_SUCCEEDED(rv) && canDrag )
     rv = mEditor->DoDrag(aDragEvent);
 
diff --git a/mozilla/editor/libeditor/text/nsInternetCiter.cpp b/mozilla/editor/libeditor/text/nsInternetCiter.cpp
index 97fd76cdb09..1b629b15760 100644
--- a/mozilla/editor/libeditor/text/nsInternetCiter.cpp
+++ b/mozilla/editor/libeditor/text/nsInternetCiter.cpp
@@ -21,9 +21,9 @@
  *   Pierre Phaneuf <pp@ludusdesign.com>
  */
 
-#include "nsInternetCiter.h"
 
 #include "nsString.h"
+#include "nsInternetCiter.h"
 
 #include "nsCOMPtr.h"
 
@@ -76,7 +76,7 @@ nsInternetCiter::QueryInterface(REFNSIID aIID, void** aInstancePtr)
 }
 
 NS_IMETHODIMP
-nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
+nsInternetCiter::GetCiteString(const nsAReadableString& aInString, nsAWritableString& aOutString)
 {
   PRInt32 i = 0;
   PRInt32 length = aInString.Length();
@@ -85,9 +85,10 @@ nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
 
   // Strip trailing new lines which will otherwise turn up
   // as ugly quoted empty lines.
+  nsString tString(aInString); //CRAPCRAP
   while(length > 0 &&
-        (aInString[length-1] == cr ||
-         aInString[length-1] == nl))
+        (tString[length-1] == cr ||
+         tString[length-1] == nl))
   {
     --length;
   }
@@ -100,11 +101,11 @@ nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
       aOutString.Append(gt);
       // No space between >: this is ">>> " style quoting, for
       // compatability with RFC 2646 and format=flowed.
-      if (aInString[i] != gt)
+      if (tString[i] != gt)
         aOutString.Append(space);
     }
 
-    uch = aInString[i++];
+    uch = tString[i++];
 
     aOutString += uch;
   }
@@ -116,8 +117,8 @@ nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
 }
 
 nsresult
-nsInternetCiter::StripCitesAndLinebreaks(const nsString& aInString,
-                                         nsString& aOutString,
+nsInternetCiter::StripCitesAndLinebreaks(const nsAReadableString& aInString,
+                                         nsAWritableString& aOutString,
                                          PRBool aLinebreaksToo,
                                          PRInt32* aCiteLevel)
 {
@@ -126,36 +127,37 @@ nsInternetCiter::StripCitesAndLinebreaks(const nsString& aInString,
 
   aOutString.SetLength(0);
 
-  PRInt32 length = aInString.Length();
+  nsString tString(aInString);//CRAPCRAP
+  PRInt32 length = tString.Length();
   PRInt32 i = 0;
   while (i < length)  // loop over lines
   {
     // Clear out cites first, at the beginning of the line:
     PRInt32 thisLineCiteLevel = 0;
-    while (aInString[i] == gt || nsCRT::IsAsciiSpace(aInString[i]))
+    while (tString[i] == gt || nsCRT::IsAsciiSpace(tString[i]))
     {
-      if (aInString[i] == gt) ++thisLineCiteLevel;
+      if (tString[i] == gt) ++thisLineCiteLevel;
       ++i;
     }
 
     // Now copy characters until line end:
-    PRInt32 nextNewline = aInString.FindCharInSet("\r\n", i);
+    PRInt32 nextNewline = tString.FindCharInSet("\r\n", i);
     if (nextNewline > i)
     {
       while (i < nextNewline)
-        aOutString.Append(aInString[i++]);
+        aOutString.Append(tString[i++]);
       if (aLinebreaksToo)
-        aOutString.AppendWithConversion(' ');
+        aOutString.Append(PRUnichar(' '));
       else
-        aOutString.AppendWithConversion('\n');    // DOM linebreaks, not NS_LINEBREAK
+        aOutString.Append(PRUnichar('\n'));    // DOM linebreaks, not NS_LINEBREAK
       // Skip over any more consecutive linebreak-like characters:
-      while (i < length && (aInString[i] == '\r' || aInString[i] == '\n'))
+      while (i < length && (tString[i] == '\r' || tString[i] == '\n'))
         ++i;
     }
     else    // no more newlines
     {
       while (i < length)
-        aOutString.Append(aInString[i++]);
+        aOutString.Append(tString[i++]);
     }
 
     // Done with this line -- update cite level
@@ -166,24 +168,24 @@ nsInternetCiter::StripCitesAndLinebreaks(const nsString& aInString,
 }
 
 NS_IMETHODIMP
-nsInternetCiter::StripCites(const nsString& aInString, nsString& aOutString)
+nsInternetCiter::StripCites(const nsAReadableString& aInString, nsAWritableString& aOutString)
 {
   return StripCitesAndLinebreaks(aInString, aOutString, PR_FALSE, 0);
 }
 
-static void AddCite(nsString& aOutString, PRInt32 citeLevel)
+static void AddCite(nsAWritableString& aOutString, PRInt32 citeLevel)
 {
   for (PRInt32 i = 0; i < citeLevel; ++i)
-    aOutString.Append(gt);
+    aOutString.Append(PRUnichar(gt));
   if (citeLevel > 0)
-    aOutString.Append(space);
+    aOutString.Append(PRUnichar(space));
 }
 
 NS_IMETHODIMP
-nsInternetCiter::Rewrap(const nsString& aInString,
+nsInternetCiter::Rewrap(const nsAReadableString& aInString,
                         PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
                         PRBool aRespectNewlines,
-                        nsString& aOutString)
+                        nsAWritableString& aOutString)
 {
   nsCOMPtr<nsILineBreaker> lineBreaker;
   nsILineBreakerFactory *lf;
@@ -205,21 +207,21 @@ nsInternetCiter::Rewrap(const nsString& aInString,
   PRUint32 posInString = 0;
   PRUint32 outStringCol = 0;
   PRUint32 citeLevel = 0;
-  const PRUnichar* unicodeStr = aInString.GetUnicode();
+  const nsPromiseFlatString &tString = PromiseFlatString(aInString);//MJUDGE SCC NEED HELP
   while (posInString < length)
   {
 #ifdef DEBUG_wrapping
-    nsAutoString debug (nsPromiseSubstring<PRUnichar>(aInString, posInString, length-posInString));
+    nsAutoString debug (nsPromiseSubstring<PRUnichar>(tString, posInString, length-posInString));
     printf("Outer loop: '%s'\n", debug.ToNewCString());
 #endif
 
     // Get the new cite level here since we're at the beginning of a line
     PRUint32 newCiteLevel = 0;
-    while (posInString < length && aInString[posInString] == gt)
+    while (posInString < length && tString[posInString] == gt)
     {
       ++newCiteLevel;
       ++posInString;
-      while (posInString < length && aInString[posInString] == space)
+      while (posInString < length && tString[posInString] == space)
         ++posInString;
     }
     if (posInString >= length)
@@ -227,9 +229,12 @@ nsInternetCiter::Rewrap(const nsString& aInString,
 
     // Special case: if this is a blank line, maintain a blank line
     // (retain the original paragraph breaks)
-    if (aInString[posInString] == nl)
+    if (tString[posInString] == nl)
     {
-      if (aOutString.Length() > 0 && aOutString[aOutString.Length()-1] != nl)
+      nsReadingIterator <PRUnichar> outPeekIter;
+      aOutString.EndReading(outPeekIter);
+      outPeekIter.advance(-1);
+      if (aOutString.Length() > 0 && (*outPeekIter) != nl)
         aOutString.Append(nl);
       AddCite(aOutString, newCiteLevel);
       aOutString.Append(nl);
@@ -267,12 +272,12 @@ nsInternetCiter::Rewrap(const nsString& aInString,
       printf("Appending space; citeLevel=%d, outStringCol=%d\n", citeLevel,
              outStringCol);
 #endif
-      aOutString.Append(space);
+      aOutString.Append(PRUnichar(space));
       ++outStringCol;
     }
 
     // find the next newline -- don't want to go farther than that
-    PRInt32 nextNewline = aInString.FindChar(nl, PR_FALSE, posInString);
+    PRInt32 nextNewline = tString.FindChar(nl, posInString);
     if (nextNewline < 0) nextNewline = length;
 
     // For now, don't wrap unquoted lines at all.
@@ -285,11 +290,11 @@ nsInternetCiter::Rewrap(const nsString& aInString,
     if (citeLevel == 0)
     {
 #ifdef DEBUG_wrapping
-      nsAutoString debug (nsPromiseSubstring<PRUnichar>(aInString, posInString,
+      nsAutoString debug (nsPromiseSubstring<PRUnichar>(tString, posInString,
                                     nextNewline-posInString));
       printf("Unquoted: appending '%s'\n", debug.ToNewCString());
 #endif
-      aOutString.Append(nsPromiseSubstring(aInString, posInString,
+      aOutString.Append(nsPromiseSubstring(tString, posInString,
                                   nextNewline-posInString));
       outStringCol += nextNewline - posInString;
       if (nextNewline != (PRInt32)length)
@@ -309,7 +314,7 @@ nsInternetCiter::Rewrap(const nsString& aInString,
     while ((PRInt32)posInString < nextNewline)
     {
 #ifdef DEBUG_wrapping
-      nsAutoString debug (nsPromiseSubstring<PRUnichar>(aInString, posInString, nextNewline-posInString));
+      nsAutoString debug (nsPromiseSubstring<PRUnichar>(tString, posInString, nextNewline-posInString));
       printf("Inner loop: '%s'\n", debug.ToNewCString());
 #endif
 
@@ -318,13 +323,13 @@ nsInternetCiter::Rewrap(const nsString& aInString,
       {
         // If this short line is the final one in the in string,
         // then we need to include the final newline, if any:
-        if (nextNewline+1 == (PRInt32)length && aInString[nextNewline-1] == nl)
+        if (nextNewline+1 == (PRInt32)length && tString[nextNewline-1] == nl)
           ++nextNewline;
 #ifdef DEBUG_wrapping
-        nsAutoString debug (nsPromiseSubstring<PRUnichar>(aInString, posInString, nextNewline - posInString));
+        nsAutoString debug (nsPromiseSubstring<PRUnichar>(tString, posInString, nextNewline - posInString));
         printf("Short line: '%s'\n", debug.ToNewCString());
 #endif
-        aOutString += nsPromiseSubstring(aInString,
+        aOutString += nsPromiseSubstring(tString,
                                 posInString, nextNewline - posInString);
         outStringCol += nextNewline - posInString;
         posInString = nextNewline + 1;
@@ -339,13 +344,13 @@ nsInternetCiter::Rewrap(const nsString& aInString,
       rv = NS_ERROR_BASE;
       if (lineBreaker)
       {
-        rv = lineBreaker->Prev(unicodeStr + posInString, length - posInString,
+        rv = lineBreaker->Prev(tString.get() + posInString, length - posInString,
                                eol - posInString, &breakPt, &needMore);
         if (NS_FAILED(rv) || needMore)
         {
           // if we couldn't find a breakpoint looking backwards,
           // try looking forwards:
-          rv = lineBreaker->Next(unicodeStr + posInString,
+          rv = lineBreaker->Next(tString.get() + posInString,
                                  length - posInString,
                                  eol - posInString, &breakPt, &needMore);
           if (needMore) rv = NS_ERROR_BASE;
@@ -365,7 +370,7 @@ nsInternetCiter::Rewrap(const nsString& aInString,
       printf("breakPt = %d\n", breakPt);
 #endif
 
-      aOutString += nsPromiseSubstring(aInString, posInString, breakPt);
+      aOutString += nsPromiseSubstring(tString, posInString, breakPt);
       posInString += breakPt;
       outStringCol += breakPt;
 
diff --git a/mozilla/editor/libeditor/text/nsInternetCiter.h b/mozilla/editor/libeditor/text/nsInternetCiter.h
index 0ee7bc9a7b2..2fe6f8b0540 100644
--- a/mozilla/editor/libeditor/text/nsInternetCiter.h
+++ b/mozilla/editor/libeditor/text/nsInternetCiter.h
@@ -38,17 +38,17 @@ public:
 //NOTE: Use   NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
   NS_DECL_ISUPPORTS
 
-  NS_IMETHOD GetCiteString(const nsString& aInString, nsString& aOutString);
+  NS_IMETHOD GetCiteString(const nsAReadableString & aInString, nsAWritableString & aOutString);
 
-  NS_IMETHOD StripCites(const nsString& aInString, nsString& aOutString);
+  NS_IMETHOD StripCites(const nsAReadableString & aInString, nsAWritableString & aOutString);
 
-  NS_IMETHOD Rewrap(const nsString& aInString,
+  NS_IMETHOD Rewrap(const nsAReadableString & aInString,
                     PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
                     PRBool aRespectNewlines,
-                    nsString& aOutString);
+                    nsAWritableString & aOutString);
 
 protected:
-  nsresult StripCitesAndLinebreaks(const nsString& aInString, nsString& aOutString,
+  nsresult StripCitesAndLinebreaks(const nsAReadableString& aInString, nsAWritableString& aOutString,
                                    PRBool aLinebreaksToo, PRInt32* aCiteLevel);
 };
 
diff --git a/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp b/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp
index 227887e6e9b..39fa66f4104 100644
--- a/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp
+++ b/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp
@@ -160,7 +160,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertTextFromTransferable(nsITransferable *tra
         textDataObj->ToString ( &text );
         stuffToPaste.Assign ( text, len / 2 );
         nsAutoEditBatch beginBatching(this);
-        rv = InsertText(stuffToPaste.GetUnicode());
+        rv = InsertText(stuffToPaste);
         if (text)
           nsMemory::Free(text);
       }
@@ -355,12 +355,14 @@ NS_IMETHODIMP nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
   return rv;
 }
 
-NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag)
+NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag)
 {
+  if (!aCanDrag)
+    return NS_ERROR_NULL_POINTER;
   /* we really should be checking the XY coordinates of the mouseevent and ensure that
    * that particular point is actually within the selection (not just that there is a selection)
    */
-  aCanDrag = PR_FALSE;
+  *aCanDrag = PR_FALSE;
  
   // KLUDGE to work around bug 50703
   // After double click and object property editing, 
@@ -395,7 +397,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDr
       res = selection->ContainsNode(eventTargetDomNode, PR_FALSE, &amTargettedCorrectly);
       if (NS_FAILED(res)) return res;
 
-    	aCanDrag = amTargettedCorrectly;
+    	*aCanDrag = amTargettedCorrectly;
     }
   }
 
@@ -532,9 +534,11 @@ NS_IMETHODIMP nsPlaintextEditor::Paste(PRInt32 aSelectionType)
 }
 
 
-NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste)
+NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste)
 {
-  aCanPaste = PR_FALSE;
+  if (!aCanPaste)
+    return NS_ERROR_NULL_POINTER;
+  *aCanPaste = PR_FALSE;
   
   // can't paste if readonly
   if (!IsModifiable())
@@ -572,6 +576,6 @@ NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPa
   rv = clipboard->HasDataMatchingFlavors(flavorsList, aSelectionType, &haveFlavors);
   if (NS_FAILED(rv)) return rv;
   
-  aCanPaste = haveFlavors;
+  *aCanPaste = haveFlavors;
   return NS_OK;
 }
diff --git a/mozilla/editor/libeditor/text/nsPlaintextEditor.cpp b/mozilla/editor/libeditor/text/nsPlaintextEditor.cpp
index 507487a7e7f..99543dd594b 100644
--- a/mozilla/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/mozilla/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -245,7 +245,7 @@ nsPlaintextEditor::EndEditorInit()
 }
 
 NS_IMETHODIMP 
-nsPlaintextEditor::SetDocumentCharacterSet(const PRUnichar* characterSet) 
+nsPlaintextEditor::SetDocumentCharacterSet(const nsAReadableString & characterSet) 
 { 
   nsresult result; 
 
@@ -312,7 +312,7 @@ nsPlaintextEditor::SetDocumentCharacterSet(const PRUnichar* characterSet)
               return NS_ERROR_FAILURE; 
 
             // Set attributes to the created element 
-            if (resultNode && nsCRT::strlen(characterSet) > 0) { 
+            if (resultNode && characterSet.Length() > 0) { 
               metaElement = do_QueryInterface(resultNode); 
               if (metaElement) { 
                 // not undoable, undo should undo CreateNode 
@@ -505,19 +505,19 @@ NS_IMETHODIMP nsPlaintextEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
      || keyCode == nsIDOMKeyEvent::DOM_VK_ENTER)
     {
       nsString empty;
-      return TypedText(empty.GetUnicode(), eTypedBreak);
+      return TypedText(empty, eTypedBreak);
     }
     else if (keyCode == nsIDOMKeyEvent::DOM_VK_ESCAPE)
     {
       // pass escape keypresses through as empty strings: needed for ime support
       nsString empty;
-      return TypedText(empty.GetUnicode(), eTypedText);
+      return TypedText(empty, eTypedText);
     }
     
     if (character && !altKey && !ctrlKey && !isShift && !metaKey)
     {
       nsAutoString key(character);
-      return TypedText(key.GetUnicode(), eTypedText);
+      return TypedText(key, eTypedText);
     }
   }
   return NS_ERROR_FAILURE;
@@ -529,7 +529,7 @@ NS_IMETHODIMP nsPlaintextEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
    to TypedText() to determine what action to take, but without passing
    an event.
    */
-NS_IMETHODIMP nsPlaintextEditor::TypedText(const PRUnichar* aString,
+NS_IMETHODIMP nsPlaintextEditor::TypedText(const nsAReadableString& aString,
                                       PRInt32 aAction)
 {
   nsAutoPlaceHolderBatch batch(this, gTypingTxnName);
@@ -944,7 +944,7 @@ NS_IMETHODIMP nsPlaintextEditor::DeleteSelection(nsIEditor::EDirection aAction)
   return result;
 }
 
-NS_IMETHODIMP nsPlaintextEditor::InsertText(const PRUnichar* aStringToInsert)
+NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAReadableString &aStringToInsert)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
@@ -967,9 +967,9 @@ NS_IMETHODIMP nsPlaintextEditor::InsertText(const PRUnichar* aStringToInsert)
   nsAutoString resultString;
   // XXX can we trust instring to outlive ruleInfo,
   // XXX and ruleInfo not to refer to instring in its dtor?
-  nsAutoString instring(aStringToInsert);
+  //nsAutoString instring(aStringToInsert);
   nsTextRulesInfo ruleInfo(theAction);
-  ruleInfo.inString = &instring;
+  ruleInfo.inString = &aStringToInsert;
   ruleInfo.outString = &resultString;
   ruleInfo.maxLength = mMaxTextLength;
 
@@ -1361,9 +1361,11 @@ NS_IMETHODIMP nsPlaintextEditor::Cut()
   return res;
 }
 
-NS_IMETHODIMP nsPlaintextEditor::CanCut(PRBool &aCanCut)
+NS_IMETHODIMP nsPlaintextEditor::CanCut(PRBool *aCanCut)
 {
-  aCanCut = PR_FALSE;
+  if (!aCanCut)
+    return NS_ERROR_NULL_POINTER;
+  *aCanCut = PR_FALSE;
   
   nsCOMPtr<nsISelection> selection;
   nsresult res = GetSelection(getter_AddRefs(selection));
@@ -1373,7 +1375,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanCut(PRBool &aCanCut)
   res = selection->GetIsCollapsed(&isCollapsed);
   if (NS_FAILED(res)) return res;
 
-  aCanCut = !isCollapsed && IsModifiable();
+  *aCanCut = !isCollapsed && IsModifiable();
   return NS_OK;
 }
 
@@ -1385,9 +1387,11 @@ NS_IMETHODIMP nsPlaintextEditor::Copy()
   return ps->DoCopy();
 }
 
-NS_IMETHODIMP nsPlaintextEditor::CanCopy(PRBool &aCanCopy)
+NS_IMETHODIMP nsPlaintextEditor::CanCopy(PRBool *aCanCopy)
 {
-  aCanCopy = PR_FALSE;
+  if (!aCanCopy)
+    return NS_ERROR_NULL_POINTER;
+  *aCanCopy = PR_FALSE;
   
   nsCOMPtr<nsISelection> selection;
   nsresult res = GetSelection(getter_AddRefs(selection));
@@ -1397,7 +1401,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanCopy(PRBool &aCanCopy)
   res = selection->GetIsCollapsed(&isCollapsed);
   if (NS_FAILED(res)) return res;
 
-  aCanCopy = !isCollapsed;
+  *aCanCopy = !isCollapsed;
   return NS_OK;
 }
 
@@ -1406,7 +1410,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanCopy(PRBool &aCanCopy)
 NS_IMETHODIMP
 nsPlaintextEditor::GetAndInitDocEncoder(const nsAReadableString& aFormatType,
                                         PRUint32 aFlags,
-                                        const nsAReadableString* aCharset,
+                                        const nsAReadableString& aCharset,
                                         nsIDocumentEncoder** encoder)
 {
   nsCOMPtr<nsIPresShell> presShell;
@@ -1426,9 +1430,9 @@ nsPlaintextEditor::GetAndInitDocEncoder(const nsAReadableString& aFormatType,
   rv = docEncoder->Init(doc, aFormatType, aFlags);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (aCharset && aCharset->Length() != 0
-      && !(aCharset->Equals(NS_LITERAL_STRING("null"))))
-    docEncoder->SetCharset(*aCharset);
+  if (aCharset.Length() != 0
+    && !(aCharset.Equals(NS_LITERAL_STRING("null"))))
+    docEncoder->SetCharset(aCharset);
 
   PRInt32 wc;
   (void) GetWrapWidth(&wc);
@@ -1512,7 +1516,7 @@ nsPlaintextEditor::OutputToString(nsAWritableString& aOutputString,
   }
 
   nsCOMPtr<nsIDocumentEncoder> encoder;
-  rv = GetAndInitDocEncoder(aFormatType, aFlags, 0, getter_AddRefs(encoder));
+  rv = GetAndInitDocEncoder(aFormatType, aFlags, NS_LITERAL_STRING(""), getter_AddRefs(encoder));
   if (NS_FAILED(rv))
     return rv;
   rv = encoder->EncodeToString(aOutputString);
@@ -1522,7 +1526,7 @@ nsPlaintextEditor::OutputToString(nsAWritableString& aOutputString,
 NS_IMETHODIMP
 nsPlaintextEditor::OutputToStream(nsIOutputStream* aOutputStream,
                              const nsAReadableString& aFormatType,
-                             const nsAReadableString* aCharset,
+                             const nsAReadableString& aCharset,
                              PRUint32 aFlags)
 {
   nsresult rv;
@@ -1647,7 +1651,7 @@ static nsICiter* MakeACiter()
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::InsertAsQuotation(const nsString& aQuotedText,
+nsPlaintextEditor::InsertAsQuotation(const nsAReadableString& aQuotedText,
                                      nsIDOMNode **aNodeInserted)
 {
   // We have the text.  Cite it appropriately:
@@ -1681,7 +1685,7 @@ nsPlaintextEditor::InsertAsQuotation(const nsString& aQuotedText,
   if (cancel) return NS_OK; // rules canceled the operation
   if (!handled)
   {
-    rv = InsertText(quotedStuff.GetUnicode());
+    rv = InsertText(quotedStuff);
 
     // XXX Should set *aNodeInserted to the first node inserted
     if (aNodeInserted && NS_SUCCEEDED(rv))
@@ -1694,17 +1698,17 @@ nsPlaintextEditor::InsertAsQuotation(const nsString& aQuotedText,
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::PasteAsCitedQuotation(const nsString& aCitation,
+nsPlaintextEditor::PasteAsCitedQuotation(const nsAReadableString& aCitation,
                                          PRInt32 aSelectionType)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
-                                          const nsString& aCitation,
+nsPlaintextEditor::InsertAsCitedQuotation(const nsAReadableString& aQuotedText,
+                                          const nsAReadableString& aCitation,
                                           PRBool aInsertHTML,
-                                          const nsString& aCharset,
+                                          const nsAReadableString& aCharset,
                                           nsIDOMNode **aNodeInserted)
 {
   return InsertAsQuotation(aQuotedText, aNodeInserted);
@@ -1752,7 +1756,7 @@ nsPlaintextEditor::Rewrap(PRBool aRespectNewlines)
     rv = SelectAll();
     if (NS_FAILED(rv)) return rv;
 
-    return InsertText(wrapped.GetUnicode());
+    return InsertText(wrapped);
   }
   else                // rewrap only the selection
   {
@@ -1770,7 +1774,7 @@ nsPlaintextEditor::Rewrap(PRBool aRespectNewlines)
                        wrapped);
     if (NS_FAILED(rv)) return rv;
 
-    return InsertText(wrapped.GetUnicode());
+    return InsertText(wrapped);
   }
   return NS_OK;
 }
@@ -1813,7 +1817,7 @@ nsPlaintextEditor::StripCites()
     rv = SelectAll();
     if (NS_FAILED(rv)) return rv;
 
-    return InsertText(stripped.GetUnicode());
+    return InsertText(stripped);
   }
   else                // rewrap only the selection
   {
@@ -1829,7 +1833,7 @@ nsPlaintextEditor::StripCites()
     rv = citer->StripCites(current, stripped);
     if (NS_FAILED(rv)) return rv;
 
-    return InsertText(stripped.GetUnicode());
+    return InsertText(stripped);
   }
   return NS_OK;
 }
@@ -1849,7 +1853,7 @@ nsPlaintextEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
 #endif
 
 NS_IMETHODIMP
-nsPlaintextEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
+nsPlaintextEditor::SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
 {
   NS_ASSERTION(aTextRangeList, "null ptr");
   if(nsnull == aTextRangeList)
@@ -1872,7 +1876,7 @@ nsPlaintextEditor::SetCompositionString(const nsString& aCompositionString, nsIP
   mIMETextRangeList = aTextRangeList;
   nsAutoPlaceHolderBatch batch(this, gIMETxnName);
 
-  result = InsertText(aCompositionString.GetUnicode());
+  result = InsertText(aCompositionString);
 
   mIMEBufferLength = aCompositionString.Length();
 
diff --git a/mozilla/editor/libeditor/text/nsPlaintextEditor.h b/mozilla/editor/libeditor/text/nsPlaintextEditor.h
index bfe586880ec..4cc4f6f0a49 100644
--- a/mozilla/editor/libeditor/text/nsPlaintextEditor.h
+++ b/mozilla/editor/libeditor/text/nsPlaintextEditor.h
@@ -70,14 +70,14 @@ public:
 
   /* ------------ nsIEditorMailSupport overrides -------------- */
   NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType);
-  NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText,
+  NS_IMETHOD InsertAsQuotation(const nsAReadableString& aQuotedText,
                                nsIDOMNode** aNodeInserted);
-  NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation,
+  NS_IMETHOD PasteAsCitedQuotation(const nsAReadableString& aCitation,
                                    PRInt32 aSelectionType);
-  NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText,
-                                    const nsString& aCitation,
+  NS_IMETHOD InsertAsCitedQuotation(const nsAReadableString& aQuotedText,
+                                    const nsAReadableString& aCitation,
                                     PRBool aInsertHTML,
-                                    const nsString& aCharset,
+                                    const nsAReadableString& aCharset,
                                     nsIDOMNode** aNodeInserted);
   NS_IMETHOD Rewrap(PRBool aRespectNewlines);
   NS_IMETHOD StripCites();
@@ -85,7 +85,7 @@ public:
 
   /* ------------ nsIEditorIMESupport overrides -------------- */
   
-  NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
+  NS_IMETHOD SetCompositionString(const nsAReadableString & aCompositionString, nsIPrivateTextRangeList * aTextRange, nsTextEventReply * aReply);
   NS_IMETHOD GetReconversionString(nsReconversionEventReply* aReply);
 
   /* ------------ Overrides of nsEditor interface methods -------------- */
@@ -97,7 +97,7 @@ public:
 
   NS_IMETHOD DeleteSelection(EDirection aAction);
 
-  NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet);
+  NS_IMETHOD SetDocumentCharacterSet(const nsAReadableString & characterSet);
 
   /** we override this here to install event listeners */
   NS_IMETHOD PostCreate();
@@ -109,13 +109,13 @@ public:
   NS_IMETHOD Redo(PRUint32 aCount);
 
   NS_IMETHOD Cut();
-  NS_IMETHOD CanCut(PRBool &aCanCut);
+  NS_IMETHOD CanCut(PRBool *aCanCut);
   NS_IMETHOD Copy();
-  NS_IMETHOD CanCopy(PRBool &aCanCopy);
+  NS_IMETHOD CanCopy(PRBool *aCanCopy);
   NS_IMETHOD Paste(PRInt32 aSelectionType);
-  NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste);
+  NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste);
 
-  NS_IMETHOD CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag);
+  NS_IMETHOD CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag);
   NS_IMETHOD DoDrag(nsIDOMEvent *aDragEvent);
   NS_IMETHOD InsertFromDrop(nsIDOMEvent* aDropEvent);
 
@@ -125,7 +125,7 @@ public:
                             
   NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
                             const nsAReadableString& aFormatType,
-                            const nsAReadableString* aCharsetOverride,
+                            const nsAReadableString& aCharsetOverride,
                             PRUint32 aFlags);
 
 
@@ -141,7 +141,7 @@ public:
   NS_IMETHOD SelectEntireDocument(nsISelection *aSelection);
 
   /* ------------ Utility Routines, not part of public API -------------- */
-  NS_IMETHOD TypedText(const PRUnichar* aString, PRInt32 aAction);
+  NS_IMETHOD TypedText(const nsAReadableString& aString, PRInt32 aAction);
 
   /** returns the absolute position of the end points of aSelection
     * in the document as a text stream.
@@ -183,7 +183,7 @@ protected:
   // Helpers for output routines
   NS_IMETHOD GetAndInitDocEncoder(const nsAReadableString& aFormatType,
                                   PRUint32 aFlags,
-                                  const nsAReadableString* aCharset,
+                                  const nsAReadableString& aCharset,
                                   nsIDocumentEncoder** encoder);
 
   // key event helpers
diff --git a/mozilla/editor/libeditor/text/nsTextEditRules.cpp b/mozilla/editor/libeditor/text/nsTextEditRules.cpp
index 62b116eb4c3..a4dc1eec027 100644
--- a/mozilla/editor/libeditor/text/nsTextEditRules.cpp
+++ b/mozilla/editor/libeditor/text/nsTextEditRules.cpp
@@ -437,13 +437,14 @@ nsTextEditRules::DidInsertBreak(nsISelection *aSelection, nsresult aResult)
   return res;
 }
 
+
 nsresult
 nsTextEditRules::WillInsertText(PRInt32          aAction,
                                 nsISelection *aSelection, 
                                 PRBool          *aCancel,
                                 PRBool          *aHandled,
-                                const nsString  *inString,
-                                nsString        *outString,
+                                const nsAReadableString *inString,
+                                nsAWritableString *outString,
                                 PRInt32          aMaxLength)
 {  
   if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
@@ -528,17 +529,40 @@ nsTextEditRules::WillInsertText(PRInt32          aAction,
   if (nsIPlaintextEditor::eEditorSingleLineMask & mFlags)
   {
     if (singleLineNewlineBehavior == eReplaceWithSpaces)
-      outString->ReplaceChar(CRLF, ' ');
+    {
+      nsString tString;
+      tString.Assign(*outString);
+      //nsAWritableString destString;
+      //NormalizeCRLF(outString,destString);
+
+      tString.ReplaceChar(CRLF, ' ');
+      outString->Assign(tString);
+    }
     else if (singleLineNewlineBehavior == eStripNewlines)
-      outString->StripChars(CRLF);
+    {
+      nsString tString;
+      tString.Assign(*outString);
+      tString.StripChars(CRLF);
+      outString->Assign(tString);
+    }
     else if (singleLineNewlineBehavior == ePasteFirstLine)
     {
-      PRInt32 firstCRLF = outString->FindCharInSet(CRLF);
+      nsString tString;
+      tString.Assign(*outString);
+      PRInt32 firstCRLF = tString.FindCharInSet(CRLF);
       if (firstCRLF > 0)
-      outString->Truncate(firstCRLF);
+      {
+        tString.Truncate(firstCRLF);
+        outString->Assign(tString);
+      }
     }
     else // even if we're pasting newlines, don't paste leading/trailing ones
-      outString->Trim(CRLF, PR_TRUE, PR_TRUE);
+    {
+      nsString tString;
+      tString.Assign(*outString);
+      tString.Trim(CRLF, PR_TRUE, PR_TRUE);
+      outString->Assign(tString);
+    }
   }
 
   // get the (collapsed) selection location
@@ -576,7 +600,8 @@ nsTextEditRules::WillInsertText(PRInt32          aAction,
     // dont spaz my selection in subtransactions
     nsAutoTxnsConserveSelection dontSpazMySelection(mEditor);
     nsSubsumeStr subStr;
-    const PRUnichar *unicodeBuf = outString->GetUnicode();
+    nsString tString(*outString);
+    const PRUnichar *unicodeBuf = tString.GetUnicode();
     nsCOMPtr<nsIDOMNode> unused;
     PRInt32 pos = 0;
         
@@ -586,11 +611,11 @@ nsTextEditRules::WillInsertText(PRInt32          aAction,
     if (isPRE)
     {
       char newlineChar = '\n';
-      while (unicodeBuf && (pos != -1) && ((PRUint32)pos < outString->Length()))
+      while (unicodeBuf && (pos != -1) && ((PRUint32)pos < tString.Length()))
       {
         PRInt32 oldPos = pos;
         PRInt32 subStrLen;
-        pos = outString->FindChar(newlineChar, PR_FALSE, oldPos);
+        pos = tString.FindChar(newlineChar, PR_FALSE, oldPos);
         
         if (pos != -1) 
         {
@@ -601,8 +626,8 @@ nsTextEditRules::WillInsertText(PRInt32          aAction,
         }
         else
         {
-          subStrLen = outString->Length() - oldPos;
-          pos = outString->Length();
+          subStrLen = tString.Length() - oldPos;
+          pos = tString.Length();
         }
 
         subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen);
@@ -631,11 +656,11 @@ nsTextEditRules::WillInsertText(PRInt32          aAction,
     {
       char specialChars[] = {'\t','\n',0};
       nsAutoString tabString; tabString.AssignWithConversion("    ");
-      while (unicodeBuf && (pos != -1) && ((PRUint32)pos < outString->Length()))
+      while (unicodeBuf && (pos != -1) && ((PRUint32)pos < tString.Length()))
       {
         PRInt32 oldPos = pos;
         PRInt32 subStrLen;
-        pos = outString->FindCharInSet(specialChars, oldPos);
+        pos = tString.FindCharInSet(specialChars, oldPos);
         
         if (pos != -1) 
         {
@@ -646,8 +671,8 @@ nsTextEditRules::WillInsertText(PRInt32          aAction,
         }
         else
         {
-          subStrLen = outString->Length() - oldPos;
-          pos = outString->Length();
+          subStrLen = tString.Length() - oldPos;
+          pos = tString.Length();
         }
 
         subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen);
@@ -671,7 +696,10 @@ nsTextEditRules::WillInsertText(PRInt32          aAction,
         if (NS_FAILED(res)) return res;
       }
     }
-    if (curNode) aSelection->Collapse(curNode, curOffset);
+    outString->Assign(tString);
+
+    if (curNode) 
+      aSelection->Collapse(curNode, curOffset);
   }
   return res;
 }
@@ -1018,8 +1046,8 @@ nsTextEditRules::DidRedo(nsISelection *aSelection, nsresult aResult)
 
 nsresult
 nsTextEditRules::WillOutputText(nsISelection *aSelection, 
-                                const nsString  *aOutputFormat,
-                                nsString *aOutString,                                
+                                const nsAReadableString  *aOutputFormat,
+                                nsAWritableString *aOutString,                                
                                 PRBool   *aCancel,
                                 PRBool   *aHandled)
 {
@@ -1031,7 +1059,9 @@ nsTextEditRules::WillOutputText(nsISelection *aSelection,
   *aCancel = PR_FALSE;
   *aHandled = PR_FALSE;
 
-  if (PR_TRUE == aOutputFormat->EqualsWithConversion("text/plain"))
+  nsAutoString outputFormat(*aOutputFormat);
+  outputFormat.ToLowerCase();
+  if (outputFormat.Equals(NS_LITERAL_STRING("text/plain")))
   { // only use these rules for plain text output
     if (mFlags & nsIPlaintextEditor::eEditorPasswordMask)
     {
@@ -1214,8 +1244,8 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsISelection *aSelection)
 
 nsresult
 nsTextEditRules::TruncateInsertionIfNeeded(nsISelection *aSelection, 
-                                           const nsString  *aInString,
-                                           nsString        *aOutString,
+                                           const nsAReadableString  *aInString,
+                                           nsAWritableString  *aOutString,
                                            PRInt32          aMaxLength)
 {
   if (!aSelection || !aInString || !aOutString) {return NS_ERROR_NULL_POINTER;}
@@ -1263,7 +1293,7 @@ nsTextEditRules::TruncateInsertionIfNeeded(nsISelection *aSelection,
 
 
 nsresult
-nsTextEditRules::EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsString *aOutString)
+nsTextEditRules::EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsAWritableString *aOutString)
 {
   if (!aOutString) {return NS_ERROR_NULL_POINTER;}
 
@@ -1275,7 +1305,9 @@ nsTextEditRules::EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsString *a
   PRInt32 i;
   aOutString->SetLength(0);
   for (i=0; i<length; i++)
-    aOutString->AppendWithConversion('*');
+  {
+    aOutString->Append(PRUnichar('*'));
+  }
 
   return NS_OK;
 }
diff --git a/mozilla/editor/libeditor/text/nsTextEditRules.h b/mozilla/editor/libeditor/text/nsTextEditRules.h
index 8e295d7d14f..da3360aed00 100644
--- a/mozilla/editor/libeditor/text/nsTextEditRules.h
+++ b/mozilla/editor/libeditor/text/nsTextEditRules.h
@@ -92,8 +92,8 @@ protected:
                             nsISelection *aSelection, 
                             PRBool          *aCancel,
                             PRBool          *aHandled,
-                            const nsString  *inString,
-                            nsString        *outString,
+                            const nsAReadableString  *inString,
+                            nsAWritableString        *outString,
                             PRInt32          aMaxLength);
   nsresult DidInsertText(nsISelection *aSelection, nsresult aResult);
   nsresult GetTopEnclosingPre(nsIDOMNode *aNode, nsIDOMNode** aOutPreNode);
@@ -132,8 +132,8 @@ protected:
     *                   and use aOutText as the result.
     */
   nsresult WillOutputText(nsISelection *aSelection,
-                          const nsString  *aInFormat,
-                          nsString *aOutText, 
+                          const nsAReadableString  *aInFormat,
+                          nsAWritableString *aOutText, 
                           PRBool   *aOutCancel, 
                           PRBool *aHandled);
 
@@ -151,13 +151,13 @@ protected:
   /** returns a truncated insertion string if insertion would place us
       over aMaxLength */
   nsresult TruncateInsertionIfNeeded(nsISelection *aSelection, 
-                                           const nsString  *aInString,
-                                           nsString        *aOutString,
+                                           const nsAReadableString  *aInString,
+                                           nsAWritableString        *aOutString,
                                            PRInt32          aMaxLength);
   
   /** Echo's the insertion text into the password buffer, and converts
       insertion text to '*'s */                                        
-  nsresult EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsString *aOutString);
+  nsresult EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsAWritableString *aOutString);
 
   nsresult CreateMozBR(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outBRNode);
 
@@ -200,9 +200,9 @@ class nsTextRulesInfo : public nsRulesInfo
   virtual ~nsTextRulesInfo() {};
   
   // kInsertText
-  const nsString *inString;
-  nsString *outString;
-  const nsString *outputFormat;
+  const nsAReadableString *inString;
+  nsAWritableString *outString;
+  const nsAReadableString *outputFormat;
   PRInt32 maxLength;
   
   // kDeleteSelection
@@ -213,10 +213,10 @@ class nsTextRulesInfo : public nsRulesInfo
   PRBool entireList;
 
   // kAlign
-  const nsString *alignType;
+  const nsAReadableString *alignType;
   
   // kMakeBasicBlock
-  const nsString *blockType;
+  const nsAReadableString *blockType;
   
   // kInsertElement
   const nsIDOMElement* insertElement;
diff --git a/mozilla/editor/libeditor/text/nsWrapUtils.cpp b/mozilla/editor/libeditor/text/nsWrapUtils.cpp
index 59a74b964dc..e85449c1e58 100644
--- a/mozilla/editor/libeditor/text/nsWrapUtils.cpp
+++ b/mozilla/editor/libeditor/text/nsWrapUtils.cpp
@@ -35,11 +35,11 @@ static NS_DEFINE_CID(kLWBrkCID, NS_LWBRK_CID);
  * Rewrap the given section of string, putting the result in aOutString.
  */
 nsresult
-nsWrapUtils::Rewrap(const nsString& aInString,
-                    PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
-                    PRBool aRespectNewlines,
-                    nsString aLineStartStr,
-                    nsString& aOutString)
+nsWrapUtils::Rewrap(const nsAReadableString& aInString,
+                         PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
+                         PRBool aRespectNewlines,
+                         const nsAReadableString &aLineStartStr,
+                         nsAWritableString& aOutString)
 {
   PRInt32 i;
 
@@ -61,7 +61,8 @@ nsWrapUtils::Rewrap(const nsString& aInString,
 
   // Now we either have a line breaker, or we don't.
   PRInt32 length = aInString.Length();
-  const PRUnichar* unicodeStr = aInString.GetUnicode();
+  nsString tString(aInString);
+  const PRUnichar* unicodeStr = tString.GetUnicode();
   for (i = 0; i < length; )    // loop over lines
   {
     nsAutoString remaining(unicodeStr + i, length - i);
@@ -75,7 +76,7 @@ nsWrapUtils::Rewrap(const nsString& aInString,
     if (eol > length)
     {
       aOutString.Append(unicodeStr + i, length - i);
-      aOutString.AppendWithConversion('\n');  // DOM line breaks, not NS_LINEBREAK
+      aOutString.Append(PRUnichar('\n'));  // DOM line breaks, not NS_LINEBREAK
       break;
     }
     if (i > 0) aFirstLineOffset = 0;
@@ -108,7 +109,7 @@ nsWrapUtils::Rewrap(const nsString& aInString,
     else breakPt += i;
     nsAutoString appending(unicodeStr + i, breakPt - i);
     aOutString.Append(unicodeStr + i, breakPt - i);
-    aOutString.AppendWithConversion('\n');  // DOM line breaks, not NS_LINEBREAK
+    aOutString.Append(PRUnichar('\n'));  // DOM line breaks, not NS_LINEBREAK
 
     i = breakPt;
   } // continue looping over lines
diff --git a/mozilla/editor/libeditor/text/nsWrapUtils.h b/mozilla/editor/libeditor/text/nsWrapUtils.h
index 00ea2fdda28..ce3e34f1f9f 100644
--- a/mozilla/editor/libeditor/text/nsWrapUtils.h
+++ b/mozilla/editor/libeditor/text/nsWrapUtils.h
@@ -30,11 +30,11 @@
 class nsWrapUtils
 {
 public:
-  static nsresult Rewrap(const nsString& aInString,
+  static nsresult Rewrap(const nsAReadableString& aInString,
                          PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
                          PRBool aRespectNewlines,
-                         nsString aLineStartStr,
-                         nsString& aOutString);
+                         const nsAReadableString &aLineStartStr,
+                         nsAWritableString& aOutString);
 };
 
 #endif //nsWrapUtils_h__
diff --git a/mozilla/editor/libeditor/txtsvc/nsTSDNotifier.cpp b/mozilla/editor/libeditor/txtsvc/nsTSDNotifier.cpp
index a5f56c707a3..59ec730b52d 100644
--- a/mozilla/editor/libeditor/txtsvc/nsTSDNotifier.cpp
+++ b/mozilla/editor/libeditor/txtsvc/nsTSDNotifier.cpp
@@ -19,7 +19,7 @@
  *
  * Contributor(s): 
  */
-
+#include "nsString.h"
 #include "nsIEditActionListener.h"
 #include "nsTSDNotifier.h"
 #include "nsTextServicesDocument.h"
@@ -173,25 +173,25 @@ nsTSDNotifier::DidJoinNodes(nsIDOMNode  *aLeftNode,
 // -------------------------------
 
 NS_IMETHODIMP
-nsTSDNotifier::WillCreateNode(const nsString& aTag, nsIDOMNode *aParent, PRInt32 aPosition)
+nsTSDNotifier::WillCreateNode(const nsAReadableString& aTag, nsIDOMNode *aParent, PRInt32 aPosition)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsTSDNotifier::DidCreateNode(const nsString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult)
+nsTSDNotifier::DidCreateNode(const nsAReadableString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsTSDNotifier::WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString)
+nsTSDNotifier::WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsTSDNotifier::DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString, nsresult aResult)
+nsTSDNotifier::DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString, nsresult aResult)
 {
   return NS_OK;
 }
diff --git a/mozilla/editor/libeditor/txtsvc/nsTSDNotifier.h b/mozilla/editor/libeditor/txtsvc/nsTSDNotifier.h
index b8df20f7d6c..c2022321793 100644
--- a/mozilla/editor/libeditor/txtsvc/nsTSDNotifier.h
+++ b/mozilla/editor/libeditor/txtsvc/nsTSDNotifier.h
@@ -74,10 +74,10 @@ public:
                           nsIDOMNode  *aParent,
                           nsresult     aResult);
   // these listen methods are unused:                        
-  NS_IMETHOD WillCreateNode(const nsString& aTag, nsIDOMNode *aParent, PRInt32 aPosition);
-  NS_IMETHOD DidCreateNode(const nsString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult);
-  NS_IMETHOD WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString);
-  NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString, nsresult aResult);
+  NS_IMETHOD WillCreateNode(const nsAReadableString& aTag, nsIDOMNode *aParent, PRInt32 aPosition);
+  NS_IMETHOD DidCreateNode(const nsAReadableString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult);
+  NS_IMETHOD WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString);
+  NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString, nsresult aResult);
   NS_IMETHOD WillDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength);
   NS_IMETHOD DidDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength, nsresult aResult);
   NS_IMETHOD WillDeleteSelection(nsISelection *aSelection);
diff --git a/mozilla/editor/libeditor/txtsvc/nsTextServicesDocument.cpp b/mozilla/editor/libeditor/txtsvc/nsTextServicesDocument.cpp
index bf5a9583af2..ac6fb0ee3ae 100644
--- a/mozilla/editor/libeditor/txtsvc/nsTextServicesDocument.cpp
+++ b/mozilla/editor/libeditor/txtsvc/nsTextServicesDocument.cpp
@@ -2074,7 +2074,7 @@ nsTextServicesDocument::InsertText(const nsString *aText)
 
   nsCOMPtr<nsIPlaintextEditor> textEditor (do_QueryInterface(mEditor, &result));
   if (textEditor)
-    result = textEditor->InsertText(aText->GetUnicode());
+    result = textEditor->InsertText(*aText);
 
   if (NS_FAILED(result))
   {
diff --git a/mozilla/editor/public/Makefile.in b/mozilla/editor/public/Makefile.in
index b9098568704..63cf73987e2 100644
--- a/mozilla/editor/public/Makefile.in
+++ b/mozilla/editor/public/Makefile.in
@@ -29,16 +29,10 @@ include $(DEPTH)/config/autoconf.mk
 MODULE		= editor
 
 EXPORTS		= \
-		nsIEditActionListener.h \
-		nsIEditor.h \
 		nsEditorCID.h \
-		nsICiter.h \
-		nsIEditorIMESupport.h \
 		nsIEditorLogging.h \
 		nsIEditorMailSupport.h \
-		nsIEditorObserver.h \
 		nsIEditorStyleSheets.h \
-		nsIHTMLEditor.h \
 		nsITableEditor.h \
 		$(NULL)
 
diff --git a/mozilla/editor/public/makefile.win b/mozilla/editor/public/makefile.win
index 6f7b3c5a7be..edea0e0b8c9 100644
--- a/mozilla/editor/public/makefile.win
+++ b/mozilla/editor/public/makefile.win
@@ -22,17 +22,11 @@
 DEPTH=..\..
 
 
-EXPORTS =		                         \
-    nsIEditActionListener.h	         \
-    nsIEditor.h	                     \
-    nsEditorCID.h	                   \
-    nsICiter.h	                     \
-    nsIEditorIMESupport.h            \
+EXPORTS =                            \
+    nsEditorCID.h                    \
     nsIEditorLogging.h               \
     nsIEditorMailSupport.h           \
-    nsIEditorObserver.h              \
     nsIEditorStyleSheets.h           \
-    nsIHTMLEditor.h                  \
     nsITableEditor.h                 \
     $(NULL)
 
diff --git a/mozilla/editor/public/nsIEditorMailSupport.h b/mozilla/editor/public/nsIEditorMailSupport.h
index 5e800b2e6b6..e65d57d0e2a 100644
--- a/mozilla/editor/public/nsIEditorMailSupport.h
+++ b/mozilla/editor/public/nsIEditorMailSupport.h
@@ -51,7 +51,7 @@ public:
     * replacing the selected text (if any).
     * @param aQuotedText  The actual text to be quoted
     */
-  NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText,
+  NS_IMETHOD InsertAsQuotation(const nsAReadableString& aQuotedText,
                                nsIDOMNode** aNodeInserted)=0;
 
   /** Paste a string as quoted text,
@@ -60,7 +60,7 @@ public:
     * @param aCitation    The "mid" URL of the source message
     * @param aSelectionType Text or html?
     */
-  NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation,
+  NS_IMETHOD PasteAsCitedQuotation(const nsAReadableString& aCitation,
                                    PRInt32 aSelectionType)=0;
 
   /** Insert a string as quoted text
@@ -72,10 +72,10 @@ public:
     * @param aInsertHTML  Insert as html?  (vs plaintext)
     * @param aCharset     The charset of the text to be inserted
     */
-  NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText,
-                                    const nsString& aCitation,
+  NS_IMETHOD InsertAsCitedQuotation(const nsAReadableString& aQuotedText,
+                                    const nsAReadableString& aCitation,
                                     PRBool aInsertHTML,
-                                    const nsString& aCharset,
+                                    const nsAReadableString& aCharset,
                                     nsIDOMNode** aNodeInserted)=0;
 
   /**
diff --git a/mozilla/editor/public/nsIEditorStyleSheets.h b/mozilla/editor/public/nsIEditorStyleSheets.h
index f5bf571ac6a..092414b5840 100644
--- a/mozilla/editor/public/nsIEditorStyleSheets.h
+++ b/mozilla/editor/public/nsIEditorStyleSheets.h
@@ -46,7 +46,7 @@ public:
     * @param aURL         The style sheet to be loaded and applied.
     * @param aStyleSheet  Optional: if not null, return the style sheet created from aURL
     */
-  NS_IMETHOD ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)=0;
+  NS_IMETHOD ApplyStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet)=0;
 
   /** load and apply an Override style sheet, specified by aURL, to
     * the editor's document. 
@@ -61,7 +61,7 @@ public:
     * @param aURL         The style sheet to be loaded and applied.
     * @param aStyleSheet  Optional: if not null, return the style sheet created from aURL
     */
-  NS_IMETHOD ApplyOverrideStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)=0;
+  NS_IMETHOD ApplyOverrideStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet)=0;
 
   /** Add the given Style Sheet to the editor's document
     * This is always synchronous
diff --git a/mozilla/editor/txtsvc/src/nsTSDNotifier.cpp b/mozilla/editor/txtsvc/src/nsTSDNotifier.cpp
index a5f56c707a3..59ec730b52d 100644
--- a/mozilla/editor/txtsvc/src/nsTSDNotifier.cpp
+++ b/mozilla/editor/txtsvc/src/nsTSDNotifier.cpp
@@ -19,7 +19,7 @@
  *
  * Contributor(s): 
  */
-
+#include "nsString.h"
 #include "nsIEditActionListener.h"
 #include "nsTSDNotifier.h"
 #include "nsTextServicesDocument.h"
@@ -173,25 +173,25 @@ nsTSDNotifier::DidJoinNodes(nsIDOMNode  *aLeftNode,
 // -------------------------------
 
 NS_IMETHODIMP
-nsTSDNotifier::WillCreateNode(const nsString& aTag, nsIDOMNode *aParent, PRInt32 aPosition)
+nsTSDNotifier::WillCreateNode(const nsAReadableString& aTag, nsIDOMNode *aParent, PRInt32 aPosition)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsTSDNotifier::DidCreateNode(const nsString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult)
+nsTSDNotifier::DidCreateNode(const nsAReadableString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsTSDNotifier::WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString)
+nsTSDNotifier::WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsTSDNotifier::DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString, nsresult aResult)
+nsTSDNotifier::DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString, nsresult aResult)
 {
   return NS_OK;
 }
diff --git a/mozilla/editor/txtsvc/src/nsTSDNotifier.h b/mozilla/editor/txtsvc/src/nsTSDNotifier.h
index b8df20f7d6c..c2022321793 100644
--- a/mozilla/editor/txtsvc/src/nsTSDNotifier.h
+++ b/mozilla/editor/txtsvc/src/nsTSDNotifier.h
@@ -74,10 +74,10 @@ public:
                           nsIDOMNode  *aParent,
                           nsresult     aResult);
   // these listen methods are unused:                        
-  NS_IMETHOD WillCreateNode(const nsString& aTag, nsIDOMNode *aParent, PRInt32 aPosition);
-  NS_IMETHOD DidCreateNode(const nsString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult);
-  NS_IMETHOD WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString);
-  NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString, nsresult aResult);
+  NS_IMETHOD WillCreateNode(const nsAReadableString& aTag, nsIDOMNode *aParent, PRInt32 aPosition);
+  NS_IMETHOD DidCreateNode(const nsAReadableString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult);
+  NS_IMETHOD WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString);
+  NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString, nsresult aResult);
   NS_IMETHOD WillDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength);
   NS_IMETHOD DidDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength, nsresult aResult);
   NS_IMETHOD WillDeleteSelection(nsISelection *aSelection);
diff --git a/mozilla/editor/txtsvc/src/nsTextServicesDocument.cpp b/mozilla/editor/txtsvc/src/nsTextServicesDocument.cpp
index bf5a9583af2..ac6fb0ee3ae 100644
--- a/mozilla/editor/txtsvc/src/nsTextServicesDocument.cpp
+++ b/mozilla/editor/txtsvc/src/nsTextServicesDocument.cpp
@@ -2074,7 +2074,7 @@ nsTextServicesDocument::InsertText(const nsString *aText)
 
   nsCOMPtr<nsIPlaintextEditor> textEditor (do_QueryInterface(mEditor, &result));
   if (textEditor)
-    result = textEditor->InsertText(aText->GetUnicode());
+    result = textEditor->InsertText(*aText);
 
   if (NS_FAILED(result))
   {