diff --git a/mozilla/extensions/spatialnavigation/src/nsSpatialNavigation.cpp b/mozilla/extensions/spatialnavigation/src/nsSpatialNavigation.cpp
index ab9dd39f7ab..65c15bb5d4b 100755
--- a/mozilla/extensions/spatialnavigation/src/nsSpatialNavigation.cpp
+++ b/mozilla/extensions/spatialnavigation/src/nsSpatialNavigation.cpp
@@ -136,7 +136,7 @@ nsSpatialNavigation::KeyDown(nsIDOMEvent* aEvent)
}
}
}
- else if (!mService->mIgnoreTextFields && targetContent->IsNodeOfType(nsINode::eHTML))
+ else if (mService->mIgnoreTextFields && targetContent->IsNodeOfType(nsINode::eHTML))
{
// Test for isindex, a deprecated kind of text field. We're using a string
// compare because is not considered a form control, so it does
@@ -195,14 +195,71 @@ nsSpatialNavigation::KeyDown(nsIDOMEvent* aEvent)
if (keyCode == mService->mKeyCodeLeft)
{
+
+ // ************************************************************************************
+ // NS_FORM_TEXTAREA cases:
+
+ // ************************************************************************************
+ // NS_FORM_INPUT_TEXT | NS_FORM_INPUT_PASSWORD | NS_FORM_INPUT_FILE cases
+
+
+ if (formControlType == NS_FORM_INPUT_TEXT ||
+ formControlType == NS_FORM_INPUT_PASSWORD)
+ {
+ PRInt32 selectionStart, textLength;
+ nsCOMPtr input = do_QueryInterface(targetContent);
+ if (input) {
+ input->GetSelectionStart (&selectionStart);
+ input->GetTextLength (&textLength);
+ } else {
+ nsCOMPtr textArea = do_QueryInterface(targetContent);
+ if (textArea) {
+ textArea->GetSelectionStart (&selectionStart);
+ textArea->GetTextLength (&textLength);
+ }
+ }
+
+ if (textLength != 0 && selectionStart != 0)
+ return NS_OK;
+ }
+
// We're using this key, no one else should
aEvent->StopPropagation();
aEvent->PreventDefault();
+
return Left();
}
if (keyCode == mService->mKeyCodeRight)
{
+ // ************************************************************************************
+ // NS_FORM_TEXTAREA cases:
+
+ // ************************************************************************************
+ // NS_FORM_INPUT_TEXT | NS_FORM_INPUT_PASSWORD | NS_FORM_INPUT_FILE cases
+
+ if (formControlType == NS_FORM_INPUT_TEXT ||
+ formControlType == NS_FORM_INPUT_PASSWORD)
+ {
+ PRInt32 selectionEnd, textLength;
+ nsCOMPtr input = do_QueryInterface(targetContent);
+ if (input) {
+ input->GetSelectionEnd (&selectionEnd);
+ input->GetTextLength (&textLength);
+ } else {
+ nsCOMPtr textArea = do_QueryInterface(targetContent);
+ if (textArea) {
+ textArea->GetSelectionEnd (&selectionEnd);
+ textArea->GetTextLength (&textLength);
+ }
+ }
+
+ // going down.
+
+ if (textLength != selectionEnd)
+ return NS_OK;
+ }
+
aEvent->StopPropagation();
aEvent->PreventDefault();
return Right();
@@ -227,12 +284,6 @@ nsSpatialNavigation::KeyDown(nsIDOMEvent* aEvent)
// if (formControlType == NS_FORM_SELECT)
// return NS_OK;
- // ************************************************************************************
- // NS_FORM_TEXTAREA cases:
-
- // ************************************************************************************
- // NS_FORM_INPUT_TEXT | NS_FORM_INPUT_PASSWORD | NS_FORM_INPUT_FILE cases
-
aEvent->StopPropagation();
aEvent->PreventDefault();
return Up();
@@ -256,12 +307,6 @@ nsSpatialNavigation::KeyDown(nsIDOMEvent* aEvent)
// if (formControlType == NS_FORM_SELECT)
// return NS_OK;
- // ************************************************************************************
- // NS_FORM_TEXTAREA cases:
-
- // ************************************************************************************
- // NS_FORM_INPUT_TEXT | NS_FORM_INPUT_PASSWORD | NS_FORM_INPUT_FILE cases
-
aEvent->StopPropagation(); // We're using this key, no one else should
aEvent->PreventDefault();
return Down();
diff --git a/mozilla/extensions/spatialnavigation/src/nsSpatialNavigationPrivate.h b/mozilla/extensions/spatialnavigation/src/nsSpatialNavigationPrivate.h
index 0400ac49dd6..fd45f046902 100755
--- a/mozilla/extensions/spatialnavigation/src/nsSpatialNavigationPrivate.h
+++ b/mozilla/extensions/spatialnavigation/src/nsSpatialNavigationPrivate.h
@@ -79,6 +79,8 @@
#include "nsIDOMNSEvent.h"
#include "nsIDOMNSHTMLElement.h"
#include "nsIDOMNSUIEvent.h"
+#include "nsIDOMNSHTMLInputElement.h"
+#include "nsIDOMNSHTMLTextAreaElement.h"
#include "nsIDOMNode.h"
#include "nsIDOMWindow.h"
#include "nsIDOMWindowInternal.h"