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
This commit is contained in:
Ehsan Akhgari 2010-07-16 17:34:36 -04:00
Родитель da0113546a
Коммит 262d16a6c3
3 изменённых файлов: 54 добавлений и 0 удалений

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

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

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

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

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

@ -0,0 +1,46 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=240933
-->
<head>
<title>Test for Bug 240933</title>
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/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=240933">
Mozilla Bug 240933
</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 240933 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var t = document.getElementById("t");
synthesizeMouse(t, t.clientWidth / 2, 5, {}, window);
is(t.selectionStart, 3, "The selection should be set before the newline");
is(t.selectionEnd, 3, "The selection should be set before the newline");
SimpleTest.finish();
});
</script>
</pre>
<textarea id="t" rows="10" cols="10">abc
</textarea>
</body>
</html>