bug 270697 make autocomplete behave more like IE r=caillon,r=mconnor

This commit is contained in:
dveditz%cruzio.com 2005-02-18 12:40:00 +00:00
Родитель 21df2d05ac
Коммит 70d866f460
8 изменённых файлов: 47 добавлений и 12 удалений

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

@ -206,6 +206,7 @@
type="autocomplete"
autocompletesearch="history"
autocompletepopup="PopupAutoComplete"
completeselectedindex="true"
tabscrolling="true"
showcommentcolumn="true"
enablehistory="true"

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

@ -67,6 +67,7 @@
<hbox align="center">
<textbox id="dialog.input" flex="1" type="autocomplete"
completeselectedindex="true"
autocompletesearch="history"
enablehistory="true"
oninput="doEnabling();"/>

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

@ -57,6 +57,7 @@
autocompletepopup="PopupAutoComplete"
autocompletesearch="form-history"
autocompletesearchparam="searchbar-history"
completeselectedindex="true"
tabscrolling="true"
onfocus="URLBarFocusHandler(event, this);"
onmousedown="URLBarMouseDownHandler(event, this);"

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

@ -40,7 +40,7 @@
interface nsIAutoCompletePopup;
[scriptable, uuid(3B6E2742-B136-4588-A6DF-699B9585AF60)]
[scriptable, uuid(e312267f-8f57-43e8-a904-ff9b5d3f5aef)]
interface nsIAutoCompleteInput : nsISupports
{
/*
@ -70,6 +70,12 @@ interface nsIAutoCompleteInput : nsISupports
*/
attribute boolean completeDefaultIndex;
/*
* complete text in the textbox as the user selects from the dropdown
* options if set to true
*/
attribute boolean completeSelectedIndex;
/*
* Option for completing to the default result whenever the user hits
* enter or the textbox loses focus

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

@ -304,17 +304,23 @@ nsAutoCompleteController::HandleKeyNavigation(PRUint16 aKey, PRBool *_retval)
popup->SelectBy(reverse, page);
// Fill in the value of the textbox with whatever is selected in the popup
PRInt32 selectedIndex;
popup->GetSelectedIndex(&selectedIndex);
if (selectedIndex >= 0) {
// A result is selected, so fill in its value
nsAutoString value;
if (NS_SUCCEEDED(GetResultValueAt(selectedIndex, PR_TRUE, value)))
CompleteValue(value, PR_FALSE);
} else {
// Nothing is selected, so fill in the last typed value
mInput->SetTextValue(mSearchString);
mInput->SelectTextRange(mSearchString.Length(), mSearchString.Length());
// if the completeSelectedIndex attribute is set
PRBool completeSelection;
mInput->GetCompleteSelectedIndex(&completeSelection);
if (completeSelection)
{
PRInt32 selectedIndex;
popup->GetSelectedIndex(&selectedIndex);
if (selectedIndex >= 0) {
// A result is selected, so fill in its value
nsAutoString value;
if (NS_SUCCEEDED(GetResultValueAt(selectedIndex, PR_TRUE, value)))
CompleteValue(value, PR_FALSE);
} else {
// Nothing is selected, so fill in the last typed value
mInput->SetTextValue(mSearchString);
mInput->SelectTextRange(mSearchString.Length(), mSearchString.Length());
}
}
} else {
// Open the popup if there has been a previous search, or else kick off a new search

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

@ -92,6 +92,7 @@ nsFormFillController::nsFormFillController() :
mMaxRows(0),
mDisableAutoComplete(PR_FALSE),
mCompleteDefaultIndex(PR_FALSE),
mCompleteSelectedIndex(PR_FALSE),
mForceComplete(PR_FALSE),
mSuppressOnInput(PR_FALSE)
{
@ -270,6 +271,20 @@ nsFormFillController::SetCompleteDefaultIndex(PRBool aCompleteDefaultIndex)
return NS_OK;
}
NS_IMETHODIMP
nsFormFillController::GetCompleteSelectedIndex(PRBool *aCompleteSelectedIndex)
{
*aCompleteSelectedIndex = mCompleteSelectedIndex;
return NS_OK;
}
NS_IMETHODIMP
nsFormFillController::SetCompleteSelectedIndex(PRBool aCompleteSelectedIndex)
{
mCompleteSelectedIndex = aCompleteSelectedIndex;
return NS_OK;
}
NS_IMETHODIMP
nsFormFillController::GetForceComplete(PRBool *aForceComplete)
{

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

@ -137,6 +137,7 @@ protected:
PRUint32 mMaxRows;
PRPackedBool mDisableAutoComplete;
PRPackedBool mCompleteDefaultIndex;
PRPackedBool mCompleteSelectedIndex;
PRPackedBool mForceComplete;
PRPackedBool mSuppressOnInput;
PRPackedBool mIgnoreClick;

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

@ -137,6 +137,10 @@
onset="this.setAttribute('completedefaultindex', val); return val;"
onget="return this.getAttribute('completedefaultindex') == 'true';"/>
<property name="completeSelectedIndex"
onset="this.setAttribute('completeselectedindex', val); return val;"
onget="return this.getAttribute('completeselectedindex') == 'true';"/>
<property name="forceComplete"
onset="this.setAttribute('forcecomplete', val); return val;"
onget="return this.getAttribute('forcecomplete') == 'true';"/>