gecko/toolkit/components/autocomplete/nsAutoCompleteController.h
Ehsan Akhgari 0fd9123eac Bug 579517 - Part 1: Automated conversion of NSPR numeric types to stdint types in Gecko; r=bsmedberg
This patch was generated by a script.  Here's the source of the script for
future reference:

function convert() {
echo "Converting $1 to $2..."
find . ! -wholename "*nsprpub*" \
       ! -wholename "*security/nss*" \
       ! -wholename "*/.hg*" \
       ! -wholename "obj-ff-dbg*" \
       ! -name nsXPCOMCID.h \
       ! -name prtypes.h \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.c" \
         -o -iname "*.cc" \
         -o -iname "*.idl" \
         -o -iname "*.ipdl" \
         -o -iname "*.ipdlh" \
         -o -iname "*.mm" \) | \
    xargs -n 1 sed -i -e "s/\b$1\b/$2/g"
}

convert PRInt8 int8_t
convert PRUint8 uint8_t
convert PRInt16 int16_t
convert PRUint16 uint16_t
convert PRInt32 int32_t
convert PRUint32 uint32_t
convert PRInt64 int64_t
convert PRUint64 uint64_t

convert PRIntn int
convert PRUintn unsigned

convert PRSize size_t

convert PROffset32 int32_t
convert PROffset64 int64_t

convert PRPtrdiff ptrdiff_t

convert PRFloat64 double
2012-08-22 11:56:38 -04:00

154 lines
5.0 KiB
C++

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __nsAutoCompleteController__
#define __nsAutoCompleteController__
#include "nsIAutoCompleteController.h"
#include "nsIAutoCompleteInput.h"
#include "nsIAutoCompletePopup.h"
#include "nsIAutoCompleteResult.h"
#include "nsIAutoCompleteSearch.h"
#include "nsString.h"
#include "nsITreeView.h"
#include "nsITreeSelection.h"
#include "nsITimer.h"
#include "nsTArray.h"
#include "nsCOMArray.h"
#include "nsCycleCollectionParticipant.h"
class nsAutoCompleteController : public nsIAutoCompleteController,
public nsIAutoCompleteObserver,
public nsITimerCallback,
public nsITreeView
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsAutoCompleteController,
nsIAutoCompleteController)
NS_DECL_NSIAUTOCOMPLETECONTROLLER
NS_DECL_NSIAUTOCOMPLETEOBSERVER
NS_DECL_NSITREEVIEW
NS_DECL_NSITIMERCALLBACK
nsAutoCompleteController();
virtual ~nsAutoCompleteController();
protected:
nsresult OpenPopup();
nsresult ClosePopup();
nsresult StartSearch(uint16_t aSearchType);
nsresult BeforeSearches();
nsresult StartSearches();
void AfterSearches();
nsresult ClearSearchTimer();
nsresult ProcessResult(int32_t aSearchIndex, nsIAutoCompleteResult *aResult);
nsresult PostSearchCleanup();
nsresult EnterMatch(bool aIsPopupSelection);
nsresult RevertTextValue();
nsresult CompleteDefaultIndex(int32_t aResultIndex);
nsresult CompleteValue(nsString &aValue);
nsresult GetResultAt(int32_t aIndex, nsIAutoCompleteResult** aResult,
int32_t* aRowIndex);
nsresult GetResultValueAt(int32_t aIndex, bool aValueOnly,
nsAString & _retval);
nsresult GetResultLabelAt(int32_t aIndex, bool aValueOnly,
nsAString & _retval);
private:
nsresult GetResultValueLabelAt(int32_t aIndex, bool aValueOnly,
bool aGetValue, nsAString & _retval);
protected:
/**
* Gets and validates the defaultComplete result and the relative
* defaultIndex value.
*
* @param aResultIndex
* Index of the defaultComplete result to be used. Pass -1 to search
* for the first result providing a valid defaultIndex.
* @param _result
* The found result.
* @param _defaultIndex
* The defaultIndex relative to _result.
*/
nsresult GetDefaultCompleteResult(int32_t aResultIndex,
nsIAutoCompleteResult** _result,
int32_t* _defaultIndex);
/**
* Gets the defaultComplete value to be suggested to the user.
*
* @param aResultIndex
* Index of the defaultComplete result to be used.
* @param aPreserveCasing
* Whether user casing should be preserved.
* @param _retval
* The value to be completed.
*/
nsresult GetDefaultCompleteValue(int32_t aResultIndex, bool aPreserveCasing,
nsAString &_retval);
/**
* Gets the defaultComplete value to be used when the user confirms the
* current match.
* The value is returned only if it case-insensitively matches the current
* input text, otherwise the method returns NS_ERROR_FAILURE.
* This happens because we don't want to replace text if the user backspaces
* just before Enter.
*
* @param _retval
* The value to be completed.
*/
nsresult GetFinalDefaultCompleteValue(nsAString &_retval);
nsresult ClearResults();
nsresult RowIndexToSearch(int32_t aRowIndex,
int32_t *aSearchIndex, int32_t *aItemIndex);
// members //////////////////////////////////////////
nsCOMPtr<nsIAutoCompleteInput> mInput;
nsCOMArray<nsIAutoCompleteSearch> mSearches;
nsCOMArray<nsIAutoCompleteResult> mResults;
// Caches the match counts for the current ongoing results to allow
// incremental results to keep the rowcount up to date.
nsTArray<uint32_t> mMatchCounts;
// Temporarily keeps the results alive while invoking startSearch() for each
// search. This is needed to allow the searches to reuse the previous result,
// since otherwise the first search clears mResults.
nsCOMArray<nsIAutoCompleteResult> mResultCache;
nsCOMPtr<nsITimer> mTimer;
nsCOMPtr<nsITreeSelection> mSelection;
nsCOMPtr<nsITreeBoxObject> mTree;
nsString mSearchString;
bool mDefaultIndexCompleted;
bool mBackspaced;
bool mPopupClosedByCompositionStart;
enum CompositionState {
eCompositionState_None,
eCompositionState_Composing,
eCompositionState_Committing
};
CompositionState mCompositionState;
uint16_t mSearchStatus;
uint32_t mRowCount;
uint32_t mSearchesOngoing;
uint32_t mSearchesFailed;
bool mFirstSearchResult;
uint32_t mImmediateSearchesCount;
};
#endif /* __nsAutoCompleteController__ */