2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-17 21:52:36 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-06-07 07:55:55 +00:00
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-06-07 07:55:55 +00:00
|
|
|
*
|
2001-09-25 01:32:19 +00:00
|
|
|
* 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.
|
1998-06-07 07:55:55 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 01:32:19 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-25 01:32:19 +00:00
|
|
|
* Contributor(s):
|
2004-04-17 21:52:36 +00:00
|
|
|
* Steve Clark (buster@netscape.com)
|
2004-08-20 18:09:19 +00:00
|
|
|
* Ilya Konstantinov (mozilla-code@future.shiny.co.il)
|
2001-09-25 01:32:19 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-17 21:52:36 +00:00
|
|
|
* either of 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"),
|
2001-09-25 01:32:19 +00:00
|
|
|
* 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
|
2004-04-17 21:52:36 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 01:32:19 +00:00
|
|
|
* 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
|
2004-04-17 21:52:36 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 01:32:19 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-06-07 07:55:55 +00:00
|
|
|
|
2000-05-05 14:47:37 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1998-06-07 07:55:55 +00:00
|
|
|
#include "nsDOMEvent.h"
|
2004-09-04 19:28:46 +00:00
|
|
|
#include "nsEventStateManager.h"
|
1998-11-18 05:25:26 +00:00
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsIContent.h"
|
1999-06-16 04:39:51 +00:00
|
|
|
#include "nsIPresShell.h"
|
1999-07-27 20:55:03 +00:00
|
|
|
#include "nsIDocument.h"
|
1999-08-31 01:20:32 +00:00
|
|
|
#include "nsIPrivateCompositionEvent.h"
|
2000-05-16 11:35:12 +00:00
|
|
|
#include "nsIDOMEventTarget.h"
|
|
|
|
#include "nsIInterfaceRequestor.h"
|
2001-09-05 21:28:38 +00:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2000-05-16 11:35:12 +00:00
|
|
|
#include "prmem.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2000-11-27 07:55:20 +00:00
|
|
|
#include "nsMutationEvent.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
#include "nsContentUtils.h"
|
2003-04-16 00:00:50 +00:00
|
|
|
#include "nsIURI.h"
|
2005-06-22 01:53:58 +00:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2006-04-10 17:04:54 +00:00
|
|
|
#include "nsIScriptError.h"
|
1998-07-17 04:52:12 +00:00
|
|
|
|
2004-02-11 06:09:51 +00:00
|
|
|
static const char* const sEventNames[] = {
|
1999-04-12 21:17:07 +00:00
|
|
|
"mousedown", "mouseup", "click", "dblclick", "mouseover",
|
2001-03-23 03:34:15 +00:00
|
|
|
"mouseout", "mousemove", "contextmenu", "keydown", "keyup", "keypress",
|
2004-02-11 06:09:51 +00:00
|
|
|
"focus", "blur", "load", "beforeunload", "unload", "abort", "error",
|
2005-06-15 23:52:46 +00:00
|
|
|
"submit", "reset", "change", "select", "input", "paint" ,"text",
|
|
|
|
"compositionstart", "compositionend", "popupshowing", "popupshown",
|
2005-03-05 08:19:05 +00:00
|
|
|
"popuphiding", "popuphidden", "close", "command", "broadcast", "commandupdate",
|
2007-04-12 04:37:39 +00:00
|
|
|
"dragenter", "dragover", "dragexit", "dragdrop", "draggesture",
|
|
|
|
"drag", "dragend", "dragstart", "dragleave", "drop", "resize",
|
|
|
|
"scroll", "overflow", "underflow", "overflowchanged",
|
2000-11-27 07:55:20 +00:00
|
|
|
"DOMSubtreeModified", "DOMNodeInserted", "DOMNodeRemoved",
|
|
|
|
"DOMNodeRemovedFromDocument", "DOMNodeInsertedIntoDocument",
|
2003-04-16 00:00:50 +00:00
|
|
|
"DOMAttrModified", "DOMCharacterDataModified",
|
2005-08-28 16:45:39 +00:00
|
|
|
"DOMActivate", "DOMFocusIn", "DOMFocusOut",
|
2007-06-07 03:28:04 +00:00
|
|
|
"pageshow", "pagehide", "DOMMouseScroll", "offline", "online"
|
2005-08-25 21:31:09 +00:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
,
|
|
|
|
"SVGLoad", "SVGUnload", "SVGAbort", "SVGError", "SVGResize", "SVGScroll",
|
|
|
|
"SVGZoom"
|
|
|
|
#endif // MOZ_SVG
|
|
|
|
};
|
1998-07-17 04:52:12 +00:00
|
|
|
|
2004-09-04 19:28:46 +00:00
|
|
|
static char *sPopupAllowedEvents;
|
|
|
|
|
|
|
|
|
2004-08-20 18:09:19 +00:00
|
|
|
nsDOMEvent::nsDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent)
|
2001-02-12 06:54:31 +00:00
|
|
|
{
|
1998-07-23 02:55:33 +00:00
|
|
|
mPresContext = aPresContext;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
|
2000-05-16 11:35:12 +00:00
|
|
|
if (aEvent) {
|
|
|
|
mEvent = aEvent;
|
2004-08-20 18:09:19 +00:00
|
|
|
mEventIsInternal = PR_FALSE;
|
2000-05-16 11:35:12 +00:00
|
|
|
}
|
|
|
|
else {
|
2001-09-22 00:25:16 +00:00
|
|
|
mEventIsInternal = PR_TRUE;
|
2004-08-20 18:09:19 +00:00
|
|
|
/*
|
|
|
|
A derived class might want to allocate its own type of aEvent
|
|
|
|
(derived from nsEvent). To do this, it should take care to pass
|
|
|
|
a non-NULL aEvent to this ctor, e.g.:
|
|
|
|
|
|
|
|
nsDOMFooEvent::nsDOMFooEvent(..., nsEvent* aEvent)
|
|
|
|
: nsDOMEvent(..., aEvent ? aEvent : new nsFooEvent())
|
|
|
|
|
2004-09-04 19:28:46 +00:00
|
|
|
Then, to override the mEventIsInternal assignments done by the
|
|
|
|
base ctor, it should do this in its own ctor:
|
2004-08-20 18:09:19 +00:00
|
|
|
|
|
|
|
nsDOMFooEvent::nsDOMFooEvent(..., nsEvent* aEvent)
|
|
|
|
...
|
|
|
|
{
|
|
|
|
...
|
|
|
|
if (aEvent) {
|
|
|
|
mEventIsInternal = PR_FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mEventIsInternal = PR_TRUE;
|
|
|
|
}
|
|
|
|
...
|
|
|
|
}
|
|
|
|
*/
|
2005-04-28 23:48:28 +00:00
|
|
|
mEvent = new nsEvent(PR_FALSE, 0);
|
2004-08-20 18:09:19 +00:00
|
|
|
mEvent->time = PR_Now();
|
2000-05-16 11:35:12 +00:00
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
|
2003-02-22 08:10:46 +00:00
|
|
|
// Get the explicit original target (if it's anonymous make it null)
|
|
|
|
{
|
2003-03-04 01:51:16 +00:00
|
|
|
mExplicitOriginalTarget = GetTargetFromFrame();
|
2003-05-21 00:42:32 +00:00
|
|
|
mTmpRealOriginalTarget = mExplicitOriginalTarget;
|
2003-02-22 08:10:46 +00:00
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(mExplicitOriginalTarget);
|
|
|
|
if (content) {
|
2006-03-07 17:08:51 +00:00
|
|
|
if (content->IsNativeAnonymous() || content->GetBindingParent()) {
|
2003-02-22 08:10:46 +00:00
|
|
|
mExplicitOriginalTarget = nsnull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-06-07 07:55:55 +00:00
|
|
|
}
|
|
|
|
|
2001-02-12 06:54:31 +00:00
|
|
|
nsDOMEvent::~nsDOMEvent()
|
|
|
|
{
|
|
|
|
NS_ASSERT_OWNINGTHREAD(nsDOMEvent);
|
|
|
|
|
2006-06-05 18:38:54 +00:00
|
|
|
if (mEventIsInternal && mEvent) {
|
2004-01-12 08:25:18 +00:00
|
|
|
delete mEvent;
|
2000-05-16 11:35:12 +00:00
|
|
|
}
|
1998-06-07 07:55:55 +00:00
|
|
|
}
|
|
|
|
|
2007-06-26 08:21:42 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMEvent)
|
1998-06-07 07:55:55 +00:00
|
|
|
|
2007-06-26 08:21:42 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMEvent)
|
2004-08-20 18:09:19 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMEvent)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMEvent)
|
2001-12-06 06:57:03 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMNSEvent)
|
1999-12-21 19:28:15 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIPrivateDOMEvent)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(Event)
|
1999-12-21 19:28:15 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
1998-06-07 07:55:55 +00:00
|
|
|
|
2007-06-26 08:21:42 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMEvent)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMEvent)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMEvent)
|
|
|
|
if (tmp->mEventIsInternal) {
|
|
|
|
tmp->mEvent->target = nsnull;
|
|
|
|
tmp->mEvent->currentTarget = nsnull;
|
|
|
|
tmp->mEvent->originalTarget = nsnull;
|
|
|
|
switch (tmp->mEvent->eventStructType) {
|
|
|
|
case NS_MOUSE_EVENT:
|
|
|
|
case NS_MOUSE_SCROLL_EVENT:
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsMouseEvent_base*>(tmp->mEvent)->relatedTarget = nsnull;
|
2007-06-26 08:21:42 +00:00
|
|
|
break;
|
|
|
|
case NS_XUL_COMMAND_EVENT:
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsXULCommandEvent*>(tmp->mEvent)->sourceEvent = nsnull;
|
2007-06-26 08:21:42 +00:00
|
|
|
break;
|
|
|
|
case NS_MUTATION_EVENT:
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsMutationEvent*>(tmp->mEvent)->mRelatedNode = nsnull;
|
2007-06-26 08:21:42 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mPresContext);
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mTmpRealOriginalTarget)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mExplicitOriginalTarget)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMEvent)
|
|
|
|
if (tmp->mEventIsInternal) {
|
|
|
|
cb.NoteXPCOMChild(tmp->mEvent->target);
|
|
|
|
cb.NoteXPCOMChild(tmp->mEvent->currentTarget);
|
|
|
|
cb.NoteXPCOMChild(tmp->mEvent->originalTarget);
|
|
|
|
switch (tmp->mEvent->eventStructType) {
|
|
|
|
case NS_MOUSE_EVENT:
|
|
|
|
case NS_MOUSE_SCROLL_EVENT:
|
|
|
|
cb.NoteXPCOMChild(
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsMouseEvent_base*>(tmp->mEvent)->relatedTarget);
|
2007-06-26 08:21:42 +00:00
|
|
|
break;
|
|
|
|
case NS_XUL_COMMAND_EVENT:
|
|
|
|
cb.NoteXPCOMChild(
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsXULCommandEvent*>(tmp->mEvent)->sourceEvent);
|
2007-06-26 08:21:42 +00:00
|
|
|
break;
|
|
|
|
case NS_MUTATION_EVENT:
|
|
|
|
cb.NoteXPCOMChild(
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsMutationEvent*>(tmp->mEvent)->mRelatedNode);
|
2007-06-26 08:21:42 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mPresContext)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTmpRealOriginalTarget)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mExplicitOriginalTarget)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
1998-06-07 07:55:55 +00:00
|
|
|
// nsIDOMEventInterface
|
2002-03-23 23:13:20 +00:00
|
|
|
NS_METHOD nsDOMEvent::GetType(nsAString& aType)
|
1998-07-17 04:52:12 +00:00
|
|
|
{
|
2003-12-23 15:41:10 +00:00
|
|
|
const char* name = GetEventName(mEvent->message);
|
1998-07-17 04:52:12 +00:00
|
|
|
|
2003-12-23 15:41:10 +00:00
|
|
|
if (name) {
|
|
|
|
CopyASCIItoUTF16(name, aType);
|
1998-07-17 04:52:12 +00:00
|
|
|
return NS_OK;
|
2006-10-06 05:24:02 +00:00
|
|
|
} else if (mEvent->message == NS_USER_DEFINED_EVENT && mEvent->userType) {
|
|
|
|
nsAutoString name;
|
|
|
|
mEvent->userType->ToString(name);
|
|
|
|
aType = Substring(name, 2, name.Length() - 2); // Remove "on"
|
|
|
|
return NS_OK;
|
2001-04-17 05:52:11 +00:00
|
|
|
}
|
1998-07-17 04:52:12 +00:00
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2007-04-17 09:18:36 +00:00
|
|
|
static nsresult
|
|
|
|
GetDOMEventTarget(nsISupports* aTarget,
|
|
|
|
nsIDOMEventTarget** aDOMTarget)
|
1998-06-07 07:55:55 +00:00
|
|
|
{
|
2007-04-17 09:18:36 +00:00
|
|
|
nsCOMPtr<nsPIDOMEventTarget> piTarget = do_QueryInterface(aTarget);
|
|
|
|
nsISupports* realTarget =
|
|
|
|
piTarget ? piTarget->GetTargetForDOMEvent() : aTarget;
|
|
|
|
if (realTarget) {
|
|
|
|
return CallQueryInterface(realTarget, aDOMTarget);
|
1998-11-18 05:25:26 +00:00
|
|
|
}
|
2007-04-17 09:18:36 +00:00
|
|
|
|
|
|
|
*aDOMTarget = nsnull;
|
1998-11-18 05:25:26 +00:00
|
|
|
return NS_OK;
|
1998-06-07 07:55:55 +00:00
|
|
|
}
|
|
|
|
|
2007-04-17 09:18:36 +00:00
|
|
|
NS_METHOD
|
|
|
|
nsDOMEvent::GetTarget(nsIDOMEventTarget** aTarget)
|
|
|
|
{
|
|
|
|
return GetDOMEventTarget(mEvent->target, aTarget);
|
|
|
|
}
|
|
|
|
|
1999-05-18 23:51:04 +00:00
|
|
|
NS_IMETHODIMP
|
2000-05-16 11:35:12 +00:00
|
|
|
nsDOMEvent::GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget)
|
1998-07-17 04:52:12 +00:00
|
|
|
{
|
2007-04-17 09:18:36 +00:00
|
|
|
return GetDOMEventTarget(mEvent->currentTarget, aCurrentTarget);
|
1998-07-17 04:52:12 +00:00
|
|
|
}
|
|
|
|
|
2003-02-22 08:10:46 +00:00
|
|
|
//
|
|
|
|
// Get the actual event target node (may have been retargeted for mouse events)
|
|
|
|
//
|
2003-03-04 01:51:16 +00:00
|
|
|
already_AddRefed<nsIDOMEventTarget>
|
|
|
|
nsDOMEvent::GetTargetFromFrame()
|
2003-02-22 08:10:46 +00:00
|
|
|
{
|
2003-03-04 01:51:16 +00:00
|
|
|
if (!mPresContext) { return nsnull; }
|
2003-02-22 08:10:46 +00:00
|
|
|
|
|
|
|
// Get the target frame (have to get the ESM first)
|
|
|
|
nsIFrame* targetFrame = nsnull;
|
2004-02-27 17:17:37 +00:00
|
|
|
mPresContext->EventStateManager()->GetEventTarget(&targetFrame);
|
2003-03-04 01:51:16 +00:00
|
|
|
if (!targetFrame) { return nsnull; }
|
2003-02-22 08:10:46 +00:00
|
|
|
|
|
|
|
// get the real content
|
|
|
|
nsCOMPtr<nsIContent> realEventContent;
|
|
|
|
targetFrame->GetContentForEvent(mPresContext, mEvent, getter_AddRefs(realEventContent));
|
2003-03-04 01:51:16 +00:00
|
|
|
if (!realEventContent) { return nsnull; }
|
2003-02-22 08:10:46 +00:00
|
|
|
|
|
|
|
// Finally, we have the real content. QI it and return.
|
2003-03-04 01:51:16 +00:00
|
|
|
nsIDOMEventTarget* target = nsnull;
|
|
|
|
CallQueryInterface(realEventContent, &target);
|
|
|
|
return target;
|
2003-02-22 08:10:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMEvent::GetExplicitOriginalTarget(nsIDOMEventTarget** aRealEventTarget)
|
|
|
|
{
|
|
|
|
if (mExplicitOriginalTarget) {
|
|
|
|
*aRealEventTarget = mExplicitOriginalTarget;
|
|
|
|
NS_ADDREF(*aRealEventTarget);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GetTarget(aRealEventTarget);
|
|
|
|
}
|
|
|
|
|
2003-05-21 00:42:32 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMEvent::GetTmpRealOriginalTarget(nsIDOMEventTarget** aRealEventTarget)
|
|
|
|
{
|
|
|
|
if (mTmpRealOriginalTarget) {
|
|
|
|
*aRealEventTarget = mTmpRealOriginalTarget;
|
|
|
|
NS_ADDREF(*aRealEventTarget);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GetOriginalTarget(aRealEventTarget);
|
|
|
|
}
|
|
|
|
|
2000-09-07 01:07:29 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMEvent::GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget)
|
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
if (mEvent->originalTarget) {
|
2007-04-17 09:18:36 +00:00
|
|
|
return GetDOMEventTarget(mEvent->originalTarget, aOriginalTarget);
|
2006-03-07 17:08:51 +00:00
|
|
|
}
|
2000-09-07 09:20:56 +00:00
|
|
|
|
2006-03-07 17:08:51 +00:00
|
|
|
return GetTarget(aOriginalTarget);
|
2000-09-07 01:07:29 +00:00
|
|
|
}
|
|
|
|
|
2000-09-07 09:20:56 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMEvent::HasOriginalTarget(PRBool* aResult)
|
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
*aResult = !!(mEvent->originalTarget);
|
2000-09-07 09:20:56 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-11-20 08:40:54 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMEvent::SetTrusted(PRBool aTrusted)
|
|
|
|
{
|
2004-09-04 19:28:46 +00:00
|
|
|
if (aTrusted) {
|
2006-04-10 17:04:54 +00:00
|
|
|
mEvent->flags |= NS_EVENT_FLAG_TRUSTED;
|
2004-09-04 19:28:46 +00:00
|
|
|
} else {
|
2006-04-10 17:04:54 +00:00
|
|
|
mEvent->flags &= ~NS_EVENT_FLAG_TRUSTED;
|
2004-09-04 19:28:46 +00:00
|
|
|
}
|
|
|
|
|
2001-11-20 08:40:54 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-18 23:51:04 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMEvent::GetEventPhase(PRUint16* aEventPhase)
|
1998-07-17 04:52:12 +00:00
|
|
|
{
|
2006-06-22 07:51:57 +00:00
|
|
|
// Note, remember to check that this works also
|
|
|
|
// if or when Bug 235441 is fixed.
|
|
|
|
if (mEvent->currentTarget == mEvent->target ||
|
|
|
|
((mEvent->flags & NS_EVENT_FLAG_CAPTURE) &&
|
|
|
|
(mEvent->flags & NS_EVENT_FLAG_BUBBLE))) {
|
2006-06-15 17:45:22 +00:00
|
|
|
*aEventPhase = nsIDOMEvent::AT_TARGET;
|
|
|
|
} else if (mEvent->flags & NS_EVENT_FLAG_CAPTURE) {
|
|
|
|
*aEventPhase = nsIDOMEvent::CAPTURING_PHASE;
|
|
|
|
} else if (mEvent->flags & NS_EVENT_FLAG_BUBBLE) {
|
2004-08-20 18:09:19 +00:00
|
|
|
*aEventPhase = nsIDOMEvent::BUBBLING_PHASE;
|
2006-06-15 17:45:22 +00:00
|
|
|
} else {
|
1999-07-19 19:54:34 +00:00
|
|
|
*aEventPhase = 0;
|
|
|
|
}
|
1999-05-18 23:51:04 +00:00
|
|
|
return NS_OK;
|
1998-07-17 04:52:12 +00:00
|
|
|
}
|
|
|
|
|
1999-11-03 07:11:45 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMEvent::GetBubbles(PRBool* aBubbles)
|
|
|
|
{
|
2000-09-19 21:47:04 +00:00
|
|
|
*aBubbles = !(mEvent->flags & NS_EVENT_FLAG_CANT_BUBBLE);
|
2000-05-16 11:35:12 +00:00
|
|
|
return NS_OK;
|
1999-11-03 07:11:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMEvent::GetCancelable(PRBool* aCancelable)
|
|
|
|
{
|
2000-09-19 21:47:04 +00:00
|
|
|
*aCancelable = !(mEvent->flags & NS_EVENT_FLAG_CANT_CANCEL);
|
2000-05-16 11:35:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMEvent::GetTimeStamp(PRUint64* aTimeStamp)
|
|
|
|
{
|
2000-05-17 00:40:22 +00:00
|
|
|
LL_UI2L(*aTimeStamp, mEvent->time);
|
2000-05-16 11:35:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMEvent::StopPropagation()
|
|
|
|
{
|
|
|
|
mEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH;
|
|
|
|
return NS_OK;
|
1999-11-03 07:11:45 +00:00
|
|
|
}
|
|
|
|
|
2006-04-10 17:04:54 +00:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
1999-05-18 23:51:04 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMEvent::PreventBubble()
|
1998-06-07 07:55:55 +00:00
|
|
|
{
|
2006-04-10 17:04:54 +00:00
|
|
|
ReportUseOfDeprecatedMethod(mEvent, this, "UseOfPreventBubbleWarning");
|
1999-05-18 23:51:04 +00:00
|
|
|
return NS_OK;
|
1998-06-07 07:55:55 +00:00
|
|
|
}
|
|
|
|
|
1999-05-18 23:51:04 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMEvent::PreventCapture()
|
1998-06-07 07:55:55 +00:00
|
|
|
{
|
2006-04-10 17:04:54 +00:00
|
|
|
ReportUseOfDeprecatedMethod(mEvent, this, "UseOfPreventCaptureWarning");
|
1999-05-18 23:51:04 +00:00
|
|
|
return NS_OK;
|
1998-06-07 07:55:55 +00:00
|
|
|
}
|
|
|
|
|
2004-09-02 15:25:39 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMEvent::GetIsTrusted(PRBool *aIsTrusted)
|
|
|
|
{
|
2005-04-28 23:48:28 +00:00
|
|
|
*aIsTrusted = NS_IS_TRUSTED_EVENT(mEvent);
|
2004-09-02 15:25:39 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-18 23:51:04 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMEvent::PreventDefault()
|
1998-06-07 07:55:55 +00:00
|
|
|
{
|
2000-05-16 11:35:12 +00:00
|
|
|
if (!(mEvent->flags & NS_EVENT_FLAG_CANT_CANCEL)) {
|
|
|
|
mEvent->flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
|
|
|
}
|
1999-05-18 23:51:04 +00:00
|
|
|
return NS_OK;
|
1998-07-17 04:52:12 +00:00
|
|
|
}
|
|
|
|
|
2000-05-16 11:35:12 +00:00
|
|
|
nsresult
|
2002-03-23 23:13:20 +00:00
|
|
|
nsDOMEvent::SetEventType(const nsAString& aEventTypeArg)
|
2000-05-16 11:35:12 +00:00
|
|
|
{
|
2005-06-22 01:53:58 +00:00
|
|
|
nsCOMPtr<nsIAtom> atom = do_GetAtom(NS_LITERAL_STRING("on") + aEventTypeArg);
|
2004-01-14 01:33:47 +00:00
|
|
|
mEvent->message = NS_USER_DEFINED_EVENT;
|
2000-05-16 11:35:12 +00:00
|
|
|
|
2004-01-12 08:25:18 +00:00
|
|
|
if (mEvent->eventStructType == NS_MOUSE_EVENT) {
|
2006-12-26 17:47:52 +00:00
|
|
|
if (atom == nsGkAtoms::onmousedown)
|
2006-11-16 21:35:39 +00:00
|
|
|
mEvent->message = NS_MOUSE_BUTTON_DOWN;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onmouseup)
|
2006-11-16 21:35:39 +00:00
|
|
|
mEvent->message = NS_MOUSE_BUTTON_UP;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onclick)
|
2006-11-16 21:35:39 +00:00
|
|
|
mEvent->message = NS_MOUSE_CLICK;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::ondblclick)
|
2006-11-16 21:35:39 +00:00
|
|
|
mEvent->message = NS_MOUSE_DOUBLECLICK;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onmouseover)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_MOUSE_ENTER_SYNTH;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onmouseout)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_MOUSE_EXIT_SYNTH;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onmousemove)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_MOUSE_MOVE;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::oncontextmenu)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_CONTEXTMENU;
|
2007-02-20 14:57:52 +00:00
|
|
|
} else if (mEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) {
|
|
|
|
if (atom == nsGkAtoms::onDOMMouseScroll)
|
|
|
|
mEvent->message = NS_MOUSE_SCROLL;
|
2004-01-12 08:25:18 +00:00
|
|
|
} else if (mEvent->eventStructType == NS_KEY_EVENT) {
|
2006-12-26 17:47:52 +00:00
|
|
|
if (atom == nsGkAtoms::onkeydown)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_KEY_DOWN;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onkeyup)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_KEY_UP;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onkeypress)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_KEY_PRESS;
|
2005-03-05 08:19:05 +00:00
|
|
|
} else if (mEvent->eventStructType == NS_COMPOSITION_EVENT) {
|
2006-12-26 17:47:52 +00:00
|
|
|
if (atom == nsGkAtoms::oncompositionstart)
|
2005-03-05 08:19:05 +00:00
|
|
|
mEvent->message = NS_COMPOSITION_START;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::oncompositionend)
|
2005-03-05 08:19:05 +00:00
|
|
|
mEvent->message = NS_COMPOSITION_END;
|
2004-01-12 08:25:18 +00:00
|
|
|
} else if (mEvent->eventStructType == NS_EVENT) {
|
2006-12-26 17:47:52 +00:00
|
|
|
if (atom == nsGkAtoms::onfocus)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_FOCUS_CONTENT;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onblur)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_BLUR_CONTENT;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onsubmit)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_FORM_SUBMIT;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onreset)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_FORM_RESET;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onchange)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_FORM_CHANGE;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onselect)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_FORM_SELECTED;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onload)
|
2006-08-31 19:33:01 +00:00
|
|
|
mEvent->message = NS_LOAD;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onunload)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_PAGE_UNLOAD;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onabort)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_IMAGE_ABORT;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onerror)
|
2006-09-02 10:00:26 +00:00
|
|
|
mEvent->message = NS_LOAD_ERROR;
|
2007-06-07 03:28:04 +00:00
|
|
|
else if (atom == nsGkAtoms::onoffline)
|
|
|
|
mEvent->message = NS_OFFLINE;
|
|
|
|
else if (atom == nsGkAtoms::ononline)
|
|
|
|
mEvent->message = NS_ONLINE;
|
2004-01-12 08:25:18 +00:00
|
|
|
} else if (mEvent->eventStructType == NS_MUTATION_EVENT) {
|
2006-12-26 17:47:52 +00:00
|
|
|
if (atom == nsGkAtoms::onDOMAttrModified)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_MUTATION_ATTRMODIFIED;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onDOMCharacterDataModified)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_MUTATION_CHARACTERDATAMODIFIED;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onDOMNodeInserted)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_MUTATION_NODEINSERTED;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onDOMNodeRemoved)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_MUTATION_NODEREMOVED;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onDOMNodeInsertedIntoDocument)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_MUTATION_NODEINSERTEDINTODOCUMENT;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onDOMNodeRemovedFromDocument)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_MUTATION_NODEREMOVEDFROMDOCUMENT;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onDOMSubtreeModified)
|
2004-01-12 08:25:18 +00:00
|
|
|
mEvent->message = NS_MUTATION_SUBTREEMODIFIED;
|
2004-08-20 18:09:19 +00:00
|
|
|
} else if (mEvent->eventStructType == NS_UI_EVENT) {
|
2006-12-26 17:47:52 +00:00
|
|
|
if (atom == nsGkAtoms::onDOMActivate)
|
2004-08-20 18:09:19 +00:00
|
|
|
mEvent->message = NS_UI_ACTIVATE;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onDOMFocusIn)
|
2004-08-20 18:09:19 +00:00
|
|
|
mEvent->message = NS_UI_FOCUSIN;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onDOMFocusOut)
|
2004-08-20 18:09:19 +00:00
|
|
|
mEvent->message = NS_UI_FOCUSOUT;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::oninput)
|
2005-08-22 18:34:21 +00:00
|
|
|
mEvent->message = NS_FORM_INPUT;
|
2005-06-15 23:52:46 +00:00
|
|
|
} else if (mEvent->eventStructType == NS_PAGETRANSITION_EVENT) {
|
2006-12-26 17:47:52 +00:00
|
|
|
if (atom == nsGkAtoms::onpageshow)
|
2005-06-15 23:52:46 +00:00
|
|
|
mEvent->message = NS_PAGE_SHOW;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onpagehide)
|
2005-06-15 23:52:46 +00:00
|
|
|
mEvent->message = NS_PAGE_HIDE;
|
2007-01-11 08:47:01 +00:00
|
|
|
} else if (mEvent->eventStructType == NS_XUL_COMMAND_EVENT) {
|
|
|
|
if (atom == nsGkAtoms::oncommand)
|
|
|
|
mEvent->message = NS_XUL_COMMAND;
|
2000-05-16 11:35:12 +00:00
|
|
|
}
|
2005-08-25 21:31:09 +00:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
else if (mEvent->eventStructType == NS_SVG_EVENT) {
|
2006-12-26 17:47:52 +00:00
|
|
|
if (atom == nsGkAtoms::onSVGLoad)
|
2005-08-25 21:31:09 +00:00
|
|
|
mEvent->message = NS_SVG_LOAD;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onSVGUnload)
|
2005-08-25 21:31:09 +00:00
|
|
|
mEvent->message = NS_SVG_UNLOAD;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onSVGAbort)
|
2005-08-25 21:31:09 +00:00
|
|
|
mEvent->message = NS_SVG_ABORT;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onSVGError)
|
2005-08-25 21:31:09 +00:00
|
|
|
mEvent->message = NS_SVG_ERROR;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onSVGResize)
|
2005-08-25 21:31:09 +00:00
|
|
|
mEvent->message = NS_SVG_RESIZE;
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (atom == nsGkAtoms::onSVGScroll)
|
2005-08-25 21:31:09 +00:00
|
|
|
mEvent->message = NS_SVG_SCROLL;
|
|
|
|
} else if (mEvent->eventStructType == NS_SVGZOOM_EVENT) {
|
2006-12-26 17:47:52 +00:00
|
|
|
if (atom == nsGkAtoms::onSVGZoom)
|
2005-08-25 21:31:09 +00:00
|
|
|
mEvent->message = NS_SVG_ZOOM;
|
|
|
|
}
|
|
|
|
#endif // MOZ_SVG
|
2004-01-14 01:33:47 +00:00
|
|
|
|
|
|
|
if (mEvent->message == NS_USER_DEFINED_EVENT)
|
2006-10-06 05:24:02 +00:00
|
|
|
mEvent->userType = atom;
|
2004-01-14 01:33:47 +00:00
|
|
|
|
2000-05-16 11:35:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-03 07:11:45 +00:00
|
|
|
NS_IMETHODIMP
|
2002-03-23 23:13:20 +00:00
|
|
|
nsDOMEvent::InitEvent(const nsAString& aEventTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg)
|
1999-11-03 07:11:45 +00:00
|
|
|
{
|
2005-06-22 01:53:58 +00:00
|
|
|
// Make sure this event isn't already being dispatched.
|
|
|
|
NS_ENSURE_TRUE(!NS_IS_EVENT_IN_DISPATCH(mEvent), NS_ERROR_INVALID_ARG);
|
|
|
|
|
|
|
|
if (NS_IS_TRUSTED_EVENT(mEvent)) {
|
|
|
|
// Ensure the caller is permitted to dispatch trusted DOM events.
|
|
|
|
|
|
|
|
PRBool enabled = PR_FALSE;
|
2005-10-14 09:07:29 +00:00
|
|
|
nsContentUtils::GetSecurityManager()->
|
2005-06-22 01:53:58 +00:00
|
|
|
IsCapabilityEnabled("UniversalBrowserWrite", &enabled);
|
|
|
|
|
|
|
|
if (!enabled) {
|
|
|
|
SetTrusted(PR_FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-16 11:35:12 +00:00
|
|
|
NS_ENSURE_SUCCESS(SetEventType(aEventTypeArg), NS_ERROR_FAILURE);
|
2005-06-22 01:53:58 +00:00
|
|
|
|
2005-11-07 22:22:49 +00:00
|
|
|
if (aCanBubbleArg) {
|
|
|
|
mEvent->flags &= ~NS_EVENT_FLAG_CANT_BUBBLE;
|
|
|
|
} else {
|
|
|
|
mEvent->flags |= NS_EVENT_FLAG_CANT_BUBBLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aCancelableArg) {
|
|
|
|
mEvent->flags &= ~NS_EVENT_FLAG_CANT_CANCEL;
|
|
|
|
} else {
|
|
|
|
mEvent->flags |= NS_EVENT_FLAG_CANT_CANCEL;
|
|
|
|
}
|
2005-06-22 01:53:58 +00:00
|
|
|
|
2006-03-14 21:51:56 +00:00
|
|
|
// Clearing the old targets, so that the event is targeted correctly when
|
|
|
|
// re-dispatching it.
|
|
|
|
mEvent->target = nsnull;
|
|
|
|
mEvent->originalTarget = nsnull;
|
|
|
|
|
2005-06-22 01:53:58 +00:00
|
|
|
// Unset the NS_EVENT_FLAG_STOP_DISPATCH_IMMEDIATELY bit (which is
|
|
|
|
// set at the end of event dispatch) so that this event can be
|
|
|
|
// dispatched.
|
|
|
|
mEvent->flags &= ~NS_EVENT_FLAG_STOP_DISPATCH_IMMEDIATELY;
|
|
|
|
|
2000-05-16 11:35:12 +00:00
|
|
|
return NS_OK;
|
1999-11-03 07:11:45 +00:00
|
|
|
}
|
|
|
|
|
1998-07-23 02:55:33 +00:00
|
|
|
NS_METHOD nsDOMEvent::DuplicatePrivateData()
|
1998-06-23 21:53:02 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
// FIXME! Simplify this method and make it somehow easily extendable,
|
|
|
|
// Bug 329127
|
|
|
|
|
|
|
|
NS_ASSERTION(mEvent, "No nsEvent for nsDOMEvent duplication!");
|
|
|
|
if (mEventIsInternal) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsEvent* newEvent = nsnull;
|
|
|
|
PRUint32 msg = mEvent->message;
|
2006-06-01 10:38:46 +00:00
|
|
|
PRBool isInputEvent = PR_FALSE;
|
2006-03-07 17:08:51 +00:00
|
|
|
|
|
|
|
switch (mEvent->eventStructType) {
|
|
|
|
case NS_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsEvent(PR_FALSE, msg);
|
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_GUI_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
// Not copying widget, it is a weak reference.
|
|
|
|
newEvent = new nsGUIEvent(PR_FALSE, msg, nsnull);
|
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_SIZE_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
|
|
|
nsSizeEvent* sizeEvent = new nsSizeEvent(PR_FALSE, msg, nsnull);
|
|
|
|
NS_ENSURE_TRUE(sizeEvent, NS_ERROR_OUT_OF_MEMORY);
|
2007-07-08 07:08:04 +00:00
|
|
|
sizeEvent->mWinWidth = static_cast<nsSizeEvent*>(mEvent)->mWinWidth;
|
|
|
|
sizeEvent->mWinHeight = static_cast<nsSizeEvent*>(mEvent)->mWinHeight;
|
2006-06-01 10:38:46 +00:00
|
|
|
newEvent = sizeEvent;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_SIZEMODE_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsSizeModeEvent(PR_FALSE, msg, nsnull);
|
2006-06-01 10:38:46 +00:00
|
|
|
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsSizeModeEvent*>(newEvent)->mSizeMode =
|
|
|
|
static_cast<nsSizeModeEvent*>(mEvent)->mSizeMode;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_ZLEVEL_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
|
|
|
nsZLevelEvent* zLevelEvent = new nsZLevelEvent(PR_FALSE, msg, nsnull);
|
|
|
|
NS_ENSURE_TRUE(zLevelEvent, NS_ERROR_OUT_OF_MEMORY);
|
2007-07-08 07:08:04 +00:00
|
|
|
nsZLevelEvent* oldZLevelEvent = static_cast<nsZLevelEvent*>(mEvent);
|
2006-06-01 10:38:46 +00:00
|
|
|
zLevelEvent->mPlacement = oldZLevelEvent->mPlacement;
|
|
|
|
zLevelEvent->mImmediate = oldZLevelEvent->mImmediate;
|
|
|
|
zLevelEvent->mAdjusted = oldZLevelEvent->mAdjusted;
|
|
|
|
newEvent = zLevelEvent;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_PAINT_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsPaintEvent(PR_FALSE, msg, nsnull);
|
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_SCROLLBAR_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsScrollbarEvent(PR_FALSE, msg, nsnull);
|
2006-06-01 10:38:46 +00:00
|
|
|
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsScrollbarEvent*>(newEvent)->position =
|
|
|
|
static_cast<nsScrollbarEvent*>(mEvent)->position;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_INPUT_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsInputEvent(PR_FALSE, msg, nsnull);
|
2006-06-01 10:38:46 +00:00
|
|
|
isInputEvent = PR_TRUE;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_KEY_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
|
|
|
nsKeyEvent* keyEvent = new nsKeyEvent(PR_FALSE, msg, nsnull);
|
|
|
|
NS_ENSURE_TRUE(keyEvent, NS_ERROR_OUT_OF_MEMORY);
|
2007-07-08 07:08:04 +00:00
|
|
|
nsKeyEvent* oldKeyEvent = static_cast<nsKeyEvent*>(mEvent);
|
2006-06-01 10:38:46 +00:00
|
|
|
isInputEvent = PR_TRUE;
|
|
|
|
keyEvent->keyCode = oldKeyEvent->keyCode;
|
|
|
|
keyEvent->charCode = oldKeyEvent->charCode;
|
|
|
|
keyEvent->isChar = oldKeyEvent->isChar;
|
|
|
|
newEvent = keyEvent;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_MOUSE_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2007-07-08 07:08:04 +00:00
|
|
|
nsMouseEvent* oldMouseEvent = static_cast<nsMouseEvent*>(mEvent);
|
2006-06-01 10:38:46 +00:00
|
|
|
nsMouseEvent* mouseEvent =
|
|
|
|
new nsMouseEvent(PR_FALSE, msg, nsnull, oldMouseEvent->reason);
|
|
|
|
NS_ENSURE_TRUE(mouseEvent, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
isInputEvent = PR_TRUE;
|
|
|
|
mouseEvent->clickCount = oldMouseEvent->clickCount;
|
|
|
|
mouseEvent->acceptActivation = oldMouseEvent->acceptActivation;
|
2006-07-13 07:51:54 +00:00
|
|
|
mouseEvent->relatedTarget = oldMouseEvent->relatedTarget;
|
2006-11-16 21:35:39 +00:00
|
|
|
mouseEvent->button = oldMouseEvent->button;
|
2006-06-01 10:38:46 +00:00
|
|
|
newEvent = mouseEvent;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_MENU_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsMenuEvent(PR_FALSE, msg, nsnull);
|
2006-06-01 10:38:46 +00:00
|
|
|
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsMenuEvent*>(newEvent)->mCommand =
|
|
|
|
static_cast<nsMenuEvent*>(mEvent)->mCommand;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_SCRIPT_ERROR_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsScriptErrorEvent(PR_FALSE, msg);
|
2006-06-01 10:38:46 +00:00
|
|
|
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsScriptErrorEvent*>(newEvent)->lineNr =
|
|
|
|
static_cast<nsScriptErrorEvent*>(mEvent)->lineNr;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_TEXT_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsTextEvent(PR_FALSE, msg, nsnull);
|
2006-06-01 10:38:46 +00:00
|
|
|
isInputEvent = PR_TRUE;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_COMPOSITION_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsCompositionEvent(PR_FALSE, msg, nsnull);
|
2006-06-01 10:38:46 +00:00
|
|
|
isInputEvent = PR_TRUE;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_RECONVERSION_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsReconversionEvent(PR_FALSE, msg, nsnull);
|
2006-06-01 10:38:46 +00:00
|
|
|
isInputEvent = PR_TRUE;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_MOUSE_SCROLL_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
|
|
|
nsMouseScrollEvent* mouseScrollEvent =
|
|
|
|
new nsMouseScrollEvent(PR_FALSE, msg, nsnull);
|
|
|
|
NS_ENSURE_TRUE(mouseScrollEvent, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
isInputEvent = PR_TRUE;
|
|
|
|
nsMouseScrollEvent* oldMouseScrollEvent =
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsMouseScrollEvent*>(mEvent);
|
2006-06-01 10:38:46 +00:00
|
|
|
mouseScrollEvent->scrollFlags = oldMouseScrollEvent->scrollFlags;
|
|
|
|
mouseScrollEvent->delta = oldMouseScrollEvent->delta;
|
2006-07-13 07:51:54 +00:00
|
|
|
mouseScrollEvent->relatedTarget = oldMouseScrollEvent->relatedTarget;
|
2006-11-16 21:35:39 +00:00
|
|
|
mouseScrollEvent->button = oldMouseScrollEvent->button;
|
2006-06-01 10:38:46 +00:00
|
|
|
newEvent = mouseScrollEvent;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_SCROLLPORT_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsScrollPortEvent(PR_FALSE, msg, nsnull);
|
2006-06-01 10:38:46 +00:00
|
|
|
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsScrollPortEvent*>(newEvent)->orient =
|
|
|
|
static_cast<nsScrollPortEvent*>(mEvent)->orient;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_MUTATION_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
|
|
|
nsMutationEvent* mutationEvent = new nsMutationEvent(PR_FALSE, msg);
|
|
|
|
NS_ENSURE_TRUE(mutationEvent, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
nsMutationEvent* oldMutationEvent =
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsMutationEvent*>(mEvent);
|
2006-06-01 10:38:46 +00:00
|
|
|
mutationEvent->mRelatedNode = oldMutationEvent->mRelatedNode;
|
|
|
|
mutationEvent->mAttrName = oldMutationEvent->mAttrName;
|
|
|
|
mutationEvent->mPrevAttrValue = oldMutationEvent->mPrevAttrValue;
|
|
|
|
mutationEvent->mNewAttrValue = oldMutationEvent->mNewAttrValue;
|
2006-06-05 18:38:54 +00:00
|
|
|
mutationEvent->mAttrChange = oldMutationEvent->mAttrChange;
|
2006-06-01 10:38:46 +00:00
|
|
|
newEvent = mutationEvent;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_ACCESSIBLE_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsAccessibleEvent(PR_FALSE, msg, nsnull);
|
2006-06-01 10:38:46 +00:00
|
|
|
isInputEvent = PR_TRUE;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_FORM_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsFormEvent(PR_FALSE, msg);
|
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_FOCUS_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsFocusEvent(PR_FALSE, msg, nsnull);
|
2006-06-01 10:38:46 +00:00
|
|
|
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsFocusEvent*>(newEvent)->isMozWindowTakingFocus =
|
|
|
|
static_cast<nsFocusEvent*>(mEvent)->isMozWindowTakingFocus;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_POPUP_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsInputEvent(PR_FALSE, msg, nsnull);
|
|
|
|
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
|
2006-06-01 10:38:46 +00:00
|
|
|
isInputEvent = PR_TRUE;
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent->eventStructType = NS_POPUP_EVENT;
|
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-12-01 11:09:53 +00:00
|
|
|
case NS_COMMAND_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-12-01 11:09:53 +00:00
|
|
|
newEvent = new nsCommandEvent(PR_FALSE, mEvent->userType,
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsCommandEvent*>(mEvent)->command, nsnull);
|
2006-06-01 10:38:46 +00:00
|
|
|
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_POPUPBLOCKED_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
|
|
|
NS_WARNING("nsPopupBlockedEvent should never be an external event!");
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsPopupBlockedEvent(PR_FALSE, msg);
|
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_BEFORE_PAGE_UNLOAD_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsBeforePageUnloadEvent(PR_FALSE, msg);
|
2006-06-01 10:38:46 +00:00
|
|
|
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsBeforePageUnloadEvent*>(newEvent)->text =
|
|
|
|
static_cast<nsBeforePageUnloadEvent*>(mEvent)->text;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_UI_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
|
|
|
newEvent = new nsUIEvent(PR_FALSE, msg,
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsUIEvent*>(mEvent)->detail);
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_QUERYCARETRECT_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsQueryCaretRectEvent(PR_FALSE, msg, nsnull);
|
2006-06-01 10:38:46 +00:00
|
|
|
isInputEvent = PR_TRUE;
|
2006-03-07 17:08:51 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_PAGETRANSITION_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent =
|
|
|
|
new nsPageTransitionEvent(PR_FALSE, msg,
|
|
|
|
((nsPageTransitionEvent*) mEvent)->persisted);
|
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
case NS_SVG_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsEvent(PR_FALSE, msg);
|
|
|
|
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
newEvent->eventStructType = NS_SVG_EVENT;
|
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
case NS_SVGZOOM_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent = new nsGUIEvent(PR_FALSE, msg, nsnull);
|
|
|
|
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
newEvent->eventStructType = NS_SVGZOOM_EVENT;
|
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
#endif // MOZ_SVG
|
2006-05-22 20:37:32 +00:00
|
|
|
case NS_XUL_COMMAND_EVENT:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-05-22 20:37:32 +00:00
|
|
|
newEvent = new nsXULCommandEvent(PR_FALSE, msg, nsnull);
|
|
|
|
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
|
2006-06-01 10:38:46 +00:00
|
|
|
isInputEvent = PR_TRUE;
|
2006-05-22 20:37:32 +00:00
|
|
|
newEvent->eventStructType = NS_XUL_COMMAND_EVENT;
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsXULCommandEvent*>(newEvent)->sourceEvent =
|
|
|
|
static_cast<nsXULCommandEvent*>(mEvent)->sourceEvent;
|
2006-05-22 20:37:32 +00:00
|
|
|
break;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
default:
|
2006-06-01 10:38:46 +00:00
|
|
|
{
|
2006-03-07 17:08:51 +00:00
|
|
|
NS_WARNING("Unknown event type!!!");
|
|
|
|
return NS_ERROR_FAILURE;
|
2006-06-01 10:38:46 +00:00
|
|
|
}
|
2006-03-07 17:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
2006-06-01 10:38:46 +00:00
|
|
|
if (isInputEvent) {
|
2007-07-08 07:08:04 +00:00
|
|
|
nsInputEvent* oldInputEvent = static_cast<nsInputEvent*>(mEvent);
|
|
|
|
nsInputEvent* newInputEvent = static_cast<nsInputEvent*>(newEvent);
|
2006-06-01 10:38:46 +00:00
|
|
|
newInputEvent->isShift = oldInputEvent->isShift;
|
|
|
|
newInputEvent->isControl = oldInputEvent->isControl;
|
|
|
|
newInputEvent->isAlt = oldInputEvent->isAlt;
|
|
|
|
newInputEvent->isMeta = oldInputEvent->isMeta;
|
|
|
|
}
|
|
|
|
|
2006-03-07 17:08:51 +00:00
|
|
|
newEvent->target = mEvent->target;
|
|
|
|
newEvent->currentTarget = mEvent->currentTarget;
|
|
|
|
newEvent->originalTarget = mEvent->originalTarget;
|
|
|
|
newEvent->flags = mEvent->flags;
|
2006-06-01 10:38:46 +00:00
|
|
|
newEvent->time = mEvent->time;
|
|
|
|
newEvent->refPoint = mEvent->refPoint;
|
2006-10-06 05:24:02 +00:00
|
|
|
newEvent->userType = mEvent->userType;
|
2006-03-07 17:08:51 +00:00
|
|
|
|
|
|
|
mEvent = newEvent;
|
|
|
|
mPresContext = nsnull;
|
|
|
|
mEventIsInternal = PR_TRUE;
|
1998-11-18 05:25:26 +00:00
|
|
|
|
1998-06-23 21:53:02 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-07-17 04:52:12 +00:00
|
|
|
|
2000-05-16 11:35:12 +00:00
|
|
|
NS_METHOD nsDOMEvent::SetTarget(nsIDOMEventTarget* aTarget)
|
1999-05-21 19:27:02 +00:00
|
|
|
{
|
2005-08-02 01:23:40 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aTarget);
|
|
|
|
|
2005-08-12 04:11:00 +00:00
|
|
|
NS_ASSERTION(!win || !win->IsInnerWindow(),
|
2005-08-02 01:23:40 +00:00
|
|
|
"Uh, inner window set as event target!");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-03-07 17:08:51 +00:00
|
|
|
mEvent->target = aTarget;
|
1999-05-21 19:27:02 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-16 11:35:12 +00:00
|
|
|
NS_METHOD nsDOMEvent::SetCurrentTarget(nsIDOMEventTarget* aCurrentTarget)
|
|
|
|
{
|
2005-08-02 01:23:40 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aCurrentTarget);
|
|
|
|
|
2005-08-12 04:11:00 +00:00
|
|
|
NS_ASSERTION(!win || !win->IsInnerWindow(),
|
2005-08-02 01:23:40 +00:00
|
|
|
"Uh, inner window set as event target!");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-03-07 17:08:51 +00:00
|
|
|
mEvent->currentTarget = aCurrentTarget;
|
2000-05-16 11:35:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-09-07 01:07:29 +00:00
|
|
|
NS_METHOD nsDOMEvent::SetOriginalTarget(nsIDOMEventTarget* aOriginalTarget)
|
|
|
|
{
|
2005-08-02 01:23:40 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aOriginalTarget);
|
|
|
|
|
2005-08-12 04:11:00 +00:00
|
|
|
NS_ASSERTION(!win || !win->IsInnerWindow(),
|
2005-08-02 01:23:40 +00:00
|
|
|
"Uh, inner window set as event target!");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-03-07 17:08:51 +00:00
|
|
|
mEvent->originalTarget = aOriginalTarget;
|
2000-09-07 01:07:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-12-15 22:04:43 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMEvent::IsDispatchStopped(PRBool* aIsDispatchStopped)
|
|
|
|
{
|
|
|
|
if (mEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) {
|
|
|
|
*aIsDispatchStopped = PR_TRUE;
|
|
|
|
} else {
|
|
|
|
*aIsDispatchStopped = PR_FALSE;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-17 05:27:22 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMEvent::GetInternalNSEvent(nsEvent** aNSEvent)
|
|
|
|
{
|
2003-04-16 00:00:50 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aNSEvent);
|
2000-05-17 05:27:22 +00:00
|
|
|
*aNSEvent = mEvent;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-09-04 19:28:46 +00:00
|
|
|
// return true if eventName is contained within events, delimited by
|
|
|
|
// spaces
|
|
|
|
static PRBool
|
|
|
|
PopupAllowedForEvent(const char *eventName)
|
|
|
|
{
|
|
|
|
if (!sPopupAllowedEvents) {
|
|
|
|
nsDOMEvent::PopupAllowedEventsChanged();
|
|
|
|
|
|
|
|
if (!sPopupAllowedEvents) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDependentCString events(sPopupAllowedEvents);
|
|
|
|
|
|
|
|
nsAFlatCString::const_iterator start, end;
|
|
|
|
nsAFlatCString::const_iterator startiter(events.BeginReading(start));
|
|
|
|
events.EndReading(end);
|
|
|
|
|
|
|
|
while (startiter != end) {
|
|
|
|
nsAFlatCString::const_iterator enditer(end);
|
|
|
|
|
|
|
|
if (!FindInReadable(nsDependentCString(eventName), startiter, enditer))
|
|
|
|
return PR_FALSE;
|
|
|
|
|
|
|
|
// the match is surrounded by spaces, or at a string boundary
|
|
|
|
if ((startiter == start || *--startiter == ' ') &&
|
|
|
|
(enditer == end || *enditer == ' ')) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Move on and see if there are other matches. (The delimitation
|
|
|
|
// requirement makes it pointless to begin the next search before
|
|
|
|
// the end of the invalid match just found.)
|
|
|
|
startiter = enditer;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
PopupControlState
|
|
|
|
nsDOMEvent::GetEventPopupControlState(nsEvent *aEvent)
|
|
|
|
{
|
|
|
|
// generally if an event handler is running, new windows are disallowed.
|
|
|
|
// check for exceptions:
|
|
|
|
PopupControlState abuse = openAbused;
|
|
|
|
|
|
|
|
switch(aEvent->eventStructType) {
|
|
|
|
case NS_EVENT :
|
|
|
|
// For these following events only allow popups if they're
|
|
|
|
// triggered while handling user input. See
|
|
|
|
// nsPresShell::HandleEventInternal() for details.
|
|
|
|
if (nsEventStateManager::IsHandlingUserInput()) {
|
|
|
|
switch(aEvent->message) {
|
|
|
|
case NS_FORM_SELECTED :
|
|
|
|
if (::PopupAllowedForEvent("select"))
|
|
|
|
abuse = openControlled;
|
2005-03-04 02:01:54 +00:00
|
|
|
break;
|
2004-09-04 19:28:46 +00:00
|
|
|
case NS_FORM_CHANGE :
|
|
|
|
if (::PopupAllowedForEvent("change"))
|
|
|
|
abuse = openControlled;
|
2005-03-04 02:01:54 +00:00
|
|
|
break;
|
2004-09-04 19:28:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NS_GUI_EVENT :
|
|
|
|
// For this following event only allow popups if it's triggered
|
|
|
|
// while handling user input. See
|
|
|
|
// nsPresShell::HandleEventInternal() for details.
|
|
|
|
if (nsEventStateManager::IsHandlingUserInput()) {
|
|
|
|
switch(aEvent->message) {
|
|
|
|
case NS_FORM_INPUT :
|
|
|
|
if (::PopupAllowedForEvent("input"))
|
|
|
|
abuse = openControlled;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NS_INPUT_EVENT :
|
|
|
|
// For this following event only allow popups if it's triggered
|
|
|
|
// while handling user input. See
|
|
|
|
// nsPresShell::HandleEventInternal() for details.
|
|
|
|
if (nsEventStateManager::IsHandlingUserInput()) {
|
|
|
|
switch(aEvent->message) {
|
|
|
|
case NS_FORM_CHANGE :
|
|
|
|
if (::PopupAllowedForEvent("change"))
|
|
|
|
abuse = openControlled;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NS_KEY_EVENT :
|
2005-04-28 23:48:28 +00:00
|
|
|
if (NS_IS_TRUSTED_EVENT(aEvent)) {
|
2007-07-08 07:08:04 +00:00
|
|
|
PRUint32 key = static_cast<nsKeyEvent *>(aEvent)->keyCode;
|
2004-09-04 19:28:46 +00:00
|
|
|
switch(aEvent->message) {
|
|
|
|
case NS_KEY_PRESS :
|
2006-11-16 21:35:39 +00:00
|
|
|
// return key on focused button. see note at NS_MOUSE_CLICK.
|
2004-09-04 19:28:46 +00:00
|
|
|
if (key == nsIDOMKeyEvent::DOM_VK_RETURN)
|
|
|
|
abuse = openAllowed;
|
|
|
|
else if (::PopupAllowedForEvent("keypress"))
|
|
|
|
abuse = openControlled;
|
|
|
|
break;
|
|
|
|
case NS_KEY_UP :
|
2006-11-16 21:35:39 +00:00
|
|
|
// space key on focused button. see note at NS_MOUSE_CLICK.
|
2004-09-04 19:28:46 +00:00
|
|
|
if (key == nsIDOMKeyEvent::DOM_VK_SPACE)
|
|
|
|
abuse = openAllowed;
|
|
|
|
else if (::PopupAllowedForEvent("keyup"))
|
|
|
|
abuse = openControlled;
|
|
|
|
break;
|
|
|
|
case NS_KEY_DOWN :
|
|
|
|
if (::PopupAllowedForEvent("keydown"))
|
|
|
|
abuse = openControlled;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NS_MOUSE_EVENT :
|
2006-11-16 21:35:39 +00:00
|
|
|
if (NS_IS_TRUSTED_EVENT(aEvent) &&
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton) {
|
2004-09-04 19:28:46 +00:00
|
|
|
switch(aEvent->message) {
|
2006-11-16 21:35:39 +00:00
|
|
|
case NS_MOUSE_BUTTON_UP :
|
2004-09-04 19:28:46 +00:00
|
|
|
if (::PopupAllowedForEvent("mouseup"))
|
|
|
|
abuse = openControlled;
|
|
|
|
break;
|
2006-11-16 21:35:39 +00:00
|
|
|
case NS_MOUSE_BUTTON_DOWN :
|
2004-09-04 19:28:46 +00:00
|
|
|
if (::PopupAllowedForEvent("mousedown"))
|
|
|
|
abuse = openControlled;
|
|
|
|
break;
|
2006-11-16 21:35:39 +00:00
|
|
|
case NS_MOUSE_CLICK :
|
2004-09-04 19:28:46 +00:00
|
|
|
/* Click events get special treatment because of their
|
|
|
|
historical status as a more legitimate event handler. If
|
|
|
|
click popups are enabled in the prefs, clear the popup
|
|
|
|
status completely. */
|
|
|
|
if (::PopupAllowedForEvent("click"))
|
|
|
|
abuse = openAllowed;
|
|
|
|
break;
|
2006-11-16 21:35:39 +00:00
|
|
|
case NS_MOUSE_DOUBLECLICK :
|
2004-09-04 19:28:46 +00:00
|
|
|
if (::PopupAllowedForEvent("dblclick"))
|
|
|
|
abuse = openControlled;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NS_SCRIPT_ERROR_EVENT :
|
|
|
|
switch(aEvent->message) {
|
2006-09-02 10:00:26 +00:00
|
|
|
case NS_LOAD_ERROR :
|
2004-09-04 19:28:46 +00:00
|
|
|
// Any error event will allow popups, if enabled in the pref.
|
|
|
|
if (::PopupAllowedForEvent("error"))
|
|
|
|
abuse = openControlled;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NS_FORM_EVENT :
|
|
|
|
// For these following events only allow popups if they're
|
|
|
|
// triggered while handling user input. See
|
|
|
|
// nsPresShell::HandleEventInternal() for details.
|
|
|
|
if (nsEventStateManager::IsHandlingUserInput()) {
|
|
|
|
switch(aEvent->message) {
|
|
|
|
case NS_FORM_SUBMIT :
|
|
|
|
if (::PopupAllowedForEvent("submit"))
|
|
|
|
abuse = openControlled;
|
|
|
|
break;
|
|
|
|
case NS_FORM_RESET :
|
|
|
|
if (::PopupAllowedForEvent("reset"))
|
|
|
|
abuse = openControlled;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2007-07-24 00:55:52 +00:00
|
|
|
case NS_XUL_COMMAND_EVENT :
|
|
|
|
if (nsEventStateManager::IsHandlingUserInput()) {
|
|
|
|
abuse = openControlled;
|
|
|
|
}
|
2004-09-04 19:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return abuse;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
void
|
|
|
|
nsDOMEvent::PopupAllowedEventsChanged()
|
|
|
|
{
|
|
|
|
if (sPopupAllowedEvents) {
|
|
|
|
nsMemory::Free(sPopupAllowedEvents);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAdoptingCString str =
|
|
|
|
nsContentUtils::GetCharPref("dom.popup_allowed_events");
|
|
|
|
|
|
|
|
// We'll want to do this even if str is empty to avoid looking up
|
|
|
|
// this pref all the time if it's not set.
|
|
|
|
sPopupAllowedEvents = ToNewCString(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
void
|
|
|
|
nsDOMEvent::Shutdown()
|
|
|
|
{
|
|
|
|
if (sPopupAllowedEvents) {
|
|
|
|
nsMemory::Free(sPopupAllowedEvents);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-26 21:38:38 +00:00
|
|
|
// To be called ONLY by nsDOMEvent::GetType (which has the additional
|
|
|
|
// logic for handling user-defined events).
|
2004-09-04 19:28:46 +00:00
|
|
|
// static
|
1998-07-17 04:52:12 +00:00
|
|
|
const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
|
|
|
|
{
|
|
|
|
switch(aEventType) {
|
2006-11-16 21:35:39 +00:00
|
|
|
case NS_MOUSE_BUTTON_DOWN:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_mousedown];
|
2006-11-16 21:35:39 +00:00
|
|
|
case NS_MOUSE_BUTTON_UP:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_mouseup];
|
2006-11-16 21:35:39 +00:00
|
|
|
case NS_MOUSE_CLICK:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_click];
|
2006-11-16 21:35:39 +00:00
|
|
|
case NS_MOUSE_DOUBLECLICK:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_dblclick];
|
2000-04-24 04:41:27 +00:00
|
|
|
case NS_MOUSE_ENTER_SYNTH:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_mouseover];
|
2000-04-24 04:41:27 +00:00
|
|
|
case NS_MOUSE_EXIT_SYNTH:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_mouseout];
|
1998-07-17 04:52:12 +00:00
|
|
|
case NS_MOUSE_MOVE:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_mousemove];
|
1998-07-17 04:52:12 +00:00
|
|
|
case NS_KEY_UP:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_keyup];
|
1998-07-17 04:52:12 +00:00
|
|
|
case NS_KEY_DOWN:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_keydown];
|
1998-11-24 07:46:58 +00:00
|
|
|
case NS_KEY_PRESS:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_keypress];
|
2005-03-05 08:19:05 +00:00
|
|
|
case NS_COMPOSITION_START:
|
|
|
|
return sEventNames[eDOMEvents_compositionstart];
|
|
|
|
case NS_COMPOSITION_END:
|
|
|
|
return sEventNames[eDOMEvents_compositionend];
|
1999-03-28 22:22:54 +00:00
|
|
|
case NS_FOCUS_CONTENT:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_focus];
|
1999-03-28 22:22:54 +00:00
|
|
|
case NS_BLUR_CONTENT:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_blur];
|
1999-12-01 22:35:33 +00:00
|
|
|
case NS_XUL_CLOSE:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_close];
|
2006-08-31 19:33:01 +00:00
|
|
|
case NS_LOAD:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_load];
|
|
|
|
case NS_BEFORE_PAGE_UNLOAD:
|
|
|
|
return sEventNames[eDOMEvents_beforeunload];
|
1998-07-24 05:06:44 +00:00
|
|
|
case NS_PAGE_UNLOAD:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_unload];
|
1998-07-24 05:06:44 +00:00
|
|
|
case NS_IMAGE_ABORT:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_abort];
|
2006-09-02 10:00:26 +00:00
|
|
|
case NS_LOAD_ERROR:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_error];
|
1998-07-31 22:09:51 +00:00
|
|
|
case NS_FORM_SUBMIT:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_submit];
|
1998-07-31 22:09:51 +00:00
|
|
|
case NS_FORM_RESET:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_reset];
|
1998-11-02 23:05:46 +00:00
|
|
|
case NS_FORM_CHANGE:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_change];
|
2004-06-21 23:35:56 +00:00
|
|
|
case NS_FORM_SELECTED:
|
|
|
|
return sEventNames[eDOMEvents_select];
|
2004-06-21 23:41:30 +00:00
|
|
|
case NS_FORM_INPUT:
|
|
|
|
return sEventNames[eDOMEvents_input];
|
1998-10-06 21:01:59 +00:00
|
|
|
case NS_PAINT:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_paint];
|
2000-05-17 05:27:22 +00:00
|
|
|
case NS_RESIZE_EVENT:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_resize];
|
2000-05-17 06:53:58 +00:00
|
|
|
case NS_SCROLL_EVENT:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_scroll];
|
2004-01-12 08:25:18 +00:00
|
|
|
case NS_TEXT_TEXT:
|
2004-09-04 19:28:46 +00:00
|
|
|
return sEventNames[eDOMEvents_text];
|
2001-08-06 21:49:35 +00:00
|
|
|
case NS_XUL_POPUP_SHOWING:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_popupShowing];
|
2001-08-06 21:49:35 +00:00
|
|
|
case NS_XUL_POPUP_SHOWN:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_popupShown];
|
2001-08-06 21:49:35 +00:00
|
|
|
case NS_XUL_POPUP_HIDING:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_popupHiding];
|
2001-08-06 21:49:35 +00:00
|
|
|
case NS_XUL_POPUP_HIDDEN:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_popupHidden];
|
2001-08-06 21:49:35 +00:00
|
|
|
case NS_XUL_COMMAND:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_command];
|
1999-09-21 23:02:35 +00:00
|
|
|
case NS_XUL_BROADCAST:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_broadcast];
|
1999-09-21 23:02:35 +00:00
|
|
|
case NS_XUL_COMMAND_UPDATE:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_commandupdate];
|
1999-09-02 03:51:03 +00:00
|
|
|
case NS_DRAGDROP_ENTER:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_dragenter];
|
2000-04-24 04:41:27 +00:00
|
|
|
case NS_DRAGDROP_OVER_SYNTH:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_dragover];
|
2000-04-24 04:41:27 +00:00
|
|
|
case NS_DRAGDROP_EXIT_SYNTH:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_dragexit];
|
2007-04-12 04:37:39 +00:00
|
|
|
case NS_DRAGDROP_DRAGDROP:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_dragdrop];
|
1999-09-02 03:51:03 +00:00
|
|
|
case NS_DRAGDROP_GESTURE:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_draggesture];
|
2007-04-12 04:37:39 +00:00
|
|
|
case NS_DRAGDROP_DRAG:
|
|
|
|
return sEventNames[eDOMEvents_drag];
|
|
|
|
case NS_DRAGDROP_END:
|
|
|
|
return sEventNames[eDOMEvents_dragend];
|
|
|
|
case NS_DRAGDROP_START:
|
|
|
|
return sEventNames[eDOMEvents_dragstart];
|
|
|
|
case NS_DRAGDROP_LEAVE_SYNTH:
|
|
|
|
return sEventNames[eDOMEvents_dragleave];
|
|
|
|
case NS_DRAGDROP_DROP:
|
|
|
|
return sEventNames[eDOMEvents_drop];
|
2000-06-23 05:15:04 +00:00
|
|
|
case NS_SCROLLPORT_OVERFLOW:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_overflow];
|
2000-06-23 05:15:04 +00:00
|
|
|
case NS_SCROLLPORT_UNDERFLOW:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_underflow];
|
2000-06-28 00:00:18 +00:00
|
|
|
case NS_SCROLLPORT_OVERFLOWCHANGED:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_overflowchanged];
|
2000-11-27 07:55:20 +00:00
|
|
|
case NS_MUTATION_SUBTREEMODIFIED:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_subtreemodified];
|
2000-11-27 07:55:20 +00:00
|
|
|
case NS_MUTATION_NODEINSERTED:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_nodeinserted];
|
2000-11-27 07:55:20 +00:00
|
|
|
case NS_MUTATION_NODEREMOVED:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_noderemoved];
|
2000-11-27 07:55:20 +00:00
|
|
|
case NS_MUTATION_NODEREMOVEDFROMDOCUMENT:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_noderemovedfromdocument];
|
2000-11-27 07:55:20 +00:00
|
|
|
case NS_MUTATION_NODEINSERTEDINTODOCUMENT:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_nodeinsertedintodocument];
|
2000-11-27 07:55:20 +00:00
|
|
|
case NS_MUTATION_ATTRMODIFIED:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_attrmodified];
|
2000-11-27 07:55:20 +00:00
|
|
|
case NS_MUTATION_CHARACTERDATAMODIFIED:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_characterdatamodified];
|
2001-03-30 02:30:17 +00:00
|
|
|
case NS_CONTEXTMENU:
|
2004-02-11 06:09:51 +00:00
|
|
|
return sEventNames[eDOMEvents_contextmenu];
|
2004-08-20 18:09:19 +00:00
|
|
|
case NS_UI_ACTIVATE:
|
2004-04-30 23:55:16 +00:00
|
|
|
return sEventNames[eDOMEvents_DOMActivate];
|
2004-08-20 18:09:19 +00:00
|
|
|
case NS_UI_FOCUSIN:
|
2004-04-30 23:55:16 +00:00
|
|
|
return sEventNames[eDOMEvents_DOMFocusIn];
|
2004-08-20 18:09:19 +00:00
|
|
|
case NS_UI_FOCUSOUT:
|
2004-04-30 23:55:16 +00:00
|
|
|
return sEventNames[eDOMEvents_DOMFocusOut];
|
2005-06-15 23:52:46 +00:00
|
|
|
case NS_PAGE_SHOW:
|
2005-07-25 22:09:39 +00:00
|
|
|
return sEventNames[eDOMEvents_pageshow];
|
2005-06-15 23:52:46 +00:00
|
|
|
case NS_PAGE_HIDE:
|
2005-07-25 22:09:39 +00:00
|
|
|
return sEventNames[eDOMEvents_pagehide];
|
2007-02-20 14:57:52 +00:00
|
|
|
case NS_MOUSE_SCROLL:
|
|
|
|
return sEventNames[eDOMEvents_DOMMouseScroll];
|
2007-06-07 03:28:04 +00:00
|
|
|
case NS_OFFLINE:
|
|
|
|
return sEventNames[eDOMEvents_offline];
|
|
|
|
case NS_ONLINE:
|
|
|
|
return sEventNames[eDOMEvents_online];
|
2005-08-25 21:31:09 +00:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
case NS_SVG_LOAD:
|
|
|
|
return sEventNames[eDOMEvents_SVGLoad];
|
|
|
|
case NS_SVG_UNLOAD:
|
|
|
|
return sEventNames[eDOMEvents_SVGUnload];
|
|
|
|
case NS_SVG_ABORT:
|
|
|
|
return sEventNames[eDOMEvents_SVGAbort];
|
|
|
|
case NS_SVG_ERROR:
|
|
|
|
return sEventNames[eDOMEvents_SVGError];
|
|
|
|
case NS_SVG_RESIZE:
|
|
|
|
return sEventNames[eDOMEvents_SVGResize];
|
|
|
|
case NS_SVG_SCROLL:
|
|
|
|
return sEventNames[eDOMEvents_SVGScroll];
|
|
|
|
case NS_SVG_ZOOM:
|
|
|
|
return sEventNames[eDOMEvents_SVGZoom];
|
|
|
|
#endif // MOZ_SVG
|
1998-07-17 04:52:12 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-08-28 16:45:39 +00:00
|
|
|
// XXXldb We can hit this case for nsEvent objects that we didn't
|
|
|
|
// create and that are not user defined events since this function and
|
|
|
|
// SetEventType are incomplete. (But fixing that requires fixing the
|
|
|
|
// arrays in nsEventListenerManager too, since the events for which
|
|
|
|
// this is a problem generally *are* created by nsDOMEvent.)
|
1998-07-17 04:52:12 +00:00
|
|
|
return nsnull;
|
|
|
|
}
|
1998-07-23 02:55:33 +00:00
|
|
|
|
2004-08-20 18:09:19 +00:00
|
|
|
nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsEvent *aEvent)
|
1998-07-23 02:55:33 +00:00
|
|
|
{
|
2004-08-20 18:09:19 +00:00
|
|
|
nsDOMEvent* it = new nsDOMEvent(aPresContext, aEvent);
|
1998-07-23 02:55:33 +00:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2002-12-11 14:24:49 +00:00
|
|
|
|
|
|
|
return CallQueryInterface(it, aInstancePtrResult);
|
1998-07-23 02:55:33 +00:00
|
|
|
}
|