From 133d6d5182ea181e47d79206ed83f16c22d4fc05 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Fri, 24 Sep 2010 15:10:53 -0400 Subject: [PATCH] Bug 597519 - Attempting to add characters to a textarea filled to its maxlength with a trailing newline results in the caret to jump to the previous line; r=roc a=blocking-final+ --- editor/libeditor/text/nsTextEditRules.cpp | 8 +++++++- layout/base/tests/Makefile.in | 2 ++ layout/base/tests/bug597519-1-ref.html | 11 +++++++++++ layout/base/tests/bug597519-1.html | 17 +++++++++++++++++ layout/base/tests/test_reftests_with_caret.html | 3 ++- 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 layout/base/tests/bug597519-1-ref.html create mode 100644 layout/base/tests/bug597519-1.html diff --git a/editor/libeditor/text/nsTextEditRules.cpp b/editor/libeditor/text/nsTextEditRules.cpp index aea336ce752..4fd8a7f44ae 100644 --- a/editor/libeditor/text/nsTextEditRules.cpp +++ b/editor/libeditor/text/nsTextEditRules.cpp @@ -658,8 +658,14 @@ nsTextEditRules::WillInsertText(PRInt32 aAction, // handle docs with a max length // NOTE, this function copies inString into outString for us. - nsresult res = TruncateInsertionIfNeeded(aSelection, inString, outString, aMaxLength, nsnull); + PRBool truncated = PR_FALSE; + nsresult res = TruncateInsertionIfNeeded(aSelection, inString, outString, + aMaxLength, &truncated); NS_ENSURE_SUCCESS(res, res); + if (truncated) { + *aCancel = PR_TRUE; + return NS_OK; + } PRUint32 start = 0; PRUint32 end = 0; diff --git a/layout/base/tests/Makefile.in b/layout/base/tests/Makefile.in index 5e7d4696d16..e8d30817929 100644 --- a/layout/base/tests/Makefile.in +++ b/layout/base/tests/Makefile.in @@ -104,6 +104,8 @@ _TEST_FILES = \ bug512295-2-ref.html \ bug585922.html \ bug585922-ref.html \ + bug597519-1.html \ + bug597519-1-ref.html \ test_bug514127.html \ test_bug518777.html \ test_bug548545.xhtml \ diff --git a/layout/base/tests/bug597519-1-ref.html b/layout/base/tests/bug597519-1-ref.html new file mode 100644 index 00000000000..f859e313dde --- /dev/null +++ b/layout/base/tests/bug597519-1-ref.html @@ -0,0 +1,11 @@ + + + + + + + diff --git a/layout/base/tests/bug597519-1.html b/layout/base/tests/bug597519-1.html new file mode 100644 index 00000000000..ecf3d35f263 --- /dev/null +++ b/layout/base/tests/bug597519-1.html @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/layout/base/tests/test_reftests_with_caret.html b/layout/base/tests/test_reftests_with_caret.html index 2b54805ebbd..d0e59dfa228 100644 --- a/layout/base/tests/test_reftests_with_caret.html +++ b/layout/base/tests/test_reftests_with_caret.html @@ -93,7 +93,8 @@ var tests = [ [ 'bug482484.html' , 'bug482484-ref.html' ] , [ 'bug512295-1.html' , 'bug512295-1-ref.html' ] , [ 'bug512295-2.html' , 'bug512295-2-ref.html' ] , - [ 'bug585922.html' , 'bug585922-ref.html' ] + [ 'bug585922.html' , 'bug585922-ref.html' ] , + [ 'bug597519-1.html' , 'bug597519-1-ref.html' ] ]; var testIndex = 0;