Bug 359552 - Remove keycode constants from nsIAutoCompleteController. r=gavin.

This commit is contained in:
mozilla.mano%sent.com 2006-12-07 12:59:02 +00:00
Родитель deaf9bba4f
Коммит ae03ce4f53
4 изменённых файлов: 22 добавлений и 54 удалений

Просмотреть файл

@ -41,7 +41,7 @@
interface nsIAutoCompleteInput;
[scriptable, uuid(8E62F092-DD82-4748-BAB3-8898C7C881A1)]
[scriptable, uuid(bafcfe4f-0850-4106-a176-be5aef2e1e52)]
interface nsIAutoCompleteController : nsISupports
{
/*
@ -51,18 +51,6 @@ interface nsIAutoCompleteController : nsISupports
const unsigned short STATUS_SEARCHING = 2;
const unsigned short STATUS_COMPLETE_NO_MATCH = 3;
const unsigned short STATUS_COMPLETE_MATCH = 4;
/*
* Possible key navigation values
*/
const unsigned short KEY_UP = 1;
const unsigned short KEY_DOWN = 2;
const unsigned short KEY_LEFT = 3;
const unsigned short KEY_RIGHT = 4;
const unsigned short KEY_PAGE_UP = 5;
const unsigned short KEY_PAGE_DOWN = 6;
const unsigned short KEY_HOME = 7;
const unsigned short KEY_END = 8;
/*
* The input widget that is currently being controlled.
@ -126,7 +114,7 @@ interface nsIAutoCompleteController : nsISupports
*
* @return True if the controller wishes to prevent event propagation and default event
*/
boolean handleKeyNavigation(in unsigned short key);
boolean handleKeyNavigation(in unsigned long key);
/*
* Notify the controller that the user chose to delete the current

Просмотреть файл

@ -61,6 +61,7 @@
#include "nsITreeColumns.h"
#include "nsIGenericFactory.h"
#include "nsIObserverService.h"
#include "nsIDOMKeyEvent.h"
static const char *kAutoCompleteSearchCID = "@mozilla.org/autocomplete/search;1?name=";
@ -362,7 +363,7 @@ nsAutoCompleteController::HandleEndComposition()
HandleText(PR_TRUE);
} else if (forceOpenPopup) {
PRBool cancel;
HandleKeyNavigation(nsIAutoCompleteController::KEY_DOWN, &cancel);
HandleKeyNavigation(nsIDOMKeyEvent::DOM_VK_DOWN, &cancel);
}
// On here, |value| and |mSearchString| are same. Therefore, next HandleText should be
// ignored. Because there are no reason to research.
@ -379,7 +380,7 @@ nsAutoCompleteController::HandleTab()
}
NS_IMETHODIMP
nsAutoCompleteController::HandleKeyNavigation(PRUint16 aKey, PRBool *_retval)
nsAutoCompleteController::HandleKeyNavigation(PRUint32 aKey, PRBool *_retval)
{
// By default, don't cancel the event
*_retval = PR_FALSE;
@ -400,10 +401,10 @@ nsAutoCompleteController::HandleKeyNavigation(PRUint16 aKey, PRBool *_retval)
mInput->GetDisableAutoComplete(&disabled);
NS_ENSURE_TRUE(!disabled, NS_OK);
if (aKey == nsIAutoCompleteController::KEY_UP ||
aKey == nsIAutoCompleteController::KEY_DOWN ||
aKey == nsIAutoCompleteController::KEY_PAGE_UP ||
aKey == nsIAutoCompleteController::KEY_PAGE_DOWN)
if (aKey == nsIDOMKeyEvent::DOM_VK_UP ||
aKey == nsIDOMKeyEvent::DOM_VK_DOWN ||
aKey == nsIDOMKeyEvent::DOM_VK_PAGE_UP ||
aKey == nsIDOMKeyEvent::DOM_VK_PAGE_DOWN)
{
// Prevent the input from handling up/down events, as it may move
// the cursor to home/end on some systems
@ -412,10 +413,10 @@ nsAutoCompleteController::HandleKeyNavigation(PRUint16 aKey, PRBool *_retval)
PRBool isOpen;
mInput->GetPopupOpen(&isOpen);
if (isOpen) {
PRBool reverse = aKey == nsIAutoCompleteController::KEY_UP ||
aKey == nsIAutoCompleteController::KEY_PAGE_UP ? PR_TRUE : PR_FALSE;
PRBool page = aKey == nsIAutoCompleteController::KEY_PAGE_UP ||
aKey == nsIAutoCompleteController::KEY_PAGE_DOWN ? PR_TRUE : PR_FALSE;
PRBool reverse = aKey == nsIDOMKeyEvent::DOM_VK_UP ||
aKey == nsIDOMKeyEvent::DOM_VK_PAGE_UP ? PR_TRUE : PR_FALSE;
PRBool page = aKey == nsIDOMKeyEvent::DOM_VK_PAGE_UP ||
aKey == nsIDOMKeyEvent::DOM_VK_PAGE_DOWN ? PR_TRUE : PR_FALSE;
// Fill in the value of the textbox with whatever is selected in the popup
// if the completeSelectedIndex attribute is set. We check this before
@ -454,10 +455,10 @@ nsAutoCompleteController::HandleKeyNavigation(PRUint16 aKey, PRBool *_retval)
} else
StartSearchTimer();
}
} else if ( aKey == nsIAutoCompleteController::KEY_LEFT
|| aKey == nsIAutoCompleteController::KEY_RIGHT
} else if ( aKey == nsIDOMKeyEvent::DOM_VK_LEFT
|| aKey == nsIDOMKeyEvent::DOM_VK_RIGHT
#ifndef XP_MACOSX
|| aKey == nsIAutoCompleteController::KEY_HOME
|| aKey == nsIDOMKeyEvent::DOM_VK_HOME
#endif
)
{

Просмотреть файл

@ -641,22 +641,12 @@ nsFormFillController::KeyPress(nsIDOMEvent* aEvent)
}
#endif
case nsIDOMKeyEvent::DOM_VK_UP:
mController->HandleKeyNavigation(nsIAutoCompleteController::KEY_UP, &cancel);
break;
case nsIDOMKeyEvent::DOM_VK_DOWN:
mController->HandleKeyNavigation(nsIAutoCompleteController::KEY_DOWN, &cancel);
break;
case nsIDOMKeyEvent::DOM_VK_LEFT:
mController->HandleKeyNavigation(nsIAutoCompleteController::KEY_LEFT, &cancel);
break;
case nsIDOMKeyEvent::DOM_VK_RIGHT:
mController->HandleKeyNavigation(nsIAutoCompleteController::KEY_RIGHT, &cancel);
break;
case nsIDOMKeyEvent::DOM_VK_PAGE_UP:
mController->HandleKeyNavigation(nsIAutoCompleteController::KEY_PAGE_UP, &cancel);
break;
case nsIDOMKeyEvent::DOM_VK_PAGE_DOWN:
mController->HandleKeyNavigation(nsIAutoCompleteController::KEY_PAGE_DOWN, &cancel);
mController->HandleKeyNavigation(k, &cancel);
break;
case nsIDOMKeyEvent::DOM_VK_ESCAPE:
mController->HandleEscape(&cancel);
@ -828,7 +818,7 @@ nsFormFillController::MouseClick(nsIDOMEvent* aMouseEvent)
// Show the popup with the complete result set. Can't use HandleText()
// because it doesn't display the popup if the input is blank.
PRBool cancel = PR_FALSE;
mController->HandleKeyNavigation(nsIAutoCompleteController::KEY_DOWN, &cancel);
mController->HandleKeyNavigation(nsIDOMKeyEvent::DOM_VK_DOWN, &cancel);
}
return NS_OK;

Просмотреть файл

@ -393,7 +393,6 @@
return false;
var cancel = false;
const IController = Components.interfaces.nsIAutoCompleteController;
// Catch any keys that could potentially move the caret. Ctrl can be
// used in combination with these keys, so only make sure that Alt
@ -401,13 +400,9 @@
if (!this.disableKeyNavigation && !aEvent.altKey) {
switch (aEvent.keyCode) {
case KeyEvent.DOM_VK_LEFT:
cancel = this.mController.handleKeyNavigation(IController.KEY_LEFT);
break;
case KeyEvent.DOM_VK_RIGHT:
cancel = this.mController.handleKeyNavigation(IController.KEY_RIGHT);
break;
case KeyEvent.DOM_VK_HOME:
cancel = this.mController.handleKeyNavigation(IController.KEY_HOME);
cancel = this.mController.handleKeyNavigation(aEvent.keyCode);
break;
}
}
@ -418,20 +413,14 @@
case KeyEvent.DOM_VK_TAB:
if (this.tabScrolling && this.popup.mPopupOpen)
cancel = this.mController.handleKeyNavigation(aEvent.shiftKey ?
IController.KEY_UP :
IController.KEY_DOWN);
KeyEvent.DOM_VK_UP :
KeyEvent.DOM_VK_DOWN);
break;
case KeyEvent.DOM_VK_UP:
cancel = this.mController.handleKeyNavigation(IController.KEY_UP);
break;
case KeyEvent.DOM_VK_DOWN:
cancel = this.mController.handleKeyNavigation(IController.KEY_DOWN);
break;
case KeyEvent.DOM_VK_PAGE_UP:
cancel = this.mController.handleKeyNavigation(IController.KEY_PAGE_UP);
break;
case KeyEvent.DOM_VK_PAGE_DOWN:
cancel = this.mController.handleKeyNavigation(IController.KEY_PAGE_DOWN);
cancel = this.mController.handleKeyNavigation(aEvent.keyCode);
break;
}
}