LCOV - code coverage report
Current view: directory - content/xbl/src - nsXBLEventHandler.h (source / functions) Found Hit Coverage
Test: app.info Lines: 17 0 0.0 %
Date: 2012-06-02 Functions: 7 0 0.0 %

       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
       4                 :  *
       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/
       9                 :  *
      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
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is Mozilla Communicator client code.
      16                 :  *
      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.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Original Author: David W. Hyatt (hyatt@netscape.com)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      27                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #ifndef nsXBLEventHandler_h__
      40                 : #define nsXBLEventHandler_h__
      41                 : 
      42                 : #include "nsCOMPtr.h"
      43                 : #include "nsIDOMEventListener.h"
      44                 : #include "nsTArray.h"
      45                 : 
      46                 : class nsIAtom;
      47                 : class nsIContent;
      48                 : class nsIDOMKeyEvent;
      49                 : class nsXBLPrototypeHandler;
      50                 : 
      51                 : class nsXBLEventHandler : public nsIDOMEventListener
      52                 : {
      53                 : public:
      54                 :   nsXBLEventHandler(nsXBLPrototypeHandler* aHandler);
      55                 :   virtual ~nsXBLEventHandler();
      56                 : 
      57                 :   NS_DECL_ISUPPORTS
      58                 : 
      59                 :   NS_DECL_NSIDOMEVENTLISTENER
      60                 : 
      61                 : protected:
      62                 :   nsXBLPrototypeHandler* mProtoHandler;
      63                 : 
      64                 : private:
      65                 :   nsXBLEventHandler();
      66               0 :   virtual bool EventMatched(nsIDOMEvent* aEvent)
      67                 :   {
      68               0 :     return true;
      69                 :   }
      70                 : };
      71                 : 
      72                 : class nsXBLMouseEventHandler : public nsXBLEventHandler
      73                 : {
      74                 : public:
      75                 :   nsXBLMouseEventHandler(nsXBLPrototypeHandler* aHandler);
      76                 :   virtual ~nsXBLMouseEventHandler();
      77                 : 
      78                 : private:
      79                 :   bool EventMatched(nsIDOMEvent* aEvent);
      80                 : };
      81                 : 
      82                 : class nsXBLKeyEventHandler : public nsIDOMEventListener
      83                 : {
      84                 : public:
      85                 :   nsXBLKeyEventHandler(nsIAtom* aEventType, PRUint8 aPhase, PRUint8 aType);
      86                 :   virtual ~nsXBLKeyEventHandler();
      87                 : 
      88                 :   NS_DECL_ISUPPORTS
      89                 : 
      90                 :   NS_DECL_NSIDOMEVENTLISTENER
      91                 : 
      92               0 :   void AddProtoHandler(nsXBLPrototypeHandler* aProtoHandler)
      93                 :   {
      94               0 :     mProtoHandlers.AppendElement(aProtoHandler);
      95               0 :   }
      96                 : 
      97               0 :   bool Matches(nsIAtom* aEventType, PRUint8 aPhase, PRUint8 aType) const
      98                 :   {
      99               0 :     return (mEventType == aEventType && mPhase == aPhase && mType == aType);
     100                 :   }
     101                 : 
     102               0 :   void GetEventName(nsAString& aString) const
     103                 :   {
     104               0 :     mEventType->ToString(aString);
     105               0 :   }
     106                 : 
     107               0 :   PRUint8 GetPhase() const
     108                 :   {
     109               0 :     return mPhase;
     110                 :   }
     111                 : 
     112               0 :   PRUint8 GetType() const
     113                 :   {
     114               0 :     return mType;
     115                 :   }
     116                 : 
     117               0 :   void SetIsBoundToChrome(bool aIsBoundToChrome)
     118                 :   {
     119               0 :     mIsBoundToChrome = aIsBoundToChrome;
     120               0 :   }
     121                 : private:
     122                 :   nsXBLKeyEventHandler();
     123                 :   bool ExecuteMatchedHandlers(nsIDOMKeyEvent* aEvent, PRUint32 aCharCode,
     124                 :                                 bool aIgnoreShiftKey);
     125                 : 
     126                 :   nsTArray<nsXBLPrototypeHandler*> mProtoHandlers;
     127                 :   nsCOMPtr<nsIAtom> mEventType;
     128                 :   PRUint8 mPhase;
     129                 :   PRUint8 mType;
     130                 :   bool mIsBoundToChrome;
     131                 : };
     132                 : 
     133                 : nsresult
     134                 : NS_NewXBLEventHandler(nsXBLPrototypeHandler* aHandler,
     135                 :                       nsIAtom* aEventType,
     136                 :                       nsXBLEventHandler** aResult);
     137                 : 
     138                 : nsresult
     139                 : NS_NewXBLKeyEventHandler(nsIAtom* aEventType, PRUint8 aPhase,
     140                 :                          PRUint8 aType, nsXBLKeyEventHandler** aResult);
     141                 : 
     142                 : #endif

Generated by: LCOV version 1.7