зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug 124990, Add additional processing loop for DOM event listeners to allow browser level handlers to be fired after content based listeners. r:saari, sr:jst
Browser based listeners can now registers themselves using the AddGroupedEventListener and passing the system event group (which can be gotten via the nsIDOMEventReceiver interface). These listeners will now fire after all content based listeners have processed. In this initial version of the checkin most browser listeners are still left in the original content group for stability purposes.
This commit is contained in:
Родитель
97531eb92c
Коммит
bdfd051dfb
|
@ -192,6 +192,10 @@
|
|||
#define NS_EVENTSTATEMANAGER_CID \
|
||||
{ 0xa1fde862, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
|
||||
|
||||
// {66856477-6596-40eb-bb87-59ca2dabb6f7}
|
||||
#define NS_DOMEVENTGROUP_CID \
|
||||
{ 0x66856477, 0x6596, 0x40eb, { 0xbb, 0x87, 0x59, 0xca, 0x2d, 0xab, 0xb6, 0xf7 } }
|
||||
|
||||
// {64F300A1-C88C-11d3-97FB-00400553EEF0}
|
||||
#define NS_XBLSERVICE_CID \
|
||||
{ 0x64f300a1, 0xc88c, 0x11d3, { 0x97, 0xfb, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
#include "nsIDOMDocumentXBL.h"
|
||||
#include "nsIDOMNavigator.h"
|
||||
#include "nsGenericElement.h"
|
||||
#include "nsIDOMEventGroup.h"
|
||||
|
||||
#include "nsICSSStyleSheet.h"
|
||||
|
||||
|
@ -131,6 +132,7 @@
|
|||
#endif
|
||||
|
||||
static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
|
||||
static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);
|
||||
|
||||
#include "nsILineBreakerFactory.h"
|
||||
#include "nsIWordBreakerFactory.h"
|
||||
|
@ -616,6 +618,7 @@ NS_INTERFACE_MAP_BEGIN(nsDocument)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIDOMDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNSDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentEvent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOM3DocumentEvent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentStyle)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentView)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentRange)
|
||||
|
@ -624,6 +627,7 @@ NS_INTERFACE_MAP_BEGIN(nsDocument)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMEventReceiver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOM3Node)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
|
@ -3374,6 +3378,16 @@ nsresult nsDocument::HandleEvent(nsIDOMEvent *aEvent)
|
|||
return DispatchEvent(aEvent, &noDefault);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetSystemEventGroup(nsIDOMEventGroup **aGroup)
|
||||
{
|
||||
nsCOMPtr<nsIEventListenerManager> manager;
|
||||
if (NS_SUCCEEDED(GetListenerManager(getter_AddRefs(manager))) && manager) {
|
||||
return manager->GetSystemEventGroupLM(aGroup);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult nsDocument::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
|
@ -3394,26 +3408,29 @@ nsresult nsDocument::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
else {
|
||||
aDOMEvent = &domEvent;
|
||||
}
|
||||
aEvent->flags = aFlags;
|
||||
aEvent->flags |= aFlags;
|
||||
aFlags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
|
||||
aFlags |= NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_CAPTURE;
|
||||
}
|
||||
|
||||
//Capturing stage
|
||||
if (NS_EVENT_FLAG_BUBBLE != aFlags && nsnull != mScriptGlobalObject) {
|
||||
mScriptGlobalObject->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_CAPTURE, aEventStatus);
|
||||
if (NS_EVENT_FLAG_CAPTURE & aFlags && nsnull != mScriptGlobalObject) {
|
||||
mScriptGlobalObject->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, aFlags & NS_EVENT_CAPTURE_MASK, aEventStatus);
|
||||
}
|
||||
|
||||
//Local handling stage
|
||||
if (mListenerManager && !(aEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) &&
|
||||
!(NS_EVENT_FLAG_BUBBLE & aFlags && NS_EVENT_FLAG_CANT_BUBBLE & aEvent->flags)) {
|
||||
//Check for null mDOMSlots or ELM, check if we're a non-bubbling event in the bubbling state (bubbling state
|
||||
//is indicated by the presence of the NS_EVENT_FLAG_BUBBLE flag and not the NS_EVENT_FLAG_INIT).
|
||||
if (mListenerManager &&
|
||||
!(NS_EVENT_FLAG_CANT_BUBBLE & aEvent->flags && NS_EVENT_FLAG_BUBBLE & aFlags && !(NS_EVENT_FLAG_INIT & aFlags))) {
|
||||
aEvent->flags |= aFlags;
|
||||
mListenerManager->HandleEvent(aPresContext, aEvent, aDOMEvent, this, aFlags, aEventStatus);
|
||||
aEvent->flags &= ~aFlags;
|
||||
}
|
||||
|
||||
//Bubbling stage
|
||||
if (NS_EVENT_FLAG_CAPTURE != aFlags && nsnull != mScriptGlobalObject) {
|
||||
mScriptGlobalObject->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_BUBBLE, aEventStatus);
|
||||
if (NS_EVENT_FLAG_BUBBLE & aFlags && nsnull != mScriptGlobalObject) {
|
||||
mScriptGlobalObject->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, aFlags & NS_EVENT_BUBBLE_MASK, aEventStatus);
|
||||
}
|
||||
|
||||
if (NS_EVENT_FLAG_INIT & aFlags) {
|
||||
|
@ -3469,28 +3486,13 @@ nsresult nsDocument::RemoveEventListenerByIID(nsIDOMEventListener *aListener, co
|
|||
nsresult nsDocument::AddEventListener(const nsAString& aType, nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture)
|
||||
{
|
||||
nsCOMPtr<nsIEventListenerManager> manager;
|
||||
|
||||
GetListenerManager(getter_AddRefs(manager));
|
||||
if (manager) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
manager->AddEventListenerByType(aListener, aType, flags);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
return AddGroupedEventListener(aType, aListener, aUseCapture, nsnull);
|
||||
}
|
||||
|
||||
nsresult nsDocument::RemoveEventListener(const nsAString& aType, nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture)
|
||||
{
|
||||
if (nsnull != mListenerManager) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
mListenerManager->RemoveEventListenerByType(aListener, aType, flags);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
return RemoveGroupedEventListener(aType, aListener, aUseCapture, nsnull);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -3519,6 +3521,47 @@ nsDocument::DispatchEvent(nsIDOMEvent* aEvent, PRBool *_retval)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::AddGroupedEventListener(const nsAString & aType, nsIDOMEventListener *aListener,
|
||||
PRBool aUseCapture, nsIDOMEventGroup *aEvtGrp)
|
||||
{
|
||||
nsCOMPtr<nsIEventListenerManager> manager;
|
||||
|
||||
nsresult rv = GetListenerManager(getter_AddRefs(manager));
|
||||
if (NS_SUCCEEDED(rv) && manager) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
manager->AddEventListenerByType(aListener, aType, flags, aEvtGrp);
|
||||
return NS_OK;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::RemoveGroupedEventListener(const nsAString & aType, nsIDOMEventListener *aListener,
|
||||
PRBool aUseCapture, nsIDOMEventGroup *aEvtGrp)
|
||||
{
|
||||
if (mListenerManager) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
mListenerManager->RemoveEventListenerByType(aListener, aType, flags, aEvtGrp);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::CanTrigger(const nsAString & type, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::IsRegisteredHere(const nsAString & type, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::CreateEvent(const nsAString& aEventType,
|
||||
nsIDOMEvent** aReturn)
|
||||
|
@ -3551,6 +3594,19 @@ nsDocument::CreateEvent(const nsAString& aEventType,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::CreateEventGroup(nsIDOMEventGroup **aInstancePtrResult)
|
||||
{
|
||||
nsresult result;
|
||||
nsCOMPtr<nsIDOMEventGroup> group(do_CreateInstance(kDOMEventGroupCID,&result));
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
*aInstancePtrResult = group.get();
|
||||
NS_ADDREF(*aInstancePtrResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::FlushPendingNotifications(PRBool aFlushReflows,
|
||||
PRBool aUpdateViews)
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "nsIDOMDocumentTraversal.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOM3EventTarget.h"
|
||||
#include "nsIDOMStyleSheetList.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
|
@ -60,6 +61,7 @@
|
|||
#include "nsIBindingManager.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIDOM3DocumentEvent.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsIWordBreakerFactory.h"
|
||||
|
@ -252,6 +254,7 @@ class nsDocument : public nsIDocument,
|
|||
public nsIDOMXMLDocument, // inherits nsIDOMDocument
|
||||
public nsIDOMNSDocument,
|
||||
public nsIDOMDocumentEvent,
|
||||
public nsIDOM3DocumentEvent,
|
||||
public nsIDOMDocumentStyle,
|
||||
public nsIDOMDocumentView,
|
||||
public nsIDOMDocumentRange,
|
||||
|
@ -260,6 +263,7 @@ class nsDocument : public nsIDocument,
|
|||
public nsIDOM3Node,
|
||||
public nsSupportsWeakReference,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIDOM3EventTarget,
|
||||
public nsIScriptObjectPrincipal
|
||||
{
|
||||
public:
|
||||
|
@ -542,6 +546,9 @@ public:
|
|||
// nsIDOMDocumentEvent
|
||||
NS_DECL_NSIDOMDOCUMENTEVENT
|
||||
|
||||
// nsIDOM3DocumentEvent
|
||||
NS_DECL_NSIDOM3DOCUMENTEVENT
|
||||
|
||||
// nsIDOMDocumentStyle
|
||||
NS_DECL_NSIDOMDOCUMENTSTYLE
|
||||
|
||||
|
@ -564,16 +571,13 @@ public:
|
|||
const nsIID& aIID);
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent);
|
||||
NS_IMETHOD GetSystemEventGroup(nsIDOMEventGroup** aGroup);
|
||||
|
||||
// nsIDOMEventTarget interface
|
||||
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);
|
||||
// nsIDOMEventTarget
|
||||
NS_DECL_NSIDOMEVENTTARGET
|
||||
|
||||
// nsIDOM3EventTarget
|
||||
NS_DECL_NSIDOM3EVENTTARGET
|
||||
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
|
|
|
@ -178,6 +178,11 @@ NS_INTERFACE_MAP_BEGIN(nsGenericDOMDataNode)
|
|||
nsDOMEventRTTearoff::Create(this));
|
||||
NS_ENSURE_TRUE(foundInterface, NS_ERROR_OUT_OF_MEMORY);
|
||||
} else
|
||||
if (aIID.Equals(NS_GET_IID(nsIDOM3EventTarget))) {
|
||||
foundInterface = NS_STATIC_CAST(nsIDOM3EventTarget *,
|
||||
nsDOMEventRTTearoff::Create(this));
|
||||
NS_ENSURE_TRUE(foundInterface, NS_ERROR_OUT_OF_MEMORY);
|
||||
} else
|
||||
NS_INTERFACE_MAP_ENTRY(nsIContent)
|
||||
// No nsITextContent since all subclasses might not want that.
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Node, nsNode3Tearoff(this))
|
||||
|
@ -855,21 +860,22 @@ nsGenericDOMDataNode::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
externalDOMEvent = PR_TRUE;
|
||||
}
|
||||
|
||||
aEvent->flags = aFlags;
|
||||
aEvent->flags |= aFlags;
|
||||
aFlags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
|
||||
aFlags |= NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_CAPTURE;
|
||||
}
|
||||
|
||||
nsIContent *parent_weak = GetParentWeak();
|
||||
|
||||
//Capturing stage evaluation
|
||||
if (NS_EVENT_FLAG_BUBBLE != aFlags) {
|
||||
if (NS_EVENT_FLAG_CAPTURE & aFlags) {
|
||||
//Initiate capturing phase. Special case first call to document
|
||||
if (parent_weak) {
|
||||
parent_weak->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
NS_EVENT_FLAG_CAPTURE, aEventStatus);
|
||||
aFlags & NS_EVENT_CAPTURE_MASK, aEventStatus);
|
||||
} else if (mDocument) {
|
||||
ret = mDocument->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
NS_EVENT_FLAG_CAPTURE, aEventStatus);
|
||||
aFlags & NS_EVENT_CAPTURE_MASK, aEventStatus);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -877,10 +883,12 @@ nsGenericDOMDataNode::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
LookupListenerManager(getter_AddRefs(listener_manager));
|
||||
|
||||
//Local handling stage
|
||||
if (listener_manager && !(aEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) &&
|
||||
!(NS_EVENT_FLAG_BUBBLE & aFlags &&
|
||||
NS_EVENT_FLAG_CANT_BUBBLE & aEvent->flags)
|
||||
&& !(aEvent->flags & NS_EVENT_FLAG_NO_CONTENT_DISPATCH)) {
|
||||
//Check for null ELM, check if we're a non-bubbling event in the bubbling state (bubbling state
|
||||
//is indicated by the presence of the NS_EVENT_FLAG_BUBBLE flag and not the NS_EVENT_FLAG_INIT), and check
|
||||
//if we're a no content dispatch event
|
||||
if (listener_manager &&
|
||||
!(NS_EVENT_FLAG_CANT_BUBBLE & aEvent->flags && NS_EVENT_FLAG_BUBBLE & aFlags && !(NS_EVENT_FLAG_INIT & aFlags)) &&
|
||||
!(aEvent->flags & NS_EVENT_FLAG_NO_CONTENT_DISPATCH)) {
|
||||
aEvent->flags |= aFlags;
|
||||
listener_manager->HandleEvent(aPresContext, aEvent, aDOMEvent, nsnull,
|
||||
aFlags, aEventStatus);
|
||||
|
@ -888,9 +896,9 @@ nsGenericDOMDataNode::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
//Bubbling stage
|
||||
if (NS_EVENT_FLAG_CAPTURE != aFlags && parent_weak) {
|
||||
if (NS_EVENT_FLAG_BUBBLE & aFlags && parent_weak) {
|
||||
ret = parent_weak->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
NS_EVENT_FLAG_BUBBLE, aEventStatus);
|
||||
aFlags & NS_EVENT_BUBBLE_MASK, aEventStatus);
|
||||
}
|
||||
|
||||
if (NS_EVENT_FLAG_INIT & aFlags) {
|
||||
|
|
|
@ -402,6 +402,15 @@ nsDOMEventRTTearoff::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(NS_GET_IID(nsIDOM3EventTarget))) {
|
||||
nsIDOM3EventTarget *inst = this;
|
||||
|
||||
NS_ADDREF(inst);
|
||||
|
||||
*aInstancePtr = inst;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return mContent->QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
@ -410,7 +419,6 @@ nsDOMEventRTTearoff::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
NS_IMPL_ADDREF(nsDOMEventRTTearoff)
|
||||
NS_IMPL_RELEASE_WITH_DESTROY(nsDOMEventRTTearoff, LastRelease())
|
||||
|
||||
|
||||
nsDOMEventRTTearoff *
|
||||
nsDOMEventRTTearoff::Create(nsIContent *aContent)
|
||||
{
|
||||
|
@ -471,6 +479,16 @@ nsDOMEventRTTearoff::GetEventReceiver(nsIDOMEventReceiver **aReceiver)
|
|||
return CallQueryInterface(listener_manager, aReceiver);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMEventRTTearoff::GetDOM3EventTarget(nsIDOM3EventTarget **aTarget)
|
||||
{
|
||||
nsCOMPtr<nsIEventListenerManager> listener_manager;
|
||||
nsresult rv = mContent->GetListenerManager(getter_AddRefs(listener_manager));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CallQueryInterface(listener_manager, aTarget);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEventRTTearoff::AddEventListenerByIID(nsIDOMEventListener *aListener,
|
||||
const nsIID& aIID)
|
||||
|
@ -509,8 +527,17 @@ nsDOMEventRTTearoff::HandleEvent(nsIDOMEvent *aEvent)
|
|||
return event_receiver->HandleEvent(aEvent);
|
||||
}
|
||||
|
||||
// nsIDOMEventTarget
|
||||
NS_IMETHODIMP
|
||||
nsDOMEventRTTearoff::GetSystemEventGroup(nsIDOMEventGroup **aGroup)
|
||||
{
|
||||
nsCOMPtr<nsIEventListenerManager> manager;
|
||||
if (NS_SUCCEEDED(GetListenerManager(getter_AddRefs(manager))) && manager) {
|
||||
return manager->GetSystemEventGroupLM(aGroup);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// nsIDOMEventTarget
|
||||
NS_IMETHODIMP
|
||||
nsDOMEventRTTearoff::AddEventListener(const nsAString& type,
|
||||
nsIDOMEventListener *listener,
|
||||
|
@ -545,6 +572,44 @@ nsDOMEventRTTearoff::DispatchEvent(nsIDOMEvent *evt, PRBool* _retval)
|
|||
return event_receiver->DispatchEvent(evt, _retval);
|
||||
}
|
||||
|
||||
// nsIDOM3EventTarget
|
||||
NS_IMETHODIMP
|
||||
nsDOMEventRTTearoff::AddGroupedEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener *aListener,
|
||||
PRBool aUseCapture,
|
||||
nsIDOMEventGroup *aEvtGrp)
|
||||
{
|
||||
nsCOMPtr<nsIDOM3EventTarget> event_target;
|
||||
nsresult rv = GetDOM3EventTarget(getter_AddRefs(event_target));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return event_target->AddGroupedEventListener(aType, aListener, aUseCapture, aEvtGrp);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEventRTTearoff::RemoveGroupedEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener *aListener,
|
||||
PRBool aUseCapture,
|
||||
nsIDOMEventGroup *aEvtGrp)
|
||||
{
|
||||
nsCOMPtr<nsIDOM3EventTarget> event_target;
|
||||
nsresult rv = GetDOM3EventTarget(getter_AddRefs(event_target));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return event_target->RemoveGroupedEventListener(aType, aListener, aUseCapture, aEvtGrp);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEventRTTearoff::CanTrigger(const nsAString & type, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEventRTTearoff::IsRegisteredHere(const nsAString & type, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
@ -1553,8 +1618,9 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
else {
|
||||
aDOMEvent = &domEvent;
|
||||
}
|
||||
aEvent->flags = aFlags;
|
||||
aEvent->flags |= aFlags;
|
||||
aFlags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
|
||||
aFlags |= NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_CAPTURE;
|
||||
}
|
||||
|
||||
// Find out if we're anonymous.
|
||||
|
@ -1634,16 +1700,16 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
|
||||
PRBool intermediateCapture = PR_FALSE;
|
||||
//Capturing stage evaluation
|
||||
if (NS_EVENT_FLAG_BUBBLE != aFlags && aEvent->message != NS_PAGE_LOAD &&
|
||||
if (NS_EVENT_FLAG_CAPTURE & aFlags && aEvent->message != NS_PAGE_LOAD &&
|
||||
aEvent->message != NS_SCRIPT_LOAD &&
|
||||
aEvent->message != NS_IMAGE_ERROR && aEvent->message != NS_IMAGE_LOAD) {
|
||||
//Initiate capturing phase. Special case first call to document
|
||||
if (parent) {
|
||||
parent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_CAPTURE, aEventStatus);
|
||||
parent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, aFlags & NS_EVENT_CAPTURE_MASK, aEventStatus);
|
||||
}
|
||||
else if (mDocument != nsnull) {
|
||||
ret = mDocument->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
NS_EVENT_FLAG_CAPTURE, aEventStatus);
|
||||
aFlags & NS_EVENT_CAPTURE_MASK, aEventStatus);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1656,9 +1722,12 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
//Local handling stage
|
||||
if (mDOMSlots && mDOMSlots->mListenerManager && !(aEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) &&
|
||||
!(NS_EVENT_FLAG_BUBBLE & aFlags && NS_EVENT_FLAG_CANT_BUBBLE & aEvent->flags)
|
||||
&& !(aEvent->flags & NS_EVENT_FLAG_NO_CONTENT_DISPATCH)) {
|
||||
//Check for null mDOMSlots or ELM, check if we're a non-bubbling event in the bubbling state (bubbling state
|
||||
//is indicated by the presence of the NS_EVENT_FLAG_BUBBLE flag and not the NS_EVENT_FLAG_INIT), and check
|
||||
//if we're a no content dispatch event
|
||||
if (mDOMSlots && mDOMSlots->mListenerManager &&
|
||||
!(NS_EVENT_FLAG_CANT_BUBBLE & aEvent->flags && NS_EVENT_FLAG_BUBBLE & aFlags && !(NS_EVENT_FLAG_INIT & aFlags)) &&
|
||||
!(aEvent->flags & NS_EVENT_FLAG_NO_CONTENT_DISPATCH)) {
|
||||
aEvent->flags |= aFlags;
|
||||
nsCOMPtr<nsIDOMEventTarget> curTarg(do_QueryInterface(NS_STATIC_CAST(nsIHTMLContent *, this)));
|
||||
mDOMSlots->mListenerManager->HandleEvent(aPresContext, aEvent, aDOMEvent, curTarg, aFlags, aEventStatus);
|
||||
|
@ -1675,7 +1744,7 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
//Bubbling stage
|
||||
if (NS_EVENT_FLAG_CAPTURE != aFlags && mDocument &&
|
||||
if (NS_EVENT_FLAG_BUBBLE & aFlags && mDocument &&
|
||||
aEvent->message != NS_PAGE_LOAD && aEvent->message != NS_SCRIPT_LOAD &&
|
||||
aEvent->message != NS_IMAGE_ERROR && aEvent->message != NS_IMAGE_LOAD) {
|
||||
if (parent) {
|
||||
|
@ -1683,14 +1752,14 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
* If there's a parent we pass the event to the parent...
|
||||
*/
|
||||
ret = parent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
NS_EVENT_FLAG_BUBBLE, aEventStatus);
|
||||
aFlags & NS_EVENT_BUBBLE_MASK, aEventStatus);
|
||||
} else {
|
||||
/*
|
||||
* If there's no parent but there is a document (i.e. this is the
|
||||
* root node) we pass the event to the document...
|
||||
*/
|
||||
ret = mDocument->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
NS_EVENT_FLAG_BUBBLE, aEventStatus);
|
||||
aFlags & NS_EVENT_BUBBLE_MASK, aEventStatus);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2583,6 +2652,10 @@ nsGenericElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
inst = NS_STATIC_CAST(nsIDOMEventReceiver *,
|
||||
nsDOMEventRTTearoff::Create(this));
|
||||
NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
|
||||
} else if (aIID.Equals(NS_GET_IID(nsIDOM3EventTarget))) {
|
||||
inst = NS_STATIC_CAST(nsIDOM3EventTarget *,
|
||||
nsDOMEventRTTearoff::Create(this));
|
||||
NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
|
||||
} else {
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMLinkStyle.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOM3EventTarget.h"
|
||||
#include "nsIStyleSheetLinkingElement.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsICSSLoaderObserver.h"
|
||||
|
@ -126,7 +127,8 @@ private:
|
|||
|
||||
#define NS_EVENT_TEAROFF_CACHE_SIZE 4
|
||||
|
||||
class nsDOMEventRTTearoff : public nsIDOMEventReceiver
|
||||
class nsDOMEventRTTearoff : public nsIDOMEventReceiver,
|
||||
public nsIDOM3EventTarget
|
||||
{
|
||||
private:
|
||||
// This class uses a caching scheme so we don't let users of this
|
||||
|
@ -146,6 +148,7 @@ private:
|
|||
void LastRelease();
|
||||
|
||||
nsresult GetEventReceiver(nsIDOMEventReceiver **aReceiver);
|
||||
nsresult GetDOM3EventTarget(nsIDOM3EventTarget **aTarget);
|
||||
|
||||
public:
|
||||
virtual ~nsDOMEventRTTearoff();
|
||||
|
@ -161,6 +164,9 @@ public:
|
|||
// nsIDOMEventTarget
|
||||
NS_DECL_NSIDOMEVENTTARGET
|
||||
|
||||
// nsIDOM3EventTarget
|
||||
NS_DECL_NSIDOM3EVENTTARGET
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener,
|
||||
const nsIID& aIID);
|
||||
|
@ -168,6 +174,7 @@ public:
|
|||
const nsIID& aIID);
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aResult);
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent);
|
||||
NS_IMETHOD GetSystemEventGroup(nsIDOMEventGroup** aGroup);
|
||||
|
||||
private:
|
||||
// Strong reference back to the content object from where an
|
||||
|
|
|
@ -192,6 +192,10 @@
|
|||
#define NS_EVENTSTATEMANAGER_CID \
|
||||
{ 0xa1fde862, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
|
||||
|
||||
// {66856477-6596-40eb-bb87-59ca2dabb6f7}
|
||||
#define NS_DOMEVENTGROUP_CID \
|
||||
{ 0x66856477, 0x6596, 0x40eb, { 0xbb, 0x87, 0x59, 0xca, 0x2d, 0xab, 0xb6, 0xf7 } }
|
||||
|
||||
// {64F300A1-C88C-11d3-97FB-00400553EEF0}
|
||||
#define NS_XBLSERVICE_CID \
|
||||
{ 0x64f300a1, 0xc88c, 0x11d3, { 0x97, 0xfb, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
#include "nsIController.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsIDOMDOMImplementation.h"
|
||||
#include "nsIDOMEventGroup.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
|
@ -278,6 +279,7 @@ extern nsresult NS_NewBindingManager(nsIBindingManager** aResult);
|
|||
extern nsresult NS_NewNodeInfoManager(nsINodeInfoManager** aResult);
|
||||
extern nsresult NS_NewContentPolicy(nsIContentPolicy** aResult);
|
||||
extern nsresult NS_NewFrameLoader(nsIFrameLoader** aResult);
|
||||
extern nsresult NS_NewDOMEventGroup(nsIDOMEventGroup** aResult);
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
extern nsresult NS_NewXULElementFactory(nsIElementFactory** aResult);
|
||||
|
@ -311,6 +313,7 @@ ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) \
|
|||
MAKE_CTOR(CreateNameSpaceManager, nsINameSpaceManager, NS_NewNameSpaceManager)
|
||||
MAKE_CTOR(CreateEventListenerManager, nsIEventListenerManager, NS_NewEventListenerManager)
|
||||
MAKE_CTOR(CreateEventStateManager, nsIEventStateManager, NS_NewEventStateManager)
|
||||
MAKE_CTOR(CreateDOMEventGroup, nsIDOMEventGroup, NS_NewDOMEventGroup)
|
||||
MAKE_CTOR(CreateDocumentViewer, nsIDocumentViewer, NS_NewDocumentViewer)
|
||||
MAKE_CTOR(CreateHTMLStyleSheet, nsIHTMLStyleSheet, NS_NewHTMLStyleSheet)
|
||||
MAKE_CTOR(CreateStyleSet, nsIStyleSet, NS_NewStyleSet)
|
||||
|
@ -484,6 +487,11 @@ static const nsModuleComponentInfo gComponents[] = {
|
|||
nsnull,
|
||||
CreateEventStateManager },
|
||||
|
||||
{ "DOM Event group",
|
||||
NS_DOMEVENTGROUP_CID,
|
||||
nsnull,
|
||||
CreateDOMEventGroup },
|
||||
|
||||
{ "Document Viewer",
|
||||
NS_DOCUMENT_VIEWER_CID,
|
||||
nsnull,
|
||||
|
|
|
@ -47,6 +47,7 @@ class nsIPresContext;
|
|||
class nsIDOMEventListener;
|
||||
class nsIScriptContext;
|
||||
class nsIDOMEventTarget;
|
||||
class nsIDOMEventGroup;
|
||||
|
||||
/*
|
||||
* Event listener manager interface.
|
||||
|
@ -81,7 +82,8 @@ public:
|
|||
*/
|
||||
NS_IMETHOD AddEventListenerByType(nsIDOMEventListener *aListener,
|
||||
const nsAString& type,
|
||||
PRInt32 flags) = 0;
|
||||
PRInt32 flags,
|
||||
nsIDOMEventGroup* aEvtGrp) = 0;
|
||||
|
||||
/**
|
||||
* Removes events listeners of all types.
|
||||
|
@ -89,7 +91,8 @@ public:
|
|||
*/
|
||||
NS_IMETHOD RemoveEventListenerByType(nsIDOMEventListener *aListener,
|
||||
const nsAString& type,
|
||||
PRInt32 flags) = 0;
|
||||
PRInt32 flags,
|
||||
nsIDOMEventGroup* aEvtGrp) = 0;
|
||||
|
||||
/**
|
||||
* Creates a script event listener for the given script object with
|
||||
|
@ -173,6 +176,13 @@ public:
|
|||
* Allows us to quickly determine if we have mutation listeners registered.
|
||||
*/
|
||||
NS_IMETHOD HasMutationListeners(PRBool* aListener) = 0;
|
||||
|
||||
/**
|
||||
* Gets the EventGroup registered for use by system event listeners.
|
||||
* This is a special EventGroup which is used in the secondary DOM Event
|
||||
* Loop pass for evaluation of system event listeners.
|
||||
*/
|
||||
NS_IMETHOD GetSystemEventGroupLM(nsIDOMEventGroup** aGroup) = 0;
|
||||
};
|
||||
|
||||
extern nsresult
|
||||
|
|
|
@ -44,7 +44,7 @@ REQUIRES = xpcom \
|
|||
htmlparser \
|
||||
view \
|
||||
necko \
|
||||
webbrwsr \
|
||||
webbrwsr \
|
||||
unicharutil \
|
||||
$(NULL)
|
||||
|
||||
|
@ -54,6 +54,7 @@ CPPSRCS = \
|
|||
nsDOMEvent.cpp \
|
||||
nsDOMMutationEvent.cpp \
|
||||
nsPrivateTextRange.cpp \
|
||||
nsDOMEventGroup.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
|
|
|
@ -55,6 +55,7 @@ CPP_OBJS= .\$(OBJDIR)\nsEventListenerManager.obj \
|
|||
.\$(OBJDIR)\nsDOMEvent.obj \
|
||||
.\$(OBJDIR)\nsDOMMutationEvent.obj \
|
||||
.\$(OBJDIR)\nsPrivateTextRange.obj \
|
||||
.\$(OBJDIR)\nsDOMEventGroup.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
|
|
|
@ -399,15 +399,15 @@ nsDOMEvent::SetTrusted(PRBool aTrusted)
|
|||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetEventPhase(PRUint16* aEventPhase)
|
||||
{
|
||||
if (mEvent->flags & NS_EVENT_FLAG_CAPTURE) {
|
||||
if (mEvent->flags & NS_EVENT_FLAG_INIT) {
|
||||
*aEventPhase = nsIDOMMouseEvent::AT_TARGET;
|
||||
}
|
||||
else if (mEvent->flags & NS_EVENT_FLAG_CAPTURE) {
|
||||
*aEventPhase = nsIDOMMouseEvent::CAPTURING_PHASE;
|
||||
}
|
||||
else if (mEvent->flags & NS_EVENT_FLAG_BUBBLE) {
|
||||
*aEventPhase = nsIDOMMouseEvent::BUBBLING_PHASE;
|
||||
}
|
||||
else if (mEvent->flags & NS_EVENT_FLAG_INIT) {
|
||||
*aEventPhase = nsIDOMMouseEvent::AT_TARGET;
|
||||
}
|
||||
else {
|
||||
*aEventPhase = 0;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Steve Clark (buster@netscape.com)
|
||||
*
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsDOMEventGroup.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsDOMEventGroup, nsIDOMEventGroup)
|
||||
|
||||
nsDOMEventGroup::nsDOMEventGroup()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
nsDOMEventGroup::~nsDOMEventGroup()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
/* boolean isSameEventGroup (in nsIDOMEventGroup other); */
|
||||
NS_IMETHODIMP nsDOMEventGroup::IsSameEventGroup(nsIDOMEventGroup *other, PRBool *retval)
|
||||
{
|
||||
*retval = PR_FALSE;
|
||||
if (other == this) {
|
||||
*retval = PR_TRUE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult NS_NewDOMEventGroup(nsIDOMEventGroup** aResult);
|
||||
|
||||
nsresult
|
||||
NS_NewDOMEventGroup(nsIDOMEventGroup** aInstancePtrResult)
|
||||
{
|
||||
*aInstancePtrResult = new nsDOMEventGroup;
|
||||
if (!*aInstancePtrResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(*aInstancePtrResult);
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIDOMEventGroup_h__
|
||||
#define nsIDOMEventGroup_h__
|
||||
|
||||
#include "nsIDOMEventGroup.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsDOMEventGroup : public nsIDOMEventGroup
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMEVENTGROUP
|
||||
|
||||
nsDOMEventGroup();
|
||||
virtual ~nsDOMEventGroup();
|
||||
};
|
||||
|
||||
#endif // nsIDOMEventGroup_h__
|
|
@ -84,11 +84,16 @@
|
|||
#include "nsIBoxObject.h"
|
||||
#include "nsIDOMNSDocument.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
#include "nsIDOMEventGroup.h"
|
||||
#include "nsContentCID.h"
|
||||
|
||||
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
|
||||
NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
||||
static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);
|
||||
|
||||
nsIDOMEventGroup * gSystemEventGroup = 0; // Strong reference
|
||||
nsIDOMEventGroup * gDOM2EventGroup = 0; // Strong reference
|
||||
PRUint32 nsEventListenerManager::mInstanceCount = 0;
|
||||
|
||||
nsEventListenerManager::nsEventListenerManager()
|
||||
{
|
||||
|
@ -101,6 +106,7 @@ nsEventListenerManager::nsEventListenerManager()
|
|||
|
||||
mTarget = nsnull;
|
||||
NS_INIT_REFCNT();
|
||||
++mInstanceCount;
|
||||
}
|
||||
|
||||
static PRBool PR_CALLBACK
|
||||
|
@ -134,10 +140,16 @@ GenericListenersHashEnum(nsHashKey *aKey, void *aData, void* closure)
|
|||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
nsEventListenerManager::~nsEventListenerManager()
|
||||
{
|
||||
RemoveAllListeners(PR_FALSE);
|
||||
|
||||
--mInstanceCount;
|
||||
if(mInstanceCount == 0) {
|
||||
NS_IF_RELEASE(gSystemEventGroup);
|
||||
NS_IF_RELEASE(gDOM2EventGroup);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult nsEventListenerManager::RemoveAllListeners(PRBool aScriptOnly)
|
||||
|
@ -193,6 +205,7 @@ NS_INTERFACE_MAP_BEGIN(nsEventListenerManager)
|
|||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIEventListenerManager)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIEventListenerManager)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMEventReceiver)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
@ -387,7 +400,8 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener,
|
|||
EventArrayType aType,
|
||||
PRInt32 aSubType,
|
||||
nsHashKey* aKey,
|
||||
PRInt32 aFlags)
|
||||
PRInt32 aFlags,
|
||||
nsIDOMEventGroup* aEvtGrp)
|
||||
{
|
||||
NS_ENSURE_TRUE(aListener, NS_ERROR_FAILURE);
|
||||
|
||||
|
@ -418,15 +432,28 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener,
|
|||
window->SetMutationListeners(aSubType);
|
||||
}
|
||||
}
|
||||
|
||||
PRBool isSame = PR_FALSE;
|
||||
PRUint16 group = 0;
|
||||
nsCOMPtr<nsIDOMEventGroup> sysGroup;
|
||||
GetSystemEventGroupLM(getter_AddRefs(sysGroup));
|
||||
if (sysGroup) {
|
||||
sysGroup->IsSameEventGroup(aEvtGrp, &isSame);
|
||||
if (isSame) {
|
||||
group = NS_EVENT_FLAG_SYSTEM_EVENT;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool found = PR_FALSE;
|
||||
nsListenerStruct* ls;
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIScriptEventListener> sel = do_QueryInterface(aListener, &rv);
|
||||
|
||||
|
||||
for (int i=0; i<listeners->Count(); i++) {
|
||||
ls = (nsListenerStruct*)listeners->ElementAt(i);
|
||||
if (ls->mListener == aListener && ls->mFlags == aFlags) {
|
||||
if (ls->mListener == aListener && ls->mFlags == aFlags && ls->mGroupFlags == group) {
|
||||
ls->mSubType |= aSubType;
|
||||
found = PR_TRUE;
|
||||
break;
|
||||
|
@ -455,6 +482,7 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener,
|
|||
ls->mSubType = aSubType;
|
||||
ls->mSubTypeCapture = NS_EVENT_BITS_NONE;
|
||||
ls->mHandlerIsString = 0;
|
||||
ls->mGroupFlags = group;
|
||||
listeners->AppendElement((void*)ls);
|
||||
NS_ADDREF(aListener);
|
||||
}
|
||||
|
@ -481,7 +509,8 @@ nsEventListenerManager::RemoveEventListener(nsIDOMEventListener *aListener,
|
|||
EventArrayType aType,
|
||||
PRInt32 aSubType,
|
||||
nsHashKey* aKey,
|
||||
PRInt32 aFlags)
|
||||
PRInt32 aFlags,
|
||||
nsIDOMEventGroup* aEvtGrp)
|
||||
{
|
||||
nsVoidArray* listeners = GetListenersByType(aType, aKey, PR_FALSE);
|
||||
|
||||
|
@ -544,7 +573,7 @@ nsEventListenerManager::RemoveEventListener(nsIDOMEventListener *aListener,
|
|||
nsresult nsEventListenerManager::AddEventListenerByIID(nsIDOMEventListener *aListener,
|
||||
const nsIID& aIID, PRInt32 aFlags)
|
||||
{
|
||||
AddEventListener(aListener, GetTypeForIID(aIID), NS_EVENT_BITS_NONE, nsnull, aFlags);
|
||||
AddEventListener(aListener, GetTypeForIID(aIID), NS_EVENT_BITS_NONE, nsnull, aFlags, nsnull);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -553,7 +582,7 @@ nsEventListenerManager::RemoveEventListenerByIID(nsIDOMEventListener *aListener,
|
|||
const nsIID& aIID,
|
||||
PRInt32 aFlags)
|
||||
{
|
||||
RemoveEventListener(aListener, GetTypeForIID(aIID), NS_EVENT_BITS_NONE, nsnull, aFlags);
|
||||
RemoveEventListener(aListener, GetTypeForIID(aIID), NS_EVENT_BITS_NONE, nsnull, aFlags, nsnull);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -760,7 +789,8 @@ nsresult nsEventListenerManager::GetIdentifiersForType(nsIAtom* aType, EventArra
|
|||
NS_IMETHODIMP
|
||||
nsEventListenerManager::AddEventListenerByType(nsIDOMEventListener *aListener,
|
||||
const nsAString& aType,
|
||||
PRInt32 aFlags)
|
||||
PRInt32 aFlags,
|
||||
nsIDOMEventGroup* aEvtGrp)
|
||||
{
|
||||
PRInt32 subType;
|
||||
EventArrayType arrayType;
|
||||
|
@ -768,12 +798,12 @@ nsEventListenerManager::AddEventListenerByType(nsIDOMEventListener *aListener,
|
|||
dont_AddRef(NS_NewAtom(NS_LITERAL_STRING("on") + aType));
|
||||
|
||||
if (NS_OK == GetIdentifiersForType(atom, &arrayType, &subType)) {
|
||||
AddEventListener(aListener, arrayType, subType, nsnull, aFlags);
|
||||
AddEventListener(aListener, arrayType, subType, nsnull, aFlags, aEvtGrp);
|
||||
}
|
||||
else {
|
||||
const nsPromiseFlatString& flatString = PromiseFlatString(aType);
|
||||
nsStringKey key(flatString);
|
||||
AddEventListener(aListener, eEventArrayType_Hash, NS_EVENT_BITS_NONE, &key, aFlags);
|
||||
AddEventListener(aListener, eEventArrayType_Hash, NS_EVENT_BITS_NONE, &key, aFlags, aEvtGrp);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -782,7 +812,8 @@ nsEventListenerManager::AddEventListenerByType(nsIDOMEventListener *aListener,
|
|||
NS_IMETHODIMP
|
||||
nsEventListenerManager::RemoveEventListenerByType(nsIDOMEventListener *aListener,
|
||||
const nsAString& aType,
|
||||
PRInt32 aFlags)
|
||||
PRInt32 aFlags,
|
||||
nsIDOMEventGroup* aEvtGrp)
|
||||
{
|
||||
PRInt32 subType;
|
||||
EventArrayType arrayType;
|
||||
|
@ -790,12 +821,12 @@ nsEventListenerManager::RemoveEventListenerByType(nsIDOMEventListener *aListener
|
|||
dont_AddRef(NS_NewAtom(NS_LITERAL_STRING("on") + aType));
|
||||
|
||||
if (NS_OK == GetIdentifiersForType(atom, &arrayType, &subType)) {
|
||||
RemoveEventListener(aListener, arrayType, subType, nsnull, aFlags);
|
||||
RemoveEventListener(aListener, arrayType, subType, nsnull, aFlags, aEvtGrp);
|
||||
}
|
||||
else {
|
||||
const nsPromiseFlatString& flatString = PromiseFlatString(aType);
|
||||
nsStringKey key(flatString);
|
||||
RemoveEventListener(aListener, eEventArrayType_Hash, NS_EVENT_BITS_NONE, &key, aFlags);
|
||||
RemoveEventListener(aListener, eEventArrayType_Hash, NS_EVENT_BITS_NONE, &key, aFlags, aEvtGrp);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -847,7 +878,7 @@ nsEventListenerManager::SetJSEventListener(nsIScriptContext *aContext,
|
|||
getter_AddRefs(scriptListener));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
AddEventListener(scriptListener, arrayType, NS_EVENT_BITS_NONE, nsnull,
|
||||
NS_EVENT_FLAG_BUBBLE | NS_PRIV_EVENT_FLAG_SCRIPT);
|
||||
NS_EVENT_FLAG_BUBBLE | NS_PRIV_EVENT_FLAG_SCRIPT, nsnull);
|
||||
|
||||
ls = FindJSEventListener(arrayType);
|
||||
}
|
||||
|
@ -1242,6 +1273,10 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
NS_ENSURE_ARG_POINTER(aEventStatus);
|
||||
nsresult ret = NS_OK;
|
||||
|
||||
if (aEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (aFlags & NS_EVENT_FLAG_INIT) {
|
||||
aFlags |= (NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_CAPTURE);
|
||||
}
|
||||
|
@ -1249,6 +1284,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
if (*aEventStatus == nsEventStatus_eConsumeNoDefault) {
|
||||
aEvent->flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||
}
|
||||
PRUint16 currentGroup = aFlags & NS_EVENT_FLAG_SYSTEM_EVENT;
|
||||
|
||||
/* Without this addref, certain events, notably ones bound to
|
||||
keys which cause window deletion, can destroy this object
|
||||
|
@ -1267,7 +1303,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
if (NS_SUCCEEDED(ret)) {
|
||||
for (int i=0; !mListenersRemoved && listeners && i<listeners->Count(); i++) {
|
||||
nsListenerStruct *ls = (nsListenerStruct*)listeners->ElementAt(i);
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (ls->mFlags & aFlags && ls->mGroupFlags == currentGroup) {
|
||||
ret = HandleEventSubType(ls, *aDOMEvent, aCurrentTarget, NS_EVENT_BITS_NONE, aFlags);
|
||||
}
|
||||
}
|
||||
|
@ -1298,7 +1334,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
for (int i=0; !mListenersRemoved && listeners && i<listeners->Count(); i++) {
|
||||
nsListenerStruct *ls = (nsListenerStruct*)listeners->ElementAt(i);
|
||||
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (ls->mFlags & aFlags && ls->mGroupFlags == currentGroup) {
|
||||
nsCOMPtr<nsIDOMMouseListener> mouseListener (do_QueryInterface(ls->mListener));
|
||||
if (mouseListener) {
|
||||
switch(aEvent->message) {
|
||||
|
@ -1403,7 +1439,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
for (int i=0; !mListenersRemoved && listeners && i<listeners->Count(); i++) {
|
||||
nsListenerStruct *ls = (nsListenerStruct*)listeners->ElementAt(i);
|
||||
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (ls->mFlags & aFlags && ls->mGroupFlags == currentGroup) {
|
||||
nsCOMPtr<nsIDOMMouseMotionListener> mousemlistener (do_QueryInterface(ls->mListener));
|
||||
if (mousemlistener) {
|
||||
switch(aEvent->message) {
|
||||
|
@ -1490,7 +1526,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
for (int i=0; !mListenersRemoved && listeners && i<listeners->Count(); i++) {
|
||||
nsListenerStruct *ls = (nsListenerStruct*)listeners->ElementAt(i);
|
||||
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (ls->mFlags & aFlags && ls->mGroupFlags == currentGroup) {
|
||||
nsCOMPtr<nsIDOMContextMenuListener> contextMenuListener (do_QueryInterface(ls->mListener));
|
||||
if (contextMenuListener) {
|
||||
switch(aEvent->message) {
|
||||
|
@ -1540,7 +1576,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
for(int i=0; !mListenersRemoved && listeners && i<listeners->Count();i++) {
|
||||
nsListenerStruct *ls = (nsListenerStruct*)listeners->ElementAt(i);
|
||||
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (ls->mFlags & aFlags && ls->mGroupFlags == currentGroup) {
|
||||
nsCOMPtr<nsIDOMCompositionListener> compositionListener (do_QueryInterface(ls->mListener));
|
||||
if (compositionListener) {
|
||||
switch (aEvent->message) {
|
||||
|
@ -1603,7 +1639,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
for (int i=0; !mListenersRemoved && listeners && i<listeners->Count(); i++) {
|
||||
nsListenerStruct *ls = (nsListenerStruct*)listeners->ElementAt(i);
|
||||
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (ls->mFlags & aFlags && ls->mGroupFlags == currentGroup) {
|
||||
nsCOMPtr<nsIDOMTextListener> textListener (do_QueryInterface(ls->mListener));
|
||||
if (textListener) {
|
||||
ret = textListener->HandleText(*aDOMEvent);
|
||||
|
@ -1636,7 +1672,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
for (int i=0; !mListenersRemoved && listeners && i<listeners->Count(); i++) {
|
||||
nsListenerStruct *ls = (nsListenerStruct*)listeners->ElementAt(i);
|
||||
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (ls->mFlags & aFlags && ls->mGroupFlags == currentGroup) {
|
||||
nsCOMPtr<nsIDOMKeyListener> keyListener (do_QueryInterface(ls->mListener));
|
||||
if (keyListener) {
|
||||
switch(aEvent->message) {
|
||||
|
@ -1699,7 +1735,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
for (int i=0; !mListenersRemoved && listeners && i<listeners->Count(); i++) {
|
||||
nsListenerStruct *ls = (nsListenerStruct*)listeners->ElementAt(i);
|
||||
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (ls->mFlags & aFlags && ls->mGroupFlags == currentGroup) {
|
||||
nsCOMPtr<nsIDOMFocusListener> focusListener (do_QueryInterface(ls->mListener));
|
||||
if (focusListener) {
|
||||
switch(aEvent->message) {
|
||||
|
@ -1756,7 +1792,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
for (int i=0; !mListenersRemoved && listeners && i<listeners->Count(); i++) {
|
||||
nsListenerStruct *ls = (nsListenerStruct*)listeners->ElementAt(i);
|
||||
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (ls->mFlags & aFlags && ls->mGroupFlags == currentGroup) {
|
||||
nsCOMPtr<nsIDOMFormListener> formListener(do_QueryInterface(ls->mListener));
|
||||
if (formListener) {
|
||||
switch(aEvent->message) {
|
||||
|
@ -1841,7 +1877,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
for (int i=0; !mListenersRemoved && listeners && i<listeners->Count(); i++) {
|
||||
nsListenerStruct *ls = (nsListenerStruct*)listeners->ElementAt(i);
|
||||
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (ls->mFlags & aFlags && ls->mGroupFlags == currentGroup) {
|
||||
nsCOMPtr<nsIDOMLoadListener> loadListener(do_QueryInterface(ls->mListener));
|
||||
if (loadListener) {
|
||||
switch(aEvent->message) {
|
||||
|
@ -1910,7 +1946,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
for (int i=0; !mListenersRemoved && listeners && i<listeners->Count(); i++) {
|
||||
nsListenerStruct *ls = (nsListenerStruct*)listeners->ElementAt(i);
|
||||
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (ls->mFlags & aFlags && ls->mGroupFlags == currentGroup) {
|
||||
nsCOMPtr<nsIDOMPaintListener> paintListener(do_QueryInterface(ls->mListener));
|
||||
if (paintListener) {
|
||||
switch(aEvent->message) {
|
||||
|
@ -1977,7 +2013,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
for (int i=0; !mListenersRemoved && listeners && i<listeners->Count(); i++) {
|
||||
nsListenerStruct *dragStruct = (nsListenerStruct*)listeners->ElementAt(i);
|
||||
|
||||
if (dragStruct->mFlags & aFlags) {
|
||||
if (dragStruct->mFlags & aFlags && dragStruct->mGroupFlags == currentGroup) {
|
||||
nsCOMPtr<nsIDOMDragListener> dragListener ( do_QueryInterface(dragStruct->mListener) );
|
||||
if ( dragListener ) {
|
||||
switch (aEvent->message) {
|
||||
|
@ -2050,7 +2086,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
for (int i=0; !mListenersRemoved && listeners && i<listeners->Count(); i++) {
|
||||
nsListenerStruct *ls = (nsListenerStruct*)listeners->ElementAt(i);
|
||||
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (ls->mFlags & aFlags && ls->mGroupFlags == currentGroup) {
|
||||
nsCOMPtr<nsIDOMScrollListener> scrollListener(do_QueryInterface(ls->mListener));
|
||||
if (scrollListener) {
|
||||
switch(aEvent->message) {
|
||||
|
@ -2118,7 +2154,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
for (int i=0; !mListenersRemoved && listeners && i<listeners->Count(); i++) {
|
||||
nsListenerStruct *ls = (nsListenerStruct*)listeners->ElementAt(i);
|
||||
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (ls->mFlags & aFlags && ls->mGroupFlags == currentGroup) {
|
||||
nsCOMPtr<nsIDOMXULListener> xulListener(do_QueryInterface(ls->mListener));
|
||||
if (xulListener) {
|
||||
switch(aEvent->message) {
|
||||
|
@ -2231,7 +2267,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
for (int i=0; !mListenersRemoved && listeners && i<listeners->Count(); i++) {
|
||||
nsListenerStruct *ls = (nsListenerStruct*)listeners->ElementAt(i);
|
||||
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (ls->mFlags & aFlags && ls->mGroupFlags == currentGroup) {
|
||||
nsCOMPtr<nsIDOMMutationListener> mutationListener = do_QueryInterface(ls->mListener);
|
||||
if (mutationListener) {
|
||||
switch(aEvent->message) {
|
||||
|
@ -2612,6 +2648,42 @@ nsEventListenerManager::SetListenerTarget(nsISupports* aTarget)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventListenerManager::GetSystemEventGroupLM(nsIDOMEventGroup **aGroup)
|
||||
{
|
||||
if (!gSystemEventGroup) {
|
||||
nsresult result;
|
||||
nsCOMPtr<nsIDOMEventGroup> group(do_CreateInstance(kDOMEventGroupCID,&result));
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
gSystemEventGroup = group;
|
||||
NS_ADDREF(gSystemEventGroup);
|
||||
}
|
||||
|
||||
*aGroup = gSystemEventGroup;
|
||||
NS_ADDREF(*aGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsEventListenerManager::GetDOM2EventGroup(nsIDOMEventGroup **aGroup)
|
||||
{
|
||||
if (!gDOM2EventGroup) {
|
||||
nsresult result;
|
||||
nsCOMPtr<nsIDOMEventGroup> group(do_CreateInstance(kDOMEventGroupCID,&result));
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
gDOM2EventGroup = group;
|
||||
NS_ADDREF(gDOM2EventGroup);
|
||||
}
|
||||
|
||||
*aGroup = gDOM2EventGroup;
|
||||
NS_ADDREF(*aGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIDOMEventTarget interface
|
||||
NS_IMETHODIMP
|
||||
nsEventListenerManager::AddEventListener(const nsAString& aType,
|
||||
|
@ -2620,7 +2692,7 @@ nsEventListenerManager::AddEventListener(const nsAString& aType,
|
|||
{
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
return AddEventListenerByType(aListener, aType, flags);
|
||||
return AddEventListenerByType(aListener, aType, flags, nsnull);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -2630,7 +2702,7 @@ nsEventListenerManager::RemoveEventListener(const nsAString& aType,
|
|||
{
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
return RemoveEventListenerByType(aListener, aType, flags);
|
||||
return RemoveEventListenerByType(aListener, aType, flags, nsnull);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -2666,6 +2738,41 @@ nsEventListenerManager::DispatchEvent(nsIDOMEvent* aEvent, PRBool *_retval)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// nsIDOM3EventTarget interface
|
||||
NS_IMETHODIMP
|
||||
nsEventListenerManager::AddGroupedEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture,
|
||||
nsIDOMEventGroup* aEvtGrp)
|
||||
{
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
return AddEventListenerByType(aListener, aType, flags, aEvtGrp);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventListenerManager::RemoveGroupedEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture,
|
||||
nsIDOMEventGroup* aEvtGrp)
|
||||
{
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
return RemoveEventListenerByType(aListener, aType, flags, aEvtGrp);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventListenerManager::CanTrigger(const nsAString & type, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventListenerManager::IsRegisteredHere(const nsAString & type, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// nsIDOMEventReceiver interface
|
||||
NS_IMETHODIMP
|
||||
nsEventListenerManager::AddEventListenerByIID(nsIDOMEventListener *aListener,
|
||||
|
@ -2696,6 +2803,12 @@ nsEventListenerManager::HandleEvent(nsIDOMEvent *aEvent)
|
|||
return DispatchEvent(aEvent, &noDefault);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventListenerManager::GetSystemEventGroup(nsIDOMEventGroup **aGroup)
|
||||
{
|
||||
return GetSystemEventGroupLM(aGroup);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewEventListenerManager(nsIEventListenerManager** aInstancePtrResult)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOM3EventTarget.h"
|
||||
#include "nsHashtable.h"
|
||||
|
||||
class nsIDOMEvent;
|
||||
|
@ -55,6 +56,7 @@ typedef struct {
|
|||
PRUint8 mSubType;
|
||||
PRUint8 mHandlerIsString;
|
||||
PRUint8 mSubTypeCapture;
|
||||
PRUint16 mGroupFlags;
|
||||
} nsListenerStruct;
|
||||
|
||||
//These define the internal type of the EventListenerManager
|
||||
|
@ -95,7 +97,8 @@ enum EventArrayType {
|
|||
*/
|
||||
|
||||
class nsEventListenerManager : public nsIEventListenerManager,
|
||||
public nsIDOMEventReceiver
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIDOM3EventTarget
|
||||
{
|
||||
|
||||
public:
|
||||
|
@ -114,10 +117,12 @@ public:
|
|||
const nsIID& aIID, PRInt32 aFlags);
|
||||
NS_IMETHOD AddEventListenerByType(nsIDOMEventListener *aListener,
|
||||
const nsAString& type,
|
||||
PRInt32 aFlags);
|
||||
PRInt32 aFlags,
|
||||
nsIDOMEventGroup* aEvtGrp);
|
||||
NS_IMETHOD RemoveEventListenerByType(nsIDOMEventListener *aListener,
|
||||
const nsAString& type,
|
||||
PRInt32 aFlags) ;
|
||||
PRInt32 aFlags,
|
||||
nsIDOMEventGroup *aEvtGrp) ;
|
||||
NS_IMETHOD AddScriptEventListener(nsIScriptContext*aContext,
|
||||
nsISupports *aObject,
|
||||
nsIAtom *aName,
|
||||
|
@ -157,18 +162,17 @@ public:
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetSystemEventGroupLM(nsIDOMEventGroup** aGroup);
|
||||
|
||||
static nsresult GetIdentifiersForType(nsIAtom* aType,
|
||||
EventArrayType* aArrayType,
|
||||
PRInt32* aSubType);
|
||||
|
||||
// nsIDOMEventTarget interface
|
||||
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);
|
||||
// nsIDOMEventTarget
|
||||
NS_DECL_NSIDOMEVENTTARGET
|
||||
|
||||
// nsIDOM3EventTarget
|
||||
NS_DECL_NSIDOM3EVENTTARGET
|
||||
|
||||
// nsIDOMEventReceiver interface
|
||||
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener,
|
||||
|
@ -177,6 +181,7 @@ public:
|
|||
const nsIID& aIID);
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent);
|
||||
NS_IMETHOD GetSystemEventGroup(nsIDOMEventGroup** aGroup);
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
|
@ -199,16 +204,19 @@ protected:
|
|||
EventArrayType aType,
|
||||
PRInt32 aSubType,
|
||||
nsHashKey* aKey,
|
||||
PRInt32 aFlags);
|
||||
PRInt32 aFlags,
|
||||
nsIDOMEventGroup* aEvtGrp);
|
||||
nsresult RemoveEventListener(nsIDOMEventListener *aListener,
|
||||
EventArrayType aType,
|
||||
PRInt32 aSubType,
|
||||
nsHashKey* aKey,
|
||||
PRInt32 aFlags);
|
||||
PRInt32 aFlags,
|
||||
nsIDOMEventGroup* aEvtGrp);
|
||||
void ReleaseListeners(nsVoidArray** aListeners, PRBool aScriptOnly);
|
||||
nsresult FlipCaptureBit(PRInt32 aEventTypes, PRBool aInitCapture);
|
||||
nsVoidArray* GetListenersByType(EventArrayType aType, nsHashKey* aKey, PRBool aCreate);
|
||||
EventArrayType GetTypeForIID(const nsIID& aIID);
|
||||
nsresult GetDOM2EventGroup(nsIDOMEventGroup** aGroup);
|
||||
|
||||
PRUint8 mManagerType;
|
||||
EventArrayType mSingleListenerType;
|
||||
|
@ -216,6 +224,7 @@ protected:
|
|||
nsVoidArray* mMultiListeners;
|
||||
nsHashtable* mGenericListeners;
|
||||
PRBool mListenersRemoved;
|
||||
static PRUint32 mInstanceCount;
|
||||
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
nsISupports* mTarget; //WEAK
|
||||
|
|
|
@ -4019,10 +4019,10 @@ nsEventStateManager::DispatchNewEvent(nsISupports* aTarget, nsIDOMEvent* aEvent,
|
|||
privEvt->SetTarget(eventTarget);
|
||||
|
||||
//Key and mouse events have additional security to prevent event spoofing
|
||||
nsEvent * internalEvent;
|
||||
privEvt->GetInternalNSEvent(&internalEvent);
|
||||
if (internalEvent && (internalEvent->eventStructType == NS_KEY_EVENT ||
|
||||
internalEvent->eventStructType == NS_MOUSE_EVENT)) {
|
||||
nsEvent * innerEvent;
|
||||
privEvt->GetInternalNSEvent(&innerEvent);
|
||||
if (innerEvent && (innerEvent->eventStructType == NS_KEY_EVENT ||
|
||||
innerEvent->eventStructType == NS_MOUSE_EVENT)) {
|
||||
//Check security state to determine if dispatcher is trusted
|
||||
nsCOMPtr<nsIScriptSecurityManager>
|
||||
securityManager(do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID));
|
||||
|
@ -4041,8 +4041,6 @@ nsEventStateManager::DispatchNewEvent(nsISupports* aTarget, nsIDOMEvent* aEvent,
|
|||
privEvt->SetTrusted(PR_TRUE);
|
||||
}
|
||||
|
||||
nsEvent* innerEvent;
|
||||
privEvt->GetInternalNSEvent(&innerEvent);
|
||||
if (innerEvent) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsCOMPtr<nsIScriptGlobalObject> target(do_QueryInterface(aTarget));
|
||||
|
|
|
@ -1392,7 +1392,7 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsIContent* aOuter,
|
|||
(*aEventStatus != nsEventStatus_eConsumeNoDefault &&
|
||||
(aEvent->message == NS_MOUSE_ENTER_SYNTH ||
|
||||
aEvent->message == NS_MOUSE_EXIT_SYNTH))) &&
|
||||
!(aFlags & NS_EVENT_FLAG_CAPTURE)) {
|
||||
!(aFlags & NS_EVENT_FLAG_CAPTURE) && !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT)) {
|
||||
|
||||
// If we're here, then aOuter should be an nsILink. We'll use the
|
||||
// nsILink interface to get a canonified URL that has been
|
||||
|
|
|
@ -475,7 +475,7 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
aEventStatus);
|
||||
|
||||
if ((NS_OK == ret) && (nsEventStatus_eIgnore == *aEventStatus) &&
|
||||
!(aFlags & NS_EVENT_FLAG_CAPTURE)) {
|
||||
!(aFlags & NS_EVENT_FLAG_CAPTURE) && !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT)) {
|
||||
switch (aEvent->message) {
|
||||
|
||||
case NS_KEY_PRESS:
|
||||
|
|
|
@ -602,7 +602,7 @@ nsHTMLFormElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
aEventStatus);
|
||||
|
||||
if ((NS_OK == ret) && (nsEventStatus_eIgnore == *aEventStatus) &&
|
||||
!(aFlags & NS_EVENT_FLAG_CAPTURE)) {
|
||||
!(aFlags & NS_EVENT_FLAG_CAPTURE) && !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT)) {
|
||||
|
||||
switch (aEvent->message) {
|
||||
case NS_FORM_RESET:
|
||||
|
|
|
@ -1341,7 +1341,7 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> selectedRadioButton;
|
||||
|
||||
if (!(aFlags & NS_EVENT_FLAG_CAPTURE) &&
|
||||
if (!(aFlags & NS_EVENT_FLAG_CAPTURE) && !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT) &&
|
||||
aEvent->message == NS_MOUSE_LEFT_CLICK) {
|
||||
GetChecked(&originalCheckedValue);
|
||||
checkWasSet = PR_TRUE;
|
||||
|
@ -1411,7 +1411,7 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
aEvent->flags |= noContentDispatch ? NS_EVENT_FLAG_NO_CONTENT_DISPATCH : NS_EVENT_FLAG_NONE;
|
||||
|
||||
// now check to see if the event was "cancelled"
|
||||
if (nsEventStatus_eConsumeNoDefault == *aEventStatus && checkWasSet
|
||||
if (nsEventStatus_eConsumeNoDefault == *aEventStatus && checkWasSet && !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT)
|
||||
&& (type == NS_FORM_INPUT_CHECKBOX || type == NS_FORM_INPUT_RADIO)) {
|
||||
// if it was cancelled and a radio button, then set the old
|
||||
// selected btn to TRUE. if it is a checkbox then set it to its
|
||||
|
@ -1452,13 +1452,13 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
if (type == NS_FORM_INPUT_IMAGE &&
|
||||
aEvent->message == NS_MOUSE_LEFT_BUTTON_UP &&
|
||||
nsEventStatus_eIgnore == *aEventStatus &&
|
||||
aFlags & NS_EVENT_FLAG_BUBBLE) {
|
||||
aFlags & NS_EVENT_FLAG_BUBBLE && !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT)) {
|
||||
// Tell the frame about the click
|
||||
return MouseClickForAltText(aPresContext);
|
||||
}
|
||||
|
||||
if ((NS_OK == rv) && (nsEventStatus_eIgnore == *aEventStatus) &&
|
||||
!(aFlags & NS_EVENT_FLAG_CAPTURE)) {
|
||||
!(aFlags & NS_EVENT_FLAG_CAPTURE) && !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT)) {
|
||||
switch (aEvent->message) {
|
||||
|
||||
case NS_FOCUS_CONTENT:
|
||||
|
|
|
@ -1800,7 +1800,7 @@ nsHTMLSelectElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
// the focused element. So the ComboboxControlFrame tracks the focus
|
||||
// at a class level (Bug 32920)
|
||||
if ((nsEventStatus_eIgnore == *aEventStatus) &&
|
||||
!(aFlags & NS_EVENT_FLAG_CAPTURE) &&
|
||||
!(aFlags & NS_EVENT_FLAG_CAPTURE) && !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT) &&
|
||||
(aEvent->message == NS_BLUR_CONTENT) && formControlFrame) {
|
||||
formControlFrame->SetFocus(PR_FALSE, PR_TRUE);
|
||||
}
|
||||
|
|
|
@ -446,7 +446,7 @@ nsXMLElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
aEventStatus);
|
||||
|
||||
if (mIsLink && (NS_OK == ret) && (nsEventStatus_eIgnore == *aEventStatus) &&
|
||||
!(aFlags & NS_EVENT_FLAG_CAPTURE)) {
|
||||
!(aFlags & NS_EVENT_FLAG_CAPTURE) && !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT)) {
|
||||
switch (aEvent->message) {
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
{
|
||||
|
|
|
@ -669,18 +669,32 @@ nsXULElement::QueryInterface(REFNSIID iid, void** result)
|
|||
else if (iid.Equals(NS_GET_IID(nsIScriptEventHandlerOwner))) {
|
||||
*result = NS_STATIC_CAST(nsIScriptEventHandlerOwner*, this);
|
||||
}
|
||||
else if (iid.Equals(NS_GET_IID(nsIDOMEventReceiver))) {
|
||||
*result = NS_STATIC_CAST(nsIDOMEventReceiver*, this);
|
||||
else if (iid.Equals(NS_GET_IID(nsIDOMEventReceiver)) ||
|
||||
iid.Equals(NS_GET_IID(nsIDOMEventTarget))) {
|
||||
nsISupports *inst = NS_STATIC_CAST(nsIDOMEventReceiver *,
|
||||
nsDOMEventRTTearoff::Create(this));
|
||||
NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ADDREF(inst);
|
||||
*result = inst;
|
||||
return NS_OK;
|
||||
}
|
||||
else if (iid.Equals(NS_GET_IID(nsIDOMEventTarget))) {
|
||||
*result = NS_STATIC_CAST(nsIDOMEventTarget*, this);
|
||||
else if (iid.Equals(NS_GET_IID(nsIDOM3EventTarget))) {
|
||||
nsISupports *inst = NS_STATIC_CAST(nsIDOM3EventTarget *,
|
||||
nsDOMEventRTTearoff::Create(this));
|
||||
NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ADDREF(inst);
|
||||
*result = inst;
|
||||
return NS_OK;
|
||||
}
|
||||
else if (iid.Equals(NS_GET_IID(nsIChromeEventHandler))) {
|
||||
*result = NS_STATIC_CAST(nsIChromeEventHandler*, this);
|
||||
}
|
||||
else if (iid.Equals(NS_GET_IID(nsIDOM3Node))) {
|
||||
*result = new nsNode3Tearoff(this);
|
||||
NS_ENSURE_TRUE(*result, NS_ERROR_OUT_OF_MEMORY);
|
||||
nsISupports *inst = new nsNode3Tearoff(this);
|
||||
NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ADDREF(inst);
|
||||
*result = inst;
|
||||
return NS_OK;
|
||||
}
|
||||
else if (iid.Equals(NS_GET_IID(nsIClassInfo))) {
|
||||
nsISupports *inst = nsContentUtils::
|
||||
|
@ -1770,90 +1784,6 @@ nsXULElement::AddScriptEventListener(nsIAtom* aName,
|
|||
return rv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMEventReceiver interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID)
|
||||
{
|
||||
nsIEventListenerManager *manager;
|
||||
|
||||
if (NS_OK == GetListenerManager(&manager)) {
|
||||
manager->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
|
||||
NS_RELEASE(manager);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID)
|
||||
{
|
||||
if (mListenerManager) {
|
||||
mListenerManager->RemoveEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture)
|
||||
{
|
||||
nsIEventListenerManager *manager;
|
||||
|
||||
if (NS_OK == GetListenerManager(&manager)) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
manager->AddEventListenerByType(aListener, aType, flags);
|
||||
NS_RELEASE(manager);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::RemoveEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture)
|
||||
{
|
||||
if (mListenerManager) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
mListenerManager->RemoveEventListenerByType(aListener, aType, flags);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::DispatchEvent(nsIDOMEvent* aEvent, PRBool *_retval)
|
||||
{
|
||||
// Do nothing if element isn't in the document
|
||||
if (!mDocument)
|
||||
return NS_OK;
|
||||
|
||||
// Obtain a presentation context
|
||||
PRInt32 count = mDocument->GetNumberOfShells();
|
||||
if (count == 0)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(shell));
|
||||
|
||||
// Retrieve the context
|
||||
nsCOMPtr<nsIPresContext> aPresContext;
|
||||
shell->GetPresContext(getter_AddRefs(aPresContext));
|
||||
|
||||
nsCOMPtr<nsIEventStateManager> esm;
|
||||
if (NS_SUCCEEDED(aPresContext->GetEventStateManager(getter_AddRefs(esm)))) {
|
||||
return esm->DispatchNewEvent(NS_STATIC_CAST(nsIStyledContent*, this), aEvent, _retval);
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::GetListenerManager(nsIEventListenerManager** aResult)
|
||||
{
|
||||
|
@ -1873,12 +1803,6 @@ nsXULElement::GetListenerManager(nsIEventListenerManager** aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::HandleEvent(nsIDOMEvent *aEvent)
|
||||
{
|
||||
PRBool noDefault;
|
||||
return DispatchEvent(aEvent, &noDefault);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::DoneCreatingElement()
|
||||
|
@ -2471,7 +2395,9 @@ nsXULElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
|||
if (event) {
|
||||
event->InitEvent(NS_LITERAL_STRING("select"), PR_FALSE, PR_TRUE);
|
||||
PRBool noDefault;
|
||||
DispatchEvent(event, &noDefault);
|
||||
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)));
|
||||
NS_ENSURE_TRUE(target, NS_ERROR_FAILURE);
|
||||
target->DispatchEvent(event, &noDefault);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3301,8 +3227,9 @@ nsXULElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
else
|
||||
aDOMEvent = &domEvent;
|
||||
|
||||
aEvent->flags = aFlags;
|
||||
aEvent->flags |= aFlags;
|
||||
aFlags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
|
||||
aFlags |= NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_CAPTURE;
|
||||
|
||||
if (!externalDOMEvent) {
|
||||
// In order for the event to have a proper target for events that don't go through
|
||||
|
@ -3342,8 +3269,10 @@ nsXULElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
// the frame. If we don't have a frame (e.g., we're a
|
||||
// menu), then that breaks.
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(domEvent);
|
||||
if (privateEvent)
|
||||
privateEvent->SetTarget(this);
|
||||
if (privateEvent) {
|
||||
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)));
|
||||
privateEvent->SetTarget(target);
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -3434,14 +3363,14 @@ nsXULElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
//Capturing stage evaluation
|
||||
if (NS_EVENT_FLAG_BUBBLE != aFlags) {
|
||||
if (NS_EVENT_FLAG_CAPTURE & aFlags) {
|
||||
//Initiate capturing phase. Special case first call to document
|
||||
if (parent) {
|
||||
parent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_CAPTURE, aEventStatus);
|
||||
parent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, aFlags & NS_EVENT_CAPTURE_MASK, aEventStatus);
|
||||
}
|
||||
else if (mDocument != nsnull) {
|
||||
ret = mDocument->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
NS_EVENT_FLAG_CAPTURE, aEventStatus);
|
||||
aFlags & NS_EVENT_CAPTURE_MASK, aEventStatus);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3457,7 +3386,8 @@ nsXULElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
//Local handling stage
|
||||
if (mListenerManager && !(aEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH)) {
|
||||
aEvent->flags |= aFlags;
|
||||
mListenerManager->HandleEvent(aPresContext, aEvent, aDOMEvent, this, aFlags, aEventStatus);
|
||||
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)));
|
||||
mListenerManager->HandleEvent(aPresContext, aEvent, aDOMEvent, target, aFlags, aEventStatus);
|
||||
aEvent->flags &= ~aFlags;
|
||||
}
|
||||
|
||||
|
@ -3471,17 +3401,17 @@ nsXULElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
//Bubbling stage
|
||||
if (NS_EVENT_FLAG_CAPTURE != aFlags) {
|
||||
if (NS_EVENT_FLAG_BUBBLE & aFlags) {
|
||||
if (parent != nsnull) {
|
||||
// We have a parent. Let them field the event.
|
||||
ret = parent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
NS_EVENT_FLAG_BUBBLE, aEventStatus);
|
||||
aFlags & NS_EVENT_BUBBLE_MASK, aEventStatus);
|
||||
}
|
||||
else if (mDocument != nsnull) {
|
||||
// We must be the document root. The event should bubble to the
|
||||
// document.
|
||||
ret = mDocument->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
NS_EVENT_FLAG_BUBBLE, aEventStatus);
|
||||
aFlags & NS_EVENT_BUBBLE_MASK, aEventStatus);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4667,9 +4597,10 @@ nsXULElement::AddPopupListener(nsIAtom* aName)
|
|||
|
||||
// Add the popup as a listener on this element.
|
||||
nsCOMPtr<nsIDOMEventListener> eventListener = do_QueryInterface(popupListener);
|
||||
|
||||
AddEventListener(NS_LITERAL_STRING("mousedown"), eventListener, PR_FALSE);
|
||||
AddEventListener(NS_LITERAL_STRING("contextmenu"), eventListener, PR_FALSE);
|
||||
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)));
|
||||
NS_ENSURE_TRUE(target, NS_ERROR_FAILURE);
|
||||
target->AddEventListener(NS_LITERAL_STRING("mousedown"), eventListener, PR_FALSE);
|
||||
target->AddEventListener(NS_LITERAL_STRING("contextmenu"), eventListener, PR_FALSE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include "nsIControllers.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOM3EventTarget.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
#include "nsIDOMXULMultSelectCntrlEl.h"
|
||||
#include "nsIEventListenerManager.h"
|
||||
|
@ -319,7 +320,6 @@ public:
|
|||
|
||||
class nsXULElement : public nsIXULContent,
|
||||
public nsIDOMXULElement,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIScriptEventHandlerOwner,
|
||||
public nsIChromeEventHandler
|
||||
{
|
||||
|
@ -403,6 +403,7 @@ public:
|
|||
NS_IMETHOD GetBindingParent(nsIContent** aContent);
|
||||
NS_IMETHOD SetBindingParent(nsIContent* aParent);
|
||||
NS_IMETHOD_(PRBool) IsContentOfType(PRUint32 aFlags);
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aResult);
|
||||
|
||||
// nsIXMLContent
|
||||
NS_IMETHOD MaybeTriggerAutoLink(nsIWebShell *aShell);
|
||||
|
@ -435,19 +436,6 @@ public:
|
|||
// nsIDOMXULElement
|
||||
NS_DECL_NSIDOMXULELEMENT
|
||||
|
||||
// nsIDOMEventTarget interface (from nsIDOMEventReceiver)
|
||||
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);
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
NS_IMETHOD RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent);
|
||||
|
||||
// nsIScriptEventHandlerOwner
|
||||
NS_IMETHOD CompileEventHandler(nsIScriptContext* aContext,
|
||||
void* aTarget,
|
||||
|
|
|
@ -593,6 +593,7 @@ NS_INTERFACE_MAP_BEGIN(nsXULDocument)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIDOM3Node)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNSDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentEvent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOM3DocumentEvent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentView)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentXBL)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentStyle)
|
||||
|
@ -601,7 +602,7 @@ NS_INTERFACE_MAP_BEGIN(nsXULDocument)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIHTMLContentContainer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMEventReceiver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMEventCapturer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStreamLoaderObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(XULDocument)
|
||||
|
@ -2591,25 +2592,26 @@ nsXULDocument::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
else {
|
||||
aDOMEvent = &domEvent;
|
||||
}
|
||||
aEvent->flags = aFlags;
|
||||
aEvent->flags |= aFlags;
|
||||
aFlags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
|
||||
aFlags |= NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_CAPTURE;
|
||||
}
|
||||
|
||||
//Capturing stage
|
||||
if (NS_EVENT_FLAG_BUBBLE != aFlags && mScriptGlobalObject) {
|
||||
mScriptGlobalObject->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_CAPTURE, aEventStatus);
|
||||
if (NS_EVENT_FLAG_CAPTURE & aFlags && mScriptGlobalObject) {
|
||||
mScriptGlobalObject->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, aFlags & NS_EVENT_CAPTURE_MASK, aEventStatus);
|
||||
}
|
||||
|
||||
//Local handling stage
|
||||
if (mListenerManager && !(aEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH)) {
|
||||
if (mListenerManager) {
|
||||
aEvent->flags |= aFlags;
|
||||
mListenerManager->HandleEvent(aPresContext, aEvent, aDOMEvent, this, aFlags, aEventStatus);
|
||||
aEvent->flags &= ~aFlags;
|
||||
}
|
||||
|
||||
//Bubbling stage
|
||||
if (NS_EVENT_FLAG_CAPTURE != aFlags && mScriptGlobalObject) {
|
||||
mScriptGlobalObject->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_BUBBLE, aEventStatus);
|
||||
if (NS_EVENT_FLAG_BUBBLE & aFlags && mScriptGlobalObject) {
|
||||
mScriptGlobalObject->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, aFlags & NS_EVENT_BUBBLE_MASK, aEventStatus);
|
||||
}
|
||||
|
||||
if (NS_EVENT_FLAG_INIT & aFlags) {
|
||||
|
@ -4708,7 +4710,7 @@ nsXULDocument::ParseTagString(const nsAString& aTagName, nsIAtom*& aName,
|
|||
}
|
||||
|
||||
|
||||
// nsIDOMEventCapturer and nsIDOMEventReceiver Interface Implementations
|
||||
// nsIDOMEventReceiver Interface Implementations
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID)
|
||||
|
@ -4738,16 +4740,7 @@ nsXULDocument::AddEventListener(const nsAString& aType,
|
|||
nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture)
|
||||
{
|
||||
nsIEventListenerManager *manager;
|
||||
|
||||
if (NS_OK == GetListenerManager(&manager)) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
manager->AddEventListenerByType(aListener, aType, flags);
|
||||
NS_RELEASE(manager);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
return AddGroupedEventListener(aType, aListener, aUseCapture, nsnull);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -4755,13 +4748,7 @@ nsXULDocument::RemoveEventListener(const nsAString& aType,
|
|||
nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture)
|
||||
{
|
||||
if (mListenerManager) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
mListenerManager->RemoveEventListenerByType(aListener, aType, flags);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
return RemoveGroupedEventListener(aType, aListener, aUseCapture, nsnull);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -4790,6 +4777,47 @@ nsXULDocument::DispatchEvent(nsIDOMEvent* aEvent, PRBool *_retval)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::AddGroupedEventListener(const nsAString & aType, nsIDOMEventListener *aListener,
|
||||
PRBool aUseCapture, nsIDOMEventGroup *aEvtGrp)
|
||||
{
|
||||
nsCOMPtr<nsIEventListenerManager> manager;
|
||||
|
||||
nsresult rv = GetListenerManager(getter_AddRefs(manager));
|
||||
if (NS_SUCCEEDED(rv) && manager) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
manager->AddEventListenerByType(aListener, aType, flags, aEvtGrp);
|
||||
return NS_OK;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::RemoveGroupedEventListener(const nsAString & aType, nsIDOMEventListener *aListener,
|
||||
PRBool aUseCapture, nsIDOMEventGroup *aEvtGrp)
|
||||
{
|
||||
if (mListenerManager) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
mListenerManager->RemoveEventListenerByType(aListener, aType, flags, aEvtGrp);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::CanTrigger(const nsAString & type, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::IsRegisteredHere(const nsAString & type, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::CreateEvent(const nsAString& aEventType,
|
||||
nsIDOMEvent** aReturn)
|
||||
|
@ -4818,6 +4846,12 @@ nsXULDocument::CreateEvent(const nsAString& aEventType,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::CreateEventGroup(nsIDOMEventGroup **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::GetListenerManager(nsIEventListenerManager** aResult)
|
||||
{
|
||||
|
@ -4844,25 +4878,12 @@ nsXULDocument::HandleEvent(nsIDOMEvent *aEvent)
|
|||
return DispatchEvent(aEvent, &noDefault);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXULDocument::CaptureEvent(const nsAString& aType)
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::GetSystemEventGroup(nsIDOMEventGroup **aGroup)
|
||||
{
|
||||
nsIEventListenerManager *mManager;
|
||||
|
||||
if (NS_OK == GetListenerManager(&mManager)) {
|
||||
//mManager->CaptureEvent(aListener);
|
||||
NS_RELEASE(mManager);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXULDocument::ReleaseEvent(const nsAString& aType)
|
||||
{
|
||||
if (mListenerManager) {
|
||||
//mListenerManager->ReleaseEvent(aListener);
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIEventListenerManager> manager;
|
||||
if (NS_SUCCEEDED(GetListenerManager(getter_AddRefs(manager))) && manager) {
|
||||
return manager->GetSystemEventGroupLM(aGroup);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,8 @@
|
|||
#include "nsIArena.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMEventCapturer.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOM3EventTarget.h"
|
||||
#include "nsIDOMNSDocument.h"
|
||||
#include "nsIDOMDocumentStyle.h"
|
||||
#include "nsIDOMDocumentView.h"
|
||||
|
@ -84,6 +85,7 @@
|
|||
#include "nsIBindingManager.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIDOM3DocumentEvent.h"
|
||||
#include "nsIFocusController.h"
|
||||
#include "nsScriptLoader.h"
|
||||
#include "pldhash.h"
|
||||
|
@ -119,6 +121,7 @@ class nsXULDocument : public nsIDocument,
|
|||
public nsIXULDocument,
|
||||
public nsIDOMXULDocument,
|
||||
public nsIDOMDocumentEvent,
|
||||
public nsIDOM3DocumentEvent,
|
||||
public nsIDOMDocumentView,
|
||||
public nsIDOMDocumentXBL,
|
||||
public nsIDOMDocumentRange,
|
||||
|
@ -126,7 +129,8 @@ class nsXULDocument : public nsIDocument,
|
|||
public nsIDOMNSDocument,
|
||||
public nsIDOM3Node,
|
||||
public nsIDOMDocumentStyle,
|
||||
public nsIDOMEventCapturer,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIDOM3EventTarget,
|
||||
public nsIHTMLContentContainer,
|
||||
public nsIStreamLoaderObserver,
|
||||
public nsSupportsWeakReference
|
||||
|
@ -371,24 +375,18 @@ public:
|
|||
NS_IMETHOD OnResumeContentSink();
|
||||
NS_IMETHOD ClearBoxObjectTable();
|
||||
|
||||
// nsIDOMEventCapturer interface
|
||||
NS_IMETHOD CaptureEvent(const nsAString& aType);
|
||||
NS_IMETHOD ReleaseEvent(const nsAString& aType);
|
||||
|
||||
// nsIDOMEventReceiver interface (yuck. inherited from nsIDOMEventCapturer)
|
||||
// nsIDOMEventReceiver interface
|
||||
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
NS_IMETHOD RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent);
|
||||
NS_IMETHOD GetSystemEventGroup(nsIDOMEventGroup** aGroup);
|
||||
|
||||
// nsIDOMEventTarget interface
|
||||
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_DECL_NSIDOMEVENTTARGET
|
||||
|
||||
// nsIDOM3EventTarget interface
|
||||
NS_DECL_NSIDOM3EVENTTARGET
|
||||
|
||||
// nsIDOMDocument interface
|
||||
NS_DECL_NSIDOMDOCUMENT
|
||||
|
@ -396,6 +394,9 @@ public:
|
|||
// nsIDOMDocumentEvent interface
|
||||
NS_DECL_NSIDOMDOCUMENTEVENT
|
||||
|
||||
// nsIDOM3DocumentEvent interface
|
||||
NS_DECL_NSIDOM3DOCUMENTEVENT
|
||||
|
||||
// nsIDOMDocumentView interface
|
||||
NS_DECL_NSIDOMDOCUMENTVIEW
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ class nsIDOMLoadListener;
|
|||
class nsIDOMDragListener;
|
||||
class nsIEventListenerManager;
|
||||
class nsIDOMEvent;
|
||||
class nsIDOMEventGroup;
|
||||
|
||||
/*
|
||||
* DOM event source class. Object that allow event registration and
|
||||
|
@ -72,5 +73,6 @@ public:
|
|||
const nsIID& aIID) = 0;
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aResult) = 0;
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent) = 0;
|
||||
NS_IMETHOD GetSystemEventGroup(nsIDOMEventGroup** aGroup) = 0;
|
||||
};
|
||||
#endif // nsIDOMEventReceiver_h__
|
||||
|
|
|
@ -107,6 +107,7 @@ interface nsIDOMHistory;
|
|||
interface nsIDOMEvent;
|
||||
interface nsIDOMEventTarget;
|
||||
interface nsIDOMEventListener;
|
||||
interface nsIDOMEventGroup;
|
||||
|
||||
// HTML
|
||||
interface nsIDOMHTMLElement;
|
||||
|
|
|
@ -8,3 +8,7 @@ nsIDOMMouseEvent.idl
|
|||
nsIDOMMutationEvent.idl
|
||||
nsIDOMUIEvent.idl
|
||||
nsIDOMNSUIEvent.idl
|
||||
nsIDOM3DocumentEvent.idl
|
||||
nsIDOM3EventTarget.idl
|
||||
nsIDOMEventGroup.idl
|
||||
nsIDOMCustomEvent.idl
|
||||
|
|
|
@ -40,6 +40,10 @@ XPIDLSRCS = \
|
|||
nsIDOMUIEvent.idl \
|
||||
nsIDOMNSUIEvent.idl \
|
||||
nsIDOMEventListener.idl \
|
||||
nsIDOM3DocumentEvent.idl \
|
||||
nsIDOM3EventTarget.idl \
|
||||
nsIDOMEventGroup.idl \
|
||||
nsIDOMCustomEvent.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -35,6 +35,10 @@ XPIDLSRCS = \
|
|||
.\nsIDOMUIEvent.idl \
|
||||
.\nsIDOMNSUIEvent.idl \
|
||||
.\nsIDOMEventListener.idl \
|
||||
.\nsIDOM3DocumentEvent.idl \
|
||||
.\nsIDOM3EventTarget.idl \
|
||||
.\nsIDOMEventGroup.idl \
|
||||
.\nsIDOMCustomEvent.idl \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Tom Pixley <joki@netscape.com> (original author)
|
||||
* Johnny Stenback <jst@netscape.com>
|
||||
*
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
/**
|
||||
* The nsIDOMDocumentEvent interface is the interface to the event
|
||||
* factory method on a DOM document object.
|
||||
*
|
||||
* For more information on this interface please see
|
||||
* http://www.w3.org/TR/DOM-Level-3-Events/
|
||||
*/
|
||||
|
||||
[scriptable, uuid(090ecc19-b7cb-4f47-ae47-ed68d4926249)]
|
||||
interface nsIDOM3DocumentEvent : nsISupports
|
||||
{
|
||||
// Introduced in DOM Level 3:
|
||||
nsIDOMEventGroup createEventGroup();
|
||||
};
|
|
@ -0,0 +1,67 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Tom Pixley <joki@netscape.com> (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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
/**
|
||||
* The nsIDOMEventTarget interface is the interface implemented by all
|
||||
* event targets in the Document Object Model.
|
||||
*
|
||||
* For more information on this interface please see
|
||||
* http://www.w3.org/TR/DOM-Level-3-Events/
|
||||
*/
|
||||
|
||||
[scriptable, uuid(3e9c01a7-de97-4c3b-8294-b4bd9d7056d1)]
|
||||
interface nsIDOM3EventTarget : nsISupports
|
||||
{
|
||||
// Introduced in DOM Level 3:
|
||||
void addGroupedEventListener(in DOMString type,
|
||||
in nsIDOMEventListener listener,
|
||||
in boolean useCapture,
|
||||
in nsIDOMEventGroup evtGroup);
|
||||
// Introduced in DOM Level 3:
|
||||
void removeGroupedEventListener(in DOMString type,
|
||||
in nsIDOMEventListener listener,
|
||||
in boolean useCapture,
|
||||
in nsIDOMEventGroup evtGroup);
|
||||
// Introduced in DOM Level 3:
|
||||
boolean canTrigger(in DOMString type);
|
||||
// Introduced in DOM Level 3:
|
||||
boolean isRegisteredHere(in DOMString type);
|
||||
};
|
|
@ -0,0 +1,57 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Tom Pixley <joki@netscape.com> (original author)
|
||||
* Johnny Stenback <jst@netscape.com>
|
||||
*
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIDOMEvent.idl"
|
||||
|
||||
/**
|
||||
* The nsIDOMEventTarget interface is the interface implemented by all
|
||||
* event targets in the Document Object Model.
|
||||
*
|
||||
* For more information on this interface please see
|
||||
* http://www.w3.org/TR/DOM-Level-3-Events/
|
||||
*/
|
||||
|
||||
[scriptable, uuid(55c7af7b-1a64-40bf-87eb-2c2cbee0491b)]
|
||||
interface nsIDOMCustomEvent : nsIDOMEvent
|
||||
{
|
||||
void setCurrentTarget(in nsIDOMNode target);
|
||||
void setEventPhase(in unsigned short phase);
|
||||
|
||||
};
|
|
@ -0,0 +1,55 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Tom Pixley <joki@netscape.com> (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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
/**
|
||||
* The nsIDOMEventTarget interface is the interface implemented by all
|
||||
* event targets in the Document Object Model.
|
||||
*
|
||||
* For more information on this interface please see
|
||||
* http://www.w3.org/TR/DOM-Level-3-Events/
|
||||
*/
|
||||
|
||||
[scriptable, uuid(33347bee-6620-4841-8152-36091ae80c7e)]
|
||||
interface nsIDOMEventGroup : nsISupports
|
||||
{
|
||||
// Introduced in DOM Level 3:
|
||||
boolean isSameEventGroup(in nsIDOMEventGroup other);
|
||||
};
|
|
@ -309,6 +309,7 @@ NS_INTERFACE_MAP_BEGIN(GlobalWindowImpl)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMEventReceiver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget)
|
||||
NS_INTERFACE_MAP_ENTRY(nsPIDOMWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMViewCSS)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMAbstractView)
|
||||
|
@ -698,12 +699,13 @@ GlobalWindowImpl::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
else {
|
||||
aDOMEvent = &domEvent;
|
||||
}
|
||||
aEvent->flags = aFlags;
|
||||
aEvent->flags |= aFlags;
|
||||
aFlags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
|
||||
aFlags |= NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_CAPTURE;
|
||||
|
||||
// Execute bindingdetached handlers before we tear ourselves
|
||||
// down.
|
||||
if (aEvent->message == NS_PAGE_UNLOAD && mDocument) {
|
||||
if (aEvent->message == NS_PAGE_UNLOAD && mDocument && !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT)) {
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
||||
nsCOMPtr<nsIBindingManager> bindingManager;
|
||||
doc->GetBindingManager(getter_AddRefs(bindingManager));
|
||||
|
@ -722,20 +724,19 @@ GlobalWindowImpl::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
// Capturing stage
|
||||
if ((NS_EVENT_FLAG_BUBBLE != aFlags) && mChromeEventHandler) {
|
||||
if ((NS_EVENT_FLAG_CAPTURE & aFlags) && mChromeEventHandler) {
|
||||
// Check chrome document capture here.
|
||||
// XXX The chrome can not handle this, see bug 51211
|
||||
if (aEvent->message != NS_IMAGE_LOAD) {
|
||||
mChromeEventHandler->HandleChromeEvent(aPresContext, aEvent, aDOMEvent,
|
||||
NS_EVENT_FLAG_CAPTURE,
|
||||
aFlags & NS_EVENT_CAPTURE_MASK,
|
||||
aEventStatus);
|
||||
}
|
||||
}
|
||||
|
||||
// Local handling stage
|
||||
if (mListenerManager && !(aEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) &&
|
||||
!((NS_EVENT_FLAG_BUBBLE & aFlags) &&
|
||||
(NS_EVENT_FLAG_CANT_BUBBLE & aEvent->flags))) {
|
||||
if (mListenerManager &&
|
||||
!(NS_EVENT_FLAG_CANT_BUBBLE & aEvent->flags && NS_EVENT_FLAG_BUBBLE & aFlags && !(NS_EVENT_FLAG_INIT & aFlags))) {
|
||||
aEvent->flags |= aFlags;
|
||||
mListenerManager->HandleEvent(aPresContext, aEvent, aDOMEvent, this,
|
||||
aFlags, aEventStatus);
|
||||
|
@ -746,7 +747,7 @@ GlobalWindowImpl::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
mIsDocumentLoaded = PR_TRUE;
|
||||
|
||||
// Bubbling stage
|
||||
if ((NS_EVENT_FLAG_CAPTURE != aFlags) && mChromeEventHandler) {
|
||||
if ((NS_EVENT_FLAG_BUBBLE & aFlags) && mChromeEventHandler) {
|
||||
// Bubble to a chrome document if it exists
|
||||
// XXX Need a way to know if an event should really bubble or not.
|
||||
// For now filter out load and unload, since they cause problems.
|
||||
|
@ -756,7 +757,7 @@ GlobalWindowImpl::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
(aEvent->message != NS_FOCUS_CONTENT) &&
|
||||
(aEvent->message != NS_BLUR_CONTENT)) {
|
||||
mChromeEventHandler->HandleChromeEvent(aPresContext, aEvent,
|
||||
aDOMEvent, NS_EVENT_FLAG_BUBBLE,
|
||||
aDOMEvent, aFlags & NS_EVENT_BUBBLE_MASK,
|
||||
aEventStatus);
|
||||
}
|
||||
}
|
||||
|
@ -3534,15 +3535,7 @@ GlobalWindowImpl::AddEventListener(const nsAString& aType,
|
|||
nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture)
|
||||
{
|
||||
nsCOMPtr<nsIEventListenerManager> manager;
|
||||
|
||||
if (NS_SUCCEEDED(GetListenerManager(getter_AddRefs(manager)))) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
manager->AddEventListenerByType(aListener, aType, flags);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
return AddGroupedEventListener(aType, aListener, aUseCapture, nsnull);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -3550,13 +3543,7 @@ GlobalWindowImpl::RemoveEventListener(const nsAString& aType,
|
|||
nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture)
|
||||
{
|
||||
if (mListenerManager) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
mListenerManager->RemoveEventListenerByType(aListener, aType, flags);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
return RemoveGroupedEventListener(aType, aListener, aUseCapture, nsnull);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -3587,6 +3574,50 @@ GlobalWindowImpl::DispatchEvent(nsIDOMEvent* aEvent, PRBool* _retval)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// GlobalWindowImpl::nsIDOM3EventTarget
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::AddGroupedEventListener(const nsAString & aType, nsIDOMEventListener *aListener,
|
||||
PRBool aUseCapture, nsIDOMEventGroup *aEvtGrp)
|
||||
{
|
||||
nsCOMPtr<nsIEventListenerManager> manager;
|
||||
|
||||
if (NS_SUCCEEDED(GetListenerManager(getter_AddRefs(manager)))) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
manager->AddEventListenerByType(aListener, aType, flags, aEvtGrp);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::RemoveGroupedEventListener(const nsAString & aType, nsIDOMEventListener *aListener,
|
||||
PRBool aUseCapture, nsIDOMEventGroup *aEvtGrp)
|
||||
{
|
||||
if (mListenerManager) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
|
||||
mListenerManager->RemoveEventListenerByType(aListener, aType, flags, aEvtGrp);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::CanTrigger(const nsAString & type, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::IsRegisteredHere(const nsAString & type, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// GlobalWindowImpl::nsIDOMEventReceiver
|
||||
//*****************************************************************************
|
||||
|
@ -3631,13 +3662,6 @@ GlobalWindowImpl::GetListenerManager(nsIEventListenerManager **aResult)
|
|||
return CallQueryInterface(mListenerManager, aResult);
|
||||
}
|
||||
|
||||
//XXX I need another way around the circular link problem.
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::GetNewListenerManager(nsIEventListenerManager **aResult)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::HandleEvent(nsIDOMEvent *aEvent)
|
||||
{
|
||||
|
@ -3645,6 +3669,16 @@ GlobalWindowImpl::HandleEvent(nsIDOMEvent *aEvent)
|
|||
return DispatchEvent(aEvent, &noDefault);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::GetSystemEventGroup(nsIDOMEventGroup **aGroup)
|
||||
{
|
||||
nsCOMPtr<nsIEventListenerManager> manager;
|
||||
if (NS_SUCCEEDED(GetListenerManager(getter_AddRefs(manager))) && manager) {
|
||||
return manager->GetSystemEventGroupLM(aGroup);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// GlobalWindowImpl::nsPIDOMWindow
|
||||
//*****************************************************************************
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDOMViewCSS.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOM3EventTarget.h"
|
||||
#include "nsIDOMNavigator.h"
|
||||
#include "nsIDOMNSLocation.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
|
@ -116,6 +117,7 @@ class GlobalWindowImpl : public nsIScriptGlobalObject,
|
|||
public nsIDOMJSWindow,
|
||||
public nsIScriptObjectPrincipal,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIDOM3EventTarget,
|
||||
public nsPIDOMWindow,
|
||||
public nsIDOMViewCSS,
|
||||
public nsSupportsWeakReference,
|
||||
|
@ -155,13 +157,10 @@ public:
|
|||
NS_DECL_NSIDOMJSWINDOW
|
||||
|
||||
// nsIDOMEventTarget
|
||||
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_DECL_NSIDOMEVENTTARGET
|
||||
|
||||
// nsIDOM3EventTarget
|
||||
NS_DECL_NSIDOM3EVENTTARGET
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener,
|
||||
|
@ -169,8 +168,8 @@ public:
|
|||
NS_IMETHOD RemoveEventListenerByIID(nsIDOMEventListener *aListener,
|
||||
const nsIID& aIID);
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
NS_IMETHOD GetNewListenerManager(nsIEventListenerManager **aInstancePtrResult);
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent);
|
||||
NS_IMETHOD GetSystemEventGroup(nsIDOMEventGroup** aGroup);
|
||||
|
||||
// nsPIDOMWindow
|
||||
NS_IMETHOD GetPrivateParent(nsPIDOMWindow** aResult);
|
||||
|
|
|
@ -55,32 +55,18 @@ nsWindowRoot::~nsWindowRoot()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS4(nsWindowRoot, nsIDOMEventReceiver, nsIChromeEventHandler, nsPIWindowRoot, nsIDOMEventTarget)
|
||||
NS_IMPL_ISUPPORTS5(nsWindowRoot, nsIDOMEventReceiver, nsIChromeEventHandler, nsPIWindowRoot, nsIDOMEventTarget, nsIDOM3EventTarget)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowRoot::AddEventListener(const nsAString& aType, nsIDOMEventListener* aListener, PRBool aUseCapture)
|
||||
{
|
||||
nsCOMPtr<nsIEventListenerManager> manager;
|
||||
GetListenerManager(getter_AddRefs(manager));
|
||||
if (manager) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
manager->AddEventListenerByType(aListener, aType, flags);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
return AddGroupedEventListener(aType, aListener, aUseCapture, nsnull);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowRoot::RemoveEventListener(const nsAString& aType, nsIDOMEventListener* aListener, PRBool aUseCapture)
|
||||
{
|
||||
nsCOMPtr<nsIEventListenerManager> manager;
|
||||
GetListenerManager(getter_AddRefs(manager));
|
||||
if (manager) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
manager->RemoveEventListenerByType(aListener, aType, flags);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
return RemoveGroupedEventListener(aType, aListener, aUseCapture, nsnull);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -112,6 +98,44 @@ nsWindowRoot::DispatchEvent(nsIDOMEvent* aEvt, PRBool *_retval)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowRoot::AddGroupedEventListener(const nsAString & aType, nsIDOMEventListener *aListener,
|
||||
PRBool aUseCapture, nsIDOMEventGroup *aEvtGrp)
|
||||
{
|
||||
nsCOMPtr<nsIEventListenerManager> manager;
|
||||
|
||||
if (NS_SUCCEEDED(GetListenerManager(getter_AddRefs(manager)))) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
manager->AddEventListenerByType(aListener, aType, flags, aEvtGrp);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowRoot::RemoveGroupedEventListener(const nsAString & aType, nsIDOMEventListener *aListener,
|
||||
PRBool aUseCapture, nsIDOMEventGroup *aEvtGrp)
|
||||
{
|
||||
if (mListenerManager) {
|
||||
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
mListenerManager->RemoveEventListenerByType(aListener, aType, flags, aEvtGrp);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowRoot::CanTrigger(const nsAString & type, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowRoot::IsRegisteredHere(const nsAString & type, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowRoot::AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID)
|
||||
{
|
||||
|
@ -157,6 +181,16 @@ nsWindowRoot::HandleEvent(nsIDOMEvent *aEvent)
|
|||
return DispatchEvent(aEvent, &noDefault);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowRoot::GetSystemEventGroup(nsIDOMEventGroup **aGroup)
|
||||
{
|
||||
nsCOMPtr<nsIEventListenerManager> manager;
|
||||
if (NS_SUCCEEDED(GetListenerManager(getter_AddRefs(manager))) && manager) {
|
||||
return manager->GetSystemEventGroupLM(aGroup);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowRoot::HandleChromeEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
|
|
|
@ -30,13 +30,14 @@ class nsIDOMEvent;
|
|||
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOM3EventTarget.h"
|
||||
#include "nsIChromeEventHandler.h"
|
||||
#include "nsIEventListenerManager.h"
|
||||
#include "nsPIWindowRoot.h"
|
||||
#include "nsIFocusController.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
|
||||
class nsWindowRoot : public nsIDOMEventReceiver, public nsIChromeEventHandler, public nsPIWindowRoot
|
||||
class nsWindowRoot : public nsIDOMEventReceiver, public nsIDOM3EventTarget, public nsIChromeEventHandler, public nsPIWindowRoot
|
||||
{
|
||||
public:
|
||||
nsWindowRoot(nsIDOMWindow* aWindow);
|
||||
|
@ -44,6 +45,7 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMEVENTTARGET
|
||||
NS_DECL_NSIDOM3EVENTTARGET
|
||||
|
||||
NS_IMETHOD HandleChromeEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent, nsIDOMEvent** aDOMEvent,
|
||||
|
@ -53,6 +55,7 @@ public:
|
|||
NS_IMETHOD RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent);
|
||||
NS_IMETHOD GetSystemEventGroup(nsIDOMEventGroup** aGroup);
|
||||
|
||||
// nsPIWindowRoot
|
||||
NS_IMETHOD GetFocusController(nsIFocusController** aResult);
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOM3EventTarget.h"
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
#include "nsIDOMKeyListener.h"
|
||||
#include "nsIDOMMouseListener.h"
|
||||
|
@ -70,6 +71,8 @@
|
|||
#include "nsIDOMHTMLAnchorElement.h"
|
||||
#include "nsISelectionController.h"
|
||||
#include "nsIDOMHTMLHtmlElement.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIDOMEventGroup.h"
|
||||
|
||||
#include "TransactionFactory.h"
|
||||
|
||||
|
@ -399,6 +402,13 @@ printf("nsTextEditor.cpp: failed to get TextEvent Listener\n");
|
|||
}
|
||||
|
||||
// register the event listeners with the DOM event reveiver
|
||||
nsCOMPtr<nsIDOM3EventTarget> dom3Targ(do_QueryInterface(erP));
|
||||
nsCOMPtr<nsIDOMEventGroup> sysGroup;
|
||||
if (NS_SUCCEEDED(erP->GetSystemEventGroup(getter_AddRefs(sysGroup)))) {
|
||||
result = dom3Targ->AddGroupedEventListener(NS_LITERAL_STRING("keypress"), mKeyListenerP, PR_FALSE, sysGroup);
|
||||
NS_ASSERTION(NS_SUCCEEDED(result), "failed to register key listener in system group");
|
||||
}
|
||||
|
||||
result = erP->AddEventListenerByIID(mKeyListenerP, NS_GET_IID(nsIDOMKeyListener));
|
||||
NS_ASSERTION(NS_SUCCEEDED(result), "failed to register key listener");
|
||||
if (NS_SUCCEEDED(result))
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "nsIDOMKeyEvent.h"
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsIDOMNSUIEvent.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIPrivateTextEvent.h"
|
||||
#include "nsIPrivateCompositionEvent.h"
|
||||
#include "nsIEditorMailSupport.h"
|
||||
|
@ -63,6 +64,7 @@
|
|||
#include "nsIPref.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsGUIEvent.h"
|
||||
// for repainting hack only
|
||||
#include "nsIView.h"
|
||||
#include "nsIViewManager.h"
|
||||
|
@ -181,6 +183,22 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// DOM event handling happens in two passes, the client pass and the system
|
||||
// pass. All system handlers need to move eventually to the system pass
|
||||
// but due to inconsistencies that would create with XBL handlers they
|
||||
// need to stay here for now and continue to process command keys. Character
|
||||
// generation, however, should be handled in the second system pass to allow
|
||||
// proper cancellation of character generating events.
|
||||
PRBool isSystemPass = PR_FALSE;
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privDOMEvent(do_QueryInterface(aKeyEvent));
|
||||
if (privDOMEvent) {
|
||||
nsEvent* innerEvent;
|
||||
privDOMEvent->GetInternalNSEvent(&innerEvent);
|
||||
if (innerEvent) {
|
||||
isSystemPass = innerEvent->flags & NS_EVENT_FLAG_SYSTEM_EVENT;
|
||||
}
|
||||
}
|
||||
|
||||
// we should check a flag here to see if we should be using built-in key bindings
|
||||
// mEditor->GetFlags(&flags);
|
||||
// if (flags & ...)
|
||||
|
@ -203,8 +221,9 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
if (!textEditor) return NS_ERROR_NO_INTERFACE;
|
||||
|
||||
// if there is no charCode, then it's a key that doesn't map to a character,
|
||||
// so look for special keys using keyCode
|
||||
if (0 != keyCode)
|
||||
// so look for special keys using keyCode.
|
||||
// Also, process these keys only during the Client Pass of the event loop.
|
||||
if (0 != keyCode && !isSystemPass)
|
||||
{
|
||||
PRBool isAnyModifierKeyButShift;
|
||||
nsresult rv;
|
||||
|
@ -289,7 +308,8 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(textEditor->HandleKeyPress(keyEvent)))
|
||||
// Process character generation during the System Pass of the event loop.
|
||||
if (isSystemPass && NS_SUCCEEDED(textEditor->HandleKeyPress(keyEvent)))
|
||||
ScrollSelectionIntoView(mEditor);
|
||||
|
||||
return NS_OK; // we don't PreventDefault() here or keybindings like control-x won't work
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOM3EventTarget.h"
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
#include "nsIDOMKeyListener.h"
|
||||
#include "nsIDOMMouseListener.h"
|
||||
|
@ -60,6 +61,7 @@
|
|||
#include "nsIDOMHTMLImageElement.h"
|
||||
#include "nsISelectionController.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIDOMEventGroup.h"
|
||||
|
||||
#include "nsIIndependentSelection.h" //domselections answer to frameselection
|
||||
|
||||
|
@ -155,6 +157,12 @@ nsPlaintextEditor::~nsPlaintextEditor()
|
|||
nsresult result = GetDOMEventReceiver(getter_AddRefs(erP));
|
||||
if (NS_SUCCEEDED(result) && erP)
|
||||
{
|
||||
nsCOMPtr<nsIDOM3EventTarget> dom3Targ(do_QueryInterface(erP));
|
||||
nsCOMPtr<nsIDOMEventGroup> sysGroup;
|
||||
if (NS_SUCCEEDED(erP->GetSystemEventGroup(getter_AddRefs(sysGroup)))) {
|
||||
result = dom3Targ->RemoveGroupedEventListener(NS_LITERAL_STRING("keypress"), mKeyListenerP, PR_FALSE, sysGroup);
|
||||
}
|
||||
|
||||
if (mKeyListenerP) {
|
||||
erP->RemoveEventListenerByIID(mKeyListenerP, NS_GET_IID(nsIDOMKeyListener));
|
||||
}
|
||||
|
@ -420,6 +428,13 @@ printf("nsTextEditor.cpp: failed to get TextEvent Listener\n");
|
|||
}
|
||||
|
||||
// register the event listeners with the DOM event reveiver
|
||||
nsCOMPtr<nsIDOM3EventTarget> dom3Targ(do_QueryInterface(erP));
|
||||
nsCOMPtr<nsIDOMEventGroup> sysGroup;
|
||||
if (NS_SUCCEEDED(erP->GetSystemEventGroup(getter_AddRefs(sysGroup)))) {
|
||||
result = dom3Targ->AddGroupedEventListener(NS_LITERAL_STRING("keypress"), mKeyListenerP, PR_FALSE, sysGroup);
|
||||
NS_ASSERTION(NS_SUCCEEDED(result), "failed to register key listener in system group");
|
||||
}
|
||||
|
||||
result = erP->AddEventListenerByIID(mKeyListenerP, NS_GET_IID(nsIDOMKeyListener));
|
||||
NS_ASSERTION(NS_SUCCEEDED(result), "failed to register key listener");
|
||||
if (NS_SUCCEEDED(result))
|
||||
|
|
|
@ -5995,6 +5995,20 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView, PRUint32 aFlags,
|
|||
}
|
||||
}
|
||||
|
||||
//Continue with second dispatch to system event handlers
|
||||
if (mCurrentEventContent) {
|
||||
rv = mCurrentEventContent->HandleDOMEvent(mPresContext, aEvent, nsnull,
|
||||
aFlags | NS_EVENT_FLAG_SYSTEM_EVENT, aStatus);
|
||||
}
|
||||
else {
|
||||
nsIContent* targetContent;
|
||||
if (NS_OK == mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent, &targetContent) && nsnull != targetContent) {
|
||||
rv = targetContent->HandleDOMEvent(mPresContext, aEvent, nsnull,
|
||||
aFlags | NS_EVENT_FLAG_SYSTEM_EVENT, aStatus);
|
||||
NS_RELEASE(targetContent);
|
||||
}
|
||||
}
|
||||
|
||||
//3. Give event to the Frames for browser default processing.
|
||||
// XXX The event isn't translated into the local coordinate space
|
||||
// of the frame...
|
||||
|
|
|
@ -5995,6 +5995,20 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView, PRUint32 aFlags,
|
|||
}
|
||||
}
|
||||
|
||||
//Continue with second dispatch to system event handlers
|
||||
if (mCurrentEventContent) {
|
||||
rv = mCurrentEventContent->HandleDOMEvent(mPresContext, aEvent, nsnull,
|
||||
aFlags | NS_EVENT_FLAG_SYSTEM_EVENT, aStatus);
|
||||
}
|
||||
else {
|
||||
nsIContent* targetContent;
|
||||
if (NS_OK == mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent, &targetContent) && nsnull != targetContent) {
|
||||
rv = targetContent->HandleDOMEvent(mPresContext, aEvent, nsnull,
|
||||
aFlags | NS_EVENT_FLAG_SYSTEM_EVENT, aStatus);
|
||||
NS_RELEASE(targetContent);
|
||||
}
|
||||
}
|
||||
|
||||
//3. Give event to the Frames for browser default processing.
|
||||
// XXX The event isn't translated into the local coordinate space
|
||||
// of the frame...
|
||||
|
|
|
@ -101,6 +101,9 @@
|
|||
#include "nsIStyleRule.h"//observe documents to send onchangenotifications
|
||||
#include "nsIDOMEventListener.h"//observe documents to send onchangenotifications
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIDOMEventGroup.h"
|
||||
#include "nsIDOM3EventTarget.h"
|
||||
#include "nsIDOMNSUIEvent.h"
|
||||
|
||||
#include "nsIDOMFocusListener.h" //onchange events
|
||||
#include "nsIDOMCharacterData.h" //for selection setting helper func
|
||||
|
@ -316,6 +319,15 @@ nsTextInputListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNSUIEvent> nsUIEvent = do_QueryInterface(aKeyEvent);
|
||||
if(nsUIEvent)
|
||||
{
|
||||
PRBool defaultPrevented;
|
||||
nsUIEvent->GetPreventDefault(&defaultPrevented);
|
||||
if(defaultPrevented)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mFrame->SetValueChanged(PR_TRUE);
|
||||
|
||||
if (mFrame && mFrame->IsSingleLineTextControl())
|
||||
|
@ -1488,7 +1500,17 @@ nsGfxTextControlFrame2::PreDestroy(nsIPresContext* aPresContext)
|
|||
if (erP)
|
||||
{
|
||||
erP->RemoveEventListenerByIID(NS_STATIC_CAST(nsIDOMFocusListener *,mTextListener), NS_GET_IID(nsIDOMFocusListener));
|
||||
erP->RemoveEventListenerByIID(NS_STATIC_CAST(nsIDOMKeyListener*,mTextListener), NS_GET_IID(nsIDOMKeyListener));
|
||||
// register the event listeners with the DOM event reveiver
|
||||
nsCOMPtr<nsIDOMEventGroup> sysGroup;
|
||||
nsresult rv = erP->GetSystemEventGroup(getter_AddRefs(sysGroup));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIDOM3EventTarget> dom3Targ(do_QueryInterface(erP));
|
||||
if (dom3Targ) {
|
||||
rv = dom3Targ->RemoveGroupedEventListener(NS_LITERAL_STRING("keypress"),
|
||||
NS_STATIC_CAST(nsIDOMKeyListener *,mTextListener),
|
||||
PR_FALSE, sysGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3418,8 +3440,21 @@ nsGfxTextControlFrame2::SetInitialChildList(nsIPresContext* aPresContext,
|
|||
if (NS_SUCCEEDED(mContent->QueryInterface(NS_GET_IID(nsIDOMEventReceiver), getter_AddRefs(erP))) && erP)
|
||||
{
|
||||
// register the event listeners with the DOM event reveiver
|
||||
rv = erP->AddEventListenerByIID(NS_STATIC_CAST(nsIDOMKeyListener *,mTextListener), NS_GET_IID(nsIDOMKeyListener));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register key listener");
|
||||
|
||||
nsCOMPtr<nsIDOMEventGroup> sysGroup;
|
||||
rv = erP->GetSystemEventGroup(getter_AddRefs(sysGroup));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIDOM3EventTarget> dom3Targ(do_QueryInterface(erP));
|
||||
if (dom3Targ) {
|
||||
rv = dom3Targ->AddGroupedEventListener(NS_LITERAL_STRING("keypress"),
|
||||
NS_STATIC_CAST(nsIDOMKeyListener *,mTextListener),
|
||||
PR_FALSE, sysGroup);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register key listener");
|
||||
}
|
||||
}
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register event listeners on nsGfxTextControlFrame2");
|
||||
|
||||
|
||||
rv = erP->AddEventListenerByIID(NS_STATIC_CAST(nsIDOMFocusListener *,mTextListener), NS_GET_IID(nsIDOMFocusListener));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register focus listener");
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
|
|
|
@ -98,6 +98,9 @@ class nsIContent;
|
|||
#define NS_EVENT_FLAG_NO_CONTENT_DISPATCH 0x0100
|
||||
#define NS_EVENT_FLAG_SYSTEM_EVENT 0x0200
|
||||
|
||||
#define NS_EVENT_CAPTURE_MASK (~(NS_EVENT_FLAG_INIT | NS_EVENT_FLAG_BUBBLE))
|
||||
#define NS_EVENT_BUBBLE_MASK (~(NS_EVENT_FLAG_INIT | NS_EVENT_FLAG_CAPTURE))
|
||||
|
||||
#define NS_APP_EVENT_FLAG_NONE 0x0000
|
||||
#define NS_APP_EVENT_FLAG_HANDLED 0x0001 // Similar to NS_EVENT_FLAG_NO_DEFAULT, but it allows focus
|
||||
|
||||
|
@ -394,6 +397,8 @@ enum nsDragDropEventStatus {
|
|||
* GUI MESSAGES
|
||||
*/
|
||||
//@{
|
||||
#define NS_EVENT_NULL 0
|
||||
|
||||
|
||||
#define NS_WINDOW_START 100
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче