michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef __nsFormFillController__ michael@0: #define __nsFormFillController__ michael@0: michael@0: #include "nsIFormFillController.h" michael@0: #include "nsIAutoCompleteInput.h" michael@0: #include "nsIAutoCompleteSearch.h" michael@0: #include "nsIAutoCompleteController.h" michael@0: #include "nsIAutoCompletePopup.h" michael@0: #include "nsIFormAutoComplete.h" michael@0: #include "nsIDOMEventListener.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsDataHashtable.h" michael@0: #include "nsIDocShell.h" michael@0: #include "nsIDOMWindow.h" michael@0: #include "nsIDOMHTMLInputElement.h" michael@0: #include "nsILoginManager.h" michael@0: #include "nsIMutationObserver.h" michael@0: #include "nsTArray.h" michael@0: michael@0: // X.h defines KeyPress michael@0: #ifdef KeyPress michael@0: #undef KeyPress michael@0: #endif michael@0: michael@0: class nsFormHistory; michael@0: class nsINode; michael@0: michael@0: class nsFormFillController : public nsIFormFillController, michael@0: public nsIAutoCompleteInput, michael@0: public nsIAutoCompleteSearch, michael@0: public nsIDOMEventListener, michael@0: public nsIFormAutoCompleteObserver, michael@0: public nsIMutationObserver michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSIFORMFILLCONTROLLER michael@0: NS_DECL_NSIAUTOCOMPLETESEARCH michael@0: NS_DECL_NSIAUTOCOMPLETEINPUT michael@0: NS_DECL_NSIFORMAUTOCOMPLETEOBSERVER michael@0: NS_DECL_NSIDOMEVENTLISTENER michael@0: NS_DECL_NSIMUTATIONOBSERVER michael@0: michael@0: nsresult Focus(nsIDOMEvent* aEvent); michael@0: nsresult KeyPress(nsIDOMEvent* aKeyEvent); michael@0: nsresult MouseDown(nsIDOMEvent* aMouseEvent); michael@0: michael@0: nsFormFillController(); michael@0: virtual ~nsFormFillController(); michael@0: michael@0: protected: michael@0: void AddWindowListeners(nsIDOMWindow *aWindow); michael@0: void RemoveWindowListeners(nsIDOMWindow *aWindow); michael@0: michael@0: void AddKeyListener(nsINode* aInput); michael@0: void RemoveKeyListener(); michael@0: michael@0: void StartControllingInput(nsIDOMHTMLInputElement *aInput); michael@0: void StopControllingInput(); michael@0: michael@0: nsresult PerformInputListAutoComplete(nsIAutoCompleteResult* aPreviousResult); michael@0: michael@0: void RevalidateDataList(); michael@0: bool RowMatch(nsFormHistory *aHistory, uint32_t aIndex, const nsAString &aInputName, const nsAString &aInputValue); michael@0: michael@0: inline nsIDocShell *GetDocShellForInput(nsIDOMHTMLInputElement *aInput); michael@0: inline nsIDOMWindow *GetWindowForDocShell(nsIDocShell *aDocShell); michael@0: inline int32_t GetIndexOfDocShell(nsIDocShell *aDocShell); michael@0: michael@0: void MaybeRemoveMutationObserver(nsINode* aNode); michael@0: michael@0: static PLDHashOperator RemoveForDocumentEnumerator(const nsINode* aKey, michael@0: bool& aEntry, michael@0: void* aUserData); michael@0: bool IsEventTrusted(nsIDOMEvent *aEvent); michael@0: // members ////////////////////////////////////////// michael@0: michael@0: nsCOMPtr mController; michael@0: nsCOMPtr mLoginManager; michael@0: nsIDOMHTMLInputElement* mFocusedInput; michael@0: nsINode* mFocusedInputNode; michael@0: michael@0: // mListNode is a element which, is set, has the form fill controller michael@0: // as a mutation observer for it. michael@0: nsINode* mListNode; michael@0: nsCOMPtr mFocusedPopup; michael@0: michael@0: nsTArray > mDocShells; michael@0: nsTArray > mPopups; michael@0: michael@0: //these are used to dynamically update the autocomplete michael@0: nsCOMPtr mLastSearchResult; michael@0: michael@0: // The observer passed to StartSearch. It will be notified when the search is michael@0: // complete or the data from a datalist changes. michael@0: nsCOMPtr mLastListener; michael@0: michael@0: // This is cleared by StopSearch(). michael@0: nsCOMPtr mLastFormAutoComplete; michael@0: nsString mLastSearchString; michael@0: michael@0: nsDataHashtable, bool> mPwmgrInputs; michael@0: michael@0: uint32_t mTimeout; michael@0: uint32_t mMinResultsForPopup; michael@0: uint32_t mMaxRows; michael@0: bool mDisableAutoComplete; michael@0: bool mCompleteDefaultIndex; michael@0: bool mCompleteSelectedIndex; michael@0: bool mForceComplete; michael@0: bool mSuppressOnInput; michael@0: }; michael@0: michael@0: #endif // __nsFormFillController__