diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 817dae9a0541..8bb9bd22d3f5 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -2838,6 +2838,9 @@ NS_IMETHODIMP nsDocShell::CreateFixupURI(const PRUnichar* aStringURI, nsAutoString uriString(aStringURI); uriString.Trim(" "); // Cleanup the empty spaces that might be on each end. + // Eliminate embedded newlines, which single-line text fields now allow: + uriString.StripChars("\r\n"); + // XXX nasty hack to check for the view-source: prefix // // The long term way and probably CORRECT way to do this is to write a diff --git a/editor/base/nsEditorShell.cpp b/editor/base/nsEditorShell.cpp index 85c8a80159ff..46964501f72d 100644 --- a/editor/base/nsEditorShell.cpp +++ b/editor/base/nsEditorShell.cpp @@ -4424,7 +4424,7 @@ nsEditorShell::GetEmbeddedObjects(nsISupportsArray **aObjectArray) if (!aObjectArray) return NS_ERROR_NULL_POINTER; - nsresult result; + nsresult result = NS_NOINTERFACE; switch (mEditorType) { diff --git a/editor/base/nsTextEditRules.cpp b/editor/base/nsTextEditRules.cpp index 517342246b3c..93ba85d1e618 100644 --- a/editor/base/nsTextEditRules.cpp +++ b/editor/base/nsTextEditRules.cpp @@ -69,10 +69,10 @@ NS_NewTextEditRules(nsIEditRules** aInstancePtrResult) nsTextEditRules::nsTextEditRules() : mEditor(nsnull) -, mFlags(0) // initialized to 0 ("no flags set"). Real initial value is given in Init() , mPasswordText() , mBogusNode(nsnull) , mBody(nsnull) +, mFlags(0) // initialized to 0 ("no flags set"). Real initial value is given in Init() , mActionNesting(0) , mLockRulesSniffing(PR_FALSE) , mTheAction(0) @@ -603,8 +603,6 @@ nsTextEditRules::WillInsertText(PRInt32 aAction, if (NS_FAILED(res)) return res; } - char specialChars[] = {'\t','\n',0}; - // if the selection isn't collapsed, delete it. PRBool bCollapsed; res = aSelection->GetIsCollapsed(&bCollapsed); @@ -630,6 +628,8 @@ nsTextEditRules::WillInsertText(PRInt32 aAction, if (NS_FAILED(res)) return res; } +#ifdef REPLACE_LINEBREAK_WITH_SPACES + // Commented out per bug 23485 // if we're a single line control, pretreat the input string to remove returns // this is unnecessary if we use
's for breaks in "plain text", because // InsertBreak() checks the string. But we don't currently do that, so we need this @@ -640,6 +640,7 @@ nsTextEditRules::WillInsertText(PRInt32 aAction, { outString->ReplaceChar(CRLF, ' '); } +#endif /* REPLACE_LINEBREAK_WITH_SPACES */ // get the (collapsed) selection location res = mEditor->GetStartNodeAndOffset(aSelection, &selNode, &selOffset); @@ -710,7 +711,10 @@ nsTextEditRules::WillInsertText(PRInt32 aAction, // is it a return? if (subStr.EqualsWithConversion("\n")) { - res = mEditor->CreateBRImpl(&curNode, &curOffset, &unused, nsIEditor::eNone); + if (nsIHTMLEditor::eEditorSingleLineMask & mFlags) + res = mEditor->InsertTextImpl(subStr, &curNode, &curOffset, doc); + else + res = mEditor->CreateBRImpl(&curNode, &curOffset, &unused, nsIEditor::eNone); pos++; } else diff --git a/editor/composer/src/nsEditorShell.cpp b/editor/composer/src/nsEditorShell.cpp index 85c8a80159ff..46964501f72d 100644 --- a/editor/composer/src/nsEditorShell.cpp +++ b/editor/composer/src/nsEditorShell.cpp @@ -4424,7 +4424,7 @@ nsEditorShell::GetEmbeddedObjects(nsISupportsArray **aObjectArray) if (!aObjectArray) return NS_ERROR_NULL_POINTER; - nsresult result; + nsresult result = NS_NOINTERFACE; switch (mEditorType) { diff --git a/editor/libeditor/text/nsTextEditRules.cpp b/editor/libeditor/text/nsTextEditRules.cpp index 517342246b3c..93ba85d1e618 100644 --- a/editor/libeditor/text/nsTextEditRules.cpp +++ b/editor/libeditor/text/nsTextEditRules.cpp @@ -69,10 +69,10 @@ NS_NewTextEditRules(nsIEditRules** aInstancePtrResult) nsTextEditRules::nsTextEditRules() : mEditor(nsnull) -, mFlags(0) // initialized to 0 ("no flags set"). Real initial value is given in Init() , mPasswordText() , mBogusNode(nsnull) , mBody(nsnull) +, mFlags(0) // initialized to 0 ("no flags set"). Real initial value is given in Init() , mActionNesting(0) , mLockRulesSniffing(PR_FALSE) , mTheAction(0) @@ -603,8 +603,6 @@ nsTextEditRules::WillInsertText(PRInt32 aAction, if (NS_FAILED(res)) return res; } - char specialChars[] = {'\t','\n',0}; - // if the selection isn't collapsed, delete it. PRBool bCollapsed; res = aSelection->GetIsCollapsed(&bCollapsed); @@ -630,6 +628,8 @@ nsTextEditRules::WillInsertText(PRInt32 aAction, if (NS_FAILED(res)) return res; } +#ifdef REPLACE_LINEBREAK_WITH_SPACES + // Commented out per bug 23485 // if we're a single line control, pretreat the input string to remove returns // this is unnecessary if we use
's for breaks in "plain text", because // InsertBreak() checks the string. But we don't currently do that, so we need this @@ -640,6 +640,7 @@ nsTextEditRules::WillInsertText(PRInt32 aAction, { outString->ReplaceChar(CRLF, ' '); } +#endif /* REPLACE_LINEBREAK_WITH_SPACES */ // get the (collapsed) selection location res = mEditor->GetStartNodeAndOffset(aSelection, &selNode, &selOffset); @@ -710,7 +711,10 @@ nsTextEditRules::WillInsertText(PRInt32 aAction, // is it a return? if (subStr.EqualsWithConversion("\n")) { - res = mEditor->CreateBRImpl(&curNode, &curOffset, &unused, nsIEditor::eNone); + if (nsIHTMLEditor::eEditorSingleLineMask & mFlags) + res = mEditor->InsertTextImpl(subStr, &curNode, &curOffset, doc); + else + res = mEditor->CreateBRImpl(&curNode, &curOffset, &unused, nsIEditor::eNone); pos++; } else