From 56697d99dc63989fa3f4019993f33613d029fd45 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Wed, 5 Jan 2011 20:55:31 -0500 Subject: [PATCH] Bug 620936 - setSelectionRange should not fail with offsets larger than the value of the editable field; r=roc a=blocking-betaN+ --- layout/forms/nsTextControlFrame.cpp | 2 +- layout/forms/test/Makefile.in | 1 + layout/forms/test/test_bug620936.html | 36 +++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 layout/forms/test/test_bug620936.html diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index f97675e198a..f4c89f642e0 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -1102,7 +1102,7 @@ nsTextControlFrame::OffsetToDOMPoint(PRInt32 aOffset, } else { // Otherwise, set the selection on the textnode itself. NS_IF_ADDREF(*aResult = firstNode); - *aPosition = aOffset; + *aPosition = PR_MIN(aOffset, textLength); } } else { NS_IF_ADDREF(*aResult = rootNode); diff --git a/layout/forms/test/Makefile.in b/layout/forms/test/Makefile.in index 87db1547bc0..71ef092b496 100644 --- a/layout/forms/test/Makefile.in +++ b/layout/forms/test/Makefile.in @@ -75,6 +75,7 @@ _TEST_FILES = test_bug231389.html \ test_bug572406.html \ test_bug572649.html \ test_bug36619.html \ + test_bug620936.html \ $(NULL) libs:: $(_TEST_FILES) diff --git a/layout/forms/test/test_bug620936.html b/layout/forms/test/test_bug620936.html new file mode 100644 index 00000000000..756fe46c4b7 --- /dev/null +++ b/layout/forms/test/test_bug620936.html @@ -0,0 +1,36 @@ + + + + + Test for Bug 620936 + + + + + + +Mozilla Bug 620936 +

+
+ +
+
+
+
+ +