2003-07-13 02:31:08 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2002-09-28 00:38:20 +00:00
|
|
|
|
|
|
|
#ifndef __nsFormFillController__
|
|
|
|
#define __nsFormFillController__
|
|
|
|
|
|
|
|
#include "nsIFormFillController.h"
|
|
|
|
#include "nsIAutoCompleteInput.h"
|
|
|
|
#include "nsIAutoCompleteSearch.h"
|
|
|
|
#include "nsIAutoCompleteController.h"
|
|
|
|
#include "nsIAutoCompletePopup.h"
|
2011-06-27 23:34:56 +00:00
|
|
|
#include "nsIDOMEventListener.h"
|
2002-09-28 00:38:20 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2007-05-16 10:02:45 +00:00
|
|
|
#include "nsDataHashtable.h"
|
2002-09-28 00:38:20 +00:00
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsIDOMWindow.h"
|
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
2007-05-16 10:02:45 +00:00
|
|
|
#include "nsILoginManager.h"
|
2010-09-10 05:20:16 +00:00
|
|
|
#include "nsIMutationObserver.h"
|
2012-12-10 21:54:32 +00:00
|
|
|
#include "nsTArray.h"
|
2006-01-26 19:17:04 +00:00
|
|
|
|
2011-08-08 18:26:22 +00:00
|
|
|
// X.h defines KeyPress
|
|
|
|
#ifdef KeyPress
|
|
|
|
#undef KeyPress
|
|
|
|
#endif
|
|
|
|
|
2006-01-26 19:17:04 +00:00
|
|
|
class nsFormHistory;
|
2012-02-22 12:59:39 +00:00
|
|
|
class nsINode;
|
2002-09-28 00:38:20 +00:00
|
|
|
|
|
|
|
class nsFormFillController : public nsIFormFillController,
|
|
|
|
public nsIAutoCompleteInput,
|
|
|
|
public nsIAutoCompleteSearch,
|
2011-06-27 23:34:56 +00:00
|
|
|
public nsIDOMEventListener,
|
2010-09-10 05:20:16 +00:00
|
|
|
public nsIMutationObserver
|
2002-09-28 00:38:20 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIFORMFILLCONTROLLER
|
|
|
|
NS_DECL_NSIAUTOCOMPLETESEARCH
|
|
|
|
NS_DECL_NSIAUTOCOMPLETEINPUT
|
2004-07-29 08:42:54 +00:00
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
2010-09-10 05:20:16 +00:00
|
|
|
NS_DECL_NSIMUTATIONOBSERVER
|
2002-09-28 00:38:20 +00:00
|
|
|
|
2011-06-27 23:34:56 +00:00
|
|
|
nsresult Focus(nsIDOMEvent* aEvent);
|
|
|
|
nsresult KeyPress(nsIDOMEvent* aKeyEvent);
|
|
|
|
nsresult MouseDown(nsIDOMEvent* aMouseEvent);
|
2006-06-19 19:55:33 +00:00
|
|
|
|
2002-09-28 00:38:20 +00:00
|
|
|
nsFormFillController();
|
|
|
|
virtual ~nsFormFillController();
|
|
|
|
|
|
|
|
protected:
|
2004-07-29 08:42:54 +00:00
|
|
|
void AddWindowListeners(nsIDOMWindow *aWindow);
|
|
|
|
void RemoveWindowListeners(nsIDOMWindow *aWindow);
|
2011-08-04 00:52:47 +00:00
|
|
|
|
2007-04-04 19:55:04 +00:00
|
|
|
void AddKeyListener(nsIDOMHTMLInputElement *aInput);
|
|
|
|
void RemoveKeyListener();
|
2011-08-04 00:52:47 +00:00
|
|
|
|
2002-09-28 00:38:20 +00:00
|
|
|
void StartControllingInput(nsIDOMHTMLInputElement *aInput);
|
|
|
|
void StopControllingInput();
|
2011-08-04 00:52:47 +00:00
|
|
|
|
2010-09-10 05:20:16 +00:00
|
|
|
void RevalidateDataList();
|
2012-08-22 15:56:38 +00:00
|
|
|
bool RowMatch(nsFormHistory *aHistory, uint32_t aIndex, const nsAString &aInputName, const nsAString &aInputValue);
|
2011-08-04 00:52:47 +00:00
|
|
|
|
2002-09-28 00:38:20 +00:00
|
|
|
inline nsIDocShell *GetDocShellForInput(nsIDOMHTMLInputElement *aInput);
|
|
|
|
inline nsIDOMWindow *GetWindowForDocShell(nsIDocShell *aDocShell);
|
2012-08-22 15:56:38 +00:00
|
|
|
inline int32_t GetIndexOfDocShell(nsIDocShell *aDocShell);
|
2002-09-28 00:38:20 +00:00
|
|
|
|
2012-02-27 23:31:23 +00:00
|
|
|
void MaybeRemoveMutationObserver(nsINode* aNode);
|
|
|
|
|
2012-02-22 12:59:39 +00:00
|
|
|
static PLDHashOperator RemoveForDocumentEnumerator(const nsINode* aKey,
|
|
|
|
bool& aEntry,
|
|
|
|
void* aUserData);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsEventTrusted(nsIDOMEvent *aEvent);
|
2002-09-28 00:38:20 +00:00
|
|
|
// members //////////////////////////////////////////
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAutoCompleteController> mController;
|
2007-05-16 10:02:45 +00:00
|
|
|
nsCOMPtr<nsILoginManager> mLoginManager;
|
2012-02-22 12:59:39 +00:00
|
|
|
nsIDOMHTMLInputElement* mFocusedInput;
|
|
|
|
nsINode* mFocusedInputNode;
|
|
|
|
nsINode* mListNode;
|
2002-09-28 00:38:20 +00:00
|
|
|
nsCOMPtr<nsIAutoCompletePopup> mFocusedPopup;
|
|
|
|
|
2012-12-10 21:54:32 +00:00
|
|
|
nsTArray<nsCOMPtr<nsIDocShell> > mDocShells;
|
|
|
|
nsTArray<nsCOMPtr<nsIAutoCompletePopup> > mPopups;
|
2007-05-16 10:02:45 +00:00
|
|
|
|
2010-09-10 05:20:16 +00:00
|
|
|
//these are used to dynamically update the autocomplete
|
|
|
|
nsCOMPtr<nsIAutoCompleteResult> mLastSearchResult;
|
|
|
|
nsCOMPtr<nsIAutoCompleteObserver> mLastListener;
|
|
|
|
nsString mLastSearchString;
|
|
|
|
|
2012-02-22 12:59:39 +00:00
|
|
|
nsDataHashtable<nsPtrHashKey<const nsINode>, bool> mPwmgrInputs;
|
2007-05-16 10:02:45 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mTimeout;
|
|
|
|
uint32_t mMinResultsForPopup;
|
|
|
|
uint32_t mMaxRows;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mDisableAutoComplete;
|
|
|
|
bool mCompleteDefaultIndex;
|
|
|
|
bool mCompleteSelectedIndex;
|
|
|
|
bool mForceComplete;
|
|
|
|
bool mSuppressOnInput;
|
2002-09-28 00:38:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __nsFormFillController__
|