toolkit/components/autocomplete/nsAutoCompleteSimpleResult.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/autocomplete/nsAutoCompleteSimpleResult.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,55 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef __nsAutoCompleteSimpleResult__
     1.9 +#define __nsAutoCompleteSimpleResult__
    1.10 +
    1.11 +#include "nsIAutoCompleteResult.h"
    1.12 +#include "nsIAutoCompleteSimpleResult.h"
    1.13 +
    1.14 +#include "nsString.h"
    1.15 +#include "nsCOMPtr.h"
    1.16 +#include "nsTArray.h"
    1.17 +#include "mozilla/Attributes.h"
    1.18 +
    1.19 +class nsAutoCompleteSimpleResult MOZ_FINAL : public nsIAutoCompleteSimpleResult
    1.20 +{
    1.21 +public:
    1.22 +  nsAutoCompleteSimpleResult();
    1.23 +  inline void CheckInvariants() {
    1.24 +    NS_ASSERTION(mValues.Length() == mComments.Length(), "Arrays out of sync");
    1.25 +    NS_ASSERTION(mValues.Length() == mImages.Length(),   "Arrays out of sync");
    1.26 +    NS_ASSERTION(mValues.Length() == mStyles.Length(),   "Arrays out of sync");
    1.27 +    NS_ASSERTION(mValues.Length() == mFinalCompleteValues.Length(), "Arrays out of sync");
    1.28 +  }
    1.29 +
    1.30 +  NS_DECL_ISUPPORTS
    1.31 +  NS_DECL_NSIAUTOCOMPLETERESULT
    1.32 +  NS_DECL_NSIAUTOCOMPLETESIMPLERESULT
    1.33 +
    1.34 +private:
    1.35 +  ~nsAutoCompleteSimpleResult() {}
    1.36 +
    1.37 +protected:
    1.38 +
    1.39 +  // What we really want is an array of structs with value/comment/image/style contents.
    1.40 +  // But then we'd either have to use COM or manage object lifetimes ourselves.
    1.41 +  // Having four arrays of string simplifies this, but is stupid.
    1.42 +  nsTArray<nsString> mValues;
    1.43 +  nsTArray<nsString> mComments;
    1.44 +  nsTArray<nsString> mImages;
    1.45 +  nsTArray<nsString> mStyles;
    1.46 +  nsTArray<nsString> mFinalCompleteValues;
    1.47 +
    1.48 +  nsString mSearchString;
    1.49 +  nsString mErrorDescription;
    1.50 +  int32_t mDefaultIndex;
    1.51 +  uint32_t mSearchResult;
    1.52 +
    1.53 +  bool mTypeAheadResult;
    1.54 +
    1.55 +  nsCOMPtr<nsIAutoCompleteSimpleResultListener> mListener;
    1.56 +};
    1.57 +
    1.58 +#endif // __nsAutoCompleteSimpleResult__

mercurial