From a90a5cba08fdf6c0ceb95101c275108a152a3aed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:37 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../autocomplete/nsAutoCompleteController.cpp | 16 +++++++------ .../autocomplete/nsIAutoCompletePopup.idl | 27 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 7 deletions(-) (limited to 'toolkit/components/autocomplete') diff --git a/toolkit/components/autocomplete/nsAutoCompleteController.cpp b/toolkit/components/autocomplete/nsAutoCompleteController.cpp index 126199e3cf..c8278f55a7 100644 --- a/toolkit/components/autocomplete/nsAutoCompleteController.cpp +++ b/toolkit/components/autocomplete/nsAutoCompleteController.cpp @@ -490,6 +490,13 @@ nsAutoCompleteController::HandleKeyNavigation(uint32_t aKey, bool* _retval) { } } + // Some script may have changed the value of the text field since our + // last keypress or after our focus handler and we don't want to + // search for a stale string. + nsAutoString value; + input->GetTextValue(value); + SetSearchStringInternal(value); + // Open the popup if there has been a previous non-errored search, or // else kick off a new search bool hadPreviousSearch = false; @@ -522,13 +529,6 @@ nsAutoCompleteController::HandleKeyNavigation(uint32_t aKey, bool* _retval) { return NS_OK; } - // Some script may have changed the value of the text field since our - // last keypress or after our focus handler and we don't want to - // search for a stale string. - nsAutoString value; - input->GetTextValue(value); - SetSearchStringInternal(value); - StartSearches(); } @@ -1235,6 +1235,8 @@ nsresult nsAutoCompleteController::EnterMatch(bool aIsPopupSelection, SetSearchStringInternal(value); } + popup->SelectEntry(); + obsSvc->NotifyObservers(input, "autocomplete-did-enter-text", nullptr); input->OnTextEntered(aEvent); diff --git a/toolkit/components/autocomplete/nsIAutoCompletePopup.idl b/toolkit/components/autocomplete/nsIAutoCompletePopup.idl index 607863c9a7..556c0d49b8 100644 --- a/toolkit/components/autocomplete/nsIAutoCompletePopup.idl +++ b/toolkit/components/autocomplete/nsIAutoCompletePopup.idl @@ -5,6 +5,7 @@ #include "nsISupports.idl" interface nsIAutoCompleteInput; +interface nsIFormFillCompleteObserver; webidl Element; @@ -32,6 +33,11 @@ interface nsIAutoCompletePopup : nsISupports */ readonly attribute boolean popupOpen; + /* + * Don't rollup the popup when the search string becomes "". + */ + boolean getNoRollupOnEmptySearch(in Element element); + /* * Bind the popup to an input object and display it with the given coordinates * @@ -69,4 +75,25 @@ interface nsIAutoCompletePopup : nsISupports * @return The currently selected result item index */ void selectBy(in boolean reverse, in boolean page); + + /* + * Search for a given string and notify a listener (either synchronously + * or asynchronously) of the result + * + * @param searchString - The string to search for + * @param searchParam - An extra parameter + * @param previousResult - A previous result to use for faster searching + * @param listener - A listener to notify when the search is complete + */ + void startSearch(in AString searchString, in Element element, in nsIFormFillCompleteObserver listener); + + /* + * Stop the search that is in progress + */ + void stopSearch(); + + /** + * Notify the autocomplete popup that an autocomplete entry is selected. + */ + void selectEntry(); }; -- cgit v1.2.3