2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef __nsFormFillController__
|
|
|
|
#define __nsFormFillController__
|
|
|
|
|
|
|
|
#include "nsIFormFillController.h"
|
|
|
|
#include "nsIAutoCompleteInput.h"
|
|
|
|
#include "nsIAutoCompleteSearch.h"
|
|
|
|
#include "nsIAutoCompleteController.h"
|
|
|
|
#include "nsIAutoCompletePopup.h"
|
2013-04-19 15:21:30 -07:00
|
|
|
#include "nsIFormAutoComplete.h"
|
2011-06-27 16:34:56 -07:00
|
|
|
#include "nsIDOMEventListener.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCOMPtr.h"
|
2007-05-16 03:02:45 -07:00
|
|
|
#include "nsDataHashtable.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsIDOMWindow.h"
|
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
2007-05-16 03:02:45 -07:00
|
|
|
#include "nsILoginManager.h"
|
2010-09-09 22:20:16 -07:00
|
|
|
#include "nsIMutationObserver.h"
|
2012-12-10 13:54:32 -08:00
|
|
|
#include "nsTArray.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-08-08 11:26:22 -07:00
|
|
|
// X.h defines KeyPress
|
|
|
|
#ifdef KeyPress
|
|
|
|
#undef KeyPress
|
|
|
|
#endif
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsFormHistory;
|
2012-02-22 04:59:39 -08:00
|
|
|
class nsINode;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsFormFillController : public nsIFormFillController,
|
|
|
|
public nsIAutoCompleteInput,
|
|
|
|
public nsIAutoCompleteSearch,
|
2011-06-27 16:34:56 -07:00
|
|
|
public nsIDOMEventListener,
|
2013-04-19 15:21:30 -07:00
|
|
|
public nsIFormAutoCompleteObserver,
|
2010-09-09 22:20:16 -07:00
|
|
|
public nsIMutationObserver
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIFORMFILLCONTROLLER
|
|
|
|
NS_DECL_NSIAUTOCOMPLETESEARCH
|
|
|
|
NS_DECL_NSIAUTOCOMPLETEINPUT
|
2013-04-19 15:21:30 -07:00
|
|
|
NS_DECL_NSIFORMAUTOCOMPLETEOBSERVER
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
2010-09-09 22:20:16 -07:00
|
|
|
NS_DECL_NSIMUTATIONOBSERVER
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-27 16:34:56 -07:00
|
|
|
nsresult Focus(nsIDOMEvent* aEvent);
|
|
|
|
nsresult KeyPress(nsIDOMEvent* aKeyEvent);
|
|
|
|
nsresult MouseDown(nsIDOMEvent* aMouseEvent);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsFormFillController();
|
|
|
|
virtual ~nsFormFillController();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void AddWindowListeners(nsIDOMWindow *aWindow);
|
|
|
|
void RemoveWindowListeners(nsIDOMWindow *aWindow);
|
2011-08-03 17:52:47 -07:00
|
|
|
|
2013-04-19 15:18:33 -07:00
|
|
|
void AddKeyListener(nsINode* aInput);
|
2007-04-04 12:55:04 -07:00
|
|
|
void RemoveKeyListener();
|
2011-08-03 17:52:47 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
void StartControllingInput(nsIDOMHTMLInputElement *aInput);
|
|
|
|
void StopControllingInput();
|
2011-08-03 17:52:47 -07:00
|
|
|
|
2013-04-19 15:21:30 -07:00
|
|
|
nsresult PerformInputListAutoComplete(nsIAutoCompleteResult* aPreviousResult);
|
|
|
|
|
2010-09-09 22:20:16 -07:00
|
|
|
void RevalidateDataList();
|
2012-08-22 08:56:38 -07:00
|
|
|
bool RowMatch(nsFormHistory *aHistory, uint32_t aIndex, const nsAString &aInputName, const nsAString &aInputValue);
|
2011-08-03 17:52:47 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
inline nsIDocShell *GetDocShellForInput(nsIDOMHTMLInputElement *aInput);
|
|
|
|
inline nsIDOMWindow *GetWindowForDocShell(nsIDocShell *aDocShell);
|
2012-08-22 08:56:38 -07:00
|
|
|
inline int32_t GetIndexOfDocShell(nsIDocShell *aDocShell);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-02-27 15:31:23 -08:00
|
|
|
void MaybeRemoveMutationObserver(nsINode* aNode);
|
|
|
|
|
2012-02-22 04:59:39 -08:00
|
|
|
static PLDHashOperator RemoveForDocumentEnumerator(const nsINode* aKey,
|
|
|
|
bool& aEntry,
|
|
|
|
void* aUserData);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsEventTrusted(nsIDOMEvent *aEvent);
|
2007-03-22 10:30:00 -07:00
|
|
|
// members //////////////////////////////////////////
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAutoCompleteController> mController;
|
2007-05-16 03:02:45 -07:00
|
|
|
nsCOMPtr<nsILoginManager> mLoginManager;
|
2012-02-22 04:59:39 -08:00
|
|
|
nsIDOMHTMLInputElement* mFocusedInput;
|
|
|
|
nsINode* mFocusedInputNode;
|
2013-04-19 15:21:30 -07:00
|
|
|
|
|
|
|
// mListNode is a <datalist> element which, is set, has the form fill controller
|
|
|
|
// as a mutation observer for it.
|
2012-02-22 04:59:39 -08:00
|
|
|
nsINode* mListNode;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIAutoCompletePopup> mFocusedPopup;
|
|
|
|
|
2012-12-10 13:54:32 -08:00
|
|
|
nsTArray<nsCOMPtr<nsIDocShell> > mDocShells;
|
|
|
|
nsTArray<nsCOMPtr<nsIAutoCompletePopup> > mPopups;
|
2007-05-16 03:02:45 -07:00
|
|
|
|
2010-09-09 22:20:16 -07:00
|
|
|
//these are used to dynamically update the autocomplete
|
|
|
|
nsCOMPtr<nsIAutoCompleteResult> mLastSearchResult;
|
2013-04-19 15:21:30 -07:00
|
|
|
|
|
|
|
// The observer passed to StartSearch. It will be notified when the search is
|
|
|
|
// complete or the data from a datalist changes.
|
2010-09-09 22:20:16 -07:00
|
|
|
nsCOMPtr<nsIAutoCompleteObserver> mLastListener;
|
2013-04-19 15:21:30 -07:00
|
|
|
|
|
|
|
// This is cleared by StopSearch().
|
|
|
|
nsCOMPtr<nsIFormAutoComplete> mLastFormAutoComplete;
|
2010-09-09 22:20:16 -07:00
|
|
|
nsString mLastSearchString;
|
|
|
|
|
2012-02-22 04:59:39 -08:00
|
|
|
nsDataHashtable<nsPtrHashKey<const nsINode>, bool> mPwmgrInputs;
|
2007-05-16 03:02:45 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mTimeout;
|
|
|
|
uint32_t mMinResultsForPopup;
|
|
|
|
uint32_t mMaxRows;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mDisableAutoComplete;
|
|
|
|
bool mCompleteDefaultIndex;
|
|
|
|
bool mCompleteSelectedIndex;
|
|
|
|
bool mForceComplete;
|
|
|
|
bool mSuppressOnInput;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __nsFormFillController__
|