From 2ed96f2ef8d3e4f9359e1551807a5c9b6a267f27 Mon Sep 17 00:00:00 2001 From: Uri Bernstein Date: Tue, 21 Oct 2008 11:52:52 +0200 Subject: [PATCH] Bug 459921 - Double-click-and-drag selects previous word when dragging to left half of first letter of a word. r+sr=roc. --- layout/generic/nsSelection.cpp | 13 +++++++ layout/generic/test/Makefile.in | 1 + layout/generic/test/test_bug459921.html | 52 +++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 layout/generic/test/test_bug459921.html diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index 475356b77523..f61ed529abd8 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -1853,6 +1853,19 @@ nsFrameSelection::HandleDrag(nsIFrame *aFrame, nsPoint aPoint) PRInt32 offset; nsIFrame* frame = GetFrameForNodeOffset(offsets.content, offsets.offset, HINTRIGHT, &offset); + + if (amount == eSelectWord && direction == eDirPrevious) { + // To avoid selecting the previous word when at start of word, + // first move one character forward. + nsPeekOffsetStruct charPos; + charPos.SetData(eSelectCharacter, eDirNext, offset, 0, + PR_FALSE, mLimiter != nsnull, PR_FALSE, PR_FALSE); + if (NS_SUCCEEDED(frame->PeekOffset(&charPos))) { + frame = charPos.mResultFrame; + offset = charPos.mContentOffset; + } + } + nsPeekOffsetStruct pos; pos.SetData(amount, direction, offset, 0, PR_FALSE, mLimiter != nsnull, PR_FALSE, PR_FALSE); diff --git a/layout/generic/test/Makefile.in b/layout/generic/test/Makefile.in index 694af4445ba5..c413d7c73145 100644 --- a/layout/generic/test/Makefile.in +++ b/layout/generic/test/Makefile.in @@ -63,6 +63,7 @@ _TEST_FILES = test_bug288789.html \ test_bug416168.html \ test_bug421436.html \ test_bug448860.html \ + test_bug459221.html \ test_bug460532.html \ test_character_movement.html \ test_word_movement.html \ diff --git a/layout/generic/test/test_bug459921.html b/layout/generic/test/test_bug459921.html new file mode 100644 index 000000000000..186ffc6a8a35 --- /dev/null +++ b/layout/generic/test/test_bug459921.html @@ -0,0 +1,52 @@ + + + + + Test for Bug 459921 + + + + + + +Mozilla Bug 459921 +

+
+World Wide Web +
+
+
+
+ +