From a928bf88c3b911a2a635d483bb0142c78f1abbfc Mon Sep 17 00:00:00 2001 From: "bryner%netscape.com" Date: Sun, 13 Jul 2003 02:27:25 +0000 Subject: [PATCH] Fix non-functioning form autocomplete (bug 212220). Instead of using an attribute on the nsIAutoCompleteInput (since it's not always a content node), add an attribute to the IDL interface. Also, make use of JS's (a || b) semantics to avoid some temporary variables. r=hewitt. --- .../autocomplete/public/nsIAutoCompleteInput.idl | 5 +++++ .../satchel/src/nsFormFillController.cpp | 15 +++++++++++++++ .../components/satchel/src/nsFormFillController.h | 1 + toolkit/content/widgets/autocomplete.xml | 13 ++++++++----- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/toolkit/components/autocomplete/public/nsIAutoCompleteInput.idl b/toolkit/components/autocomplete/public/nsIAutoCompleteInput.idl index 93e690e8280..7307cf592dd 100644 --- a/toolkit/components/autocomplete/public/nsIAutoCompleteInput.idl +++ b/toolkit/components/autocomplete/public/nsIAutoCompleteInput.idl @@ -81,6 +81,11 @@ interface nsIAutoCompleteInput : nsISupports */ attribute unsigned long minResultsForPopup; + /* + * The maximum number of rows to show in the autocomplete popup. + */ + attribute unsigned long maxRows; + /* * Option to show a second column in the popup which contains * the comment for each autocomplete result diff --git a/toolkit/components/satchel/src/nsFormFillController.cpp b/toolkit/components/satchel/src/nsFormFillController.cpp index 47139beb8e7..f33cb7fca1d 100644 --- a/toolkit/components/satchel/src/nsFormFillController.cpp +++ b/toolkit/components/satchel/src/nsFormFillController.cpp @@ -78,6 +78,7 @@ NS_IMPL_RELEASE(nsFormFillController); nsFormFillController::nsFormFillController() : mTimeout(50), mMinResultsForPopup(1), + mMaxRows(0), mDisableAutoComplete(PR_FALSE), mCompleteDefaultIndex(PR_FALSE), mForceComplete(PR_FALSE) @@ -290,6 +291,20 @@ NS_IMETHODIMP nsFormFillController::SetMinResultsForPopup(PRUint32 aMinResultsFo return NS_OK; } +NS_IMETHODIMP +nsFormFillController::GetMaxRows(PRUint32 *aMaxRows) +{ + *aMaxRows = mMaxRows; + return NS_OK; +} + +NS_IMETHODIMP +nsFormFillController::SetMaxRows(PRUint32 aMaxRows) +{ + mMaxRows = aMaxRows; + return NS_OK; +} + NS_IMETHODIMP nsFormFillController::GetShowCommentColumn(PRUint32 *aShowCommentColumn) { diff --git a/toolkit/components/satchel/src/nsFormFillController.h b/toolkit/components/satchel/src/nsFormFillController.h index 505c424add9..033fa3e358c 100644 --- a/toolkit/components/satchel/src/nsFormFillController.h +++ b/toolkit/components/satchel/src/nsFormFillController.h @@ -106,6 +106,7 @@ protected: PRUint32 mTimeout; PRUint32 mMinResultsForPopup; + PRUint32 mMaxRows; PRPackedBool mDisableAutoComplete; PRPackedBool mCompleteDefaultIndex; PRPackedBool mForceComplete; diff --git a/toolkit/content/widgets/autocomplete.xml b/toolkit/content/widgets/autocomplete.xml index ec8290c9a77..5362048f0d7 100644 --- a/toolkit/content/widgets/autocomplete.xml +++ b/toolkit/content/widgets/autocomplete.xml @@ -102,7 +102,7 @@ + onget="return parseInt(this.getAttribute('minresultsforpopup')) || 0;"/> + onget="return parseInt(this.getAttribute('timeout')) || 50;"/> + onget="return parseInt(this.getAttribute('maxrows')) || 0;"/> @@ -504,8 +504,11 @@ ]]> - + + +