Back to index

lightning-sunbird  0.9+nobinonly
nsDOMEvent.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.org 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  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef nsDOMEvent_h__
00039 #define nsDOMEvent_h__
00040 
00041 #include "nsIDOMEvent.h"
00042 #include "nsIDOMNSEvent.h"
00043 #include "nsISupports.h"
00044 #include "nsIPrivateDOMEvent.h"
00045 #include "nsCOMPtr.h"
00046 #include "nsIDOMEventTarget.h"
00047 #include "nsPIDOMWindow.h"
00048 #include "nsPresContext.h"
00049 #include "nsPoint.h"
00050 #include "nsGUIEvent.h"
00051 #include "nsRecycled.h"
00052 
00053 class nsIContent;
00054 class nsIScrollableView;
00055 
00056 /* Currently we use a single-object recycler (nsRecycledSingle).
00057  * With our current usage pattern, we almost never have more than
00058  * a single nsDOMEvent active in memory at a time under normal circumstances.
00059  */
00060  
00061 class nsDOMEvent : public nsIDOMEvent,
00062                    public nsIDOMNSEvent,
00063                    public nsIPrivateDOMEvent,
00064                    public nsRecycledSingle<nsDOMEvent>
00065 {
00066 public:
00067 
00068   // Note: this enum must be kept in sync with mEventNames in nsDOMEvent.cpp
00069   enum nsDOMEvents {
00070     eDOMEvents_mousedown=0,
00071     eDOMEvents_mouseup,
00072     eDOMEvents_click,
00073     eDOMEvents_dblclick,
00074     eDOMEvents_mouseover,
00075     eDOMEvents_mouseout,
00076     eDOMEvents_mousemove,
00077     eDOMEvents_contextmenu,
00078     eDOMEvents_keydown,
00079     eDOMEvents_keyup,
00080     eDOMEvents_keypress,
00081     eDOMEvents_focus,
00082     eDOMEvents_blur,
00083     eDOMEvents_load,
00084     eDOMEvents_beforeunload,
00085     eDOMEvents_unload,
00086     eDOMEvents_abort,
00087     eDOMEvents_error,
00088     eDOMEvents_submit,
00089     eDOMEvents_reset,
00090     eDOMEvents_change,
00091     eDOMEvents_select,
00092     eDOMEvents_input,
00093     eDOMEvents_paint,
00094     eDOMEvents_text,
00095     eDOMEvents_compositionstart,
00096     eDOMEvents_compositionend,
00097     eDOMEvents_popupShowing,
00098     eDOMEvents_popupShown,
00099     eDOMEvents_popupHiding,
00100     eDOMEvents_popupHidden,
00101     eDOMEvents_close,
00102     eDOMEvents_command,
00103     eDOMEvents_broadcast,
00104     eDOMEvents_commandupdate,
00105     eDOMEvents_dragenter,
00106     eDOMEvents_dragover,
00107     eDOMEvents_dragexit,
00108     eDOMEvents_dragdrop,
00109     eDOMEvents_draggesture,
00110     eDOMEvents_resize,
00111     eDOMEvents_scroll,
00112     eDOMEvents_overflow,
00113     eDOMEvents_underflow,
00114     eDOMEvents_overflowchanged,
00115     eDOMEvents_subtreemodified,
00116     eDOMEvents_nodeinserted,
00117     eDOMEvents_noderemoved,
00118     eDOMEvents_noderemovedfromdocument,
00119     eDOMEvents_nodeinsertedintodocument,
00120     eDOMEvents_attrmodified,
00121     eDOMEvents_characterdatamodified,
00122     eDOMEvents_DOMActivate,
00123     eDOMEvents_DOMFocusIn,
00124     eDOMEvents_DOMFocusOut,
00125     eDOMEvents_pageshow,
00126     eDOMEvents_pagehide
00127 #ifdef MOZ_SVG
00128    ,
00129     eDOMEvents_SVGLoad,
00130     eDOMEvents_SVGUnload,
00131     eDOMEvents_SVGAbort,
00132     eDOMEvents_SVGError,
00133     eDOMEvents_SVGResize,
00134     eDOMEvents_SVGScroll,
00135     eDOMEvents_SVGZoom
00136 #endif // MOZ_SVG
00137   };
00138 
00139   nsDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent);
00140   virtual ~nsDOMEvent();
00141 
00142   NS_DECL_ISUPPORTS
00143 
00144   // nsIDOMEvent Interface
00145   NS_DECL_NSIDOMEVENT
00146 
00147   // nsIDOMNSEvent Interface
00148   NS_DECL_NSIDOMNSEVENT
00149 
00150   // nsIPrivateDOMEvent interface
00151   NS_IMETHOD    DuplicatePrivateData();
00152   NS_IMETHOD    SetTarget(nsIDOMEventTarget* aTarget);
00153   NS_IMETHOD    SetCurrentTarget(nsIDOMEventTarget* aCurrentTarget);
00154   NS_IMETHOD    SetOriginalTarget(nsIDOMEventTarget* aOriginalTarget);
00155   NS_IMETHOD    IsDispatchStopped(PRBool* aIsDispatchStopped);
00156   NS_IMETHOD    GetInternalNSEvent(nsEvent** aNSEvent);
00157   NS_IMETHOD    HasOriginalTarget(PRBool* aResult);
00158   NS_IMETHOD    SetTrusted(PRBool aTrusted);
00159 
00160   NS_IMETHOD    IsHandled(PRBool* aHandled);
00161   NS_IMETHOD    SetHandled(PRBool aHandled);
00162 
00163   static PopupControlState GetEventPopupControlState(nsEvent *aEvent);
00164 
00165   static void PopupAllowedEventsChanged();
00166 
00167   static void Shutdown();
00168 
00169 protected:
00170 
00171   // Internal helper functions
00172   nsresult SetEventType(const nsAString& aEventTypeArg);
00173   static const char* GetEventName(PRUint32 aEventType);
00174   already_AddRefed<nsIDOMEventTarget> GetTargetFromFrame();
00175 
00176   nsEvent* mEvent;
00177   nsCOMPtr<nsPresContext> mPresContext;
00178   nsCOMPtr<nsIDOMEventTarget> mTarget;
00179   nsCOMPtr<nsIDOMEventTarget> mCurrentTarget;
00180   nsCOMPtr<nsIDOMEventTarget> mOriginalTarget;
00181   nsCOMPtr<nsIDOMEventTarget> mExplicitOriginalTarget;
00182   nsCOMPtr<nsIDOMEventTarget> mTmpRealOriginalTarget;
00183   PRPackedBool mEventIsInternal;
00184 
00185   void* mScriptObject;
00186 };
00187 
00188 #define NS_FORWARD_TO_NSDOMEVENT \
00189   NS_FORWARD_NSIDOMEVENT(nsDOMEvent::)
00190 
00191 #endif // nsDOMEvent_h__