M1301093 part 1 for URL bar (see also M1283329)

This commit is contained in:
Cameron Kaiser 2018-01-25 18:52:29 -08:00
parent 4d24850e28
commit d1607c7743
4 changed files with 40 additions and 20 deletions

View File

@ -905,8 +905,12 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
this._value = this.inputField.value;
gBrowser.userTypedValue = this.value;
this.valueIsTyped = true;
this.gotResultForCurrentQuery = false;
this.mController.handleText();
// Only wait for a result when we are sure to get one. In some
// cases, like when pasting the same exact text, we may not fire
// a new search and we won't get a result.
if (this.mController.handleText()) {
this.gotResultForCurrentQuery = false;
}
}
this.resetActionType();
]]></body>
@ -955,7 +959,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
// a backspace on the text value instead of removing the result.
if (this.popup.selectedIndex == 0 &&
this.popup._isFirstResultHeuristic) {
return this.mController.handleText();
this.mController.handleText();
return false;
}
return this.mController.handleDelete();
]]></body>

View File

@ -180,8 +180,9 @@ nsAutoCompleteController::StartSearch(const nsAString &aSearchString)
}
NS_IMETHODIMP
nsAutoCompleteController::HandleText()
nsAutoCompleteController::HandleText(bool *_retval)
{
*_retval = false;
// Note: the events occur in the following order when IME is used.
// 1. a compositionstart event(HandleStartComposition)
// 2. some input events (HandleText), eCompositionState_Composing
@ -284,6 +285,7 @@ nsAutoCompleteController::HandleText()
return NS_OK;
}
*_retval = true;
StartSearches();
return NS_OK;
@ -610,7 +612,8 @@ nsAutoCompleteController::HandleDelete(bool *_retval)
input->GetPopupOpen(&isOpen);
if (!isOpen || mRowCount <= 0) {
// Nothing left to delete, proceed as normal
HandleText();
bool unused = false;
HandleText(&unused);
return NS_OK;
}
@ -621,7 +624,8 @@ nsAutoCompleteController::HandleDelete(bool *_retval)
popup->GetSelectedIndex(&index);
if (index == -1) {
// No row is selected in the list
HandleText();
bool unused = false;
HandleText(&unused);
return NS_OK;
}
@ -1185,7 +1189,7 @@ nsAutoCompleteController::StartSearch(uint16_t aSearchType)
nsAutoString searchParam;
nsresult rv = input->GetSearchParam(searchParam);
if (NS_FAILED(rv))
return rv;
return rv;
// FormFill expects the searchParam to only contain the input element id,
// other consumers may have other expectations, so this modifies it only

View File

@ -37,7 +37,7 @@ interface nsIAutoCompleteController : nsISupports
*/
void startSearch(in AString searchString);
/*
/*
* Stop all asynchronous searches
*/
void stopSearch();
@ -54,8 +54,10 @@ interface nsIAutoCompleteController : nsISupports
* it's not in composing mode. DOM compositionend event is not good
* timing for calling handleText(). DOM input event immediately after
* DOM compositionend event is the best timing to call this.
*
* @return whether this handler started a new search.
*/
void handleText();
boolean handleText();
/*
* Notify the controller that the user wishes to enter the current text. If
@ -63,14 +65,16 @@ interface nsIAutoCompleteController : nsISupports
* fill this value into the input field before continuing. If false, just
* use the current value of the input field.
*
* @return True if the controller wishes to prevent event propagation and default event
* @return Whether the controller wishes to prevent event propagation and
* default event.
*/
boolean handleEnter(in boolean aIsPopupSelection);
/*
* Notify the controller that the user wishes to revert autocomplete
*
* @return True if the controller wishes to prevent event propagation and default event
* @return Whether the controller wishes to prevent event propagation and
* default event.
*/
boolean handleEscape();
@ -90,7 +94,7 @@ interface nsIAutoCompleteController : nsISupports
*/
void handleEndComposition();
/*
/*
* Handle tab. Just closes up.
*/
void handleTab();
@ -99,16 +103,19 @@ interface nsIAutoCompleteController : nsISupports
* Notify the controller of the following key navigation events:
* up, down, left, right, page up, page down
*
* @return True if the controller wishes to prevent event propagation and default event
* @return Whether the controller wishes to prevent event propagation and
* default event
*/
boolean handleKeyNavigation(in unsigned long key);
/*
* Notify the controller that the user chose to delete the current
* auto-complete result.
*
* @return Whether the controller removed a result item.
*/
boolean handleDelete();
/*
* Get the value of the result at a given index in the last completed search
*/

View File

@ -821,8 +821,9 @@ nsFormFillController::HandleEvent(nsIDOMEvent* aEvent)
return KeyPress(aEvent);
}
if (type.EqualsLiteral("input")) {
bool unused = false;
return (!mSuppressOnInput && mController && mFocusedInput) ?
mController->HandleText() : NS_OK;
mController->HandleText(&unused) : NS_OK;
}
if (type.EqualsLiteral("blur")) {
if (mFocusedInput)
@ -932,6 +933,7 @@ nsFormFillController::KeyPress(nsIDOMEvent* aEvent)
return NS_ERROR_FAILURE;
bool cancel = false;
bool unused = false;
uint32_t k;
keyEvent->GetKeyCode(&k);
@ -941,7 +943,7 @@ nsFormFillController::KeyPress(nsIDOMEvent* aEvent)
mController->HandleDelete(&cancel);
break;
case nsIDOMKeyEvent::DOM_VK_BACK_SPACE:
mController->HandleText();
mController->HandleText(&unused);
break;
#else
case nsIDOMKeyEvent::DOM_VK_BACK_SPACE:
@ -949,10 +951,11 @@ nsFormFillController::KeyPress(nsIDOMEvent* aEvent)
bool isShift = false;
keyEvent->GetShiftKey(&isShift);
if (isShift)
if (isShift) {
mController->HandleDelete(&cancel);
else
mController->HandleText();
} else {
mController->HandleText(&unused);
}
break;
}
@ -1062,7 +1065,8 @@ nsFormFillController::MouseDown(nsIDOMEvent* aEvent)
if (value.Length() > 0) {
// Show the popup with a filtered result set
mController->SetSearchString(EmptyString());
mController->HandleText();
bool unused = false;
mController->HandleText(&unused);
} else {
// Show the popup with the complete result set. Can't use HandleText()
// because it doesn't display the popup if the input is blank.