1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is Mozilla Communicator client code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
23 * Joe Hewitt <hewitt@netscape.com> (Original Author)
24 * Dean Tessman <dean_tessman@hotmail.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef __nsFormFillController__
41 #define __nsFormFillController__
43 #include "nsIFormFillController.h"
44 #include "nsIAutoCompleteInput.h"
45 #include "nsIAutoCompleteSearch.h"
46 #include "nsIAutoCompleteController.h"
47 #include "nsIAutoCompletePopup.h"
48 #include "nsIDOMFocusListener.h"
49 #include "nsIDOMKeyListener.h"
50 #include "nsIDOMCompositionListener.h"
51 #include "nsIDOMFormListener.h"
52 #include "nsIDOMMouseListener.h"
53 #include "nsIDOMContextMenuListener.h"
55 #include "nsISupportsArray.h"
56 #include "nsDataHashtable.h"
57 #include "nsIDocShell.h"
58 #include "nsIDOMWindow.h"
59 #include "nsIDOMHTMLInputElement.h"
60 #include "nsILoginManager.h"
64 class nsFormFillController
: public nsIFormFillController
,
65 public nsIAutoCompleteInput
,
66 public nsIAutoCompleteSearch
,
67 public nsIDOMFocusListener
,
68 public nsIDOMKeyListener
,
69 public nsIDOMCompositionListener
,
70 public nsIDOMFormListener
,
71 public nsIDOMMouseListener
,
72 public nsIDOMContextMenuListener
76 NS_DECL_NSIFORMFILLCONTROLLER
77 NS_DECL_NSIAUTOCOMPLETESEARCH
78 NS_DECL_NSIAUTOCOMPLETEINPUT
79 NS_DECL_NSIDOMEVENTLISTENER
81 // nsIDOMFocusListener
82 NS_IMETHOD
Focus(nsIDOMEvent
* aEvent
);
83 NS_IMETHOD
Blur(nsIDOMEvent
* aEvent
);
86 NS_IMETHOD
KeyDown(nsIDOMEvent
* aKeyEvent
);
87 NS_IMETHOD
KeyUp(nsIDOMEvent
* aKeyEvent
);
88 NS_IMETHOD
KeyPress(nsIDOMEvent
* aKeyEvent
);
90 // nsIDOMCompositionListener
91 NS_IMETHOD
HandleStartComposition(nsIDOMEvent
* aCompositionEvent
);
92 NS_IMETHOD
HandleEndComposition(nsIDOMEvent
* aCompositionEvent
);
93 NS_IMETHOD
HandleQueryComposition(nsIDOMEvent
* aCompositionEvent
);
96 NS_IMETHOD
Submit(nsIDOMEvent
* aEvent
);
97 NS_IMETHOD
Reset(nsIDOMEvent
* aEvent
);
98 NS_IMETHOD
Change(nsIDOMEvent
* aEvent
);
99 NS_IMETHOD
Select(nsIDOMEvent
* aEvent
);
100 NS_IMETHOD
Input(nsIDOMEvent
* aEvent
);
102 // nsIDOMMouseListener
103 NS_IMETHOD
MouseDown(nsIDOMEvent
* aMouseEvent
);
104 NS_IMETHOD
MouseUp(nsIDOMEvent
* aMouseEvent
);
105 NS_IMETHOD
MouseClick(nsIDOMEvent
* aMouseEvent
);
106 NS_IMETHOD
MouseDblClick(nsIDOMEvent
* aMouseEvent
);
107 NS_IMETHOD
MouseOver(nsIDOMEvent
* aMouseEvent
);
108 NS_IMETHOD
MouseOut(nsIDOMEvent
* aMouseEvent
);
110 // nsIDOMContextMenuListener
111 NS_IMETHOD
ContextMenu(nsIDOMEvent
* aContextMenuEvent
);
113 nsFormFillController();
114 virtual ~nsFormFillController();
117 void AddWindowListeners(nsIDOMWindow
*aWindow
);
118 void RemoveWindowListeners(nsIDOMWindow
*aWindow
);
120 void AddKeyListener(nsIDOMHTMLInputElement
*aInput
);
121 void RemoveKeyListener();
123 void StartControllingInput(nsIDOMHTMLInputElement
*aInput
);
124 void StopControllingInput();
126 PRBool
RowMatch(nsFormHistory
*aHistory
, PRUint32 aIndex
, const nsAString
&aInputName
, const nsAString
&aInputValue
);
128 inline nsIDocShell
*GetDocShellForInput(nsIDOMHTMLInputElement
*aInput
);
129 inline nsIDOMWindow
*GetWindowForDocShell(nsIDocShell
*aDocShell
);
130 inline PRInt32
GetIndexOfDocShell(nsIDocShell
*aDocShell
);
132 static PLDHashOperator PR_CALLBACK
RemoveForDOMDocumentEnumerator(nsISupports
* aKey
,
135 // members //////////////////////////////////////////
137 nsCOMPtr
<nsIAutoCompleteController
> mController
;
138 nsCOMPtr
<nsILoginManager
> mLoginManager
;
139 nsCOMPtr
<nsIDOMHTMLInputElement
> mFocusedInput
;
140 nsCOMPtr
<nsIAutoCompletePopup
> mFocusedPopup
;
142 nsCOMPtr
<nsISupportsArray
> mDocShells
;
143 nsCOMPtr
<nsISupportsArray
> mPopups
;
145 nsDataHashtable
<nsISupportsHashKey
,PRInt32
> mPwmgrInputs
;
148 PRUint32 mMinResultsForPopup
;
150 PRPackedBool mDisableAutoComplete
;
151 PRPackedBool mCompleteDefaultIndex
;
152 PRPackedBool mCompleteSelectedIndex
;
153 PRPackedBool mForceComplete
;
154 PRPackedBool mSuppressOnInput
;
157 #endif // __nsFormFillController__