Fixing bug 110798. Freezing nsIDOMEvent and related interfaces. r=harishd@netscape.com, sr=jband@netscape.com

git-svn-id: svn://10.0.0.236/branches/MOZILLA_0_9_4_BRANCH@109987 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jst%netscape.com
2001-12-07 08:22:02 +00:00
parent dc48d37b85
commit 7a4b830d2c
38 changed files with 558 additions and 264 deletions

View File

@@ -30,6 +30,7 @@
#include "nsIFrame.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMElement.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMEventReceiver.h"
#include "nsReadableUtils.h"
#include "nsILink.h"
@@ -293,7 +294,12 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
NS_IMETHODIMP nsRootAccessible::GetTargetNode(nsIDOMEvent *aEvent, nsCOMPtr<nsIDOMNode>& aTargetNode)
{
nsCOMPtr<nsIDOMEventTarget> domEventTarget;
aEvent->GetOriginalTarget(getter_AddRefs(domEventTarget));
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aEvent));
if (nsevent) {
nsevent->GetOriginalTarget(getter_AddRefs(domEventTarget));
}
nsresult rv;
aTargetNode = do_QueryInterface(domEventTarget, &rv);

View File

@@ -1557,18 +1557,19 @@ nsDocument::EndLoad()
i--;
}
}
// Fire a DOM event notifying listeners that this document has been
// loaded (excluding images and other loads initiated by this
// document).
nsCOMPtr<nsIDOMEvent> event;
CreateEvent(NS_LITERAL_STRING("Events"),
getter_AddRefs(event));
if (event) {
event->InitEvent(NS_LITERAL_STRING("DOMContentLoaded"), PR_TRUE, PR_TRUE);
DispatchEvent(event);
}
// Fire a DOM event notifying listeners that this document has been
// loaded (excluding images and other loads initiated by this
// document).
nsCOMPtr<nsIDOMEvent> event;
CreateEvent(NS_LITERAL_STRING("Events"),
getter_AddRefs(event));
if (event) {
event->InitEvent(NS_LITERAL_STRING("DOMContentLoaded"), PR_TRUE, PR_TRUE);
PRBool noDefault;
DispatchEvent(event, &noDefault);
}
return NS_OK;
}
@@ -2917,7 +2918,8 @@ nsresult nsDocument::GetListenerManager(nsIEventListenerManager **aInstancePtrRe
nsresult nsDocument::HandleEvent(nsIDOMEvent *aEvent)
{
return DispatchEvent(aEvent);
PRBool noDefault;
return DispatchEvent(aEvent, &noDefault);
}
nsresult nsDocument::HandleDOMEvent(nsIPresContext* aPresContext,
@@ -3040,8 +3042,10 @@ nsresult nsDocument::RemoveEventListener(const nsAReadableString& aType, nsIDOME
}
NS_IMETHODIMP
nsDocument::DispatchEvent(nsIDOMEvent* aEvent)
nsDocument::DispatchEvent(nsIDOMEvent* aEvent, PRBool *aRetVal)
{
*aRetVal = PR_TRUE;
// Obtain a presentation context
PRInt32 count = GetNumberOfShells();
if (count == 0)

View File

@@ -506,14 +506,7 @@ public:
NS_DECL_NSIDISKDOCUMENT
// nsIDOMEventTarget interface
NS_IMETHOD AddEventListener(const nsAReadableString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture);
NS_IMETHOD RemoveEventListener(const nsAReadableString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture);
NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent);
NS_DECL_NSIDOMEVENTTARGET
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext,
nsEvent* aEvent,

View File

@@ -599,13 +599,13 @@ nsDOMEventRTTearoff::RemoveEventListener(const nsAReadableString& type,
}
NS_IMETHODIMP
nsDOMEventRTTearoff::DispatchEvent(nsIDOMEvent *evt)
nsDOMEventRTTearoff::DispatchEvent(nsIDOMEvent *evt, PRBool *aRetVal)
{
nsCOMPtr<nsIDOMEventReceiver> event_receiver;
nsresult rv = GetEventReceiver(getter_AddRefs(event_receiver));
NS_ENSURE_SUCCESS(rv, rv);
return event_receiver->DispatchEvent(evt);
return event_receiver->DispatchEvent(evt, aRetVal);
}

View File

@@ -256,6 +256,7 @@ NS_INTERFACE_MAP_BEGIN(nsDOMEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMKeyEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSUIEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSEvent)
NS_INTERFACE_MAP_ENTRY(nsIPrivateDOMEvent)
NS_INTERFACE_MAP_ENTRY(nsIPrivateTextEvent)
NS_INTERFACE_MAP_ENTRY(nsIPrivateCompositionEvent)

View File

@@ -26,6 +26,7 @@
#include "nsIDOMKeyEvent.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMNSUIEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsISupports.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIPrivateCompositionEvent.h"
@@ -39,15 +40,16 @@
class nsIContent;
class nsIScrollableView;
class nsDOMEvent : public nsIDOMKeyEvent,
class nsDOMEvent : public nsIDOMKeyEvent,
public nsIDOMNSEvent,
public nsIDOMMouseEvent,
public nsIDOMNSUIEvent,
public nsIPrivateDOMEvent,
public nsIPrivateTextEvent,
public nsIDOMNSUIEvent,
public nsIPrivateDOMEvent,
public nsIPrivateTextEvent,
public nsIPrivateCompositionEvent
{
public:
// Note: this enum must be kept in sync with mEventNames in nsDOMEvent.cpp
enum nsDOMEvents {
eDOMEvents_mousedown=0,
@@ -108,27 +110,13 @@ public:
NS_DECL_ISUPPORTS
// nsIDOMEvent Interface
NS_IMETHOD GetType(nsAWritableString& aType);
NS_IMETHOD GetTarget(nsIDOMEventTarget** aTarget);
NS_IMETHOD GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget);
NS_IMETHOD GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget);
NS_IMETHOD GetEventPhase(PRUint16* aEventPhase);
NS_IMETHOD GetBubbles(PRBool* aBubbles);
NS_IMETHOD GetCancelable(PRBool* aCancelable);
NS_IMETHOD GetTimeStamp(PRUint64* aTimestamp);
NS_IMETHOD StopPropagation();
NS_IMETHOD PreventBubble();
NS_IMETHOD PreventCapture();
NS_IMETHOD PreventDefault();
NS_IMETHOD InitEvent(const nsAReadableString& aEventTypeArg,
PRBool aCanBubbleArg, PRBool aCancelableArg);
NS_DECL_NSIDOMEVENT
// nsIDOMNSEvent Interface
NS_DECL_NSIDOMNSEVENT
// nsIDOMUIEvent Interface
NS_IMETHOD GetView(nsIDOMAbstractView** aView);
NS_IMETHOD GetDetail(PRInt32* aDetail);
NS_IMETHOD InitUIEvent(const nsAReadableString& aTypeArg,
PRBool aCanBubbleArg, PRBool aCancelableArg,
nsIDOMAbstractView* aViewArg, PRInt32 aDetailArg);
NS_DECL_NSIDOMUIEVENT
// nsIDOMMouseEvent Interface and nsIDOMKeyEvent Interface
NS_IMETHOD GetScreenX(PRInt32* aScreenX);

View File

@@ -24,6 +24,7 @@
#include "nsGUIEvent.h"
#include "nsDOMEvent.h"
#include "nsEventListenerManager.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMMouseListener.h"
#include "nsIDOMMouseMotionListener.h"
@@ -2360,7 +2361,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
EventArrayType arrayType;
nsListenerStruct *ls;
if (aEventTypes & nsIDOMEvent::MOUSEDOWN) {
if (aEventTypes & nsIDOMNSEvent::MOUSEDOWN) {
arrayType = eEventArrayType_Mouse;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2369,7 +2370,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::MOUSEUP) {
if (aEventTypes & nsIDOMNSEvent::MOUSEUP) {
arrayType = eEventArrayType_Mouse;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2378,7 +2379,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::MOUSEOVER) {
if (aEventTypes & nsIDOMNSEvent::MOUSEOVER) {
arrayType = eEventArrayType_Mouse;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2387,7 +2388,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::MOUSEOUT) {
if (aEventTypes & nsIDOMNSEvent::MOUSEOUT) {
arrayType = eEventArrayType_Mouse;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2396,7 +2397,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::MOUSEMOVE) {
if (aEventTypes & nsIDOMNSEvent::MOUSEMOVE) {
arrayType = eEventArrayType_MouseMotion;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2405,7 +2406,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::CLICK) {
if (aEventTypes & nsIDOMNSEvent::CLICK) {
arrayType = eEventArrayType_Mouse;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2414,7 +2415,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::DBLCLICK) {
if (aEventTypes & nsIDOMNSEvent::DBLCLICK) {
arrayType = eEventArrayType_Mouse;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2423,7 +2424,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::KEYDOWN) {
if (aEventTypes & nsIDOMNSEvent::KEYDOWN) {
arrayType = eEventArrayType_Key;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2432,7 +2433,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::KEYUP) {
if (aEventTypes & nsIDOMNSEvent::KEYUP) {
arrayType = eEventArrayType_Key;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2441,7 +2442,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::KEYPRESS) {
if (aEventTypes & nsIDOMNSEvent::KEYPRESS) {
arrayType = eEventArrayType_Key;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2450,7 +2451,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::DRAGDROP) {
if (aEventTypes & nsIDOMNSEvent::DRAGDROP) {
arrayType = eEventArrayType_Drag;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2459,7 +2460,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
/*if (aEventTypes & nsIDOMEvent::MOUSEDRAG) {
/*if (aEventTypes & nsIDOMNSEvent::MOUSEDRAG) {
arrayType = kIDOMMouseListenerarrayType;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2468,7 +2469,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}*/
if (aEventTypes & nsIDOMEvent::FOCUS) {
if (aEventTypes & nsIDOMNSEvent::FOCUS) {
arrayType = eEventArrayType_Focus;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2477,7 +2478,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::BLUR) {
if (aEventTypes & nsIDOMNSEvent::BLUR) {
arrayType = eEventArrayType_Focus;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2486,7 +2487,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::SELECT) {
if (aEventTypes & nsIDOMNSEvent::SELECT) {
arrayType = eEventArrayType_Form;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2495,7 +2496,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::CHANGE) {
if (aEventTypes & nsIDOMNSEvent::CHANGE) {
arrayType = eEventArrayType_Form;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2504,7 +2505,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::RESET) {
if (aEventTypes & nsIDOMNSEvent::RESET) {
arrayType = eEventArrayType_Form;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2513,7 +2514,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::SUBMIT) {
if (aEventTypes & nsIDOMNSEvent::SUBMIT) {
arrayType = eEventArrayType_Form;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2522,7 +2523,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::LOAD) {
if (aEventTypes & nsIDOMNSEvent::LOAD) {
arrayType = eEventArrayType_Load;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2531,7 +2532,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::UNLOAD) {
if (aEventTypes & nsIDOMNSEvent::UNLOAD) {
arrayType = eEventArrayType_Load;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2540,7 +2541,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::ABORT) {
if (aEventTypes & nsIDOMNSEvent::ABORT) {
arrayType = eEventArrayType_Load;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2549,7 +2550,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::ERROR) {
if (aEventTypes & nsIDOMNSEvent::ERROR) {
arrayType = eEventArrayType_Load;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2558,7 +2559,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::RESIZE) {
if (aEventTypes & nsIDOMNSEvent::RESIZE) {
arrayType = eEventArrayType_Paint;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2567,7 +2568,7 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::SCROLL) {
if (aEventTypes & nsIDOMNSEvent::SCROLL) {
arrayType = eEventArrayType_Scroll;
ls = FindJSEventListener(arrayType);
if (ls) {
@@ -2609,8 +2610,10 @@ nsEventListenerManager::RemoveEventListener(const nsAReadableString& aType,
}
NS_IMETHODIMP
nsEventListenerManager::DispatchEvent(nsIDOMEvent* aEvent)
nsEventListenerManager::DispatchEvent(nsIDOMEvent* aEvent, PRBool *aRetVal)
{
*aRetVal = PR_TRUE;
//If we don't have a target set this doesn't work.
if (mTarget) {
nsCOMPtr<nsIContent> targetContent(do_QueryInterface(mTarget));
@@ -2667,7 +2670,8 @@ nsEventListenerManager::GetListenerManager(nsIEventListenerManager** aInstancePt
NS_IMETHODIMP
nsEventListenerManager::HandleEvent(nsIDOMEvent *aEvent)
{
return DispatchEvent(aEvent);
PRBool noDefault;
return DispatchEvent(aEvent, &noDefault);
}
nsresult

View File

@@ -152,7 +152,7 @@ public:
NS_IMETHOD RemoveEventListener(const nsAReadableString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture);
NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent);
NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent, PRBool *aRetVal);
// nsIDOMEventReceiver interface
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener,

View File

@@ -37,6 +37,7 @@
#include "nsIFormControlFrame.h"
#include "nsIEventStateManager.h"
#include "nsIDOMEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsISizeOfHandler.h"
#include "nsIDocument.h"
#include "nsGUIEvent.h"
@@ -461,11 +462,20 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext* aPresContext,
case NS_MOUSE_RIGHT_DOUBLECLICK:
case NS_MOUSE_RIGHT_BUTTON_DOWN:
case NS_MOUSE_RIGHT_BUTTON_UP:
if (aDOMEvent != nsnull && *aDOMEvent != nsnull) {
(*aDOMEvent)->PreventBubble();
} else {
ret = NS_ERROR_FAILURE;
{
nsCOMPtr<nsIDOMNSEvent> nsevent;
if (aDOMEvent) {
nsevent = do_QueryInterface(*aDOMEvent);
}
if (nsevent) {
nsevent->PreventBubble();
} else {
ret = NS_ERROR_FAILURE;
}
}
break;
case NS_MOUSE_ENTER_SYNTH:

View File

@@ -58,6 +58,7 @@
#include "nsIPresState.h"
#include "nsIDOMEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMHTMLCollection.h"
#include "nsICheckboxControlFrame.h"
@@ -1019,7 +1020,13 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
(*aDOMEvent)->GetTarget(getter_AddRefs(oldTarget));
nsCOMPtr<nsIDOMEventTarget> originalTarget;
(*aDOMEvent)->GetOriginalTarget(getter_AddRefs(originalTarget));
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(*aDOMEvent));
if (nsevent) {
nsevent->GetOriginalTarget(getter_AddRefs(originalTarget));
}
if (!originalTarget) {
privateEvent->SetOriginalTarget(oldTarget);
}
@@ -1243,8 +1250,14 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
if (type == NS_FORM_INPUT_BUTTON ||
type == NS_FORM_INPUT_RESET ||
type == NS_FORM_INPUT_SUBMIT ) {
if (aDOMEvent != nsnull && *aDOMEvent != nsnull) {
(*aDOMEvent)->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent;
if (aDOMEvent) {
nsevent = do_QueryInterface(*aDOMEvent);
}
if (nsevent) {
nsevent->PreventBubble();
} else {
rv = NS_ERROR_FAILURE;
}
@@ -1682,7 +1695,9 @@ nsHTMLInputElement::FireEventForAccessibility(nsIPresContext* aPresContext,
nsCOMPtr<nsIDOMEventReceiver> eventReceiver(do_QueryInterface(listenerManager));
if ( ! eventReceiver )
return NS_ERROR_FAILURE;
eventReceiver->DispatchEvent(domEvent);
PRBool noDefault;
eventReceiver->DispatchEvent(domEvent, &noDefault);
return NS_OK;
}

View File

@@ -2008,8 +2008,10 @@ nsXULElement::RemoveEventListener(const nsAReadableString& aType,
}
NS_IMETHODIMP
nsXULElement::DispatchEvent(nsIDOMEvent* aEvent)
nsXULElement::DispatchEvent(nsIDOMEvent* aEvent, PRBool *aRetVal)
{
*aRetVal = PR_TRUE;
// Obtain a presentation context
PRInt32 count = mDocument->GetNumberOfShells();
if (count == 0)
@@ -2052,7 +2054,8 @@ nsXULElement::GetListenerManager(nsIEventListenerManager** aResult)
NS_IMETHODIMP
nsXULElement::HandleEvent(nsIDOMEvent *aEvent)
{
return DispatchEvent(aEvent);
PRBool noDefault;
return DispatchEvent(aEvent, &noDefault);
}

View File

@@ -443,11 +443,7 @@ public:
NS_DECL_NSIDOMXULELEMENT
// nsIDOMEventTarget interface (from nsIDOMEventReceiver)
NS_IMETHOD AddEventListener(const nsAReadableString& aType, nsIDOMEventListener* aListener,
PRBool aUseCapture);
NS_IMETHOD RemoveEventListener(const nsAReadableString& aType, nsIDOMEventListener* aListener,
PRBool aUseCapture);
NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent);
NS_DECL_NSIDOMEVENTTARGET
// nsIDOMEventReceiver
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);

View File

@@ -54,6 +54,7 @@
#include "nsITimer.h"
#include "nsIDOMNSUIEvent.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMNSEvent.h"
#include "nsIBoxObject.h"
#include "nsIPopupBoxObject.h"
@@ -357,6 +358,8 @@ XULPopupListenerImpl::PreLaunchPopup(nsIDOMEvent* aMouseEvent)
// Store clicked-on node in xul document.
xulDocument->SetPopupNode( targetNode );
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aMouseEvent));
switch (popupType) {
case eXULPopupType_popup:
// Check for left mouse button down
@@ -364,7 +367,11 @@ XULPopupListenerImpl::PreLaunchPopup(nsIDOMEvent* aMouseEvent)
if (button == 0) {
// Time to launch a popup menu.
LaunchPopup(aMouseEvent);
aMouseEvent->PreventBubble();
if (nsevent) {
nsevent->PreventBubble();
}
aMouseEvent->PreventDefault();
}
break;
@@ -377,7 +384,11 @@ XULPopupListenerImpl::PreLaunchPopup(nsIDOMEvent* aMouseEvent)
FireFocusOnTargetContent(targetNode);
#endif
LaunchPopup(aMouseEvent);
aMouseEvent->PreventBubble();
if (nsevent) {
nsevent->PreventBubble();
}
aMouseEvent->PreventDefault();
break;

View File

@@ -4265,8 +4265,10 @@ nsXULDocument::RemoveEventListener(const nsAReadableString& aType,
}
NS_IMETHODIMP
nsXULDocument::DispatchEvent(nsIDOMEvent* aEvent)
nsXULDocument::DispatchEvent(nsIDOMEvent* aEvent, PRBool *aRetVal)
{
*aRetVal = PR_TRUE;
// Obtain a presentation context
PRInt32 count = GetNumberOfShells();
if (count == 0)
@@ -4335,7 +4337,8 @@ nsXULDocument::GetListenerManager(nsIEventListenerManager** aResult)
NS_IMETHODIMP
nsXULDocument::HandleEvent(nsIDOMEvent *aEvent)
{
return DispatchEvent(aEvent);
PRBool noDefault;
return DispatchEvent(aEvent, &noDefault);
}
nsresult

View File

@@ -355,13 +355,7 @@ public:
NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent);
// nsIDOMEventTarget interface
NS_IMETHOD AddEventListener(const nsAReadableString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture);
NS_IMETHOD RemoveEventListener(const nsAReadableString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture);
NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent);
NS_DECL_NSIDOMEVENTTARGET
// nsIDOMDocument interface
NS_DECL_NSIDOMDOCUMENT

View File

@@ -1,9 +1,10 @@
nsIDOMDocumentEvent.idl
nsIDOMEvent.idl
nsIDOMNSEvent.idl
nsIDOMEventListener.idl
nsIDOMEventTarget.idl
nsIDOMKeyEvent.idl
nsIDOMMouseEvent.idl
nsIDOMMutationEvent.idl
nsIDOMNSUIEvent.idl
nsIDOMUIEvent.idl
nsIDOMNSUIEvent.idl

View File

@@ -32,12 +32,13 @@ XPIDL_MODULE = dom_events
XPIDLSRCS = \
nsIDOMDocumentEvent.idl \
nsIDOMEvent.idl \
nsIDOMNSEvent.idl \
nsIDOMEventTarget.idl \
nsIDOMKeyEvent.idl \
nsIDOMMouseEvent.idl \
nsIDOMMutationEvent.idl \
nsIDOMNSUIEvent.idl \
nsIDOMUIEvent.idl \
nsIDOMNSUIEvent.idl \
nsIDOMEventListener.idl \
$(NULL)

View File

@@ -27,12 +27,13 @@ XPIDL_MODULE=dom_events
XPIDLSRCS = \
.\nsIDOMDocumentEvent.idl \
.\nsIDOMEvent.idl \
.\nsIDOMNSEvent.idl \
.\nsIDOMEventTarget.idl \
.\nsIDOMKeyEvent.idl \
.\nsIDOMMouseEvent.idl \
.\nsIDOMMutationEvent.idl \
.\nsIDOMNSUIEvent.idl \
.\nsIDOMUIEvent.idl \
.\nsIDOMNSUIEvent.idl \
.\nsIDOMEventListener.idl \
$(NULL)

View File

@@ -1,31 +1,58 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* 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/
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 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 Netscape are
* Copyright (C) 2000 Netscape Communications Corporation. All
* Rights Reserved.
* 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-2-Events/
*
* @status FROZEN
*/
[scriptable, uuid(46b91d66-28e2-11d4-ab1e-0010830123b4)]
interface nsIDOMDocumentEvent : nsISupports
{
nsIDOMEvent createEvent(in DOMString eventType);
nsIDOMEvent createEvent(in DOMString eventType)
raises(DOMException);
};

View File

@@ -1,88 +1,74 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* 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/
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 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 Netscape are
* Copyright (C) 2000 Netscape Communications Corporation. All
* Rights Reserved.
* 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"
interface nsIDOMEventTarget;
/**
* The nsIDOMEvent interface is the primary datatype for all events in
* the Document Object Model.
*
* For more information on this interface please see
* http://www.w3.org/TR/DOM-Level-2-Events/
*
* @status FROZEN
*/
[scriptable, uuid(a66b7b80-ff46-bd97-0080-5f8ae38add32)]
interface nsIDOMEvent : nsISupports
{
const unsigned short CAPTURING_PHASE = 1;
const unsigned short AT_TARGET = 2;
const unsigned short BUBBLING_PHASE = 3;
const long MOUSEDOWN = 0x00000001;
const long MOUSEUP = 0x00000002;
const long MOUSEOVER = 0x00000004;
const long MOUSEOUT = 0x00000008;
const long MOUSEMOVE = 0x00000010;
const long MOUSEDRAG = 0x00000020;
const long CLICK = 0x00000040;
const long DBLCLICK = 0x00000080;
const long KEYDOWN = 0x00000100;
const long KEYUP = 0x00000200;
const long KEYPRESS = 0x00000400;
const long DRAGDROP = 0x00000800;
const long FOCUS = 0x00001000;
const long BLUR = 0x00002000;
const long SELECT = 0x00004000;
const long CHANGE = 0x00008000;
const long RESET = 0x00010000;
const long SUBMIT = 0x00020000;
const long SCROLL = 0x00040000;
const long LOAD = 0x00080000;
const long UNLOAD = 0x00100000;
const long XFER_DONE = 0x00200000;
const long ABORT = 0x00400000;
const long ERROR = 0x00800000;
const long LOCATE = 0x01000000;
const long MOVE = 0x02000000;
const long RESIZE = 0x04000000;
const long FORWARD = 0x08000000;
const long HELP = 0x10000000;
const long BACK = 0x20000000;
const long TEXT = 0x40000000;
const long ALT_MASK = 0x00000001;
const long CONTROL_MASK = 0x00000002;
const long SHIFT_MASK = 0x00000004;
const long META_MASK = 0x00000008;
// PhaseType
const unsigned short CAPTURING_PHASE = 1;
const unsigned short AT_TARGET = 2;
const unsigned short BUBBLING_PHASE = 3;
readonly attribute DOMString type;
readonly attribute nsIDOMEventTarget target;
readonly attribute nsIDOMEventTarget currentTarget;
readonly attribute nsIDOMEventTarget originalTarget;
readonly attribute unsigned short eventPhase;
readonly attribute boolean bubbles;
readonly attribute boolean cancelable;
readonly attribute DOMTimeStamp timeStamp;
void stopPropagation();
void preventBubble();
void preventCapture();
void preventDefault();
void initEvent(in DOMString eventTypeArg,
in boolean canBubbleArg,

View File

@@ -1,29 +1,55 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* 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/
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 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 Netscape are
* Copyright (C) 2000 Netscape Communications Corporation. All
* Rights Reserved.
* 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 nsIDOMEventListener interface is a callback interface for
* listening to events in the Document Object Model.
*
* For more information on this interface please see
* http://www.w3.org/TR/DOM-Level-2-Events/
*
* @status FROZEN
*/
[scriptable, function, uuid(df31c120-ded6-11d1-bd85-00805f8ae3f4)]
interface nsIDOMEventListener : nsISupports
{

View File

@@ -1,29 +1,55 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* 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/
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 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 Netscape are
* Copyright (C) 2000 Netscape Communications Corporation. All
* Rights Reserved.
* 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 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-2-Events/
*
* @status FROZEN
*/
[scriptable, uuid(1c773b30-d1cf-11d2-bd95-00805f8ae3f4)]
interface nsIDOMEventTarget : nsISupports
{
@@ -34,5 +60,6 @@ interface nsIDOMEventTarget : nsISupports
void removeEventListener(in DOMString type,
in nsIDOMEventListener listener,
in boolean useCapture);
void dispatchEvent(in nsIDOMEvent evt);
boolean dispatchEvent(in nsIDOMEvent evt)
raises(DOMException);
};

View File

@@ -43,6 +43,7 @@
#include "nsIDOMDocument.h"
#include "nsIDOMNSDocument.h"
#include "nsIDOMEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMEventListener.h"
@@ -1051,6 +1052,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(Event, nsIDOMEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMKeyEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSUIEvent)
@@ -2619,6 +2621,14 @@ nsWindowSH::GlobalResolve(nsISupports *native, JSContext *cx, JSObject *obj,
rv = DefineInterfaceConstants(cx, cfnc_obj, &primary_iid);
NS_ENSURE_SUCCESS(rv, rv);
// Special case for |Event|, Event needs constants from NSEvent
// too for backwards compatibility.
if (primary_iid.Equals(NS_GET_IID(nsIDOMEvent))) {
rv = DefineInterfaceConstants(cx, cfnc_obj,
&NS_GET_IID(nsIDOMNSEvent));
NS_ENSURE_SUCCESS(rv, rv);
}
nsCOMPtr<nsIInterfaceInfoManager> iim =
dont_AddRef(XPTI_GetInterfaceInfoManager());
NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE);

View File

@@ -29,6 +29,7 @@
#include "nsIDOMNSHTMLInputElement.h"
#include "nsIDOMNSHTMLTextAreaElement.h"
#include "nsIDOMUIEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMWindowInternal.h"
#include "nsIDocument.h"
#include "nsIPresContext.h"
@@ -245,8 +246,12 @@ nsFocusController::Focus(nsIDOMEvent* aEvent)
return NS_OK;
nsCOMPtr<nsIDOMEventTarget> t;
aEvent->GetOriginalTarget(getter_AddRefs(t));
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aEvent));
if (nsevent) {
nsevent->GetOriginalTarget(getter_AddRefs(t));
}
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(t);
if (domElement && (domElement != mCurrentElement)) {
SetFocusedElement(domElement);
@@ -297,7 +302,12 @@ nsFocusController::Blur(nsIDOMEvent* aEvent)
return NS_OK;
nsCOMPtr<nsIDOMEventTarget> t;
aEvent->GetOriginalTarget(getter_AddRefs(t));
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aEvent));
if (nsevent) {
nsevent->GetOriginalTarget(getter_AddRefs(t));
}
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(t);
if (domElement) {

View File

@@ -2690,8 +2690,11 @@ GlobalWindowImpl::RemoveEventListener(const nsAReadableString& aType,
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP GlobalWindowImpl::DispatchEvent(nsIDOMEvent* aEvent)
NS_IMETHODIMP GlobalWindowImpl::DispatchEvent(nsIDOMEvent* aEvent,
PRBool *aRetVal)
{
*aRetVal = PR_TRUE;
if (mDocument) {
nsCOMPtr<nsIDocument> idoc(do_QueryInterface(mDocument));
if (idoc) {
@@ -2770,7 +2773,8 @@ GlobalWindowImpl::GetNewListenerManager(nsIEventListenerManager **aResult)
NS_IMETHODIMP GlobalWindowImpl::HandleEvent(nsIDOMEvent *aEvent)
{
return DispatchEvent(aEvent);
PRBool noDefault;
return DispatchEvent(aEvent, &noDefault);
}
//*****************************************************************************

View File

@@ -140,7 +140,7 @@ public:
NS_IMETHOD RemoveEventListener(const nsAReadableString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture);
NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent);
NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent, PRBool *aRetVal);
// nsIDOMEventReceiver
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener,

View File

@@ -84,7 +84,7 @@ nsWindowRoot::RemoveEventListener(const nsAReadableString& aType, nsIDOMEventLis
}
NS_IMETHODIMP
nsWindowRoot::DispatchEvent(nsIDOMEvent* aEvt)
nsWindowRoot::DispatchEvent(nsIDOMEvent* aEvt, PRBool *aRetVal)
{
// Obtain a presentation context
nsCOMPtr<nsIDOMDocument> domDoc;
@@ -153,7 +153,8 @@ nsWindowRoot::GetListenerManager(nsIEventListenerManager** aResult)
NS_IMETHODIMP
nsWindowRoot::HandleEvent(nsIDOMEvent *aEvent)
{
return DispatchEvent(aEvent);
PRBool noDefault;
return DispatchEvent(aEvent, &noDefault);
}
NS_IMETHODIMP nsWindowRoot::HandleChromeEvent(nsIPresContext* aPresContext,

View File

@@ -26,6 +26,7 @@
#include "nsString.h"
#include "nsIDOMEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMDocument.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
@@ -427,9 +428,14 @@ nsTextEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
else
editor->Paste(clipboard);
// Prevent the event from bubbling up to be possibly handled
// again by the containing window:
mouseEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(mouseEvent));
if (nsevent) {
// Prevent the event from bubbling up to be possibly handled
// again by the containing window:
nsevent->PreventBubble();
}
mouseEvent->PreventDefault();
// We processed the event, whether drop/paste succeeded or not
@@ -725,8 +731,13 @@ nsTextEditorDragListener::DragDrop(nsIDOMEvent* aMouseEvent)
nsCOMPtr<nsIDOMNSUIEvent> nsuiEvent (do_QueryInterface(aMouseEvent));
if (!nsuiEvent) return NS_OK;
//some day we want to use another way to stop this from bubbling.
aMouseEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aMouseEvent));
if (nsevent) {
//some day we want to use another way to stop this from bubbling.
nsevent->PreventBubble();
}
aMouseEvent->PreventDefault();
/* for bug 47399, when dropping a drag session, if you are over your original
@@ -1061,7 +1072,13 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
if (mEditor)
{
PRUint32 flags;
aEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aEvent));
if (nsevent) {
nsevent->PreventBubble();
}
mEditor->GetFlags(&flags);
if (! (flags & nsIPlaintextEditor::eEditorDisabledMask))
{ // only enable caret and selection if the editor is not disabled
@@ -1122,7 +1139,13 @@ nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent)
if (mEditor)
{
PRUint32 flags;
aEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aEvent));
if (nsevent) {
nsevent->PreventBubble();
}
mEditor->GetFlags(&flags);
nsCOMPtr<nsIEditor>editor = do_QueryInterface(mEditor);
if (editor)

View File

@@ -34,6 +34,7 @@
#include "nsIDOMAttr.h"
#include "nsIDocument.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMKeyListener.h"
#include "nsIDOMMouseListener.h"
@@ -923,8 +924,15 @@ NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag)
return NS_OK;
nsCOMPtr<nsIDOMEventTarget> eventTarget;
res = aDragEvent->GetOriginalTarget(getter_AddRefs(eventTarget));
if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aDragEvent));
if (nsevent) {
res = nsevent->GetOriginalTarget(getter_AddRefs(eventTarget));
if (NS_FAILED(res))
return res;
}
if ( eventTarget )
{
nsCOMPtr<nsIDOMNode> eventTargetDomNode = do_QueryInterface(eventTarget);
@@ -1056,7 +1064,11 @@ NS_IMETHODIMP nsHTMLEditor::DoDrag(nsIDOMEvent *aDragEvent)
rv = dragService->InvokeDragSession( domnode, transferableArray, nsnull, flags);
if (NS_FAILED(rv)) return rv;
aDragEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aDragEvent));
if (nsevent) {
nsevent->PreventBubble();
}
}
}

View File

@@ -30,6 +30,7 @@
#include "nsIDOMAttr.h"
#include "nsIDocument.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMKeyListener.h"
#include "nsIDOMMouseListener.h"
@@ -387,8 +388,15 @@ NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDr
return NS_OK;
nsCOMPtr<nsIDOMEventTarget> eventTarget;
res = aDragEvent->GetOriginalTarget(getter_AddRefs(eventTarget));
if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aDragEvent));
if (nsevent) {
res = nsevent->GetOriginalTarget(getter_AddRefs(eventTarget));
if (NS_FAILED(res))
return res;
}
if ( eventTarget )
{
nsCOMPtr<nsIDOMNode> eventTargetDomNode = do_QueryInterface(eventTarget);
@@ -520,7 +528,11 @@ NS_IMETHODIMP nsPlaintextEditor::DoDrag(nsIDOMEvent *aDragEvent)
rv = dragService->InvokeDragSession( domnode, transferableArray, nsnull, flags);
if (NS_FAILED(rv)) return rv;
aDragEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aDragEvent));
if (nsevent) {
nsevent->PreventBubble();
}
}
}

View File

@@ -34,6 +34,7 @@
#include "nsIDOMAttr.h"
#include "nsIDocument.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMKeyListener.h"
#include "nsIDOMMouseListener.h"
@@ -923,8 +924,16 @@ NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag)
return NS_OK;
nsCOMPtr<nsIDOMEventTarget> eventTarget;
res = aDragEvent->GetOriginalTarget(getter_AddRefs(eventTarget));
if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aDragEvent));
if (nsevent) {
res = nsevent->GetOriginalTarget(getter_AddRefs(eventTarget));
if (NS_FAILED(res)) {
return res;
}
}
if ( eventTarget )
{
nsCOMPtr<nsIDOMNode> eventTargetDomNode = do_QueryInterface(eventTarget);
@@ -1056,7 +1065,11 @@ NS_IMETHODIMP nsHTMLEditor::DoDrag(nsIDOMEvent *aDragEvent)
rv = dragService->InvokeDragSession( domnode, transferableArray, nsnull, flags);
if (NS_FAILED(rv)) return rv;
aDragEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aDragEvent));
if (nsevent) {
nsevent->PreventBubble();
}
}
}

View File

@@ -26,6 +26,7 @@
#include "nsString.h"
#include "nsIDOMEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMDocument.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
@@ -429,7 +430,12 @@ nsTextEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
// Prevent the event from bubbling up to be possibly handled
// again by the containing window:
mouseEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(mouseEvent));
if (nsevent) {
nsevent->PreventBubble();
}
mouseEvent->PreventDefault();
// We processed the event, whether drop/paste succeeded or not
@@ -726,7 +732,12 @@ nsTextEditorDragListener::DragDrop(nsIDOMEvent* aMouseEvent)
if (!nsuiEvent) return NS_OK;
//some day we want to use another way to stop this from bubbling.
aMouseEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aMouseEvent));
if (nsevent) {
nsevent->PreventBubble();
}
aMouseEvent->PreventDefault();
/* for bug 47399, when dropping a drag session, if you are over your original
@@ -1061,7 +1072,13 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
if (mEditor)
{
PRUint32 flags;
aEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aEvent));
if (nsevent) {
nsevent->PreventBubble();
}
mEditor->GetFlags(&flags);
if (! (flags & nsIPlaintextEditor::eEditorDisabledMask))
{ // only enable caret and selection if the editor is not disabled
@@ -1122,7 +1139,13 @@ nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent)
if (mEditor)
{
PRUint32 flags;
aEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aEvent));
if (nsevent) {
nsevent->PreventBubble();
}
mEditor->GetFlags(&flags);
nsCOMPtr<nsIEditor>editor = do_QueryInterface(mEditor);
if (editor)

View File

@@ -30,6 +30,7 @@
#include "nsIDOMAttr.h"
#include "nsIDocument.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMKeyListener.h"
#include "nsIDOMMouseListener.h"
@@ -387,8 +388,16 @@ NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDr
return NS_OK;
nsCOMPtr<nsIDOMEventTarget> eventTarget;
res = aDragEvent->GetOriginalTarget(getter_AddRefs(eventTarget));
if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aDragEvent));
if (nsevent) {
res = nsevent->GetOriginalTarget(getter_AddRefs(eventTarget));
if (NS_FAILED(res)) {
return res;
}
}
if ( eventTarget )
{
nsCOMPtr<nsIDOMNode> eventTargetDomNode = do_QueryInterface(eventTarget);
@@ -520,7 +529,11 @@ NS_IMETHODIMP nsPlaintextEditor::DoDrag(nsIDOMEvent *aDragEvent)
rv = dragService->InvokeDragSession( domnode, transferableArray, nsnull, flags);
if (NS_FAILED(rv)) return rv;
aDragEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aDragEvent));
if (nsevent) {
nsevent->PreventBubble();
}
}
}

View File

@@ -211,7 +211,7 @@ nsXMLHttpRequest::RemoveEventListener(const nsAReadableString & type,
/* void dispatchEvent (in nsIDOMEvent evt); */
NS_IMETHODIMP
nsXMLHttpRequest::DispatchEvent(nsIDOMEvent *evt)
nsXMLHttpRequest::DispatchEvent(nsIDOMEvent *evt, PRBool *aRetVal)
{
// Ignored

View File

@@ -64,6 +64,7 @@
#include "nsIDOMMouseMotionListener.h"
#include "nsIDOMFocusListener.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOMNSEvent.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIDocumentEncoder.h"
#include "nsXPIDLString.h"
@@ -3007,7 +3008,13 @@ nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
nsEventStatus rv = ProcessEvent(focusEvent);
if (nsEventStatus_eConsumeNoDefault == rv) {
aFocusEvent->PreventDefault();
aFocusEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aFocusEvent));
if (nsevent) {
nsevent->PreventBubble();
}
return NS_ERROR_FAILURE; // means consume event
}
}
@@ -3037,7 +3044,13 @@ nsresult nsPluginInstanceOwner::KeyPress(nsIDOMEvent* aKeyEvent)
// If this event is going to the plugin, we want to kill it.
// Not actually sending keypress to the plugin, since we didn't before.
aKeyEvent->PreventDefault();
aKeyEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
if (nsevent) {
nsevent->PreventBubble();
}
return NS_ERROR_FAILURE; // means consume event
}
return NS_OK;
@@ -3055,7 +3068,13 @@ nsresult nsPluginInstanceOwner::DispatchKeyToPlugin(nsIDOMEvent* aKeyEvent)
nsEventStatus rv = ProcessEvent(*keyEvent);
if (nsEventStatus_eConsumeNoDefault == rv) {
aKeyEvent->PreventDefault();
aKeyEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
if (nsevent) {
nsevent->PreventBubble();
}
return NS_ERROR_FAILURE; // means consume event
}
}
@@ -3171,7 +3190,13 @@ nsresult nsPluginInstanceOwner::DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent)
nsEventStatus rv = ProcessEvent(*mouseEvent);
if (nsEventStatus_eConsumeNoDefault == rv) {
aMouseEvent->PreventDefault();
aMouseEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aMouseEvent));
if (nsevent) {
nsevent->PreventBubble();
}
return NS_ERROR_FAILURE; // means consume event
}
}

View File

@@ -59,6 +59,7 @@
#include "nsVoidArray.h"
#include "nsIScrollableFrame.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMNSEvent.h"
#include "nsGUIEvent.h"
#ifdef ACCESSIBILITY
#include "nsIAccessibilityService.h"
@@ -3363,8 +3364,13 @@ nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent)
if (IsInDropDownMode() == PR_TRUE) {
if (!IsClickingInCombobox(aMouseEvent)) {
aMouseEvent->PreventDefault();
aMouseEvent->PreventCapture();
aMouseEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aMouseEvent));
if (nsevent) {
nsevent->PreventCapture();
nsevent->PreventBubble();
}
} else {
mButtonDown = PR_FALSE;
CaptureMouseEvents(mPresContext, PR_FALSE);
@@ -3547,8 +3553,13 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
if (IsInDropDownMode()) {
if (!IsClickingInCombobox(aMouseEvent)) {
aMouseEvent->PreventDefault();
aMouseEvent->PreventCapture();
aMouseEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aMouseEvent));
if (nsevent) {
nsevent->PreventCapture();
nsevent->PreventBubble();
}
} else {
return NS_OK;
}
@@ -3988,8 +3999,13 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
mComboboxFrame->IsDroppedDown(&isDroppedDown);
mComboboxFrame->ShowDropDown(!isDroppedDown);
aKeyEvent->PreventDefault();
aKeyEvent->PreventCapture();
aKeyEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
if (nsevent) {
nsevent->PreventCapture();
nsevent->PreventBubble();
}
}
}
#endif
@@ -4013,9 +4029,14 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
} else {
return rv;
}
// We are handling this so don't let it bubble up
aKeyEvent->PreventBubble();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
if (nsevent) {
// We are handling this so don't let it bubble up
nsevent->PreventBubble();
}
// this tells us whether we need to process the new index that was set
// DOM_VK_RETURN & DOM_VK_ESCAPE will leave this false

View File

@@ -30,6 +30,7 @@
#include "nsIDOMEventReceiver.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMNSUIEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsGUIEvent.h"
// Drag & Drop, Clipboard
@@ -142,8 +143,13 @@ nsMenuBarListener::KeyUp(nsIDOMEvent* aKeyEvent)
PRBool active = mMenuBarFrame->IsActive();
if (active) {
aKeyEvent->PreventBubble();
aKeyEvent->PreventCapture();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
if (nsevent) {
nsevent->PreventBubble();
nsevent->PreventCapture();
}
aKeyEvent->PreventDefault();
return NS_ERROR_BASE; // I am consuming event
}
@@ -172,6 +178,8 @@ nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent)
if (mAccessKey)
{
nsCOMPtr<nsIDOMNSUIEvent> nsUIEvent = do_QueryInterface(aKeyEvent);
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
PRBool preventDefault;
nsUIEvent->GetPreventDefault(&preventDefault);
@@ -193,8 +201,11 @@ nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent)
mMenuBarFrame->ShortcutNavigation(theChar, active);
if (active) {
aKeyEvent->PreventBubble();
aKeyEvent->PreventCapture();
if (nsevent) {
nsevent->PreventBubble();
nsevent->PreventCapture();
}
aKeyEvent->PreventDefault();
retVal = NS_ERROR_BASE; // I am consuming event
@@ -213,8 +224,11 @@ nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent)
// In Windows, both of these activate the menu bar.
mMenuBarFrame->ToggleMenuActiveState();
aKeyEvent->PreventBubble();
aKeyEvent->PreventCapture();
if (nsevent) {
nsevent->PreventBubble();
nsevent->PreventCapture();
}
aKeyEvent->PreventDefault();
return NS_ERROR_BASE; // consume the event
}

View File

@@ -30,6 +30,7 @@
#include "nsIDOMEventReceiver.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMNSUIEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsGUIEvent.h"
// Drag & Drop, Clipboard
@@ -76,9 +77,14 @@ nsMenuListener::~nsMenuListener()
////////////////////////////////////////////////////////////////////////
nsresult
nsMenuListener::KeyUp(nsIDOMEvent* aKeyEvent)
{
aKeyEvent->PreventBubble();
aKeyEvent->PreventCapture();
{
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
if (nsevent) {
nsevent->PreventBubble();
nsevent->PreventCapture();
}
aKeyEvent->PreventDefault();
return NS_ERROR_BASE; // I am consuming event
@@ -142,8 +148,13 @@ nsMenuListener::KeyDown(nsIDOMEvent* aKeyEvent)
mMenuParent->DismissChain();
}
aKeyEvent->PreventBubble();
aKeyEvent->PreventCapture();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
if (nsevent) {
nsevent->PreventBubble();
nsevent->PreventCapture();
}
aKeyEvent->PreventDefault();
return NS_ERROR_BASE; // I am consuming event
@@ -209,8 +220,13 @@ nsMenuListener::KeyPress(nsIDOMEvent* aKeyEvent)
}
}
aKeyEvent->PreventBubble();
aKeyEvent->PreventCapture();
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
if (nsevent) {
nsevent->PreventBubble();
nsevent->PreventCapture();
}
aKeyEvent->PreventDefault();
return NS_ERROR_BASE; // I am consuming event