2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Mozilla.org.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2006
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Olli Pettay <Olli.Pettay@helsinki.fi> (Original Author)
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#ifndef nsPIDOMEventTarget_h_
|
|
|
|
#define nsPIDOMEventTarget_h_
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsEvent.h"
|
|
|
|
|
|
|
|
class nsIDOMEvent;
|
|
|
|
class nsPresContext;
|
|
|
|
class nsEventChainPreVisitor;
|
|
|
|
class nsEventChainPostVisitor;
|
|
|
|
class nsIEventListenerManager;
|
2007-05-14 02:11:38 -07:00
|
|
|
class nsIDOMEventListener;
|
|
|
|
class nsIDOMEventGroup;
|
2008-07-19 08:11:37 -07:00
|
|
|
class nsIScriptContext;
|
2010-02-20 09:05:20 -08:00
|
|
|
struct JSContext;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-02-20 09:05:20 -08:00
|
|
|
// 89292f3a-535d-4ba0-882a-10cff9e21bcc
|
2007-03-22 10:30:00 -07:00
|
|
|
#define NS_PIDOMEVENTTARGET_IID \
|
2010-02-20 09:05:20 -08:00
|
|
|
{ 0x89292f3a, 0x535d, 0x4ba0, \
|
|
|
|
{ 0x88, 0x2a, 0x10, 0xcf, 0xf9, 0xe2, 0x1b, 0xcc } }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsPIDOMEventTarget : public nsISupports
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_PIDOMEVENTTARGET_IID)
|
|
|
|
|
2007-04-17 02:18:36 -07:00
|
|
|
/**
|
|
|
|
* Returns the nsPIDOMEventTarget object which should be used as the target
|
|
|
|
* of DOMEvents.
|
|
|
|
* Usually |this| is returned, but for example global object returns
|
|
|
|
* the outer object.
|
|
|
|
*/
|
|
|
|
virtual nsPIDOMEventTarget* GetTargetForDOMEvent() { return this; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the nsPIDOMEventTarget object which should be used as the target
|
|
|
|
* of the event and when constructing event target chain.
|
|
|
|
* Usually |this| is returned, but for example global object returns
|
|
|
|
* the inner object.
|
|
|
|
*/
|
|
|
|
virtual nsPIDOMEventTarget* GetTargetForEventTargetChain() { return this; }
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Called before the capture phase of the event flow.
|
|
|
|
* This is used to create the event target chain and implementations
|
|
|
|
* should set the necessary members of nsEventChainPreVisitor.
|
|
|
|
* At least aVisitor.mCanHandle must be set,
|
|
|
|
* usually also aVisitor.mParentTarget if mCanHandle is PR_TRUE.
|
|
|
|
* First one tells that this object can handle the aVisitor.mEvent event and
|
|
|
|
* the latter one is the possible parent object for the event target chain.
|
|
|
|
* @see nsEventDispatcher.h for more documentation about aVisitor.
|
|
|
|
*
|
|
|
|
* @param aVisitor the visitor object which is used to create the
|
|
|
|
* event target chain for event dispatching.
|
|
|
|
*
|
|
|
|
* @note Only nsEventDispatcher should call this method.
|
|
|
|
*/
|
|
|
|
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) = 0;
|
|
|
|
|
2008-04-17 15:15:07 -07:00
|
|
|
/**
|
2008-10-08 04:35:29 -07:00
|
|
|
* If nsEventChainPreVisitor.mWantsWillHandleEvent is set PR_TRUE,
|
|
|
|
* called just before possible event handlers on this object will be called.
|
2008-04-17 15:15:07 -07:00
|
|
|
*/
|
|
|
|
virtual nsresult WillHandleEvent(nsEventChainPostVisitor& aVisitor)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Called after the bubble phase of the system event group.
|
|
|
|
* The default handling of the event should happen here.
|
|
|
|
* @param aVisitor the visitor object which is used during post handling.
|
|
|
|
*
|
|
|
|
* @see nsEventDispatcher.h for documentation about aVisitor.
|
|
|
|
* @note Only nsEventDispatcher should call this method.
|
|
|
|
*/
|
|
|
|
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatch an event.
|
|
|
|
* @param aEvent the event that is being dispatched.
|
|
|
|
* @param aDOMEvent the event that is being dispatched, use if you want to
|
|
|
|
* dispatch nsIDOMEvent, not only nsEvent.
|
|
|
|
* @param aPresContext the current presentation context, can be nsnull.
|
|
|
|
* @param aEventStatus the status returned from the function, can be nsnull.
|
|
|
|
*
|
|
|
|
* @note If both aEvent and aDOMEvent are used, aEvent must be the internal
|
|
|
|
* event of the aDOMEvent.
|
|
|
|
*
|
|
|
|
* If aDOMEvent is not nsnull (in which case aEvent can be nsnull) it is used
|
|
|
|
* for dispatching, otherwise aEvent is used.
|
|
|
|
*
|
|
|
|
* @deprecated This method is here just until all the callers outside Gecko
|
|
|
|
* have been converted to use nsIDOMEventTarget::dispatchEvent.
|
|
|
|
*/
|
|
|
|
virtual nsresult DispatchDOMEvent(nsEvent* aEvent,
|
|
|
|
nsIDOMEvent* aDOMEvent,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsEventStatus* aEventStatus) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the event listener manager, the guy you talk to to register for events
|
|
|
|
* on this node.
|
2009-06-23 04:23:52 -07:00
|
|
|
* @param aMayCreate If PR_FALSE, returns a listener manager only if
|
|
|
|
* one already exists.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2009-06-23 04:23:52 -07:00
|
|
|
virtual nsIEventListenerManager* GetListenerManager(PRBool aMayCreate) = 0;
|
2007-05-14 02:11:38 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add an event listener for nsIID.
|
|
|
|
*/
|
|
|
|
virtual nsresult AddEventListenerByIID(nsIDOMEventListener *aListener,
|
|
|
|
const nsIID& aIID) = 0;
|
|
|
|
/**
|
|
|
|
* Remove event listener for nsIID.
|
|
|
|
*/
|
|
|
|
virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener,
|
|
|
|
const nsIID& aIID) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the system event group.
|
|
|
|
*/
|
|
|
|
virtual nsresult GetSystemEventGroup(nsIDOMEventGroup** aGroup) = 0;
|
2008-07-19 08:11:37 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the script context in which the event handlers should be run.
|
|
|
|
* May return null.
|
2009-04-24 02:18:37 -07:00
|
|
|
* @note Caller *must* check the value of aRv.
|
2008-07-19 08:11:37 -07:00
|
|
|
*/
|
2009-04-24 02:18:37 -07:00
|
|
|
virtual nsIScriptContext* GetContextForEventHandlers(nsresult* aRv) = 0;
|
2010-02-20 09:05:20 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If the method above returns null, but a success code, this method
|
|
|
|
* is called.
|
|
|
|
*/
|
|
|
|
virtual JSContext* GetJSContextForEventHandlers() { return nsnull; }
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsPIDOMEventTarget, NS_PIDOMEVENTTARGET_IID)
|
|
|
|
|
|
|
|
#endif // !defined(nsPIDOMEventTarget_h_)
|