Back out 4f0f7fe10716

This commit is contained in:
Antonio Gomes 2009-01-22 12:33:03 -04:00
commit 0a51ec4120
3 changed files with 22 additions and 43 deletions

View File

@ -126,52 +126,26 @@ function _onInputKeyPress (event, callback) {
return;
}
// if it is a single-line input fields ...
if (target instanceof Ci.nsIDOMHTMLInputElement &&
(target.type == "text" || target.type == "password")) {
// up/down should not care and just move.
if (key != PrefObserver['keyCodeUp'] &&
key != PrefObserver['keyCodeDown']) {
// if there is any selection at all, just ignore
if (target.selectionEnd - target.selectionStart > 0)
return;
// if there is no text, there is nothing special to do.
if (target.textLength > 0)
if (key == PrefObserver['keyCodeLeft']) {
// if there is text, there it isn't okay to move
if (target.selectionStart != 0)
return;
}
else if (key == PrefObserver['keyCodeRight']) {
// we are moving forward into the document
if (target.textLength != target.selectionEnd)
return;
}
}
}
// if it is a multi-line input field ...
else if (target instanceof Ci.nsIDOMHTMLTextAreaElement) {
// if there is any selection at all, again just ignore
if ((target instanceof Ci.nsIDOMHTMLInputElement && (target.type == "text" || target.type == "password")) ||
target instanceof Ci.nsIDOMHTMLTextAreaElement ) {
// if there is any selection at all, just ignore
if (target.selectionEnd - target.selectionStart > 0)
return;
// if there is no text, there is nothing special to do.
if (target.textLength > 0) {
if (key == PrefObserver['keyCodeUp'] ||
key == PrefObserver['keyCodeLeft']) {
// if there is text, there it isn't okay to move
if (target.selectionStart != 0)
if (key == PrefObserver['keyCodeRight'] ||
key == PrefObserver['keyCodeDown'] ) {
// we are moving forward into the document
if (target.textLength != target.selectionEnd)
return;
}
else {
if (key == PrefObserver['keyCodeDown'] ||
key == PrefObserver['keyCodeRight'])
if (target.selectionEnd != target.textLength)
return;
else
{
// we are at the start of the text, okay to move
if (target.selectionStart != 0)
return;
}
}
}

View File

@ -50,10 +50,11 @@ MOCHI_TESTS = chrome/test_snav.xul \
chrome/test_snav_selects.xul \
chrome/test_snav_prefDisabled.xul \
chrome/test_snav_prefKeyCode.xul \
chrome/test_snav_textFields.xul \
chrome/SpatialNavUtils.js \
$(NULL)
# bug 447671 chrome/test_snav_textFields.xul \
include $(topsrcdir)/config/rules.mk
libs:: $(MOCHI_TESTS) $(MOCHI_CONTENT)

View File

@ -6,7 +6,7 @@
https://bugzilla.mozilla.org/show_bug.cgi?id=436084
-->
<window title="Mozilla Bug 436084"
<window title="Mozilla Bug 288254"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="onLoad();">
@ -36,21 +36,25 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=436084
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
Components.utils.import("resource://gre/modules/SpatialNavigation.js");
var moveTable = [
["DOWN", "textinput"],
["DOWN", "textinput"],
["DOWN", "textarea"],
["DOWN", "textarea"],
["DOWN", "end"],
["UP", "textarea"],
["UP", "textarea"],
["UP", "textinput"],
["UP", "textinput"],
["UP", "start"],
["DOWN", "textinput"],
["HOME", "textinput"],
["LEFT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
@ -79,7 +83,7 @@ var moveTable = [
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textarea"],
["HOME", "textarea"],
["LEFT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],