Bug 459921 - Double-click-and-drag selects previous word when dragging to left half of first letter of a word. r+sr=roc.

This commit is contained in:
Uri Bernstein 2008-10-21 11:52:52 +02:00
Родитель f99bbd6c4b
Коммит 2ed96f2ef8
3 изменённых файлов: 66 добавлений и 0 удалений

Просмотреть файл

@ -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);

Просмотреть файл

@ -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 \

Просмотреть файл

@ -0,0 +1,52 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=459921
-->
<head>
<title>Test for Bug 459921</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=459921">Mozilla Bug 459921</a>
<p id="display"></p>
<div id="content">
World <span id="wide">Wide</span> <span id="web">Web</span>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 459921 **/
function test() {
var sel = window.getSelection();
// Ctrl[Cmd]-doubleclick "Web".
var web = document.getElementById('web');
synthesizeMouse(web, 3, 3, { type: "mousedown", clickCount: 2, accelKey: true });
// Drag to the very beginning of "Wide" and release.
var wide = document.getElementById('wide');
synthesizeMouse(wide, 1, 3, { type: "mousemove", accelKey: true });
synthesizeMouse(wide, 1, 3, { type: "mouseup", clickCount: 2, accelKey: true });
var selstr = sel.toString();
is(selstr, "Wide Web");
SimpleTest.finish();
}
function doe() {
setTimeout(test, 0);
}
addLoadEvent(doe);
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>