From 98e3352cf6574aa09dffe0a9d6ee3ecfc753721e Mon Sep 17 00:00:00 2001 From: "akkana%netscape.com" Date: Mon, 28 Aug 2000 22:15:03 +0000 Subject: [PATCH] 23485: make it possible for urlbar to go to urls spanning multiple lines. r=jfrancis git-svn-id: svn://10.0.0.236/trunk@77375 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsDocShell.cpp | 3 +++ mozilla/editor/base/nsEditorShell.cpp | 2 +- mozilla/editor/base/nsTextEditRules.cpp | 12 ++++++++---- mozilla/editor/composer/src/nsEditorShell.cpp | 2 +- mozilla/editor/libeditor/text/nsTextEditRules.cpp | 12 ++++++++---- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 817dae9a054..8bb9bd22d3f 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/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/mozilla/editor/base/nsEditorShell.cpp b/mozilla/editor/base/nsEditorShell.cpp index 85c8a80159f..46964501f72 100644 --- a/mozilla/editor/base/nsEditorShell.cpp +++ b/mozilla/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/mozilla/editor/base/nsTextEditRules.cpp b/mozilla/editor/base/nsTextEditRules.cpp index 517342246b3..93ba85d1e61 100644 --- a/mozilla/editor/base/nsTextEditRules.cpp +++ b/mozilla/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/mozilla/editor/composer/src/nsEditorShell.cpp b/mozilla/editor/composer/src/nsEditorShell.cpp index 85c8a80159f..46964501f72 100644 --- a/mozilla/editor/composer/src/nsEditorShell.cpp +++ b/mozilla/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/mozilla/editor/libeditor/text/nsTextEditRules.cpp b/mozilla/editor/libeditor/text/nsTextEditRules.cpp index 517342246b3..93ba85d1e61 100644 --- a/mozilla/editor/libeditor/text/nsTextEditRules.cpp +++ b/mozilla/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