From 262d16a6c3de656633ca4d5fda103ee8f9a3d592 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Fri, 16 Jul 2010 17:34:36 -0400 Subject: [PATCH] Bug 240933 - Part 3.1: Position the selection before the terminating newline when clicking to the right of the line; r=roc a=dbaron --HG-- extra : rebase_source : 51ab2d6caf2b8827cf2e1eb88e5034d75268f658 --- layout/generic/nsTextFrameThebes.cpp | 7 ++++ layout/generic/test/Makefile.in | 1 + layout/generic/test/test_bug240933.html | 46 +++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 layout/generic/test/test_bug240933.html diff --git a/layout/generic/nsTextFrameThebes.cpp b/layout/generic/nsTextFrameThebes.cpp index c10c92ec1361..4dc203f467a7 100644 --- a/layout/generic/nsTextFrameThebes.cpp +++ b/layout/generic/nsTextFrameThebes.cpp @@ -5062,6 +5062,13 @@ nsTextFrame::GetCharacterOffsetAtFramePointInternal(const nsPoint &aPoint, // intrinsic widths. selectedOffset = provider.GetStart().GetOriginalOffset() + provider.GetOriginalLength(); + // If we're at the end of a preformatted line which has a terminating + // linefeed, we want to reduce the offset by one to make sure that the + // selection is placed before the linefeed character. + if (GetStyleText()->NewlineIsSignificant() && + HasTerminalNewline()) { + --selectedOffset; + } } offsets.content = GetContent(); diff --git a/layout/generic/test/Makefile.in b/layout/generic/test/Makefile.in index 2b0dc6c5fe11..44e456b47658 100644 --- a/layout/generic/test/Makefile.in +++ b/layout/generic/test/Makefile.in @@ -58,6 +58,7 @@ _TEST_FILES = \ plugin_clipping_lib.js \ plugin_focus_helper.html \ test_backspace_delete.xul \ + test_bug240933.html \ test_bug263683.html \ test_bug288789.html \ test_bug290397.html \ diff --git a/layout/generic/test/test_bug240933.html b/layout/generic/test/test_bug240933.html new file mode 100644 index 000000000000..fa90106bafbe --- /dev/null +++ b/layout/generic/test/test_bug240933.html @@ -0,0 +1,46 @@ + + + + + + Test for Bug 240933 + + + + + + + + + Mozilla Bug 240933 + +

+ + +
+    
+  
+ + + + +