Bug 658714 Part 1: Merge nsPIDOMEventTarget into nsIDOMEventTarget. r=smaug,bent

This commit is contained in:
Jonas Sicking 2011-06-23 19:17:58 -07:00
parent 05d24287f8
commit 50c51df5f9
34 changed files with 638 additions and 202 deletions

View File

@ -123,7 +123,6 @@ class nsIUGenCategory;
class nsIWidget;
class nsIDragSession;
class nsPIDOMWindow;
class nsPIDOMEventTarget;
class nsIPresShell;
class nsIXPConnectJSObjectHolder;
#ifdef MOZ_XTF
@ -1821,10 +1820,10 @@ public:
~nsCxPusher(); // Calls Pop();
// Returns PR_FALSE if something erroneous happened.
PRBool Push(nsPIDOMEventTarget *aCurrentTarget);
PRBool Push(nsIDOMEventTarget *aCurrentTarget);
// If nothing has been pushed to stack, this works like Push.
// Otherwise if context will change, Pop and Push will be called.
PRBool RePush(nsPIDOMEventTarget *aCurrentTarget);
PRBool RePush(nsIDOMEventTarget *aCurrentTarget);
// If a null JSContext is passed to Push(), that will cause no
// push to happen and false to be returned.
PRBool Push(JSContext *cx, PRBool aRequiresScriptContext = PR_TRUE);

View File

@ -288,7 +288,7 @@ private:
* nsIContent and nsIDocument share. An instance of this interface has a list
* of nsIContent children and provides access to them.
*/
class nsINode : public nsPIDOMEventTarget,
class nsINode : public nsIDOMEventTarget,
public nsWrapperCache
{
public:
@ -704,6 +704,15 @@ public:
return mParent;
}
/**
* See nsIDOMNSEventTarget
*/
NS_IMETHOD AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
PRBool aUseCapture,
PRBool aWantsUntrusted,
PRUint8 optional_argc);
/**
* Adds a mutation observer to be notified when this node, or any of its
* descendants, are modified. The node will hold a weak reference to the

View File

@ -132,12 +132,10 @@ DOMCI_NODE_DATA(Attr, nsDOMAttribute)
NS_INTERFACE_TABLE_HEAD(nsDOMAttribute)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_NODE_INTERFACE_TABLE6(nsDOMAttribute, nsIDOMAttr, nsIAttribute, nsIDOMNode,
nsIDOM3Attr, nsPIDOMEventTarget, nsIMutationObserver)
nsIDOM3Attr, nsIDOMEventTarget, nsIMutationObserver)
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsDOMAttribute)
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
new nsNodeSupportsWeakRefTearoff(this))
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMEventTarget,
nsDOMEventRTTearoff::Create(this))
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3EventTarget,
nsDOMEventRTTearoff::Create(this))
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSEventTarget,
@ -792,6 +790,38 @@ nsDOMAttribute::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
return NS_OK;
}
NS_IMPL_DOMTARGET_DEFAULTS(nsDOMAttribute)
NS_IMETHODIMP
nsDOMAttribute::AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
PRBool useCapture)
{
return AddEventListener(aType, aListener, useCapture, PR_FALSE, 1);
}
NS_IMETHODIMP
nsDOMAttribute::RemoveEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture)
{
nsCOMPtr<nsIDOMEventTarget> event_target =
do_QueryInterface(GetListenerManager(PR_TRUE));
NS_ENSURE_STATE(event_target);
return event_target->RemoveEventListener(aType, aListener, aUseCapture);
}
NS_IMETHODIMP
nsDOMAttribute::DispatchEvent(nsIDOMEvent *aEvt, PRBool* _retval)
{
nsCOMPtr<nsIDOMEventTarget> target =
do_QueryInterface(GetListenerManager(PR_TRUE));
NS_ENSURE_STATE(target);
return target->DispatchEvent(aEvt, _retval);
}
nsresult
nsDOMAttribute::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
{
@ -848,6 +878,12 @@ nsDOMAttribute::GetSystemEventGroup(nsIDOMEventGroup** aGroup)
return elm->GetSystemEventGroupLM(aGroup);
}
nsIScriptContext*
nsDOMAttribute::GetContextForEventHandlers(nsresult* aRv)
{
return nsContentUtils::GetContextForEventHandlers(this, aRv);
}
void
nsDOMAttribute::EnsureChildState()
{

View File

@ -80,6 +80,18 @@ public:
// nsIDOM3Attr interface
NS_DECL_NSIDOM3ATTR
NS_DECL_NSIDOMEVENTTARGET
nsresult AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
PRBool aUseCapture,
PRBool aWantsUntrusted,
PRUint8 optional_argc)
{
return nsIAttribute::AddEventListener(aType, aListener, aUseCapture,
aWantsUntrusted, optional_argc);
}
// nsIAttribute interface
void SetMap(nsDOMAttributeMap *aMap);
nsIContent *GetContent() const;
@ -95,21 +107,6 @@ public:
PRBool aNotify);
virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify);
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus);
virtual nsIEventListenerManager* GetListenerManager(PRBool aCreateIfNotFound);
virtual nsresult AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult GetSystemEventGroup(nsIDOMEventGroup** aGroup);
virtual nsIScriptContext* GetContextForEventHandlers(nsresult* aRv)
{
return nsContentUtils::GetContextForEventHandlers(this, aRv);
}
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual already_AddRefed<nsIURI> GetBaseURI() const;

View File

@ -1692,9 +1692,9 @@ NS_INTERFACE_TABLE_HEAD(nsDocument)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDocument)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentXBL)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIScriptObjectPrincipal)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMEventTarget)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOM3EventTarget)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMNSEventTarget)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsPIDOMEventTarget)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsISupportsWeakReference)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIRadioGroupContainer)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIRadioGroupContainer_MOZILLA_2_0_BRANCH)
@ -6210,6 +6210,8 @@ nsDocument::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
return nsINode::GetOwnerDocument(aOwnerDocument);
}
NS_IMPL_DOMTARGET_DEFAULTS(nsDocument)
nsIEventListenerManager*
nsDocument::GetListenerManager(PRBool aCreateIfNotFound)
{
@ -6233,6 +6235,12 @@ nsDocument::GetSystemEventGroup(nsIDOMEventGroup **aGroup)
return manager->GetSystemEventGroupLM(aGroup);
}
nsIScriptContext*
nsDocument::GetContextForEventHandlers(nsresult* aRv)
{
return nsContentUtils::GetContextForEventHandlers(this, aRv);
}
nsresult
nsDocument::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
{

View File

@ -492,7 +492,6 @@ class nsDocument : public nsIDocument,
public nsIDOMXMLDocument, // inherits nsIDOMDocument
public nsIDOMDocumentXBL,
public nsSupportsWeakReference,
public nsIDOMEventTarget,
public nsIDOM3EventTarget,
public nsIDOMNSEventTarget,
public nsIScriptObjectPrincipal,
@ -731,21 +730,6 @@ public:
PRBool aNotify);
virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify);
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus);
virtual nsIEventListenerManager* GetListenerManager(PRBool aCreateIfNotFound);
virtual nsresult AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult GetSystemEventGroup(nsIDOMEventGroup** aGroup);
virtual nsIScriptContext* GetContextForEventHandlers(nsresult* aRv)
{
return nsContentUtils::GetContextForEventHandlers(this, aRv);
}
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
{
return NS_ERROR_NOT_IMPLEMENTED;

View File

@ -126,9 +126,7 @@ NS_INTERFACE_MAP_BEGIN(nsGenericDOMDataNode)
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsGenericDOMDataNode)
NS_INTERFACE_MAP_ENTRY(nsIContent)
NS_INTERFACE_MAP_ENTRY(nsINode)
NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMEventTarget,
nsDOMEventRTTearoff::Create(this))
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3EventTarget,
nsDOMEventRTTearoff::Create(this))
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSEventTarget,
@ -631,6 +629,37 @@ nsGenericDOMDataNode::GetAttrCount() const
return 0;
}
NS_IMPL_DOMTARGET_DEFAULTS(nsGenericDOMDataNode)
NS_IMETHODIMP
nsGenericDOMDataNode::AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
PRBool useCapture)
{
return AddEventListener(aType, aListener, useCapture, PR_FALSE, 1);
}
NS_IMETHODIMP
nsGenericDOMDataNode::RemoveEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture)
{
nsCOMPtr<nsIDOMEventTarget> event_target =
do_QueryInterface(GetListenerManager(PR_TRUE));
NS_ENSURE_STATE(event_target);
return event_target->RemoveEventListener(aType, aListener, aUseCapture);
}
NS_IMETHODIMP
nsGenericDOMDataNode::DispatchEvent(nsIDOMEvent *aEvt, PRBool* _retval)
{
nsCOMPtr<nsIDOMEventTarget> target =
do_QueryInterface(GetListenerManager(PR_TRUE));
NS_ENSURE_STATE(target);
return target->DispatchEvent(aEvt, _retval);
}
nsresult
nsGenericDOMDataNode::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
{
@ -687,6 +716,12 @@ nsGenericDOMDataNode::GetSystemEventGroup(nsIDOMEventGroup** aGroup)
return elm->GetSystemEventGroupLM(aGroup);
}
nsIScriptContext*
nsGenericDOMDataNode::GetContextForEventHandlers(nsresult* aRv)
{
return nsContentUtils::GetContextForEventHandlers(this, aRv);
}
PRUint32
nsGenericDOMDataNode::GetChildCount() const
{

View File

@ -85,6 +85,18 @@ class nsGenericDOMDataNode : public nsIContent
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIDOMEVENTTARGET
nsresult AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
PRBool aUseCapture,
PRBool aWantsUntrusted,
PRUint8 optional_argc)
{
return nsIContent::AddEventListener(aType, aListener, aUseCapture,
aWantsUntrusted, optional_argc);
}
nsGenericDOMDataNode(already_AddRefed<nsINodeInfo> aNodeInfo);
virtual ~nsGenericDOMDataNode();
@ -173,21 +185,6 @@ public:
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
PRBool aNotify);
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus);
virtual nsIEventListenerManager* GetListenerManager(PRBool aCreateIfNotFound);
virtual nsresult AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult GetSystemEventGroup(nsIDOMEventGroup** aGroup);
virtual nsIScriptContext* GetContextForEventHandlers(nsresult* aRv)
{
return nsContentUtils::GetContextForEventHandlers(this, aRv);
}
NS_IMETHOD GetTextContent(nsAString &aTextContent)
{
nsresult rv = GetNodeValue(aTextContent);

View File

@ -263,6 +263,12 @@ nsGenericElement::GetSystemEventGroup(nsIDOMEventGroup** aGroup)
return elm->GetSystemEventGroupLM(aGroup);
}
nsIScriptContext*
nsGenericElement::GetContextForEventHandlers(nsresult* aRv)
{
return nsContentUtils::GetContextForEventHandlers(this, aRv);
}
nsINode::nsSlots*
nsINode::CreateSlots()
{
@ -979,6 +985,33 @@ nsINode::LookupNamespaceURI(const nsAString& aNamespacePrefix,
return NS_OK;
}
NS_IMETHODIMP
nsINode::AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
PRBool aUseCapture,
PRBool aWantsUntrusted,
PRUint8 optional_argc)
{
NS_ASSERTION(!aWantsUntrusted || optional_argc > 1,
"Won't check if this is chrome, you want to set "
"aWantsUntrusted to PR_FALSE or make the aWantsUntrusted "
"explicit by making optional_argc non-zero.");
nsIEventListenerManager* listener_manager = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(listener_manager);
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
if (aWantsUntrusted ||
(optional_argc < 2 &&
!nsContentUtils::IsChromeDoc(GetOwnerDoc()))) {
flags |= NS_PRIV_EVENT_UNTRUSTED_PERMITTED;
}
return listener_manager->AddEventListenerByType(aListener, aType, flags,
nsnull);
}
//----------------------------------------------------------------------
nsEventStates
@ -1978,7 +2011,6 @@ nsDOMEventRTTearoff::~nsDOMEventRTTearoff()
NS_IMPL_CYCLE_COLLECTION_1(nsDOMEventRTTearoff, mNode)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMEventRTTearoff)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSEventTarget)
NS_INTERFACE_MAP_END_AGGREGATED(mNode)
@ -2065,32 +2097,6 @@ nsDOMEventRTTearoff::SetScriptTypeID(PRUint32 aLang)
}
// nsIDOMEventTarget
NS_IMETHODIMP
nsDOMEventRTTearoff::AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
PRBool useCapture)
{
return AddEventListener(aType, aListener, useCapture, PR_FALSE, 1);
}
NS_IMETHODIMP
nsDOMEventRTTearoff::RemoveEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture)
{
return RemoveGroupedEventListener(aType, aListener, aUseCapture, nsnull);
}
NS_IMETHODIMP
nsDOMEventRTTearoff::DispatchEvent(nsIDOMEvent *aEvt, PRBool* _retval)
{
nsCOMPtr<nsIDOMEventTarget> target =
do_QueryInterface(mNode->GetListenerManager(PR_TRUE));
NS_ENSURE_STATE(target);
return target->DispatchEvent(aEvt, _retval);
}
// nsIDOM3EventTarget
NS_IMETHODIMP
nsDOMEventRTTearoff::AddGroupedEventListener(const nsAString& aType,
@ -3181,6 +3187,36 @@ nsGenericElement::GetChildren(PRUint32 aFilter)
return returnList;
}
NS_IMETHODIMP
nsGenericElement::AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
PRBool useCapture)
{
return AddEventListener(aType, aListener, useCapture, PR_FALSE, 1);
}
NS_IMETHODIMP
nsGenericElement::RemoveEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture)
{
nsCOMPtr<nsIDOMEventTarget> event_target =
do_QueryInterface(GetListenerManager(PR_TRUE));
NS_ENSURE_STATE(event_target);
return event_target->RemoveEventListener(aType, aListener, aUseCapture);
}
NS_IMETHODIMP
nsGenericElement::DispatchEvent(nsIDOMEvent *aEvt, PRBool* _retval)
{
nsCOMPtr<nsIDOMEventTarget> target =
do_QueryInterface(GetListenerManager(PR_TRUE));
NS_ENSURE_STATE(target);
return target->DispatchEvent(aEvt, _retval);
}
NS_IMPL_DOMTARGET_DEFAULTS(nsGenericElement)
nsresult
nsGenericElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
@ -4409,10 +4445,8 @@ NS_INTERFACE_MAP_BEGIN(nsGenericElement)
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsGenericElement)
NS_INTERFACE_MAP_ENTRY(nsIContent)
NS_INTERFACE_MAP_ENTRY(nsINode)
NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSElement, new nsNSElementTearoff(this))
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMEventTarget,
nsDOMEventRTTearoff::Create(this))
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3EventTarget,
nsDOMEventRTTearoff::Create(this))
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSEventTarget,

View File

@ -212,8 +212,7 @@ private:
* @see nsDOMEventRTTearoff::Create
*/
class nsDOMEventRTTearoff : public nsIDOMEventTarget,
public nsIDOM3EventTarget,
class nsDOMEventRTTearoff : public nsIDOM3EventTarget,
public nsIDOMNSEventTarget
{
private:
@ -254,9 +253,6 @@ public:
// nsISupports
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
// nsIDOMEventTarget
NS_DECL_NSIDOMEVENTTARGET
// nsIDOM3EventTarget
NS_DECL_NSIDOM3EVENTTARGET
@ -264,7 +260,7 @@ public:
NS_DECL_NSIDOMNSEVENTTARGET
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsDOMEventRTTearoff,
nsIDOMEventTarget)
nsIDOM3EventTarget)
private:
/**
@ -314,6 +310,18 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIDOMEVENTTARGET
nsresult AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
PRBool aUseCapture,
PRBool aWantsUntrusted,
PRUint8 optional_argc)
{
return nsINode::AddEventListener(aType, aListener, aUseCapture,
aWantsUntrusted, optional_argc);
}
/**
* Called during QueryInterface to give the binding manager a chance to
* get an interface for this element.
@ -328,21 +336,6 @@ public:
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
PRBool aNotify);
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus);
virtual nsIEventListenerManager* GetListenerManager(PRBool aCreateIfNotFound);
virtual nsresult AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult GetSystemEventGroup(nsIDOMEventGroup** aGroup);
virtual nsIScriptContext* GetContextForEventHandlers(nsresult* aRv)
{
return nsContentUtils::GetContextForEventHandlers(this, aRv);
}
NS_IMETHOD GetTextContent(nsAString &aTextContent)
{
nsContentUtils::GetNodeTextContent(this, PR_TRUE, aTextContent);

View File

@ -453,7 +453,9 @@ nsXMLHttpRequest::~nsXMLHttpRequest()
void
nsXMLHttpRequest::RootResultArrayBuffer()
{
nsContentUtils::PreserveWrapper(static_cast<nsPIDOMEventTarget*>(this), this);
nsContentUtils::PreserveWrapper(
static_cast<nsIDOMEventTarget*>(
static_cast<nsDOMEventTargetHelper*>(this)), this);
}
/**
@ -1273,7 +1275,7 @@ nsXMLHttpRequest::CreateReadystatechangeEvent(nsIDOMEvent** aDOMEvent)
}
void
nsXMLHttpRequest::DispatchProgressEvent(nsPIDOMEventTarget* aTarget,
nsXMLHttpRequest::DispatchProgressEvent(nsDOMEventTargetHelper* aTarget,
const nsAString& aType,
PRBool aUseLSEventWrapper,
PRBool aLengthComputable,

View File

@ -171,7 +171,7 @@ public:
// and aTotalSize is LL_MAXUINT when unknown. Both those values are
// used by nsXMLHttpProgressEvent. Normal progress event should not use
// headers in aLoaded and aTotal is 0 when unknown.
void DispatchProgressEvent(nsPIDOMEventTarget* aTarget,
void DispatchProgressEvent(nsDOMEventTargetHelper* aTarget,
const nsAString& aType,
// Whether to use nsXMLHttpProgressEvent,
// which implements LS Progress Event.
@ -181,7 +181,7 @@ public:
PRUint64 aLoaded, PRUint64 aTotal,
// For LS Progress Events
PRUint64 aPosition, PRUint64 aTotalSize);
void DispatchProgressEvent(nsPIDOMEventTarget* aTarget,
void DispatchProgressEvent(nsDOMEventTargetHelper* aTarget,
const nsAString& aType,
PRBool aLengthComputable,
PRUint64 aLoaded, PRUint64 aTotal)

View File

@ -46,8 +46,8 @@ class nsIContent;
class nsIDocument;
class nsPresContext;
class nsIDOMEvent;
class nsPIDOMEventTarget;
class nsIScriptGlobalObject;
class nsIDOMEventTarget;
class nsEventTargetChainItem;
template<class E> class nsCOMArray;
@ -178,7 +178,7 @@ public:
PRPackedBool mOriginalTargetIsInAnon;
/**
* Whether or not nsPIDOMEventTarget::WillHandleEvent will be
* Whether or not nsIDOMEventTarget::WillHandleEvent will be
* called. Default is PR_FALSE;
*/
PRPackedBool mWantsWillHandleEvent;
@ -192,13 +192,13 @@ public:
/**
* Parent item in the event target chain.
*/
nsPIDOMEventTarget* mParentTarget;
nsIDOMEventTarget* mParentTarget;
/**
* If the event needs to be retargeted, this is the event target,
* which should be used when the event is handled at mParentTarget.
*/
nsPIDOMEventTarget* mEventTargetAtParent;
nsIDOMEventTarget* mEventTargetAtParent;
};
class nsEventChainPostVisitor : public nsEventChainVisitor {
@ -228,7 +228,7 @@ class nsEventDispatcher
{
public:
/**
* aTarget should QI to nsPIDOMEventTarget.
* aTarget should QI to nsIDOMEventTarget.
* If the target of aEvent is set before calling this method, the target of
* aEvent is used as the target (unless there is event
* retargeting) and the originalTarget of the DOM Event.
@ -249,7 +249,7 @@ public:
nsIDOMEvent* aDOMEvent = nsnull,
nsEventStatus* aEventStatus = nsnull,
nsDispatchingCallback* aCallback = nsnull,
nsCOMArray<nsPIDOMEventTarget>* aTargets = nsnull);
nsCOMArray<nsIDOMEventTarget>* aTargets = nsnull);
/**
* Dispatches an event.

View File

@ -47,7 +47,6 @@ class nsIScriptContext;
class nsIDOMEventTarget;
class nsIDOMEventGroup;
class nsIAtom;
class nsPIDOMEventTarget;
class nsIEventListenerInfo;
template<class E> class nsCOMArray;
class nsCxPusher;

View File

@ -38,7 +38,9 @@
#ifndef nsPIDOMEventTarget_h_
#define nsPIDOMEventTarget_h_
#include "nsISupports.h"
#include "nsIDOMEventTarget.h"
#if 0
#include "nsEvent.h"
class nsIDOMEvent;
@ -174,5 +176,6 @@ public:
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsPIDOMEventTarget, NS_PIDOMEVENTTARGET_IID)
#endif
#endif // !defined(nsPIDOMEventTarget_h_)

View File

@ -81,7 +81,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMEventTargetHelper)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsPIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSEventTarget)
NS_INTERFACE_MAP_END
@ -89,6 +88,7 @@ NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMEventTargetHelper)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMEventTargetHelper)
NS_IMPL_DOMTARGET_DEFAULTS(nsDOMEventTargetHelper);
NS_IMETHODIMP
nsDOMEventTargetHelper::AddEventListener(const nsAString& aType,

View File

@ -67,8 +67,7 @@ protected:
nsCOMPtr<nsIDOMEventListener> mListener;
};
class nsDOMEventTargetHelper : public nsPIDOMEventTarget,
public nsIDOMEventTarget,
class nsDOMEventTargetHelper : public nsIDOMEventTarget,
public nsIDOMNSEventTarget
{
public:
@ -80,19 +79,6 @@ public:
NS_DECL_NSIDOMNSEVENTTARGET
NS_DECL_NSIDOMEVENTTARGET
// nsPIDOMEventTarget
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus);
virtual nsIEventListenerManager* GetListenerManager(PRBool aCreateIfNotFound);
virtual nsresult AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult GetSystemEventGroup(nsIDOMEventGroup** aGroup);
virtual nsIScriptContext* GetContextForEventHandlers(nsresult* aRv);
PRBool HasListenersFor(const nsAString& aType)
{

View File

@ -1357,6 +1357,96 @@ nsEventListenerManager::DispatchEvent(nsIDOMEvent* aEvent, PRBool *_retval)
return rv;
}
nsIDOMEventTarget *
nsEventListenerManager::GetTargetForDOMEvent()
{
NS_ERROR("Should not be called");
return nsnull;
}
nsIDOMEventTarget *
nsEventListenerManager::GetTargetForEventTargetChain()
{
NS_ERROR("Should not be called");
return nsnull;
}
nsresult
nsEventListenerManager::PreHandleEvent(nsEventChainPreVisitor & aVisitor)
{
NS_ERROR("Should not be called");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsEventListenerManager::WillHandleEvent(nsEventChainPostVisitor & aVisitor)
{
NS_ERROR("Should not be called");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsEventListenerManager::PostHandleEvent(nsEventChainPostVisitor & aVisitor)
{
NS_ERROR("Should not be called");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsEventListenerManager::DispatchDOMEvent(nsEvent *aEvent,
nsIDOMEvent *aDOMEvent,
nsPresContext *aPresContext,
nsEventStatus *aEventStatus)
{
NS_ERROR("Should not be called");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsIEventListenerManager*
nsEventListenerManager::GetListenerManager(PRBool aMayCreate)
{
NS_ERROR("Should not be called");
return nsnull;
}
nsresult
nsEventListenerManager::AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID & aIID)
{
NS_ERROR("Should not be called");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsEventListenerManager::RemoveEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID & aIID)
{
NS_ERROR("Should not be called");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsEventListenerManager::GetSystemEventGroup(nsIDOMEventGroup **_retval)
{
NS_ERROR("Should not be called");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsIScriptContext*
nsEventListenerManager::GetContextForEventHandlers(nsresult *aRv)
{
NS_ERROR("Should not be called");
*aRv = NS_ERROR_NOT_IMPLEMENTED;
return nsnull;
}
JSContext*
nsEventListenerManager::GetJSContextForEventHandlers()
{
NS_ERROR("Should not be called");
return nsnull;
}
// nsIDOM3EventTarget interface
NS_IMETHODIMP
nsEventListenerManager::AddGroupedEventListener(const nsAString& aType,

View File

@ -49,7 +49,7 @@
class nsIContent;
class nsIDocument;
class nsPIDOMEventTarget;
class nsIDOMEventTarget;
class nsIDOMNodeList;
class nsXBLBinding;
class nsXBLDocumentInfo;
@ -88,8 +88,8 @@ public:
nsXBLDocumentInfo** aResult) = 0;
// Hooks up the global key event handlers to the document root.
NS_IMETHOD AttachGlobalKeyHandler(nsPIDOMEventTarget* aTarget)=0;
NS_IMETHOD DetachGlobalKeyHandler(nsPIDOMEventTarget* aTarget)=0;
NS_IMETHOD AttachGlobalKeyHandler(nsIDOMEventTarget* aTarget) = 0;
NS_IMETHOD DetachGlobalKeyHandler(nsIDOMEventTarget* aTarget) = 0;
};

View File

@ -47,7 +47,6 @@ class nsIAtom;
class nsIContent;
class nsIDOM3EventTarget;
class nsIDOMKeyEvent;
class nsPIDOMEventTarget;
class nsXBLPrototypeHandler;
class nsXBLEventHandler : public nsIDOMEventListener

View File

@ -55,7 +55,7 @@ class nsIContent;
class nsIDOMUIEvent;
class nsIDOMKeyEvent;
class nsIDOMMouseEvent;
class nsPIDOMEventTarget;
class nsIDOMEventTarget;
class nsIDOM3EventTarget;
class nsXBLPrototypeBinding;
@ -126,7 +126,7 @@ public:
nsXBLPrototypeHandler* GetNextHandler() { return mNextHandler; }
void SetNextHandler(nsXBLPrototypeHandler* aHandler) { mNextHandler = aHandler; }
nsresult ExecuteHandler(nsPIDOMEventTarget* aTarget, nsIDOMEvent* aEvent);
nsresult ExecuteHandler(nsIDOMEventTarget* aTarget, nsIDOMEvent* aEvent);
already_AddRefed<nsIAtom> GetEventName();
void SetEventName(nsIAtom* aName) { mEventName = aName; }
@ -162,7 +162,7 @@ public:
static PRUint32 gRefCnt;
protected:
already_AddRefed<nsIController> GetController(nsPIDOMEventTarget* aTarget);
already_AddRefed<nsIController> GetController(nsIDOMEventTarget* aTarget);
inline PRInt32 GetMatchingKeyCode(const nsAString& aKeyName);
void ConstructPrototype(nsIContent* aKeyElement,
@ -178,7 +178,7 @@ protected:
void GetEventType(nsAString& type);
PRBool ModifiersMatchMask(nsIDOMUIEvent* aEvent,
PRBool aIgnoreShiftKey = PR_FALSE);
nsresult DispatchXBLCommand(nsPIDOMEventTarget* aTarget, nsIDOMEvent* aEvent);
nsresult DispatchXBLCommand(nsIDOMEventTarget* aTarget, nsIDOMEvent* aEvent);
nsresult DispatchXULKeyCommand(nsIDOMEvent* aEvent);
nsresult EnsureEventHandler(nsIScriptGlobalObject* aGlobal,
nsIScriptContext *aBoundContext, nsIAtom *aName,

View File

@ -87,8 +87,8 @@ class nsXBLService : public nsIXBLService,
nsXBLDocumentInfo** aResult);
// Used by XUL key bindings and for window XBL.
NS_IMETHOD AttachGlobalKeyHandler(nsPIDOMEventTarget* aTarget);
NS_IMETHOD DetachGlobalKeyHandler(nsPIDOMEventTarget* aTarget);
NS_IMETHOD AttachGlobalKeyHandler(nsIDOMEventTarget* aTarget);
NS_IMETHOD DetachGlobalKeyHandler(nsIDOMEventTarget* aTarget);
NS_DECL_NSIOBSERVER

View File

@ -47,7 +47,7 @@ class nsIAtom;
class nsIDOMElement;
class nsIDOMEventTarget;
class nsIDOMKeyEvent;
class nsPIDOMEventTarget;
class nsIDOMEventTarget;
class nsIXBLDocumentInfo;
class nsXBLSpecialDocInfo;
class nsXBLPrototypeHandler;
@ -55,7 +55,7 @@ class nsXBLPrototypeHandler;
class nsXBLWindowKeyHandler : public nsIDOMKeyListener
{
public:
nsXBLWindowKeyHandler(nsIDOMElement* aElement, nsPIDOMEventTarget* aTarget);
nsXBLWindowKeyHandler(nsIDOMElement* aElement, nsIDOMEventTarget* aTarget);
virtual ~nsXBLWindowKeyHandler();
// nsIDOMetc.
@ -103,7 +103,7 @@ protected:
already_AddRefed<nsIDOMElement> GetElement();
// Using weak pointer to the DOM Element.
nsWeakPtr mWeakPtrForElement;
nsPIDOMEventTarget* mTarget; // weak ref
nsIDOMEventTarget* mTarget; // weak ref
// these are not owning references; the prototype handlers are owned
// by the prototype bindings which are owned by the docinfo.
@ -117,7 +117,7 @@ protected:
nsresult
NS_NewXBLWindowKeyHandler(nsIDOMElement* aElement,
nsPIDOMEventTarget* aTarget,
nsIDOMEventTarget* aTarget,
nsXBLWindowKeyHandler** aResult);
#endif

View File

@ -1334,7 +1334,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGlobalWindow)
NS_INTERFACE_MAP_ENTRY(nsIDOMJSWindow)
NS_INTERFACE_MAP_ENTRY(nsIScriptGlobalObject)
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSEventTarget)
@ -2519,6 +2518,31 @@ nsGlobalWindow::GetIsTabModalPromptAllowed()
return allowTabModal;
}
nsPIDOMEventTarget*
nsGlobalWindow::GetTargetForDOMEvent()
{
return static_cast<nsPIDOMEventTarget*>(GetOuterWindowInternal());
}
nsPIDOMEventTarget*
nsGlobalWindow::GetTargetForEventTargetChain()
{
return IsInnerWindow() ?
this : static_cast<nsPIDOMEventTarget*>(GetCurrentInnerWindowInternal());
}
nsresult
nsGlobalWindow::WillHandleEvent(nsEventChainPostVisitor& aVisitor)
{
return NS_OK;
}
JSContext*
nsGlobalWindow::GetJSContextForEventHandlers()
{
return nsnull;
}
nsresult
nsGlobalWindow::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
{

View File

@ -276,7 +276,6 @@ class nsGlobalWindow : public nsPIDOMWindow,
public nsIDOMJSWindow,
public nsIScriptObjectPrincipal,
public nsIDOMEventTarget,
public nsPIDOMEventTarget,
public nsIDOM3EventTarget,
public nsIDOMNSEventTarget,
public nsIDOMStorageWindow,
@ -376,29 +375,6 @@ public:
virtual NS_HIDDEN_(PRBool) WouldReuseInnerWindow(nsIDocument *aNewDocument);
virtual NS_HIDDEN_(nsPIDOMEventTarget*) GetTargetForDOMEvent()
{
return static_cast<nsPIDOMEventTarget*>(GetOuterWindowInternal());
}
virtual NS_HIDDEN_(nsPIDOMEventTarget*) GetTargetForEventTargetChain()
{
return IsInnerWindow() ?
this : static_cast<nsPIDOMEventTarget*>(GetCurrentInnerWindowInternal());
}
virtual NS_HIDDEN_(nsresult) PreHandleEvent(nsEventChainPreVisitor& aVisitor);
virtual NS_HIDDEN_(nsresult) PostHandleEvent(nsEventChainPostVisitor& aVisitor);
virtual NS_HIDDEN_(nsresult) DispatchDOMEvent(nsEvent* aEvent,
nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus);
virtual NS_HIDDEN_(nsIEventListenerManager*) GetListenerManager(PRBool aCreateIfNotFound);
virtual NS_HIDDEN_(nsresult) AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual NS_HIDDEN_(nsresult) RemoveEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual NS_HIDDEN_(nsresult) GetSystemEventGroup(nsIDOMEventGroup** aGroup);
virtual NS_HIDDEN_(nsIScriptContext*) GetContextForEventHandlers(nsresult* aRv);
virtual NS_HIDDEN_(void) SetDocShell(nsIDocShell* aDocShell);
virtual NS_HIDDEN_(nsresult) SetNewDocument(nsIDocument *aDocument,
nsISupports *aState,

View File

@ -53,7 +53,8 @@ struct JSContext;
{ 0x426c1b56, 0xe38a, 0x435e, \
{ 0xb2, 0x91, 0xbe, 0x15, 0x57, 0xf2, 0xa0, 0xa2 } }
class nsPIWindowRoot : public nsPIDOMEventTarget {
class nsPIWindowRoot : public nsIDOMEventTarget
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWINDOWROOT_IID)

View File

@ -84,7 +84,6 @@ NS_IMPL_CYCLE_COLLECTION_3(nsWindowRoot, mListenerManager, mPopupNode,
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsWindowRoot)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY(nsPIWindowRoot)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget)
@ -94,6 +93,8 @@ NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsWindowRoot)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsWindowRoot)
NS_IMPL_DOMTARGET_DEFAULTS(nsWindowRoot)
NS_IMETHODIMP
nsWindowRoot::AddEventListener(const nsAString& aType, nsIDOMEventListener* aListener, PRBool aUseCapture)
{
@ -229,6 +230,12 @@ nsWindowRoot::GetSystemEventGroup(nsIDOMEventGroup **aGroup)
return manager->GetSystemEventGroupLM(aGroup);
}
nsIScriptContext*
nsWindowRoot::GetContextForEventHandlers(nsresult* aRv)
{
*aRv = NS_OK;
return nsnull;
}
nsresult
nsWindowRoot::PreHandleEvent(nsEventChainPreVisitor& aVisitor)

View File

@ -55,8 +55,7 @@ class nsEventChainPostVisitor;
#include "nsIDOMEventTarget.h"
#include "nsCycleCollectionParticipant.h"
class nsWindowRoot : public nsIDOMEventTarget,
public nsIDOM3EventTarget,
class nsWindowRoot : public nsIDOM3EventTarget,
public nsIDOMNSEventTarget,
public nsPIWindowRoot
{
@ -69,24 +68,6 @@ public:
NS_DECL_NSIDOM3EVENTTARGET
NS_DECL_NSIDOMNSEVENTTARGET
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
virtual nsresult DispatchDOMEvent(nsEvent* aEvent,
nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus);
virtual nsIEventListenerManager* GetListenerManager(PRBool aCreateIfNotFound);
virtual nsresult AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult GetSystemEventGroup(nsIDOMEventGroup** aGroup);
virtual nsIScriptContext* GetContextForEventHandlers(nsresult* aRv)
{
*aRv = NS_OK;
return nsnull;
}
// nsPIWindowRoot
virtual nsPIDOMWindow* GetWindow();

View File

@ -39,6 +39,15 @@
#include "domstubs.idl"
%{C++
#include "nsEvent.h"
class nsPresContext;
class nsEventChainPreVisitor;
class nsEventChainPostVisitor;
struct JSContext;
%}
/**
* The nsIDOMEventTarget interface is the interface implemented by all
* event targets in the Document Object Model.
@ -47,7 +56,20 @@
* http://www.w3.org/TR/DOM-Level-2-Events/
*/
[scriptable, builtinclass, uuid(1c773b30-d1cf-11d2-bd95-00805f8ae3f4)]
[ref] native nsEventChainPreVisitorRef(nsEventChainPreVisitor);
[ref] native nsEventChainPostVisitorRef(nsEventChainPostVisitor);
[ptr] native nsEventPtr(nsEvent);
[ptr] native nsPresContextPtr(nsPresContext);
[ptr] native nsEventStatusPtr(nsEventStatus);
[ptr] native JSContextPtr(JSContext);
interface nsIEventListenerManager;
interface nsIScriptContext;
interface nsIDOMEventListener;
interface nsIDOMEventGroup;
interface nsIDOMEvent;
[scriptable, builtinclass, uuid(d56b0ac7-16e0-4fda-8255-06158d475606)]
interface nsIDOMEventTarget : nsISupports
{
/**
@ -123,4 +145,124 @@ interface nsIDOMEventTarget : nsISupports
*/
boolean dispatchEvent(in nsIDOMEvent evt)
raises(DOMException);
/**
* 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.
*/
[notxpcom] nsIDOMEventTarget GetTargetForDOMEvent();
/**
* 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.
*/
[notxpcom] nsIDOMEventTarget GetTargetForEventTargetChain();
/**
* 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.
*/
[noscript] void PreHandleEvent(in nsEventChainPreVisitorRef aVisitor);
/**
* If nsEventChainPreVisitor.mWantsWillHandleEvent is set PR_TRUE,
* called just before possible event handlers on this object will be called.
*/
[noscript] void WillHandleEvent(in nsEventChainPostVisitorRef aVisitor);
/**
* 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.
*/
[noscript] void PostHandleEvent(in nsEventChainPostVisitorRef aVisitor);
/**
* 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.
*/
[noscript] void DispatchDOMEvent(in nsEventPtr aEvent,
in nsIDOMEvent aDOMEvent,
in nsPresContextPtr aPresContext,
in nsEventStatusPtr aEventStatus);
/**
* Get the event listener manager, the guy you talk to to register for events
* on this node.
* @param aMayCreate If PR_FALSE, returns a listener manager only if
* one already exists.
*/
[notxpcom] nsIEventListenerManager GetListenerManager(in boolean aMayCreate);
/**
* Add an event listener for nsIID.
*/
[noscript] void AddEventListenerByIID(in nsIDOMEventListener aListener,
in nsIIDRef aIID);
/**
* Remove event listener for nsIID.
*/
[noscript] void RemoveEventListenerByIID(in nsIDOMEventListener aListener,
in nsIIDRef aIID);
/**
* Get the system event group.
*/
[noscript] nsIDOMEventGroup GetSystemEventGroup();
/**
* Get the script context in which the event handlers should be run.
* May return null.
* @note Caller *must* check the value of aRv.
*/
[notxpcom] nsIScriptContext GetContextForEventHandlers(out nsresult aRv);
/**
* If the method above returns null, but a success code, this method
* is called.
*/
[notxpcom] JSContextPtr GetJSContextForEventHandlers();
};
%{C++
typedef nsIDOMEventTarget nsPIDOMEventTarget;
#define NS_IMPL_DOMTARGET_DEFAULTS(_class) \
nsPIDOMEventTarget* _class::GetTargetForDOMEvent() { return this; } \
nsPIDOMEventTarget* _class::GetTargetForEventTargetChain() { return this; } \
nsresult _class::WillHandleEvent(nsEventChainPostVisitor& aVisitor) { return NS_OK; } \
JSContext* _class::GetJSContextForEventHandlers() { return nsnull; }
%}

View File

@ -81,7 +81,17 @@ class nsDOMWorkerScope : public nsDOMWorkerMessageHandler,
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMEVENTTARGET
// nsIDOMEventHandler
NS_FORWARD_INTERNAL_NSIDOMEVENTTARGET(nsDOMWorkerMessageHandler::)
NS_IMETHOD AddEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture);
NS_IMETHOD RemoveEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture);
NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent,
PRBool* _retval);
// nsIDOMNSEventTarget
NS_IMETHOD AddEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
@ -162,7 +172,18 @@ class nsDOMWorker : public nsDOMWorkerMessageHandler,
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMEVENTTARGET
// nsIDOMEventHandler
NS_FORWARD_INTERNAL_NSIDOMEVENTTARGET(nsDOMWorkerMessageHandler::)
NS_IMETHOD AddEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture);
NS_IMETHOD RemoveEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture);
NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent,
PRBool* _retval);
// nsIDOMNSEventTarget
NS_IMETHOD AddEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,

View File

@ -370,6 +370,95 @@ nsDOMWorkerMessageHandler::AddEventListener(const nsAString& aType,
return NS_OK;
}
nsIDOMEventTarget *
nsDOMWorkerMessageHandler::GetTargetForDOMEvent()
{
NS_ERROR("Should not be called");
return nsnull;
}
nsIDOMEventTarget *
nsDOMWorkerMessageHandler::GetTargetForEventTargetChain()
{
NS_ERROR("Should not be called");
return nsnull;
}
nsresult
nsDOMWorkerMessageHandler::PreHandleEvent(nsEventChainPreVisitor & aVisitor)
{
NS_ERROR("Should not be called");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsDOMWorkerMessageHandler::WillHandleEvent(nsEventChainPostVisitor & aVisitor)
{
NS_ERROR("Should not be called");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsDOMWorkerMessageHandler::PostHandleEvent(nsEventChainPostVisitor & aVisitor)
{
NS_ERROR("Should not be called");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsDOMWorkerMessageHandler::DispatchDOMEvent(nsEvent *aEvent, nsIDOMEvent *aDOMEvent,
nsPresContext *aPresContext,
nsEventStatus *aEventStatus)
{
NS_ERROR("Should not be called");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsIEventListenerManager*
nsDOMWorkerMessageHandler::GetListenerManager(PRBool aMayCreate)
{
NS_ERROR("Should not be called");
return nsnull;
}
nsresult
nsDOMWorkerMessageHandler::AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID & aIID)
{
NS_ERROR("Should not be called");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsDOMWorkerMessageHandler::RemoveEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID & aIID)
{
NS_ERROR("Should not be called");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsDOMWorkerMessageHandler::GetSystemEventGroup(nsIDOMEventGroup **_retval)
{
NS_ERROR("Should not be called");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsIScriptContext*
nsDOMWorkerMessageHandler::GetContextForEventHandlers(nsresult *aRv)
{
NS_ERROR("Should not be called");
*aRv = NS_ERROR_NOT_IMPLEMENTED;
return nsnull;
}
JSContext*
nsDOMWorkerMessageHandler::GetJSContextForEventHandlers()
{
NS_ERROR("Should not be called");
return nsnull;
}
/**
* See nsIDOMNSEventTarget
*/

View File

@ -161,4 +161,19 @@ private:
nsTArray<ListenerCollection> mCollections;
};
#define NS_FORWARD_INTERNAL_NSIDOMEVENTTARGET(_to) \
virtual nsIDOMEventTarget * GetTargetForDOMEvent(void) { return _to GetTargetForDOMEvent(); } \
virtual nsIDOMEventTarget * GetTargetForEventTargetChain(void) { return _to GetTargetForEventTargetChain(); } \
virtual nsresult PreHandleEvent(nsEventChainPreVisitor & aVisitor) { return _to PreHandleEvent(aVisitor); } \
virtual nsresult WillHandleEvent(nsEventChainPostVisitor & aVisitor) { return _to WillHandleEvent(aVisitor); } \
virtual nsresult PostHandleEvent(nsEventChainPostVisitor & aVisitor) { return _to PostHandleEvent(aVisitor); } \
virtual nsresult DispatchDOMEvent(nsEvent *aEvent, nsIDOMEvent *aDOMEvent, nsPresContext *aPresContext, nsEventStatus *aEventStatus) { return _to DispatchDOMEvent(aEvent, aDOMEvent, aPresContext, aEventStatus); } \
virtual nsIEventListenerManager * GetListenerManager(PRBool aMayCreate) { return _to GetListenerManager(aMayCreate); } \
virtual nsresult AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID & aIID) { return _to AddEventListenerByIID(aListener, aIID); } \
virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID & aIID) { return _to RemoveEventListenerByIID(aListener, aIID); } \
virtual nsresult GetSystemEventGroup(nsIDOMEventGroup **_retval NS_OUTPARAM) { return _to GetSystemEventGroup(_retval); } \
virtual nsIScriptContext * GetContextForEventHandlers(nsresult *aRv NS_OUTPARAM) { return _to GetContextForEventHandlers(aRv); } \
virtual JSContext * GetJSContextForEventHandlers(void) { return _to GetJSContextForEventHandlers(); }
#endif /* __NSDOMWORKERMESSAGEHANDLER_H__ */

View File

@ -141,7 +141,17 @@ class nsDOMWorkerXHRUpload : public nsDOMWorkerXHREventTarget,
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMEVENTTARGET
// nsIDOMEventHandler
NS_FORWARD_INTERNAL_NSIDOMEVENTTARGET(nsDOMWorkerMessageHandler::)
NS_IMETHOD AddEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture);
NS_IMETHOD RemoveEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture);
NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent,
PRBool* _retval);
NS_IMETHOD AddEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture,

View File

@ -52,7 +52,6 @@
class nsEditor;
class nsIDOMDragEvent;
class nsPIDOMEventTarget;
class nsEditorEventListener : public nsIDOMKeyListener,
public nsIDOMTextListener,