toolkit/components/autocomplete/nsAutoCompleteController.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef __nsAutoCompleteController__
michael@0 6 #define __nsAutoCompleteController__
michael@0 7
michael@0 8 #include "nsIAutoCompleteController.h"
michael@0 9
michael@0 10 #include "nsCOMPtr.h"
michael@0 11 #include "nsIAutoCompleteInput.h"
michael@0 12 #include "nsIAutoCompletePopup.h"
michael@0 13 #include "nsIAutoCompleteResult.h"
michael@0 14 #include "nsIAutoCompleteSearch.h"
michael@0 15 #include "nsString.h"
michael@0 16 #include "nsITreeView.h"
michael@0 17 #include "nsITreeSelection.h"
michael@0 18 #include "nsITimer.h"
michael@0 19 #include "nsTArray.h"
michael@0 20 #include "nsCOMArray.h"
michael@0 21 #include "nsCycleCollectionParticipant.h"
michael@0 22
michael@0 23 class nsAutoCompleteController : public nsIAutoCompleteController,
michael@0 24 public nsIAutoCompleteObserver,
michael@0 25 public nsITimerCallback,
michael@0 26 public nsITreeView
michael@0 27 {
michael@0 28 public:
michael@0 29 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
michael@0 30 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsAutoCompleteController,
michael@0 31 nsIAutoCompleteController)
michael@0 32 NS_DECL_NSIAUTOCOMPLETECONTROLLER
michael@0 33 NS_DECL_NSIAUTOCOMPLETEOBSERVER
michael@0 34 NS_DECL_NSITREEVIEW
michael@0 35 NS_DECL_NSITIMERCALLBACK
michael@0 36
michael@0 37 nsAutoCompleteController();
michael@0 38 virtual ~nsAutoCompleteController();
michael@0 39
michael@0 40 protected:
michael@0 41 nsresult OpenPopup();
michael@0 42 nsresult ClosePopup();
michael@0 43
michael@0 44 nsresult StartSearch(uint16_t aSearchType);
michael@0 45
michael@0 46 nsresult BeforeSearches();
michael@0 47 nsresult StartSearches();
michael@0 48 void AfterSearches();
michael@0 49 nsresult ClearSearchTimer();
michael@0 50
michael@0 51 nsresult ProcessResult(int32_t aSearchIndex, nsIAutoCompleteResult *aResult);
michael@0 52 nsresult PostSearchCleanup();
michael@0 53
michael@0 54 nsresult EnterMatch(bool aIsPopupSelection);
michael@0 55 nsresult RevertTextValue();
michael@0 56
michael@0 57 nsresult CompleteDefaultIndex(int32_t aResultIndex);
michael@0 58 nsresult CompleteValue(nsString &aValue);
michael@0 59
michael@0 60 nsresult GetResultAt(int32_t aIndex, nsIAutoCompleteResult** aResult,
michael@0 61 int32_t* aRowIndex);
michael@0 62 nsresult GetResultValueAt(int32_t aIndex, bool aGetFinalValue,
michael@0 63 nsAString & _retval);
michael@0 64 nsresult GetResultLabelAt(int32_t aIndex, nsAString & _retval);
michael@0 65 private:
michael@0 66 nsresult GetResultValueLabelAt(int32_t aIndex, bool aGetFinalValue,
michael@0 67 bool aGetValue, nsAString & _retval);
michael@0 68 protected:
michael@0 69
michael@0 70 /**
michael@0 71 * Gets and validates the defaultComplete result and the relative
michael@0 72 * defaultIndex value.
michael@0 73 *
michael@0 74 * @param aResultIndex
michael@0 75 * Index of the defaultComplete result to be used. Pass -1 to search
michael@0 76 * for the first result providing a valid defaultIndex.
michael@0 77 * @param _result
michael@0 78 * The found result.
michael@0 79 * @param _defaultIndex
michael@0 80 * The defaultIndex relative to _result.
michael@0 81 */
michael@0 82 nsresult GetDefaultCompleteResult(int32_t aResultIndex,
michael@0 83 nsIAutoCompleteResult** _result,
michael@0 84 int32_t* _defaultIndex);
michael@0 85
michael@0 86 /**
michael@0 87 * Gets the defaultComplete value to be suggested to the user.
michael@0 88 *
michael@0 89 * @param aResultIndex
michael@0 90 * Index of the defaultComplete result to be used.
michael@0 91 * @param aPreserveCasing
michael@0 92 * Whether user casing should be preserved.
michael@0 93 * @param _retval
michael@0 94 * The value to be completed.
michael@0 95 */
michael@0 96 nsresult GetDefaultCompleteValue(int32_t aResultIndex, bool aPreserveCasing,
michael@0 97 nsAString &_retval);
michael@0 98
michael@0 99 /**
michael@0 100 * Gets the defaultComplete value to be used when the user confirms the
michael@0 101 * current match.
michael@0 102 * The value is returned only if it case-insensitively matches the current
michael@0 103 * input text, otherwise the method returns NS_ERROR_FAILURE.
michael@0 104 * This happens because we don't want to replace text if the user backspaces
michael@0 105 * just before Enter.
michael@0 106 *
michael@0 107 * @param _retval
michael@0 108 * The value to be completed.
michael@0 109 */
michael@0 110 nsresult GetFinalDefaultCompleteValue(nsAString &_retval);
michael@0 111
michael@0 112 nsresult ClearResults();
michael@0 113
michael@0 114 nsresult RowIndexToSearch(int32_t aRowIndex,
michael@0 115 int32_t *aSearchIndex, int32_t *aItemIndex);
michael@0 116
michael@0 117 // members //////////////////////////////////////////
michael@0 118
michael@0 119 nsCOMPtr<nsIAutoCompleteInput> mInput;
michael@0 120
michael@0 121 nsCOMArray<nsIAutoCompleteSearch> mSearches;
michael@0 122 nsCOMArray<nsIAutoCompleteResult> mResults;
michael@0 123 // Caches the match counts for the current ongoing results to allow
michael@0 124 // incremental results to keep the rowcount up to date.
michael@0 125 nsTArray<uint32_t> mMatchCounts;
michael@0 126 // Temporarily keeps the results alive while invoking startSearch() for each
michael@0 127 // search. This is needed to allow the searches to reuse the previous result,
michael@0 128 // since otherwise the first search clears mResults.
michael@0 129 nsCOMArray<nsIAutoCompleteResult> mResultCache;
michael@0 130
michael@0 131 nsCOMPtr<nsITimer> mTimer;
michael@0 132 nsCOMPtr<nsITreeSelection> mSelection;
michael@0 133 nsCOMPtr<nsITreeBoxObject> mTree;
michael@0 134
michael@0 135 nsString mSearchString;
michael@0 136 bool mDefaultIndexCompleted;
michael@0 137 bool mBackspaced;
michael@0 138 bool mPopupClosedByCompositionStart;
michael@0 139 enum CompositionState {
michael@0 140 eCompositionState_None,
michael@0 141 eCompositionState_Composing,
michael@0 142 eCompositionState_Committing
michael@0 143 };
michael@0 144 CompositionState mCompositionState;
michael@0 145 uint16_t mSearchStatus;
michael@0 146 uint32_t mRowCount;
michael@0 147 uint32_t mSearchesOngoing;
michael@0 148 uint32_t mSearchesFailed;
michael@0 149 bool mFirstSearchResult;
michael@0 150 uint32_t mImmediateSearchesCount;
michael@0 151 };
michael@0 152
michael@0 153 #endif /* __nsAutoCompleteController__ */

mercurial