diff --git a/mozilla/extensions/spatialnavigation/src/nsSpatialNavigation.cpp b/mozilla/extensions/spatialnavigation/src/nsSpatialNavigation.cpp index faae6d6d01c..bcd1326d7db 100755 --- a/mozilla/extensions/spatialnavigation/src/nsSpatialNavigation.cpp +++ b/mozilla/extensions/spatialnavigation/src/nsSpatialNavigation.cpp @@ -85,47 +85,47 @@ NS_IMETHODIMP nsSpatialNavigation::KeyPress(nsIDOMEvent* aEvent) { + PRInt32 formControlType = -1; // check to see if we are in a text field. + // based on nsTypeAheadFind. + + //nsEvent should be renamed. + nsCOMPtr nsEvent = do_QueryInterface(aEvent); + if (!nsEvent) + return NS_ERROR_FAILURE; - if (!mService->mIgnoreTextFields) + nsCOMPtr domEventTarget; + nsEvent->GetOriginalTarget(getter_AddRefs(domEventTarget)); + + nsCOMPtr targetContent = do_QueryInterface(domEventTarget); + + if (targetContent->IsContentOfType(nsIContent::eHTML_FORM_CONTROL)) { - // based on nsTypeAheadFind. - - //nsEvent should be renamed. - nsCOMPtr nsEvent = do_QueryInterface(aEvent); - if (!nsEvent) - return NS_ERROR_FAILURE; - - nsCOMPtr domEventTarget; - nsEvent->GetOriginalTarget(getter_AddRefs(domEventTarget)); - - nsCOMPtr targetContent = do_QueryInterface(domEventTarget); - - if (targetContent->IsContentOfType(nsIContent::eHTML_FORM_CONTROL)) - { nsCOMPtr formControl(do_QueryInterface(targetContent)); - PRInt32 controlType = formControl->GetType(); + formControlType = formControl->GetType(); - if (controlType == NS_FORM_TEXTAREA || - controlType == NS_FORM_INPUT_TEXT || - controlType == NS_FORM_INPUT_PASSWORD || - controlType == NS_FORM_INPUT_FILE) + if (!mService->mIgnoreTextFields) { - return NS_OK; + if (formControlType == NS_FORM_TEXTAREA || + formControlType == NS_FORM_INPUT_TEXT || + formControlType == NS_FORM_INPUT_PASSWORD || + formControlType == NS_FORM_INPUT_FILE) + { + return NS_OK; + } } - } - else if (targetContent->IsContentOfType(nsIContent::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 - // not support nsIFormControl or eHTML_FORM_CONTROL, and it's not worth - // having a table of atoms just for it. - + } + else if (!mService->mIgnoreTextFields && targetContent->IsContentOfType(nsIContent::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 + // not support nsIFormControl or eHTML_FORM_CONTROL, and it's not worth + // having a table of atoms just for it. + if (isContentOfType(targetContent, "isindex")) return NS_OK; - } } - + PRUint32 keyCode; PRBool isModifier; nsCOMPtr keyEvent(do_QueryInterface(aEvent)); @@ -189,6 +189,18 @@ nsSpatialNavigation::KeyPress(nsIDOMEvent* aEvent) if (keyCode == mService->mKeyCodeUp) { + + // If we are going up or down, in a select, lets not + // navigate. + // + // FIX: What we really want to do is determine if we are + // at the start or the end fo the form element, and + // based on the selected position we decide to nav. or + // not. + + if (formControlType == NS_FORM_SELECT) + return NS_OK; + aEvent->StopPropagation(); aEvent->PreventDefault(); return Up(); @@ -196,6 +208,17 @@ nsSpatialNavigation::KeyPress(nsIDOMEvent* aEvent) if (keyCode == mService->mKeyCodeDown) { + // If we are going up or down, in a select, lets not + // navigate. + // + // FIX: What we really want to do is determine if we are + // at the start or the end fo the form element, and + // based on the selected position we decide to nav. or + // not. + + if (formControlType == NS_FORM_SELECT) + return NS_OK; + aEvent->StopPropagation(); // We're using this key, no one else should aEvent->PreventDefault(); return Down();