mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 418712 - nsIAutoCompleteInput should fire an event when a search begins. r=gavin, a1.9=beltzner
This commit is contained in:
parent
2130a28164
commit
7c4d95852e
@ -40,7 +40,7 @@
|
||||
|
||||
interface nsIAutoCompletePopup;
|
||||
|
||||
[scriptable, uuid(8a5918dc-89ba-4bd0-934c-90e9c21568b8)]
|
||||
[scriptable, uuid(f5eddd39-f8e0-43b7-bc3d-03623f595e52)]
|
||||
interface nsIAutoCompleteInput : nsISupports
|
||||
{
|
||||
/*
|
||||
@ -144,6 +144,11 @@ interface nsIAutoCompleteInput : nsISupports
|
||||
*/
|
||||
void selectTextRange(in long startIndex, in long endIndex);
|
||||
|
||||
/*
|
||||
* Notification that the search has started
|
||||
*/
|
||||
void onSearchBegin();
|
||||
|
||||
/*
|
||||
* Notification that the search concluded successfully
|
||||
*/
|
||||
|
@ -978,6 +978,9 @@ nsAutoCompleteController::StartSearch()
|
||||
mSearchesOngoing = count;
|
||||
mFirstSearchResult = PR_TRUE;
|
||||
|
||||
// notify the input that the search is beginning
|
||||
mInput->OnSearchBegin();
|
||||
|
||||
PRUint32 searchesFailed = 0;
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsCOMPtr<nsIAutoCompleteSearch> search;
|
||||
|
@ -76,6 +76,7 @@ AutoCompleteInput.prototype = {
|
||||
return this.searches[aIndex];
|
||||
},
|
||||
|
||||
onSearchBegin: function() {},
|
||||
onSearchComplete: function() {},
|
||||
|
||||
popupOpen: false,
|
||||
@ -274,8 +275,17 @@ function run_test() {
|
||||
// Make an AutoCompleteInput that uses our searches
|
||||
// and confirms results on search complete
|
||||
var input = new AutoCompleteInput([emptySearch.name, regularSearch.name]);
|
||||
var numSearchesStarted = 0;
|
||||
|
||||
input.onSearchBegin = function() {
|
||||
numSearchesStarted++;
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
};
|
||||
|
||||
input.onSearchComplete = function() {
|
||||
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
|
||||
do_check_eq(controller.searchStatus,
|
||||
Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH);
|
||||
do_check_eq(controller.matchCount, 2);
|
||||
|
@ -75,6 +75,7 @@ AutoCompleteInput.prototype = {
|
||||
return this.searches[aIndex];
|
||||
},
|
||||
|
||||
onSearchBegin: function() {},
|
||||
onSearchComplete: function() {},
|
||||
|
||||
popupOpen: false,
|
||||
@ -266,8 +267,17 @@ function run_test() {
|
||||
// Make an AutoCompleteInput that uses our search
|
||||
// and confirms results on search complete
|
||||
var input = new AutoCompleteInput([emptySearch.name]);
|
||||
var numSearchesStarted = 0;
|
||||
|
||||
input.onSearchBegin = function() {
|
||||
numSearchesStarted++;
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
};
|
||||
|
||||
input.onSearchComplete = function() {
|
||||
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
|
||||
do_check_eq(controller.searchStatus,
|
||||
Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH);
|
||||
do_check_eq(controller.matchCount, 0);
|
||||
|
@ -69,6 +69,7 @@ AutoCompleteInput.prototype = {
|
||||
return this.searches[aIndex];
|
||||
},
|
||||
|
||||
onSearchBegin: function() {},
|
||||
onSearchComplete: function() {},
|
||||
|
||||
popupOpen: false,
|
||||
@ -271,8 +272,17 @@ function run_test() {
|
||||
// Make an AutoCompleteInput that uses our searches
|
||||
// and confirms results on search complete
|
||||
var input = new AutoCompleteInput([search1.name, search2.name]);
|
||||
var numSearchesStarted = 0;
|
||||
|
||||
input.onSearchBegin = function() {
|
||||
numSearchesStarted++;
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
};
|
||||
|
||||
input.onSearchComplete = function() {
|
||||
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
|
||||
do_check_eq(controller.searchStatus,
|
||||
Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH);
|
||||
do_check_eq(controller.matchCount, expected1.length + expected2.length);
|
||||
|
@ -195,6 +195,7 @@ AutoCompleteInput.prototype = {
|
||||
return this.searches[aIndex];
|
||||
},
|
||||
|
||||
onSearchBegin: function() {},
|
||||
onSearchComplete: function() {},
|
||||
|
||||
popupOpen: false,
|
||||
@ -236,7 +237,14 @@ function run_test() {
|
||||
// Search is asynchronous, so don't let the test finish immediately
|
||||
do_test_pending();
|
||||
|
||||
var numSearchesStarted = 0;
|
||||
input.onSearchBegin = function() {
|
||||
numSearchesStarted++;
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
};
|
||||
|
||||
input.onSearchComplete = function() {
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
do_check_eq(controller.searchStatus,
|
||||
Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH);
|
||||
|
||||
|
@ -62,6 +62,7 @@ AutoCompleteInput.prototype = {
|
||||
return this.searches[aIndex];
|
||||
},
|
||||
|
||||
onSearchBegin: function() {},
|
||||
onSearchComplete: function() {},
|
||||
|
||||
popupOpen: false,
|
||||
@ -112,7 +113,14 @@ function ensure_tag_results(uris, searchTerm)
|
||||
// Search is asynchronous, so don't let the test finish immediately
|
||||
do_test_pending();
|
||||
|
||||
var numSearchesStarted = 0;
|
||||
input.onSearchBegin = function() {
|
||||
numSearchesStarted++;
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
};
|
||||
|
||||
input.onSearchComplete = function() {
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
do_check_eq(controller.searchStatus,
|
||||
Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH);
|
||||
do_check_eq(controller.matchCount, uris.length);
|
||||
|
@ -91,6 +91,7 @@ AutoCompleteInput.prototype = {
|
||||
return this.searches[aIndex];
|
||||
},
|
||||
|
||||
onSearchBegin: function() {},
|
||||
onSearchComplete: function() {},
|
||||
|
||||
popupOpen: false,
|
||||
@ -132,7 +133,14 @@ function run_test() {
|
||||
// Search is asynchronous, so don't let the test finish immediately
|
||||
do_test_pending();
|
||||
|
||||
var numSearchesStarted = 0;
|
||||
input.onSearchBegin = function() {
|
||||
numSearchesStarted++;
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
};
|
||||
|
||||
input.onSearchComplete = function() {
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
do_check_eq(controller.searchStatus,
|
||||
Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH);
|
||||
|
||||
|
@ -102,6 +102,7 @@ AutoCompleteInput.prototype = {
|
||||
return this.searches[aIndex];
|
||||
},
|
||||
|
||||
onSearchBegin: function() {},
|
||||
onSearchComplete: function() {},
|
||||
|
||||
popupOpen: false,
|
||||
@ -143,7 +144,14 @@ function run_test() {
|
||||
// Search is asynchronous, so don't let the test finish immediately
|
||||
do_test_pending();
|
||||
|
||||
var numSearchesStarted = 0;
|
||||
input.onSearchBegin = function() {
|
||||
numSearchesStarted++;
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
};
|
||||
|
||||
input.onSearchComplete = function() {
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
do_check_eq(controller.searchStatus,
|
||||
Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH);
|
||||
|
||||
|
@ -69,6 +69,7 @@ AutoCompleteInput.prototype = {
|
||||
return this.searches[aIndex];
|
||||
},
|
||||
|
||||
onSearchBegin: function() {},
|
||||
onSearchComplete: function() {},
|
||||
|
||||
popupOpen: false,
|
||||
@ -111,7 +112,14 @@ function ensure_results(uris, searchTerm)
|
||||
// Search is asynchronous, so don't let the test finish immediately
|
||||
do_test_pending();
|
||||
|
||||
var numSearchesStarted = 0;
|
||||
input.onSearchBegin = function() {
|
||||
numSearchesStarted++;
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
};
|
||||
|
||||
input.onSearchComplete = function() {
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
do_check_eq(controller.searchStatus,
|
||||
Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH);
|
||||
do_check_eq(controller.matchCount, uris.length);
|
||||
|
@ -62,6 +62,7 @@ AutoCompleteInput.prototype = {
|
||||
return this.searches[aIndex];
|
||||
},
|
||||
|
||||
onSearchBegin: function() {},
|
||||
onSearchComplete: function() {},
|
||||
|
||||
popupOpen: false,
|
||||
@ -112,7 +113,14 @@ function ensure_tag_results(uris, searchTerm)
|
||||
// Search is asynchronous, so don't let the test finish immediately
|
||||
do_test_pending();
|
||||
|
||||
var numSearchesStarted = 0;
|
||||
input.onSearchBegin = function() {
|
||||
numSearchesStarted++;
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
};
|
||||
|
||||
input.onSearchComplete = function() {
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
do_check_eq(controller.searchStatus,
|
||||
Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH);
|
||||
do_check_eq(controller.matchCount, uris.length);
|
||||
|
@ -71,6 +71,7 @@ AutoCompleteInput.prototype = {
|
||||
return this.searches[aIndex];
|
||||
},
|
||||
|
||||
onSearchBegin: function() {},
|
||||
onSearchComplete: function() {},
|
||||
|
||||
popupOpen: false,
|
||||
@ -110,7 +111,14 @@ function ensure_results(aSearch, aExpected)
|
||||
|
||||
controller.input = input;
|
||||
|
||||
var numSearchesStarted = 0;
|
||||
input.onSearchBegin = function() {
|
||||
numSearchesStarted++;
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
};
|
||||
|
||||
input.onSearchComplete = function() {
|
||||
do_check_eq(numSearchesStarted, 1);
|
||||
// If we expect results, make sure we got matches
|
||||
do_check_eq(controller.searchStatus, aExpected.length ?
|
||||
Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH :
|
||||
|
@ -436,6 +436,12 @@ nsFormFillController::SelectTextRange(PRInt32 aStartIndex, PRInt32 aEndIndex)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormFillController::OnSearchBegin()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormFillController::OnSearchComplete()
|
||||
{
|
||||
|
@ -200,6 +200,12 @@
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="onSearchBegin">
|
||||
<body><![CDATA[
|
||||
this.fireEvent("searchbegin");
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="onSearchComplete">
|
||||
<body><![CDATA[
|
||||
if (this.mController.matchCount == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user