Bug 330494, Remove NS_EVENT_FLAG_INIT. Makes NN4 event handling and preventBubble and preventCapture methods no-op. r=sicking, sr=jst

This commit is contained in:
Olli.Pettay%helsinki.fi 2006-04-10 17:04:54 +00:00
Родитель 6d1550b350
Коммит 107fe84cd5
14 изменённых файлов: 126 добавлений и 263 удалений

Просмотреть файл

@ -53,8 +53,8 @@ struct JSObject;
* Event listener manager interface. * Event listener manager interface.
*/ */
#define NS_IEVENTLISTENERMANAGER_IID \ #define NS_IEVENTLISTENERMANAGER_IID \
{ 0xdbd8fcee, 0xb93e, 0x42f3, \ { 0x68588aa5, 0x41e6, 0x4642, \
{ 0x9d, 0xe5, 0xf9, 0x90, 0xfc, 0x66, 0xb7, 0x5a } } { 0xac, 0x8e, 0x7d, 0x43, 0x9c, 0x7d, 0x2a, 0xaa } }
class nsIEventListenerManager : public nsISupports { class nsIEventListenerManager : public nsISupports {
@ -153,18 +153,6 @@ public:
const nsAString& aEventType, const nsAString& aEventType,
nsIDOMEvent** aDOMEvent) = 0; nsIDOMEvent** aDOMEvent) = 0;
/**
* Changes script listener of specified event types from bubbling
* listeners to capturing listeners.
* @param event types */
NS_IMETHOD CaptureEvent(PRInt32 aEventTypes) = 0;
/**
* Changes script listener of specified event types from capturing
* listeners to bubbling listeners.
* @param event types */
NS_IMETHOD ReleaseEvent(PRInt32 aEventTypes) = 0;
/** /**
* Tells the event listener manager that its target (which owns it) is * Tells the event listener manager that its target (which owns it) is
* no longer using it (and could go away). * no longer using it (and could go away).

Просмотреть файл

@ -54,6 +54,7 @@
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsIURI.h" #include "nsIURI.h"
#include "nsIScriptSecurityManager.h" #include "nsIScriptSecurityManager.h"
#include "nsIScriptError.h"
static const char* const sEventNames[] = { static const char* const sEventNames[] = {
"mousedown", "mouseup", "click", "dblclick", "mouseover", "mousedown", "mouseup", "click", "dblclick", "mouseover",
@ -258,9 +259,9 @@ NS_IMETHODIMP
nsDOMEvent::SetTrusted(PRBool aTrusted) nsDOMEvent::SetTrusted(PRBool aTrusted)
{ {
if (aTrusted) { if (aTrusted) {
mEvent->internalAppFlags |= NS_APP_EVENT_FLAG_TRUSTED; mEvent->flags |= NS_EVENT_FLAG_TRUSTED;
} else { } else {
mEvent->internalAppFlags &= ~NS_APP_EVENT_FLAG_TRUSTED; mEvent->flags &= ~NS_EVENT_FLAG_TRUSTED;
} }
return NS_OK; return NS_OK;
@ -315,21 +316,44 @@ nsDOMEvent::StopPropagation()
return NS_OK; return NS_OK;
} }
static void
ReportUseOfDeprecatedMethod(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
const char* aWarning)
{
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsINode> node = do_QueryInterface(aEvent->currentTarget);
if (node) {
doc = node->GetOwnerDoc();
} else {
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aEvent->currentTarget);
if (window) {
doc = do_QueryInterface(window->GetExtantDocument());
}
}
nsAutoString type;
aDOMEvent->GetType(type);
const PRUnichar *strings[] = { type.get() };
nsContentUtils::ReportToConsole(nsContentUtils::eDOM_PROPERTIES,
aWarning,
strings, NS_ARRAY_LENGTH(strings),
doc ? doc->GetDocumentURI() : nsnull,
EmptyString(), 0, 0,
nsIScriptError::warningFlag,
"DOM Events");
}
NS_IMETHODIMP NS_IMETHODIMP
nsDOMEvent::PreventBubble() nsDOMEvent::PreventBubble()
{ {
if (mEvent->flags & NS_EVENT_FLAG_BUBBLE || mEvent->flags & NS_EVENT_FLAG_INIT) { ReportUseOfDeprecatedMethod(mEvent, this, "UseOfPreventBubbleWarning");
mEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH;
}
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMEvent::PreventCapture() nsDOMEvent::PreventCapture()
{ {
if (mEvent->flags & NS_EVENT_FLAG_CAPTURE) { ReportUseOfDeprecatedMethod(mEvent, this, "UseOfPreventCaptureWarning");
mEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH;
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -358,25 +358,18 @@ NS_IMETHODIMP
nsDOMUIEvent::GetCancelBubble(PRBool* aCancelBubble) nsDOMUIEvent::GetCancelBubble(PRBool* aCancelBubble)
{ {
NS_ENSURE_ARG_POINTER(aCancelBubble); NS_ENSURE_ARG_POINTER(aCancelBubble);
if (mEvent->flags & NS_EVENT_FLAG_BUBBLE || mEvent->flags & NS_EVENT_FLAG_INIT) { *aCancelBubble =
*aCancelBubble = (mEvent->flags &= NS_EVENT_FLAG_STOP_DISPATCH) ? PR_TRUE : PR_FALSE; (mEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) ? PR_TRUE : PR_FALSE;
}
else {
*aCancelBubble = PR_FALSE;
}
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMUIEvent::SetCancelBubble(PRBool aCancelBubble) nsDOMUIEvent::SetCancelBubble(PRBool aCancelBubble)
{ {
if (mEvent->flags & NS_EVENT_FLAG_BUBBLE || mEvent->flags & NS_EVENT_FLAG_INIT) { if (aCancelBubble) {
if (aCancelBubble) { mEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH;
mEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH; } else {
} mEvent->flags &= ~NS_EVENT_FLAG_STOP_DISPATCH;
else {
mEvent->flags &= ~NS_EVENT_FLAG_STOP_DISPATCH;
}
} }
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -457,8 +457,8 @@ nsEventTargetChainItem::HandleEventTargetChain(nsEventChainPostVisitor& aVisitor
} }
// Bubble // Bubble
aVisitor.mEvent->flags &= ~NS_EVENT_FLAG_CAPTURE;
if (!(aVisitor.mEvent->flags & NS_EVENT_FLAG_CANT_BUBBLE)) { if (!(aVisitor.mEvent->flags & NS_EVENT_FLAG_CANT_BUBBLE)) {
aVisitor.mEvent->flags &= ~NS_EVENT_FLAG_CAPTURE;
item = item->mParent; item = item->mParent;
while (item) { while (item) {
nsISupports* newTarget = item->GetNewTarget(); nsISupports* newTarget = item->GetNewTarget();

Просмотреть файл

@ -750,7 +750,6 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener,
ls->mListener.Set(aListener, participant); ls->mListener.Set(aListener, participant);
ls->mFlags = aFlags; ls->mFlags = aFlags;
ls->mSubType = aSubType; ls->mSubType = aSubType;
ls->mSubTypeCapture = NS_EVENT_BITS_NONE;
ls->mHandlerIsString = 0; ls->mHandlerIsString = 0;
ls->mGroupFlags = group; ls->mGroupFlags = group;
listeners->AppendElement((void*)ls); listeners->AppendElement((void*)ls);
@ -1610,35 +1609,20 @@ nsEventListenerManager::HandleEventSubType(nsListenerStruct* aListenerStruct,
// If this is a script handler and we haven't yet // If this is a script handler and we haven't yet
// compiled the event handler itself // compiled the event handler itself
if (aListenerStruct->mFlags & NS_PRIV_EVENT_FLAG_SCRIPT) { if ((aListenerStruct->mFlags & NS_PRIV_EVENT_FLAG_SCRIPT) &&
// If we're not in the capture phase we must *NOT* have capture flags (aListenerStruct->mHandlerIsString & aSubType)) {
// set. Compiled script handlers are one or the other, not both. nsCOMPtr<nsIJSEventListener> jslistener = do_QueryInterface(aListener);
if (aPhaseFlags & NS_EVENT_FLAG_BUBBLE && !aPhaseFlags & NS_EVENT_FLAG_INIT) { if (jslistener) {
if (aListenerStruct->mSubTypeCapture & aSubType) { nsAutoString eventString;
return result; if (NS_SUCCEEDED(aDOMEvent->GetType(eventString))) {
} nsCOMPtr<nsIAtom> atom = do_GetAtom(NS_LITERAL_STRING("on") + eventString);
}
// If we're in the capture phase we must have capture flags set.
else if (aPhaseFlags & NS_EVENT_FLAG_CAPTURE && !aPhaseFlags & NS_EVENT_FLAG_INIT) {
if (!(aListenerStruct->mSubTypeCapture & aSubType)) {
return result;
}
}
if (aListenerStruct->mHandlerIsString & aSubType) {
nsCOMPtr<nsIJSEventListener> jslistener = do_QueryInterface(aListener); result = CompileEventHandlerInternal(jslistener->GetEventContext(),
if (jslistener) { jslistener->GetEventScope(),
nsAutoString eventString; jslistener->GetEventTarget(),
if (NS_SUCCEEDED(aDOMEvent->GetType(eventString))) { atom, aListenerStruct,
nsCOMPtr<nsIAtom> atom = do_GetAtom(NS_LITERAL_STRING("on") + eventString); aCurrentTarget,
aSubType);
result = CompileEventHandlerInternal(jslistener->GetEventContext(),
jslistener->GetEventScope(),
jslistener->GetEventTarget(),
atom, aListenerStruct,
aCurrentTarget,
aSubType);
}
} }
} }
} }
@ -1674,9 +1658,6 @@ nsEventListenerManager::HandleEvent(nsPresContext* aPresContext,
return ret; return ret;
} }
if (aFlags & NS_EVENT_FLAG_INIT) {
aFlags |= (NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_CAPTURE);
}
//Set the value of the internal PreventDefault flag properly based on aEventStatus //Set the value of the internal PreventDefault flag properly based on aEventStatus
if (*aEventStatus == nsEventStatus_eConsumeNoDefault) { if (*aEventStatus == nsEventStatus_eConsumeNoDefault) {
aEvent->flags |= NS_EVENT_FLAG_NO_DEFAULT; aEvent->flags |= NS_EVENT_FLAG_NO_DEFAULT;
@ -1782,151 +1763,6 @@ nsEventListenerManager::CreateEvent(nsPresContext* aPresContext,
aEventType, aDOMEvent); aEventType, aDOMEvent);
} }
/**
* Captures all events designated for descendant objects at the current level.
* @param an event listener
*/
NS_IMETHODIMP
nsEventListenerManager::CaptureEvent(PRInt32 aEventTypes)
{
return FlipCaptureBit(aEventTypes, PR_TRUE);
}
/**
* Releases all events designated for descendant objects at the current level.
* @param an event listener
*/
NS_IMETHODIMP
nsEventListenerManager::ReleaseEvent(PRInt32 aEventTypes)
{
return FlipCaptureBit(aEventTypes, PR_FALSE);
}
nsresult
nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes,
PRBool aInitCapture)
{
// This method exists for Netscape 4.x event handling compatibility.
// New events do not need to be added here.
EventArrayType arrayType = eEventArrayType_None;
PRUint8 bits = 0;
if (aEventTypes & nsIDOMNSEvent::MOUSEDOWN) {
arrayType = eEventArrayType_Mouse;
bits = NS_EVENT_BITS_MOUSE_MOUSEDOWN;
}
if (aEventTypes & nsIDOMNSEvent::MOUSEUP) {
arrayType = eEventArrayType_Mouse;
bits = NS_EVENT_BITS_MOUSE_MOUSEUP;
}
if (aEventTypes & nsIDOMNSEvent::MOUSEOVER) {
arrayType = eEventArrayType_Mouse;
bits = NS_EVENT_BITS_MOUSE_MOUSEOVER;
}
if (aEventTypes & nsIDOMNSEvent::MOUSEOUT) {
arrayType = eEventArrayType_Mouse;
bits = NS_EVENT_BITS_MOUSE_MOUSEOUT;
}
if (aEventTypes & nsIDOMNSEvent::MOUSEMOVE) {
arrayType = eEventArrayType_MouseMotion;
bits = NS_EVENT_BITS_MOUSEMOTION_MOUSEMOVE;
}
if (aEventTypes & nsIDOMNSEvent::CLICK) {
arrayType = eEventArrayType_Mouse;
bits = NS_EVENT_BITS_MOUSE_CLICK;
}
if (aEventTypes & nsIDOMNSEvent::DBLCLICK) {
arrayType = eEventArrayType_Mouse;
bits = NS_EVENT_BITS_MOUSE_DBLCLICK;
}
if (aEventTypes & nsIDOMNSEvent::KEYDOWN) {
arrayType = eEventArrayType_Key;
bits = NS_EVENT_BITS_KEY_KEYDOWN;
}
if (aEventTypes & nsIDOMNSEvent::KEYUP) {
arrayType = eEventArrayType_Key;
bits = NS_EVENT_BITS_KEY_KEYUP;
}
if (aEventTypes & nsIDOMNSEvent::KEYPRESS) {
arrayType = eEventArrayType_Key;
bits = NS_EVENT_BITS_KEY_KEYPRESS;
}
if (aEventTypes & nsIDOMNSEvent::DRAGDROP) {
arrayType = eEventArrayType_Drag;
bits = NS_EVENT_BITS_DRAG_ENTER;
}
/*if (aEventTypes & nsIDOMNSEvent::MOUSEDRAG) {
arrayType = kIDOMMouseListenerarrayType;
bits = NS_EVENT_BITS_MOUSE_MOUSEDOWN;
}*/
if (aEventTypes & nsIDOMNSEvent::FOCUS) {
arrayType = eEventArrayType_Focus;
bits = NS_EVENT_BITS_FOCUS_FOCUS;
}
if (aEventTypes & nsIDOMNSEvent::BLUR) {
arrayType = eEventArrayType_Focus;
bits = NS_EVENT_BITS_FOCUS_BLUR;
}
if (aEventTypes & nsIDOMNSEvent::SELECT) {
arrayType = eEventArrayType_Form;
bits = NS_EVENT_BITS_FORM_SELECT;
}
if (aEventTypes & nsIDOMNSEvent::CHANGE) {
arrayType = eEventArrayType_Form;
bits = NS_EVENT_BITS_FORM_CHANGE;
}
if (aEventTypes & nsIDOMNSEvent::RESET) {
arrayType = eEventArrayType_Form;
bits = NS_EVENT_BITS_FORM_RESET;
}
if (aEventTypes & nsIDOMNSEvent::SUBMIT) {
arrayType = eEventArrayType_Form;
bits = NS_EVENT_BITS_FORM_SUBMIT;
}
if (aEventTypes & nsIDOMNSEvent::LOAD) {
arrayType = eEventArrayType_Load;
bits = NS_EVENT_BITS_LOAD_LOAD;
}
if (aEventTypes & nsIDOMNSEvent::UNLOAD) {
arrayType = eEventArrayType_Load;
bits = NS_EVENT_BITS_LOAD_UNLOAD;
}
if (aEventTypes & nsIDOMNSEvent::ABORT) {
arrayType = eEventArrayType_Load;
bits = NS_EVENT_BITS_LOAD_ABORT;
}
if (aEventTypes & nsIDOMNSEvent::ERROR) {
arrayType = eEventArrayType_Load;
bits = NS_EVENT_BITS_LOAD_ERROR;
}
if (aEventTypes & nsIDOMNSEvent::RESIZE) {
arrayType = eEventArrayType_Paint;
bits = NS_EVENT_BITS_PAINT_RESIZE;
}
if (aEventTypes & nsIDOMNSEvent::SCROLL) {
arrayType = eEventArrayType_Scroll;
bits = NS_EVENT_BITS_PAINT_RESIZE;
}
if (arrayType != eEventArrayType_None) {
nsListenerStruct *ls = FindJSEventListener(arrayType);
if (ls) {
if (aInitCapture)
ls->mSubTypeCapture |= bits;
else
ls->mSubTypeCapture &= ~bits;
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsEventListenerManager::Disconnect() nsEventListenerManager::Disconnect()
{ {

Просмотреть файл

@ -66,7 +66,6 @@ typedef struct {
PRUint16 mGroupFlags; PRUint16 mGroupFlags;
PRUint8 mSubType; PRUint8 mSubType;
PRUint8 mHandlerIsString; PRUint8 mHandlerIsString;
PRUint8 mSubTypeCapture;
} nsListenerStruct; } nsListenerStruct;
//These define the internal type of the EventListenerManager //These define the internal type of the EventListenerManager
@ -154,9 +153,6 @@ public:
nsISupports *aObject, nsISupports *aObject,
nsIAtom* aName, PRBool *aDidCompile); nsIAtom* aName, PRBool *aDidCompile);
NS_IMETHOD CaptureEvent(PRInt32 aEventTypes);
NS_IMETHOD ReleaseEvent(PRInt32 aEventTypes);
NS_IMETHOD HandleEvent(nsPresContext* aPresContext, NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
nsEvent* aEvent, nsEvent* aEvent,
nsIDOMEvent** aDOMEvent, nsIDOMEvent** aDOMEvent,
@ -239,7 +235,6 @@ protected:
nsIDOMEventGroup* aEvtGrp); nsIDOMEventGroup* aEvtGrp);
void ReleaseListeners(nsVoidArray** aListeners); void ReleaseListeners(nsVoidArray** aListeners);
nsresult RemoveAllListeners(); nsresult RemoveAllListeners();
nsresult FlipCaptureBit(PRInt32 aEventTypes, PRBool aInitCapture);
nsVoidArray* GetListenersByType(EventArrayType aType, nsHashKey* aKey, PRBool aCreate); nsVoidArray* GetListenersByType(EventArrayType aType, nsHashKey* aKey, PRBool aCreate);
EventArrayType GetTypeForIID(const nsIID& aIID); EventArrayType GetTypeForIID(const nsIID& aIID);
nsresult FixContextMenuEvent(nsPresContext* aPresContext, nsresult FixContextMenuEvent(nsPresContext* aPresContext,

Просмотреть файл

@ -122,6 +122,7 @@
#include "nsIDocumentViewer.h" #include "nsIDocumentViewer.h"
#include "nsIWyciwygChannel.h" #include "nsIWyciwygChannel.h"
#include "nsIScriptElement.h" #include "nsIScriptElement.h"
#include "nsIScriptError.h"
#include "nsArray.h" #include "nsArray.h"
#include "nsIPrompt.h" #include "nsIPrompt.h"
@ -2933,28 +2934,37 @@ nsHTMLDocument::GetSelection(nsAString& aReturn)
return rv; return rv;
} }
static void
ReportUseOfDeprecatedMethod(nsHTMLDocument* aDoc, const char* aWarning)
{
nsContentUtils::ReportToConsole(nsContentUtils::eDOM_PROPERTIES,
aWarning,
nsnull, 0,
NS_STATIC_CAST(nsIDocument*, aDoc)->
GetDocumentURI(),
EmptyString(), 0, 0,
nsIScriptError::warningFlag,
"HTML Document");
}
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLDocument::CaptureEvents(PRInt32 aEventFlags) nsHTMLDocument::CaptureEvents(PRInt32 aEventFlags)
{ {
nsCOMPtr<nsIEventListenerManager> manager; ReportUseOfDeprecatedMethod(this, "UseOfCaptureEventsWarning");
nsresult rv = GetListenerManager(PR_TRUE, getter_AddRefs(manager)); return NS_OK;
NS_ENSURE_SUCCESS(rv, rv);
return manager->CaptureEvent(aEventFlags);
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLDocument::ReleaseEvents(PRInt32 aEventFlags) nsHTMLDocument::ReleaseEvents(PRInt32 aEventFlags)
{ {
nsCOMPtr<nsIEventListenerManager> manager; ReportUseOfDeprecatedMethod(this, "UseOfReleaseEventsWarning");
nsresult rv = GetListenerManager(PR_FALSE, getter_AddRefs(manager)); return NS_OK;
NS_ENSURE_SUCCESS(rv, rv);
return manager ? manager->ReleaseEvent(aEventFlags) : NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLDocument::RouteEvent(nsIDOMEvent* aEvt) nsHTMLDocument::RouteEvent(nsIDOMEvent* aEvt)
{ {
//XXX Not the best solution -joki ReportUseOfDeprecatedMethod(this, "UseOfRouteEventWarning");
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -9,3 +9,8 @@ OnBeforeUnloadPreMessage=Are you sure you want to navigate away from this page?
OnBeforeUnloadPostMessage=Press OK to continue, or Cancel to stay on the current page. OnBeforeUnloadPostMessage=Press OK to continue, or Cancel to stay on the current page.
DocumentAllUsed=Non-standard document.all property was used. Use W3C standard document.getElementById() instead. DocumentAllUsed=Non-standard document.all property was used. Use W3C standard document.getElementById() instead.
GlobalScopeElementReference=Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead. GlobalScopeElementReference=Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead.
UseOfCaptureEventsWarning=Use of captureEvents() is deprecated, see bug 330494.
UseOfReleaseEventsWarning=Use of releaseEvents() is deprecated, see bug 330494.
UseOfRouteEventWarning=Use of routeEvent() is deprecated, see bug 330494.
UseOfPreventBubbleWarning=Event=%S, use of preventBubble() is deprecated. Use W3C standard stopPropagation() instead.
UseOfPreventCaptureWarning=Event=%S, use of preventCapture() is deprecated. Use W3C standard stopPropagation() instead.

Просмотреть файл

@ -60,11 +60,16 @@ interface nsIDOMJSWindow : nsISupports
void clearTimeout(); void clearTimeout();
void clearInterval(); void clearInterval();
// This method is here for backwards compatibility with 4.x only, /**
// it's implementation is a no-op * This method is here for backwards compatibility with 4.x only,
* its implementation is a no-op
*/
void setResizable(in boolean resizable); void setResizable(in boolean resizable);
// These are 4.x event related methods. /**
* @deprecated These are old Netscape 4 methods. Do not use,
* the implementation is no-op.
*/
void captureEvents(in long eventFlags); void captureEvents(in long eventFlags);
void releaseEvents(in long eventFlags); void releaseEvents(in long eventFlags);
void routeEvent(in nsIDOMEvent evt); void routeEvent(in nsIDOMEvent evt);

Просмотреть файл

@ -104,7 +104,14 @@ interface nsIDOMNSEvent : nsISupports
*/ */
[noscript] readonly attribute nsIDOMEventTarget tmpRealOriginalTarget; [noscript] readonly attribute nsIDOMEventTarget tmpRealOriginalTarget;
/**
* @deprecated Use nsIDOMEvent::stopPropagation.
*/
void preventBubble(); void preventBubble();
/**
* @deprecated Use nsIDOMEvent::stopPropagation.
*/
void preventCapture(); void preventCapture();
readonly attribute boolean isTrusted; readonly attribute boolean isTrusted;

Просмотреть файл

@ -70,6 +70,10 @@ interface nsIDOMNSHTMLDocument : nsISupports
void writeln(); void writeln();
void clear(); void clear();
/**
* @deprecated These are old Netscape 4 methods. Do not use,
* the implementation is no-op.
*/
void captureEvents(in long eventFlags); void captureEvents(in long eventFlags);
void releaseEvents(in long eventFlags); void releaseEvents(in long eventFlags);
void routeEvent(in nsIDOMEvent evt); void routeEvent(in nsIDOMEvent evt);

Просмотреть файл

@ -3814,28 +3814,37 @@ nsGlobalWindow::SetResizable(PRBool aResizable)
return NS_OK; return NS_OK;
} }
static void
ReportUseOfDeprecatedMethod(nsGlobalWindow* aWindow, const char* aWarning)
{
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aWindow->GetExtantDocument());
nsContentUtils::ReportToConsole(nsContentUtils::eDOM_PROPERTIES,
aWarning,
nsnull, 0,
doc ? doc->GetDocumentURI() : nsnull,
EmptyString(), 0, 0,
nsIScriptError::warningFlag,
"DOM Window");
}
NS_IMETHODIMP NS_IMETHODIMP
nsGlobalWindow::CaptureEvents(PRInt32 aEventFlags) nsGlobalWindow::CaptureEvents(PRInt32 aEventFlags)
{ {
nsCOMPtr<nsIEventListenerManager> manager; ReportUseOfDeprecatedMethod(this, "UseOfCaptureEventsWarning");
nsresult rv = GetListenerManager(PR_TRUE, getter_AddRefs(manager)); return NS_OK;
NS_ENSURE_SUCCESS(rv, rv);
return manager->CaptureEvent(aEventFlags);
} }
NS_IMETHODIMP NS_IMETHODIMP
nsGlobalWindow::ReleaseEvents(PRInt32 aEventFlags) nsGlobalWindow::ReleaseEvents(PRInt32 aEventFlags)
{ {
nsCOMPtr<nsIEventListenerManager> manager; ReportUseOfDeprecatedMethod(this, "UseOfReleaseEventsWarning");
nsresult rv = GetListenerManager(PR_FALSE, getter_AddRefs(manager)); return NS_OK;
NS_ENSURE_SUCCESS(rv, rv);
return manager ? manager->ReleaseEvent(aEventFlags) : NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsGlobalWindow::RouteEvent(nsIDOMEvent* aEvt) nsGlobalWindow::RouteEvent(nsIDOMEvent* aEvt)
{ {
//XXX Not the best solution -joki ReportUseOfDeprecatedMethod(this, "UseOfRouteEventWarning");
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -6074,7 +6074,7 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView,
if (!NS_EVENT_NEEDS_FRAME(aEvent) || GetCurrentEventFrame()) { if (!NS_EVENT_NEEDS_FRAME(aEvent) || GetCurrentEventFrame()) {
PRBool isHandlingUserInput = PR_FALSE; PRBool isHandlingUserInput = PR_FALSE;
if (aEvent->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED) { if (NS_IS_TRUSTED_EVENT(aEvent)) {
switch (aEvent->message) { switch (aEvent->message) {
case NS_GOTFOCUS: case NS_GOTFOCUS:
case NS_LOSTFOCUS: case NS_LOSTFOCUS:

Просмотреть файл

@ -104,7 +104,7 @@ class nsIDOMEventTarget;
// listener flags and event flags, but only some of them. You've been // listener flags and event flags, but only some of them. You've been
// warned! // warned!
#define NS_EVENT_FLAG_NONE 0x0000 #define NS_EVENT_FLAG_NONE 0x0000
#define NS_EVENT_FLAG_INIT 0x0001 #define NS_EVENT_FLAG_TRUSTED 0x0001
#define NS_EVENT_FLAG_BUBBLE 0x0002 #define NS_EVENT_FLAG_BUBBLE 0x0002
#define NS_EVENT_FLAG_CAPTURE 0x0004 #define NS_EVENT_FLAG_CAPTURE 0x0004
#define NS_EVENT_FLAG_STOP_DISPATCH 0x0008 #define NS_EVENT_FLAG_STOP_DISPATCH 0x0008
@ -119,15 +119,8 @@ class nsIDOMEventTarget;
#define NS_PRIV_EVENT_UNTRUSTED_PERMITTED 0x8000 #define NS_PRIV_EVENT_UNTRUSTED_PERMITTED 0x8000
#define NS_EVENT_CAPTURE_MASK (~(NS_EVENT_FLAG_INIT | NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_NO_CONTENT_DISPATCH)) #define NS_EVENT_CAPTURE_MASK (~(NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_NO_CONTENT_DISPATCH))
#define NS_EVENT_BUBBLE_MASK (~(NS_EVENT_FLAG_INIT | NS_EVENT_FLAG_CAPTURE | NS_EVENT_FLAG_NO_CONTENT_DISPATCH)) #define NS_EVENT_BUBBLE_MASK (~(NS_EVENT_FLAG_CAPTURE | NS_EVENT_FLAG_NO_CONTENT_DISPATCH))
// Flags for internalAppFlags
#define NS_APP_EVENT_FLAG_NONE 0x00000000
// True if the event came from a trusted source
#define NS_APP_EVENT_FLAG_TRUSTED 0x00000001
#define NS_EVENT_TYPE_NULL 0 #define NS_EVENT_TYPE_NULL 0
@ -387,9 +380,7 @@ protected:
message(msg), message(msg),
refPoint(0, 0), refPoint(0, 0),
time(0), time(0),
flags(0), flags(isTrusted ? NS_EVENT_FLAG_TRUSTED : NS_EVENT_FLAG_NONE),
internalAppFlags(isTrusted ? NS_APP_EVENT_FLAG_TRUSTED :
NS_APP_EVENT_FLAG_NONE),
userType(0) userType(0)
{ {
} }
@ -400,9 +391,7 @@ public:
message(msg), message(msg),
refPoint(0, 0), refPoint(0, 0),
time(0), time(0),
flags(0), flags(isTrusted ? NS_EVENT_FLAG_TRUSTED : NS_EVENT_FLAG_NONE),
internalAppFlags(isTrusted ? NS_APP_EVENT_FLAG_TRUSTED :
NS_APP_EVENT_FLAG_NONE),
userType(0) userType(0)
{ {
} }
@ -410,17 +399,15 @@ public:
// See event struct types // See event struct types
PRUint8 eventStructType; PRUint8 eventStructType;
// See GUI MESSAGES, // See GUI MESSAGES,
PRUint32 message; PRUint32 message;
// In widget relative coordinates, not modified by layout code. // In widget relative coordinates, not modified by layout code.
nsPoint refPoint; nsPoint refPoint;
// Elapsed time, in milliseconds, from the time the system was // Elapsed time, in milliseconds, from the time the system was
// started to the time the message was created // started to the time the message was created
PRUint32 time; PRUint32 time;
// Flags to hold event flow stage and capture/bubble cancellation // Flags to hold event flow stage and capture/bubble cancellation
// status // status. This is used also to indicate whether the event is trusted.
PRUint32 flags; PRUint32 flags;
// Flags for indicating more event state for Mozilla applications.
PRUint32 internalAppFlags;
// Additional type info for user defined events // Additional type info for user defined events
nsHashKey* userType; nsHashKey* userType;
// Event targets, needed by DOM Events // Event targets, needed by DOM Events
@ -992,7 +979,7 @@ enum nsDragDropEventStatus {
((evnt)->message == NS_PLUGIN_ACTIVATE)) ((evnt)->message == NS_PLUGIN_ACTIVATE))
#define NS_IS_TRUSTED_EVENT(event) \ #define NS_IS_TRUSTED_EVENT(event) \
(((event)->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED) != 0) (((event)->flags & NS_EVENT_FLAG_TRUSTED) != 0)
// Mark an event as being dispatching. // Mark an event as being dispatching.
#define NS_MARK_EVENT_DISPATCH_STARTED(event) \ #define NS_MARK_EVENT_DISPATCH_STARTED(event) \