Back to index

lightning-sunbird  0.9+nobinonly
nsFormFillController.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Joe Hewitt <hewitt@netscape.com> (Original Author)
00024  *   Dean Tessman <dean_tessman@hotmail.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #ifndef __nsFormFillController__
00041 #define __nsFormFillController__
00042 
00043 #include "nsIFormFillController.h"
00044 #include "nsIAutoCompleteInput.h"
00045 #include "nsIAutoCompleteSearch.h"
00046 #include "nsIAutoCompleteController.h"
00047 #include "nsIAutoCompletePopup.h"
00048 #include "nsIDOMFocusListener.h"
00049 #include "nsIDOMKeyListener.h"
00050 #include "nsIDOMCompositionListener.h"
00051 #include "nsIDOMFormListener.h"
00052 #include "nsIDOMMouseListener.h"
00053 #include "nsIDOMLoadListener.h"
00054 #include "nsIDOMContextMenuListener.h"
00055 #include "nsCOMPtr.h"
00056 #include "nsISupportsArray.h"
00057 #include "nsIDocShell.h"
00058 #include "nsIDOMWindow.h"
00059 #include "nsIDOMHTMLInputElement.h"
00060 
00061 class nsFormHistory;
00062 
00063 class nsFormFillController : public nsIFormFillController,
00064                              public nsIAutoCompleteInput_MOZILLA_1_8_BRANCH,
00065                              public nsIAutoCompleteSearch,
00066                              public nsIDOMFocusListener,
00067                              public nsIDOMKeyListener,
00068                              public nsIDOMCompositionListener,
00069                              public nsIDOMFormListener,
00070                              public nsIDOMMouseListener,
00071                              public nsIDOMLoadListener,
00072                              public nsIDOMContextMenuListener
00073 {
00074 public:
00075   NS_DECL_ISUPPORTS
00076   NS_DECL_NSIFORMFILLCONTROLLER
00077   NS_DECL_NSIAUTOCOMPLETESEARCH
00078   NS_DECL_NSIAUTOCOMPLETEINPUT
00079   NS_DECL_NSIAUTOCOMPLETEINPUT_MOZILLA_1_8_BRANCH
00080   NS_DECL_NSIDOMEVENTLISTENER
00081 
00082   // nsIDOMFocusListener
00083   NS_IMETHOD Focus(nsIDOMEvent* aEvent);
00084   NS_IMETHOD Blur(nsIDOMEvent* aEvent);
00085 
00086   // nsIDOMKeyListener
00087   NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
00088   NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
00089   NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
00090 
00091   // nsIDOMCompositionListener
00092   NS_IMETHOD HandleStartComposition(nsIDOMEvent* aCompositionEvent);
00093   NS_IMETHOD HandleEndComposition(nsIDOMEvent* aCompositionEvent);
00094   NS_IMETHOD HandleQueryComposition(nsIDOMEvent* aCompositionEvent);
00095   NS_IMETHOD HandleQueryReconversion(nsIDOMEvent* aCompositionEvent);
00096   NS_IMETHOD HandleQueryCaretRect(nsIDOMEvent* aCompositionEvent);
00097 
00098   // nsIDOMFormListener
00099   NS_IMETHOD Submit(nsIDOMEvent* aEvent);
00100   NS_IMETHOD Reset(nsIDOMEvent* aEvent);
00101   NS_IMETHOD Change(nsIDOMEvent* aEvent);
00102   NS_IMETHOD Select(nsIDOMEvent* aEvent);
00103   NS_IMETHOD Input(nsIDOMEvent* aEvent);
00104 
00105   // nsIDOMMouseListener
00106   NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
00107   NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
00108   NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
00109   NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent);
00110   NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent);
00111   NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent);
00112 
00113   // nsIDOMLoadListener
00114   NS_IMETHOD Load(nsIDOMEvent *aLoadEvent);
00115   NS_IMETHOD BeforeUnload(nsIDOMEvent *aLoadEvent);
00116   NS_IMETHOD Unload(nsIDOMEvent *aLoadEvent);
00117   NS_IMETHOD Abort(nsIDOMEvent *aLoadEvent);
00118   NS_IMETHOD Error(nsIDOMEvent *aLoadEvent);
00119 
00120   // nsIDOMContextMenuListener
00121   NS_IMETHOD ContextMenu(nsIDOMEvent* aContextMenuEvent);
00122 
00123   nsFormFillController();
00124   virtual ~nsFormFillController();
00125 
00126 protected:
00127   void AddWindowListeners(nsIDOMWindow *aWindow);
00128   void RemoveWindowListeners(nsIDOMWindow *aWindow);
00129   
00130   void AddKeyListener(nsIDOMHTMLInputElement *aInput);
00131   void RemoveKeyListener();
00132   
00133   void StartControllingInput(nsIDOMHTMLInputElement *aInput);
00134   void StopControllingInput();
00135   
00136   PRBool RowMatch(nsFormHistory *aHistory, PRUint32 aIndex, const nsAString &aInputName, const nsAString &aInputValue);
00137   
00138   inline nsIDocShell *GetDocShellForInput(nsIDOMHTMLInputElement *aInput);
00139   inline nsIDOMWindow *GetWindowForDocShell(nsIDocShell *aDocShell);
00140   inline PRInt32 GetIndexOfDocShell(nsIDocShell *aDocShell);
00141 
00142   // members //////////////////////////////////////////
00143 
00144   nsCOMPtr<nsIAutoCompleteController> mController;
00145   nsCOMPtr<nsIDOMHTMLInputElement> mFocusedInput;
00146   nsCOMPtr<nsIAutoCompletePopup> mFocusedPopup;
00147 
00148   nsCOMPtr<nsISupportsArray> mDocShells;
00149   nsCOMPtr<nsISupportsArray> mPopups;
00150   
00151   PRUint32 mTimeout;
00152   PRUint32 mMinResultsForPopup;
00153   PRUint32 mMaxRows;
00154   PRPackedBool mDisableAutoComplete; 
00155   PRPackedBool mCompleteDefaultIndex;
00156   PRPackedBool mCompleteSelectedIndex;
00157   PRPackedBool mForceComplete;
00158   PRPackedBool mSuppressOnInput;
00159   PRPackedBool mIgnoreClick;
00160 };
00161 
00162 #endif // __nsFormFillController__