2003-07-13 06:31:08 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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 04:38:20 +04:00
|
|
|
|
|
|
|
#ifndef __nsFormFillController__
|
|
|
|
#define __nsFormFillController__
|
|
|
|
|
|
|
|
#include "nsIFormFillController.h"
|
|
|
|
#include "nsIAutoCompleteInput.h"
|
|
|
|
#include "nsIAutoCompleteSearch.h"
|
|
|
|
#include "nsIAutoCompleteController.h"
|
|
|
|
#include "nsIAutoCompletePopup.h"
|
2013-04-20 02:21:30 +04:00
|
|
|
#include "nsIFormAutoComplete.h"
|
2011-06-28 03:34:56 +04:00
|
|
|
#include "nsIDOMEventListener.h"
|
2002-09-28 04:38:20 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2007-05-16 14:02:45 +04:00
|
|
|
#include "nsDataHashtable.h"
|
2002-09-28 04:38:20 +04:00
|
|
|
#include "nsIDocShell.h"
|
2007-05-16 14:02:45 +04:00
|
|
|
#include "nsILoginManager.h"
|
2010-09-10 09:20:16 +04:00
|
|
|
#include "nsIMutationObserver.h"
|
2012-12-11 01:54:32 +04:00
|
|
|
#include "nsTArray.h"
|
2014-09-10 06:45:50 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2017-12-14 05:11:45 +03:00
|
|
|
#include "nsILoginReputation.h"
|
2006-01-26 22:17:04 +03:00
|
|
|
|
2011-08-08 22:26:22 +04:00
|
|
|
// X.h defines KeyPress
|
|
|
|
#ifdef KeyPress
|
|
|
|
#undef KeyPress
|
|
|
|
#endif
|
|
|
|
|
2006-01-26 22:17:04 +03:00
|
|
|
class nsFormHistory;
|
2012-02-22 16:59:39 +04:00
|
|
|
class nsINode;
|
2016-01-30 20:05:36 +03:00
|
|
|
class nsPIDOMWindowOuter;
|
2002-09-28 04:38:20 +04:00
|
|
|
|
2018-01-30 08:25:36 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class HTMLInputElement;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsFormFillController final : public nsIFormFillController,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIAutoCompleteInput,
|
|
|
|
public nsIAutoCompleteSearch,
|
|
|
|
public nsIDOMEventListener,
|
|
|
|
public nsIFormAutoCompleteObserver,
|
|
|
|
public nsIMutationObserver
|
2002-09-28 04:38:20 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-09-10 06:45:50 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2002-09-28 04:38:20 +04:00
|
|
|
NS_DECL_NSIFORMFILLCONTROLLER
|
|
|
|
NS_DECL_NSIAUTOCOMPLETESEARCH
|
|
|
|
NS_DECL_NSIAUTOCOMPLETEINPUT
|
2013-04-20 02:21:30 +04:00
|
|
|
NS_DECL_NSIFORMAUTOCOMPLETEOBSERVER
|
2004-07-29 12:42:54 +04:00
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
2010-09-10 09:20:16 +04:00
|
|
|
NS_DECL_NSIMUTATIONOBSERVER
|
2002-09-28 04:38:20 +04:00
|
|
|
|
2014-09-10 06:45:50 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsFormFillController, nsIFormFillController)
|
|
|
|
|
2018-04-20 07:49:30 +03:00
|
|
|
nsresult Focus(mozilla::dom::Event* aEvent);
|
2018-06-22 13:37:09 +03:00
|
|
|
nsresult KeyDown(mozilla::dom::Event* aKeyEvent);
|
2018-04-20 07:49:30 +03:00
|
|
|
nsresult KeyPress(mozilla::dom::Event* aKeyEvent);
|
|
|
|
nsresult MouseDown(mozilla::dom::Event* aMouseEvent);
|
2006-06-19 23:55:33 +04:00
|
|
|
|
2002-09-28 04:38:20 +04:00
|
|
|
nsFormFillController();
|
|
|
|
|
|
|
|
protected:
|
2014-06-24 02:40:02 +04:00
|
|
|
virtual ~nsFormFillController();
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
void AddWindowListeners(nsPIDOMWindowOuter* aWindow);
|
|
|
|
void RemoveWindowListeners(nsPIDOMWindowOuter* aWindow);
|
2011-08-04 04:52:47 +04:00
|
|
|
|
2013-04-20 02:18:33 +04:00
|
|
|
void AddKeyListener(nsINode* aInput);
|
2007-04-04 23:55:04 +04:00
|
|
|
void RemoveKeyListener();
|
2011-08-04 04:52:47 +04:00
|
|
|
|
2018-01-30 08:25:36 +03:00
|
|
|
void StartControllingInput(mozilla::dom::HTMLInputElement *aInput);
|
2002-09-28 04:38:20 +04:00
|
|
|
void StopControllingInput();
|
2015-01-24 20:37:47 +03:00
|
|
|
/**
|
|
|
|
* Checks that aElement is a type of element we want to fill, then calls
|
|
|
|
* StartControllingInput on it.
|
|
|
|
*/
|
2018-01-30 08:25:36 +03:00
|
|
|
void MaybeStartControllingInput(mozilla::dom::HTMLInputElement* aElement);
|
2011-08-04 04:52:47 +04:00
|
|
|
|
2015-05-28 19:55:46 +03:00
|
|
|
nsresult PerformInputListAutoComplete(const nsAString& aSearch,
|
|
|
|
nsIAutoCompleteResult** aResult);
|
2013-04-20 02:21:30 +04:00
|
|
|
|
2010-09-10 09:20:16 +04:00
|
|
|
void RevalidateDataList();
|
2012-08-22 19:56:38 +04:00
|
|
|
bool RowMatch(nsFormHistory *aHistory, uint32_t aIndex, const nsAString &aInputName, const nsAString &aInputValue);
|
2011-08-04 04:52:47 +04:00
|
|
|
|
2018-01-30 08:25:36 +03:00
|
|
|
inline nsIDocShell *GetDocShellForInput(mozilla::dom::HTMLInputElement *aInput);
|
2016-01-30 20:05:36 +03:00
|
|
|
inline nsPIDOMWindowOuter *GetWindowForDocShell(nsIDocShell *aDocShell);
|
2012-08-22 19:56:38 +04:00
|
|
|
inline int32_t GetIndexOfDocShell(nsIDocShell *aDocShell);
|
2002-09-28 04:38:20 +04:00
|
|
|
|
2012-02-28 03:31:23 +04:00
|
|
|
void MaybeRemoveMutationObserver(nsINode* aNode);
|
|
|
|
|
2015-11-25 03:53:46 +03:00
|
|
|
void RemoveForDocument(nsIDocument* aDoc);
|
2017-02-10 14:45:26 +03:00
|
|
|
|
2017-06-21 04:37:20 +03:00
|
|
|
bool IsTextControl(nsINode* aNode);
|
|
|
|
|
2018-01-30 08:25:36 +03:00
|
|
|
nsresult StartQueryLoginReputation(mozilla::dom::HTMLInputElement *aInput);
|
2017-12-14 05:11:45 +03:00
|
|
|
|
2002-09-28 04:38:20 +04:00
|
|
|
// members //////////////////////////////////////////
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAutoCompleteController> mController;
|
2007-05-16 14:02:45 +04:00
|
|
|
nsCOMPtr<nsILoginManager> mLoginManager;
|
2017-12-14 05:11:45 +03:00
|
|
|
nsCOMPtr<nsILoginReputationService> mLoginReputationService;
|
2018-01-30 08:25:36 +03:00
|
|
|
mozilla::dom::HTMLInputElement* mFocusedInput;
|
2013-04-20 02:21:30 +04:00
|
|
|
|
|
|
|
// mListNode is a <datalist> element which, is set, has the form fill controller
|
|
|
|
// as a mutation observer for it.
|
2012-02-22 16:59:39 +04:00
|
|
|
nsINode* mListNode;
|
2002-09-28 04:38:20 +04:00
|
|
|
nsCOMPtr<nsIAutoCompletePopup> mFocusedPopup;
|
|
|
|
|
2012-12-11 01:54:32 +04:00
|
|
|
nsTArray<nsCOMPtr<nsIDocShell> > mDocShells;
|
|
|
|
nsTArray<nsCOMPtr<nsIAutoCompletePopup> > mPopups;
|
2007-05-16 14:02:45 +04:00
|
|
|
|
2013-04-20 02:21:30 +04:00
|
|
|
// The observer passed to StartSearch. It will be notified when the search is
|
|
|
|
// complete or the data from a datalist changes.
|
2010-09-10 09:20:16 +04:00
|
|
|
nsCOMPtr<nsIAutoCompleteObserver> mLastListener;
|
2013-04-20 02:21:30 +04:00
|
|
|
|
|
|
|
// This is cleared by StopSearch().
|
|
|
|
nsCOMPtr<nsIFormAutoComplete> mLastFormAutoComplete;
|
2010-09-10 09:20:16 +04:00
|
|
|
nsString mLastSearchString;
|
|
|
|
|
2012-02-22 16:59:39 +04:00
|
|
|
nsDataHashtable<nsPtrHashKey<const nsINode>, bool> mPwmgrInputs;
|
2016-09-22 10:26:28 +03:00
|
|
|
nsDataHashtable<nsPtrHashKey<const nsINode>, bool> mAutofillInputs;
|
2007-05-16 14:02:45 +04:00
|
|
|
|
2017-04-07 01:01:31 +03:00
|
|
|
uint16_t mFocusAfterRightClickThreshold;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mTimeout;
|
|
|
|
uint32_t mMinResultsForPopup;
|
|
|
|
uint32_t mMaxRows;
|
2017-04-07 01:01:31 +03:00
|
|
|
mozilla::TimeStamp mLastRightClickTimeStamp;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mDisableAutoComplete;
|
|
|
|
bool mCompleteDefaultIndex;
|
|
|
|
bool mCompleteSelectedIndex;
|
|
|
|
bool mForceComplete;
|
|
|
|
bool mSuppressOnInput;
|
2002-09-28 04:38:20 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __nsFormFillController__
|