|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #ifndef __nsAutoCompleteSimpleResult__ |
|
6 #define __nsAutoCompleteSimpleResult__ |
|
7 |
|
8 #include "nsIAutoCompleteResult.h" |
|
9 #include "nsIAutoCompleteSimpleResult.h" |
|
10 |
|
11 #include "nsString.h" |
|
12 #include "nsCOMPtr.h" |
|
13 #include "nsTArray.h" |
|
14 #include "mozilla/Attributes.h" |
|
15 |
|
16 class nsAutoCompleteSimpleResult MOZ_FINAL : public nsIAutoCompleteSimpleResult |
|
17 { |
|
18 public: |
|
19 nsAutoCompleteSimpleResult(); |
|
20 inline void CheckInvariants() { |
|
21 NS_ASSERTION(mValues.Length() == mComments.Length(), "Arrays out of sync"); |
|
22 NS_ASSERTION(mValues.Length() == mImages.Length(), "Arrays out of sync"); |
|
23 NS_ASSERTION(mValues.Length() == mStyles.Length(), "Arrays out of sync"); |
|
24 NS_ASSERTION(mValues.Length() == mFinalCompleteValues.Length(), "Arrays out of sync"); |
|
25 } |
|
26 |
|
27 NS_DECL_ISUPPORTS |
|
28 NS_DECL_NSIAUTOCOMPLETERESULT |
|
29 NS_DECL_NSIAUTOCOMPLETESIMPLERESULT |
|
30 |
|
31 private: |
|
32 ~nsAutoCompleteSimpleResult() {} |
|
33 |
|
34 protected: |
|
35 |
|
36 // What we really want is an array of structs with value/comment/image/style contents. |
|
37 // But then we'd either have to use COM or manage object lifetimes ourselves. |
|
38 // Having four arrays of string simplifies this, but is stupid. |
|
39 nsTArray<nsString> mValues; |
|
40 nsTArray<nsString> mComments; |
|
41 nsTArray<nsString> mImages; |
|
42 nsTArray<nsString> mStyles; |
|
43 nsTArray<nsString> mFinalCompleteValues; |
|
44 |
|
45 nsString mSearchString; |
|
46 nsString mErrorDescription; |
|
47 int32_t mDefaultIndex; |
|
48 uint32_t mSearchResult; |
|
49 |
|
50 bool mTypeAheadResult; |
|
51 |
|
52 nsCOMPtr<nsIAutoCompleteSimpleResultListener> mListener; |
|
53 }; |
|
54 |
|
55 #endif // __nsAutoCompleteSimpleResult__ |