зеркало из https://github.com/mozilla/gecko-dev.git
Bug 612271 - Cursor jumps back to the end of the previous line after pressing enter at the end of a textarea managed by the jQuery autoResize plugin; r=roc a=blocking-betaN+
This commit is contained in:
Родитель
6eefbe8ef2
Коммит
36cdf253ea
|
@ -122,6 +122,10 @@ _TEST_FILES = \
|
|||
bug602141-3-ref.html \
|
||||
bug602141-4.html \
|
||||
bug602141-4-ref.html \
|
||||
bug612271-1.html \
|
||||
bug612271-2.html \
|
||||
bug612271-3.html \
|
||||
bug612271-ref.html \
|
||||
bug613433-1.html \
|
||||
bug613433-2.html \
|
||||
bug613433-3.html \
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE HTML><html><head>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<textarea id="target" style="height: 100px"
|
||||
onkeydown="this.style.display='block';this.style.height='200px';">foo</textarea>
|
||||
<script>
|
||||
var t = document.querySelector("textarea");
|
||||
t.focus();
|
||||
sendKey('ENTER', "target");
|
||||
document.body.appendChild(document.createTextNode(t.selectionStart + " - " + t.selectionEnd));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE HTML><html><head>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<textarea id="target" style="height: 100px"
|
||||
onkeypress="this.style.display='block';this.style.height='200px';">foo</textarea>
|
||||
<script>
|
||||
var t = document.querySelector("textarea");
|
||||
t.focus();
|
||||
sendKey('ENTER', "target");
|
||||
document.body.appendChild(document.createTextNode(t.selectionStart + " - " + t.selectionEnd));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE HTML><html><head>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<textarea id="target" style="height: 100px"
|
||||
onkeyup="this.style.display='block';this.style.height='200px';">foo</textarea>
|
||||
<script>
|
||||
var t = document.querySelector("textarea");
|
||||
t.focus();
|
||||
sendKey('ENTER', "target");
|
||||
document.body.appendChild(document.createTextNode(t.selectionStart + " - " + t.selectionEnd));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE HTML><html><head>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<textarea autofocus style="height: 200px; display: block;"
|
||||
>foo
|
||||
</textarea>
|
||||
4 - 4
|
||||
</body>
|
||||
</html>
|
|
@ -102,6 +102,9 @@ var tests = [
|
|||
[ 'bug602141-2.html' , 'bug602141-2-ref.html' ] ,
|
||||
[ 'bug602141-3.html' , 'bug602141-3-ref.html' ] ,
|
||||
[ 'bug602141-4.html' , 'bug602141-4-ref.html' ] ,
|
||||
[ 'bug612271-1.html' , 'bug612271-ref.html' ] ,
|
||||
[ 'bug612271-2.html' , 'bug612271-ref.html' ] ,
|
||||
[ 'bug612271-3.html' , 'bug612271-ref.html' ] ,
|
||||
[ 'bug613433-1.html' , 'bug613433-ref.html' ] ,
|
||||
[ 'bug613433-2.html' , 'bug613433-ref.html' ] ,
|
||||
[ 'bug613433-3.html' , 'bug613433-ref.html' ] ,
|
||||
|
|
|
@ -1092,8 +1092,18 @@ nsTextControlFrame::OffsetToDOMPoint(PRInt32 aOffset,
|
|||
NS_IF_ADDREF(*aResult = rootNode);
|
||||
*aPosition = 0;
|
||||
} else if (textNode) {
|
||||
NS_IF_ADDREF(*aResult = firstNode);
|
||||
*aPosition = aOffset;
|
||||
PRUint32 textLength = 0;
|
||||
textNode->GetLength(&textLength);
|
||||
if (length == 2 && PRUint32(aOffset) == textLength) {
|
||||
// If we're at the end of the text node and we have a trailing BR node,
|
||||
// set the selection on the BR node.
|
||||
NS_IF_ADDREF(*aResult = rootNode);
|
||||
*aPosition = 1;
|
||||
} else {
|
||||
// Otherwise, set the selection on the textnode itself.
|
||||
NS_IF_ADDREF(*aResult = firstNode);
|
||||
*aPosition = aOffset;
|
||||
}
|
||||
} else {
|
||||
NS_IF_ADDREF(*aResult = rootNode);
|
||||
*aPosition = 0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче