Addresses 305712. There is more worked needed to make this solid with respect to form elements. However, this patch makes it so that you can navigate select elements with the normal up/down arrow keys, and you can use the left/right+modifier to use snav NPODB
git-svn-id: svn://10.0.0.236/trunk@179493 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -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<nsIDOMNSEvent> nsEvent = do_QueryInterface(aEvent);
|
||||
if (!nsEvent)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (!mService->mIgnoreTextFields)
|
||||
nsCOMPtr<nsIDOMEventTarget> domEventTarget;
|
||||
nsEvent->GetOriginalTarget(getter_AddRefs(domEventTarget));
|
||||
|
||||
nsCOMPtr<nsIContent> targetContent = do_QueryInterface(domEventTarget);
|
||||
|
||||
if (targetContent->IsContentOfType(nsIContent::eHTML_FORM_CONTROL))
|
||||
{
|
||||
// based on nsTypeAheadFind.
|
||||
|
||||
//nsEvent should be renamed.
|
||||
nsCOMPtr<nsIDOMNSEvent> nsEvent = do_QueryInterface(aEvent);
|
||||
if (!nsEvent)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMEventTarget> domEventTarget;
|
||||
nsEvent->GetOriginalTarget(getter_AddRefs(domEventTarget));
|
||||
|
||||
nsCOMPtr<nsIContent> targetContent = do_QueryInterface(domEventTarget);
|
||||
|
||||
if (targetContent->IsContentOfType(nsIContent::eHTML_FORM_CONTROL))
|
||||
{
|
||||
nsCOMPtr<nsIFormControl> 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 <isindex> 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 <isindex> 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<nsIDOMKeyEvent> 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();
|
||||
|
||||
Reference in New Issue
Block a user