Back to index

lightning-sunbird  0.9+nobinonly
nsXBLWindowHandler.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  *   - David W. Hyatt (hyatt@netscape.com)
00024  *   - Mike Pinkerton (pinkerton@netscape.com)
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or 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 nsXBLWindowHandler_h__
00041 #define nsXBLWindowHandler_h__
00042 
00043 #include "prtypes.h"
00044 #include "nsError.h"
00045 #include "nsString.h"
00046 #include "nsCOMPtr.h"
00047 #include "nsXBLPrototypeHandler.h"
00048 #include "nsIBoxObject.h"
00049 
00050 
00051 class nsIDOMEventReceiver;
00052 class nsIDOMElement;
00053 class nsIDOMEvent;
00054 class nsIAtom;
00055 class nsIXBLDocumentInfo;
00056 class nsXBLSpecialDocInfo;
00057 
00058 
00059 //
00060 // class nsXBLWindowHandler
00061 //
00062 // A virtual base class that all window-level event handlers inherit
00063 // from. Provides the code to parse and walk the XBL bindings.
00064 //
00065 class nsXBLWindowHandler 
00066 {
00067 public:
00068 
00069   nsXBLWindowHandler(nsIDOMElement* aElement, nsIDOMEventReceiver* aReceiver);
00070   virtual ~nsXBLWindowHandler();
00071 
00072 protected:
00073 
00074   // are we working with editor or browser?
00075   PRBool IsEditor() ;
00076 
00077   // lazily load the handlers
00078   virtual nsresult EnsureHandlers(PRBool *aIsEditor);
00079   
00080   // walk the handlers, looking for one to handle the event
00081   virtual nsresult WalkHandlersInternal(nsIDOMEvent* aKeyEvent,
00082                                         nsIAtom* aEventType, 
00083                                         nsXBLPrototypeHandler* aHandler);
00084 
00085     // does the handler care about the particular event?
00086   virtual PRBool EventMatched(nsXBLPrototypeHandler* inHandler,
00087                               nsIAtom* inEventType,
00088                               nsIDOMEvent* inEvent) = 0;
00089 
00090   // Returns the element which was passed as a parameter to the constructor,
00091   // unless the element has been removed from the document.
00092   already_AddRefed<nsIDOMElement> GetElement();
00093 
00094   // Using nsIBoxObject as a weak reference to a DOM Element.
00095   nsCOMPtr<nsIBoxObject> mBoxObjectForElement;
00096   nsIDOMEventReceiver*   mReceiver;     // weak ref
00097 
00098   // these are not owning references; the prototype handlers are owned
00099   // by the prototype bindings which are owned by the docinfo.
00100   nsXBLPrototypeHandler* mHandler;            // platform bindings
00101   nsXBLPrototypeHandler* mUserHandler;        // user-specific bindings
00102 
00103   static nsXBLSpecialDocInfo* sXBLSpecialDocInfo;       // holds document info about bindings
00104     
00105 private:
00106 
00107   static PRUint32 sRefCnt;
00108 
00109 }; // class nsXBLWindowHandler
00110 
00111 
00112 #endif