зеркало из https://github.com/mozilla/pjs.git
bug 270697 make autocomplete behave more like IE r=caillon,r=mconnor
This commit is contained in:
Родитель
21df2d05ac
Коммит
70d866f460
|
@ -206,6 +206,7 @@
|
||||||
type="autocomplete"
|
type="autocomplete"
|
||||||
autocompletesearch="history"
|
autocompletesearch="history"
|
||||||
autocompletepopup="PopupAutoComplete"
|
autocompletepopup="PopupAutoComplete"
|
||||||
|
completeselectedindex="true"
|
||||||
tabscrolling="true"
|
tabscrolling="true"
|
||||||
showcommentcolumn="true"
|
showcommentcolumn="true"
|
||||||
enablehistory="true"
|
enablehistory="true"
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
|
|
||||||
<hbox align="center">
|
<hbox align="center">
|
||||||
<textbox id="dialog.input" flex="1" type="autocomplete"
|
<textbox id="dialog.input" flex="1" type="autocomplete"
|
||||||
|
completeselectedindex="true"
|
||||||
autocompletesearch="history"
|
autocompletesearch="history"
|
||||||
enablehistory="true"
|
enablehistory="true"
|
||||||
oninput="doEnabling();"/>
|
oninput="doEnabling();"/>
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
autocompletepopup="PopupAutoComplete"
|
autocompletepopup="PopupAutoComplete"
|
||||||
autocompletesearch="form-history"
|
autocompletesearch="form-history"
|
||||||
autocompletesearchparam="searchbar-history"
|
autocompletesearchparam="searchbar-history"
|
||||||
|
completeselectedindex="true"
|
||||||
tabscrolling="true"
|
tabscrolling="true"
|
||||||
onfocus="URLBarFocusHandler(event, this);"
|
onfocus="URLBarFocusHandler(event, this);"
|
||||||
onmousedown="URLBarMouseDownHandler(event, this);"
|
onmousedown="URLBarMouseDownHandler(event, this);"
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
interface nsIAutoCompletePopup;
|
interface nsIAutoCompletePopup;
|
||||||
|
|
||||||
[scriptable, uuid(3B6E2742-B136-4588-A6DF-699B9585AF60)]
|
[scriptable, uuid(e312267f-8f57-43e8-a904-ff9b5d3f5aef)]
|
||||||
interface nsIAutoCompleteInput : nsISupports
|
interface nsIAutoCompleteInput : nsISupports
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -70,6 +70,12 @@ interface nsIAutoCompleteInput : nsISupports
|
||||||
*/
|
*/
|
||||||
attribute boolean completeDefaultIndex;
|
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
|
* Option for completing to the default result whenever the user hits
|
||||||
* enter or the textbox loses focus
|
* enter or the textbox loses focus
|
||||||
|
|
|
@ -304,17 +304,23 @@ nsAutoCompleteController::HandleKeyNavigation(PRUint16 aKey, PRBool *_retval)
|
||||||
popup->SelectBy(reverse, page);
|
popup->SelectBy(reverse, page);
|
||||||
|
|
||||||
// Fill in the value of the textbox with whatever is selected in the popup
|
// Fill in the value of the textbox with whatever is selected in the popup
|
||||||
PRInt32 selectedIndex;
|
// if the completeSelectedIndex attribute is set
|
||||||
popup->GetSelectedIndex(&selectedIndex);
|
PRBool completeSelection;
|
||||||
if (selectedIndex >= 0) {
|
mInput->GetCompleteSelectedIndex(&completeSelection);
|
||||||
// A result is selected, so fill in its value
|
if (completeSelection)
|
||||||
nsAutoString value;
|
{
|
||||||
if (NS_SUCCEEDED(GetResultValueAt(selectedIndex, PR_TRUE, value)))
|
PRInt32 selectedIndex;
|
||||||
CompleteValue(value, PR_FALSE);
|
popup->GetSelectedIndex(&selectedIndex);
|
||||||
} else {
|
if (selectedIndex >= 0) {
|
||||||
// Nothing is selected, so fill in the last typed value
|
// A result is selected, so fill in its value
|
||||||
mInput->SetTextValue(mSearchString);
|
nsAutoString value;
|
||||||
mInput->SelectTextRange(mSearchString.Length(), mSearchString.Length());
|
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 {
|
} else {
|
||||||
// Open the popup if there has been a previous search, or else kick off a new search
|
// 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),
|
mMaxRows(0),
|
||||||
mDisableAutoComplete(PR_FALSE),
|
mDisableAutoComplete(PR_FALSE),
|
||||||
mCompleteDefaultIndex(PR_FALSE),
|
mCompleteDefaultIndex(PR_FALSE),
|
||||||
|
mCompleteSelectedIndex(PR_FALSE),
|
||||||
mForceComplete(PR_FALSE),
|
mForceComplete(PR_FALSE),
|
||||||
mSuppressOnInput(PR_FALSE)
|
mSuppressOnInput(PR_FALSE)
|
||||||
{
|
{
|
||||||
|
@ -270,6 +271,20 @@ nsFormFillController::SetCompleteDefaultIndex(PRBool aCompleteDefaultIndex)
|
||||||
return NS_OK;
|
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
|
NS_IMETHODIMP
|
||||||
nsFormFillController::GetForceComplete(PRBool *aForceComplete)
|
nsFormFillController::GetForceComplete(PRBool *aForceComplete)
|
||||||
{
|
{
|
||||||
|
|
|
@ -137,6 +137,7 @@ protected:
|
||||||
PRUint32 mMaxRows;
|
PRUint32 mMaxRows;
|
||||||
PRPackedBool mDisableAutoComplete;
|
PRPackedBool mDisableAutoComplete;
|
||||||
PRPackedBool mCompleteDefaultIndex;
|
PRPackedBool mCompleteDefaultIndex;
|
||||||
|
PRPackedBool mCompleteSelectedIndex;
|
||||||
PRPackedBool mForceComplete;
|
PRPackedBool mForceComplete;
|
||||||
PRPackedBool mSuppressOnInput;
|
PRPackedBool mSuppressOnInput;
|
||||||
PRPackedBool mIgnoreClick;
|
PRPackedBool mIgnoreClick;
|
||||||
|
|
|
@ -137,6 +137,10 @@
|
||||||
onset="this.setAttribute('completedefaultindex', val); return val;"
|
onset="this.setAttribute('completedefaultindex', val); return val;"
|
||||||
onget="return this.getAttribute('completedefaultindex') == 'true';"/>
|
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"
|
<property name="forceComplete"
|
||||||
onset="this.setAttribute('forcecomplete', val); return val;"
|
onset="this.setAttribute('forcecomplete', val); return val;"
|
||||||
onget="return this.getAttribute('forcecomplete') == 'true';"/>
|
onget="return this.getAttribute('forcecomplete') == 'true';"/>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче