Bug 238773 Separating nsDOMEvent into separate classes

patch by mozilla-bugzilla@future.shiny.co.il r=bryner sr=jst
This commit is contained in:
timeless%mozdev.org 2004-08-20 18:09:19 +00:00
Родитель b0945b613c
Коммит 758a700395
26 изменённых файлов: 2075 добавлений и 1196 удалений

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

@ -1159,8 +1159,9 @@ nsGenericElement::InternalIsSupported(const nsAString& aFeature,
PL_strcasecmp(f, "CSS") == 0 ||
PL_strcasecmp(f, "CSS2") == 0 ||
PL_strcasecmp(f, "Events") == 0 ||
// PL_strcasecmp(f, "UIEvents") == 0 ||
PL_strcasecmp(f, "UIEvents") == 0 ||
PL_strcasecmp(f, "MouseEvents") == 0 ||
// Non-standard!
PL_strcasecmp(f, "MouseScrollEvents") == 0 ||
PL_strcasecmp(f, "HTMLEvents") == 0 ||
PL_strcasecmp(f, "Range") == 0) {

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

@ -38,7 +38,6 @@
#ifndef nsIPrivateDOMEvent_h__
#define nsIPrivateDOMEvent_h__
#include "nsEvent.h"
#include "nsISupports.h"
class nsPresContext;
@ -53,6 +52,7 @@ class nsPresContext;
class nsIDOMEventTarget;
class nsIDOMEvent;
struct nsEvent;
class nsIPrivateDOMEvent : public nsISupports {
@ -71,11 +71,18 @@ public:
};
nsresult
NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext, const nsAString& aEventType,
nsEvent *aEvent);
NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, struct nsEvent *aEvent);
nsresult
NS_NewDOMMutationEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext,
nsEvent* aEvent);
NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, struct nsGUIEvent *aEvent);
nsresult
NS_NewDOMMouseEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, struct nsInputEvent *aEvent);
nsresult
NS_NewDOMKeyboardEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, struct nsKeyEvent *aEvent);
nsresult
NS_NewDOMMutationEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, struct nsMutationEvent* aEvent);
nsresult
NS_NewDOMPopupBlockedEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, struct nsPopupBlockedEvent* aEvent);
nsresult
NS_NewDOMTextEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, struct nsTextEvent* aEvent);
#endif // nsIPrivateDOMEvent_h__

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

@ -67,7 +67,12 @@ CPPSRCS = \
nsEventListenerManager.cpp \
nsEventStateManager.cpp \
nsDOMEvent.cpp \
nsDOMUIEvent.cpp \
nsDOMKeyboardEvent.cpp \
nsDOMTextEvent.cpp \
nsDOMMouseEvent.cpp \
nsDOMMutationEvent.cpp \
nsDOMPopupBlockedEvent.cpp \
nsPrivateTextRange.cpp \
nsDOMEventGroup.cpp \
nsXMLEventsManager.cpp \

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -38,34 +38,29 @@
#ifndef nsDOMEvent_h__
#define nsDOMEvent_h__
#include "nsIDOMKeyEvent.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMPopupBlockedEvent.h"
#include "nsIDOMNSUIEvent.h"
#include "nsIDOMEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsISupports.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIPrivateCompositionEvent.h"
#include "nsIPrivateTextEvent.h"
#include "nsIPrivateTextRange.h"
#include "nsIDOMEvent.h"
#include "nsCOMPtr.h"
#include "nsIDOMEventTarget.h"
#include "nsPresContext.h"
#include "nsPoint.h"
#include "nsGUIEvent.h"
#include "nsRecycled.h"
class nsIContent;
class nsIScrollableView;
class nsDOMEvent : public nsIDOMKeyEvent,
/* Currently we use a single-object recycler (nsRecycledSingle).
* With our current usage pattern, we almost never have more than
* a single nsDOMEvent active in memory at a time under normal circumstances.
*/
class nsDOMEvent : public nsIDOMEvent,
public nsIDOMNSEvent,
public nsIDOMMouseEvent,
public nsIDOMPopupBlockedEvent,
public nsIDOMNSUIEvent,
public nsIPrivateDOMEvent,
public nsIPrivateTextEvent,
public nsIPrivateCompositionEvent
public nsRecycledSingle<nsDOMEvent>
{
public:
@ -127,8 +122,7 @@ public:
eDOMEvents_DOMFocusOut
};
nsDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent,
const nsAString& aEventType);
nsDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent);
virtual ~nsDOMEvent();
NS_DECL_ISUPPORTS
@ -139,32 +133,6 @@ public:
// nsIDOMNSEvent Interface
NS_DECL_NSIDOMNSEVENT
// nsIDOMUIEvent Interface
NS_DECL_NSIDOMUIEVENT
// nsIDOMPopupBlockedEvent interface
NS_DECL_NSIDOMPOPUPBLOCKEDEVENT
// nsIDOMMouseEvent interface
NS_DECL_NSIDOMMOUSEEVENT
// nsIDOMKeyEvent interface
NS_IMETHOD GetCharCode(PRUint32 *aCharCode);
NS_IMETHOD GetKeyCode(PRUint32 *aKeyCode);
// defined in nsIDOMMouseEvent
// NS_IMETHOD GetAltKey(PRBool *aAltKey);
// NS_IMETHOD GetCtrlKey(PRBool *aCtrlKey);
// NS_IMETHOD GetShiftKey(PRBool *aShiftKey);
// NS_IMETHOD GetMetaKey(PRBool *aMetaKey);
NS_IMETHOD InitKeyEvent(const nsAString &aTypeTag, PRBool aCanBubbleArg,
PRBool aCancelableArg, nsIDOMAbstractView *aViewArg,
PRBool aCtrlKeyArg, PRBool aAltKeyArg,
PRBool aShiftKeyArg, PRBool aMetaKeyArg,
PRUint32 aKeyCodeArg, PRUint32 aCharCodeArg);
// nsIDOMNSUIEvent interface
NS_DECL_NSIDOMNSUIEVENT
// nsIPrivateDOMEvent interface
NS_IMETHOD DuplicatePrivateData();
NS_IMETHOD SetTarget(nsIDOMEventTarget* aTarget);
@ -179,47 +147,12 @@ public:
NS_IMETHOD IsHandled(PRBool* aHandled);
NS_IMETHOD SetHandled(PRBool aHandled);
// nsIPrivateTextEvent interface
NS_IMETHOD GetText(nsString& aText);
NS_IMETHOD GetInputRange(nsIPrivateTextRangeList** aInputRange);
NS_IMETHOD GetEventReply(nsTextEventReply** aReply);
// nsIPrivateCompositionEvent interface
NS_IMETHOD GetCompositionReply(nsTextEventReply** aReply);
NS_IMETHOD GetReconversionReply(nsReconversionEventReply** aReply);
/** Overloaded new operator. Initializes the memory to 0.
* Relies on a recycler to perform the allocation,
* optionally from a pool.
*/
void* operator new(size_t sz) CPP_THROW_NEW;
/** Overloaded delete operator. Relies on a recycler to either
* recycle the object or call the global delete operator, as needed.
*/
void operator delete(void* aPtr);
protected:
nsDOMEvent() {}; // private constructor for pool, not for general use
/** bit to say whether the event pool is in use or not.
* note that it would be trivial to make this a bitmap if we ever
* wanted to increase the size of the pool from one. But with our
* current usage pattern, we almost never have more than a single
* nsDOMEvent active in memory at a time under normal circumstances.
*/
static PRBool gEventPoolInUse;
//Internal helper funcs
nsresult GetScrollInfo(nsIScrollableView** aScrollableView, float* aP2T,
float* aT2P);
// Internal helper functions
nsresult SetEventType(const nsAString& aEventTypeArg);
const char* GetEventName(PRUint32 aEventType);
static const char* GetEventName(PRUint32 aEventType);
already_AddRefed<nsIDOMEventTarget> GetTargetFromFrame();
void AllocateEvent(const nsAString& aEventType);
nsPoint GetClientPoint();
nsPoint GetScreenPoint();
nsEvent* mEvent;
nsCOMPtr<nsPresContext> mPresContext;
@ -228,17 +161,13 @@ protected:
nsCOMPtr<nsIDOMEventTarget> mOriginalTarget;
nsCOMPtr<nsIDOMEventTarget> mExplicitOriginalTarget;
nsCOMPtr<nsIDOMEventTarget> mTmpRealOriginalTarget;
nsString* mText;
nsCOMPtr<nsIPrivateTextRangeList> mTextRange;
PRPackedBool mEventIsInternal;
PRPackedBool mEventIsTrusted;
//These are use for internal data for user created events
PRInt16 mButton;
nsPoint mScreenPoint;
nsPoint mClientPoint;
void* mScriptObject;
};
#define NS_FORWARD_TO_NSDOMEVENT \
NS_FORWARD_NSIDOMEVENT(nsDOMEvent::)
#endif // nsDOMEvent_h__

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

@ -0,0 +1,201 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Steve Clark (buster@netscape.com)
* Ilya Konstantinov (mozilla-code@future.shiny.co.il)
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDOMKeyboardEvent.h"
#include "nsContentUtils.h"
nsDOMKeyboardEvent::nsDOMKeyboardEvent(nsPresContext* aPresContext, nsKeyEvent* aEvent)
: nsDOMUIEvent(aPresContext, aEvent ? aEvent : new nsKeyEvent())
{
NS_ASSERTION(mEvent->eventStructType == NS_KEY_EVENT, "event type mismatch");
if (aEvent) {
mEventIsInternal = PR_FALSE;
mEventIsTrusted = PR_TRUE;
}
else {
mEventIsInternal = PR_TRUE;
mEventIsTrusted = PR_FALSE;
mEvent->time = PR_Now();
}
}
NS_IMPL_ADDREF_INHERITED(nsDOMKeyboardEvent, nsDOMUIEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMKeyboardEvent, nsDOMUIEvent)
NS_INTERFACE_MAP_BEGIN(nsDOMKeyboardEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMKeyEvent)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(KeyboardEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
NS_IMETHODIMP
nsDOMKeyboardEvent::GetAltKey(PRBool* aIsDown)
{
NS_ENSURE_ARG_POINTER(aIsDown);
*aIsDown = ((nsInputEvent*)mEvent)->isAlt;
return NS_OK;
}
NS_IMETHODIMP
nsDOMKeyboardEvent::GetCtrlKey(PRBool* aIsDown)
{
NS_ENSURE_ARG_POINTER(aIsDown);
*aIsDown = ((nsInputEvent*)mEvent)->isControl;
return NS_OK;
}
NS_IMETHODIMP
nsDOMKeyboardEvent::GetShiftKey(PRBool* aIsDown)
{
NS_ENSURE_ARG_POINTER(aIsDown);
*aIsDown = ((nsInputEvent*)mEvent)->isShift;
return NS_OK;
}
NS_IMETHODIMP
nsDOMKeyboardEvent::GetMetaKey(PRBool* aIsDown)
{
NS_ENSURE_ARG_POINTER(aIsDown);
*aIsDown = ((nsInputEvent*)mEvent)->isMeta;
return NS_OK;
}
NS_IMETHODIMP
nsDOMKeyboardEvent::GetCharCode(PRUint32* aCharCode)
{
NS_ENSURE_ARG_POINTER(aCharCode);
switch (mEvent->message) {
case NS_KEY_UP:
case NS_KEY_DOWN:
#if defined(NS_DEBUG) && defined(DEBUG_brade)
printf("GetCharCode used for wrong key event; should use onkeypress.\n");
#endif
*aCharCode = 0;
break;
case NS_KEY_PRESS:
*aCharCode = ((nsKeyEvent*)mEvent)->charCode;
break;
default:
break;
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMKeyboardEvent::GetKeyCode(PRUint32* aKeyCode)
{
NS_ENSURE_ARG_POINTER(aKeyCode);
switch (mEvent->message) {
case NS_KEY_UP:
case NS_KEY_PRESS:
case NS_KEY_DOWN:
*aKeyCode = ((nsKeyEvent*)mEvent)->keyCode;
break;
default:
*aKeyCode = 0;
break;
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMKeyboardEvent::GetWhich(PRUint32* aWhich)
{
NS_ENSURE_ARG_POINTER(aWhich);
switch (mEvent->message) {
case NS_KEY_UP:
case NS_KEY_DOWN:
return GetKeyCode(aWhich);
case NS_KEY_PRESS:
//Special case for 4xp bug 62878. Try to make value of which
//more closely mirror the values that 4.x gave for RETURN and BACKSPACE
{
PRUint32 keyCode = ((nsKeyEvent*)mEvent)->keyCode;
if (keyCode == NS_VK_RETURN || keyCode == NS_VK_BACK) {
*aWhich = keyCode;
return NS_OK;
}
return GetCharCode(aWhich);
}
break;
default:
*aWhich = 0;
break;
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMKeyboardEvent::InitKeyEvent(const nsAString& aType, PRBool aCanBubble, PRBool aCancelable,
nsIDOMAbstractView* aView, PRBool aCtrlKey, PRBool aAltKey,
PRBool aShiftKey, PRBool aMetaKey,
PRUint32 aKeyCode, PRUint32 aCharCode)
{
nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, 0);
NS_ENSURE_SUCCESS(rv, rv);
nsKeyEvent* keyEvent = NS_STATIC_CAST(nsKeyEvent*, mEvent);
keyEvent->isControl = aCtrlKey;
keyEvent->isAlt = aAltKey;
keyEvent->isShift = aShiftKey;
keyEvent->isMeta = aMetaKey;
keyEvent->keyCode = aKeyCode;
keyEvent->charCode = aCharCode;
return NS_OK;
}
nsresult NS_NewDOMKeyboardEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
nsKeyEvent *aEvent)
{
nsDOMKeyboardEvent* it = new nsDOMKeyboardEvent(aPresContext, aEvent);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return CallQueryInterface(it, aInstancePtrResult);
}

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

@ -0,0 +1,64 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ilya Konstantinov (mozilla-code@future.shiny.co.il)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDOMKeyboardEvent_h__
#define nsDOMKeyboardEvent_h__
#include "nsIDOMKeyEvent.h"
#include "nsDOMUIEvent.h"
class nsDOMKeyboardEvent : public nsIDOMKeyEvent,
public nsDOMUIEvent
{
public:
nsDOMKeyboardEvent(nsPresContext* aPresContext, nsKeyEvent* aEvent);
NS_DECL_ISUPPORTS_INHERITED
// nsIDOMKeyEvent Interface
NS_DECL_NSIDOMKEYEVENT
// Forward to base class
NS_FORWARD_TO_NSDOMUIEVENT_NO_WHICH
// Specific implementation for a keyboard event.
NS_IMETHOD GetWhich(PRUint32 *aWhich);
};
#endif // nsDOMKeyboardEvent_h__

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

@ -0,0 +1,271 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Steve Clark (buster@netscape.com)
* Ilya Konstantinov (mozilla-code@future.shiny.co.il)
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDOMMouseEvent.h"
#include "nsGUIEvent.h"
#include "nsIContent.h"
#include "nsIEventStateManager.h"
#include "nsContentUtils.h"
nsDOMMouseEvent::nsDOMMouseEvent(nsPresContext* aPresContext, nsInputEvent* aEvent)
: nsDOMUIEvent(aPresContext, aEvent ? aEvent : new nsMouseEvent()), mButton(-1)
{
// There's no way to make this class' ctor allocate an nsMouseScrollEvent.
// It's not that important, though, since a scroll event is not a real
// DOM event.
if (aEvent) {
mEventIsInternal = PR_FALSE;
mEventIsTrusted = PR_TRUE;
}
else {
mEventIsInternal = PR_TRUE;
mEventIsTrusted = PR_FALSE;
mEvent->time = PR_Now();
mEvent->refPoint.x = mEvent->refPoint.y = mEvent->point.x = mEvent->point.y = 0;
}
switch (mEvent->eventStructType)
{
case NS_MOUSE_EVENT:
mDetail = NS_STATIC_CAST(nsMouseEvent*, mEvent)->clickCount;
break;
case NS_MOUSE_SCROLL_EVENT:
mDetail = NS_STATIC_CAST(nsMouseScrollEvent*, mEvent)->delta;
break;
default:
break;
}
}
NS_IMPL_ADDREF_INHERITED(nsDOMMouseEvent, nsDOMUIEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMMouseEvent, nsDOMUIEvent)
NS_INTERFACE_MAP_BEGIN(nsDOMMouseEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseEvent)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(MouseEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
NS_IMETHODIMP
nsDOMMouseEvent::InitMouseEvent(const nsAString & aType, PRBool aCanBubble, PRBool aCancelable,
nsIDOMAbstractView *aView, PRInt32 aDetail, PRInt32 aScreenX,
PRInt32 aScreenY, PRInt32 aClientX, PRInt32 aClientY,
PRBool aCtrlKey, PRBool aAltKey, PRBool aShiftKey,
PRBool aMetaKey, PRUint16 aButton, nsIDOMEventTarget *aRelatedTarget)
{
nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
NS_ENSURE_SUCCESS(rv, rv);
switch(mEvent->eventStructType)
{
case NS_MOUSE_EVENT:
case NS_MOUSE_SCROLL_EVENT:
{
nsInputEvent* inputEvent = NS_STATIC_CAST(nsInputEvent*, mEvent);
inputEvent->isControl = aCtrlKey;
inputEvent->isAlt = aAltKey;
inputEvent->isShift = aShiftKey;
inputEvent->isMeta = aMetaKey;
inputEvent->point.x = aClientX;
inputEvent->point.y = aClientY;
inputEvent->refPoint.x = aScreenX;
inputEvent->refPoint.y = aScreenY;
mButton = aButton;
if (mEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) {
nsMouseScrollEvent* scrollEvent = NS_STATIC_CAST(nsMouseScrollEvent*, mEvent);
scrollEvent->delta = aDetail;
} else {
nsMouseEvent* mouseEvent = NS_STATIC_CAST(nsMouseEvent*, mEvent);
mouseEvent->clickCount = aDetail;
}
break;
}
default:
break;
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMMouseEvent::GetButton(PRUint16* aButton)
{
NS_ENSURE_ARG_POINTER(aButton);
if (!mEvent || mEvent->eventStructType != NS_MOUSE_EVENT) {
NS_WARNING("Tried to get mouse button for null or non-mouse event!");
*aButton = (PRUint16)-1;
return NS_OK;
}
// If button has been set then use that instead.
if (mButton > 0) {
*aButton = (PRUint16)mButton;
}
else {
switch (mEvent->message) {
case NS_MOUSE_LEFT_BUTTON_UP:
case NS_MOUSE_LEFT_BUTTON_DOWN:
case NS_MOUSE_LEFT_CLICK:
case NS_MOUSE_LEFT_DOUBLECLICK:
*aButton = 0;
break;
case NS_MOUSE_MIDDLE_BUTTON_UP:
case NS_MOUSE_MIDDLE_BUTTON_DOWN:
case NS_MOUSE_MIDDLE_CLICK:
case NS_MOUSE_MIDDLE_DOUBLECLICK:
*aButton = 1;
break;
case NS_MOUSE_RIGHT_BUTTON_UP:
case NS_MOUSE_RIGHT_BUTTON_DOWN:
case NS_MOUSE_RIGHT_CLICK:
case NS_MOUSE_RIGHT_DOUBLECLICK:
*aButton = 2;
break;
default:
break;
}
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMMouseEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
{
NS_ENSURE_ARG_POINTER(aRelatedTarget);
*aRelatedTarget = nsnull;
if (!mPresContext) {
return NS_OK;
}
nsCOMPtr<nsIContent> relatedContent;
mPresContext->EventStateManager()->
GetEventRelatedContent(getter_AddRefs(relatedContent));
if (!relatedContent) {
return NS_OK;
}
return CallQueryInterface(relatedContent, aRelatedTarget);
}
NS_METHOD nsDOMMouseEvent::GetScreenX(PRInt32* aScreenX)
{
NS_ENSURE_ARG_POINTER(aScreenX);
*aScreenX = GetScreenPoint().x;
return NS_OK;
}
NS_IMETHODIMP
nsDOMMouseEvent::GetScreenY(PRInt32* aScreenY)
{
NS_ENSURE_ARG_POINTER(aScreenY);
*aScreenY = GetScreenPoint().y;
return NS_OK;
}
NS_METHOD nsDOMMouseEvent::GetClientX(PRInt32* aClientX)
{
NS_ENSURE_ARG_POINTER(aClientX);
*aClientX = GetClientPoint().x;
return NS_OK;
}
NS_IMETHODIMP
nsDOMMouseEvent::GetClientY(PRInt32* aClientY)
{
NS_ENSURE_ARG_POINTER(aClientY);
*aClientY = GetClientPoint().y;
return NS_OK;
}
NS_IMETHODIMP
nsDOMMouseEvent::GetAltKey(PRBool* aIsDown)
{
NS_ENSURE_ARG_POINTER(aIsDown);
*aIsDown = ((nsInputEvent*)mEvent)->isAlt;
return NS_OK;
}
NS_IMETHODIMP
nsDOMMouseEvent::GetCtrlKey(PRBool* aIsDown)
{
NS_ENSURE_ARG_POINTER(aIsDown);
*aIsDown = ((nsInputEvent*)mEvent)->isControl;
return NS_OK;
}
NS_IMETHODIMP
nsDOMMouseEvent::GetShiftKey(PRBool* aIsDown)
{
NS_ENSURE_ARG_POINTER(aIsDown);
*aIsDown = ((nsInputEvent*)mEvent)->isShift;
return NS_OK;
}
NS_IMETHODIMP
nsDOMMouseEvent::GetMetaKey(PRBool* aIsDown)
{
NS_ENSURE_ARG_POINTER(aIsDown);
*aIsDown = ((nsInputEvent*)mEvent)->isMeta;
return NS_OK;
}
NS_IMETHODIMP
nsDOMMouseEvent::GetWhich(PRUint32* aWhich)
{
NS_ENSURE_ARG_POINTER(aWhich);
PRUint16 button;
(void) GetButton(&button);
*aWhich = button + 1;
return NS_OK;
}
nsresult NS_NewDOMMouseEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
nsInputEvent *aEvent)
{
nsDOMMouseEvent* it = new nsDOMMouseEvent(aPresContext, aEvent);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return CallQueryInterface(it, aInstancePtrResult);
}

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

@ -0,0 +1,72 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ilya Konstantinov (mozilla-code@future.shiny.co.il)
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDOMMouseEvent_h__
#define nsDOMMouseEvent_h__
#include "nsIDOMMouseEvent.h"
#include "nsDOMUIEvent.h"
class nsIContent;
class nsIScrollableView;
struct nsEvent;
class nsDOMMouseEvent : public nsIDOMMouseEvent,
public nsDOMUIEvent
{
public:
nsDOMMouseEvent(nsPresContext* aPresContext, nsInputEvent* aEvent);
NS_DECL_ISUPPORTS_INHERITED
// nsIDOMMouseEvent Interface
NS_DECL_NSIDOMMOUSEEVENT
// Forward to base class
NS_FORWARD_TO_NSDOMUIEVENT_NO_WHICH
// Specific implementation for a mouse event.
NS_IMETHOD GetWhich(PRUint32 *aWhich);
protected:
// These are used for internal data for user created events
PRInt16 mButton;
};
#endif // nsDOMMouseEvent_h__

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

@ -36,96 +36,70 @@
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsIDOMMutationEvent.h"
#include "nsDOMEvent.h"
#include "nsDOMMutationEvent.h"
#include "nsMutationEvent.h"
#include "nsContentUtils.h"
class nsPresContext;
class nsDOMMutationEvent : public nsDOMEvent, public nsIDOMMutationEvent
{
NS_DECL_NSIDOMMUTATIONEVENT
NS_FORWARD_NSIDOMEVENT(nsDOMEvent::)
NS_DECL_ISUPPORTS_INHERITED
nsDOMMutationEvent(nsPresContext* aPresContext,
nsEvent* aEvent);
~nsDOMMutationEvent();
};
nsDOMMutationEvent::nsDOMMutationEvent(nsPresContext* aPresContext,
nsEvent* aEvent)
:nsDOMEvent(aPresContext, aEvent, NS_LITERAL_STRING("MutationEvents"))
nsDOMMutationEvent::nsDOMMutationEvent(nsPresContext* aPresContext, nsMutationEvent* aEvent)
:nsDOMEvent(aPresContext, aEvent ? aEvent : new nsMutationEvent())
{
if ( aEvent ) {
mEventIsInternal = PR_FALSE;
mEventIsTrusted = PR_TRUE;
nsMutationEvent* mutation = (nsMutationEvent*)aEvent;
SetTarget(mutation->mTarget);
}
}
nsDOMMutationEvent::~nsDOMMutationEvent() {
else
{
mEventIsInternal = PR_TRUE;
mEventIsTrusted = PR_FALSE;
}
}
NS_INTERFACE_MAP_BEGIN(nsDOMMutationEvent)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMMutationEvent)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEvent, nsIDOMMutationEvent)
NS_INTERFACE_MAP_ENTRY(nsIPrivateDOMEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMMutationEvent)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(MutationEvent)
NS_INTERFACE_MAP_END
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
NS_IMPL_ADDREF_INHERITED(nsDOMMutationEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMMutationEvent, nsDOMEvent)
NS_IMETHODIMP
nsDOMMutationEvent::GetRelatedNode(nsIDOMNode** aRelatedNode)
{
*aRelatedNode = nsnull;
if (mEvent) {
nsMutationEvent* mutation = NS_STATIC_CAST(nsMutationEvent*, mEvent);
*aRelatedNode = mutation->mRelatedNode;
NS_IF_ADDREF(*aRelatedNode);
}
else *aRelatedNode = nsnull;
nsMutationEvent* mutation = NS_STATIC_CAST(nsMutationEvent*, mEvent);
*aRelatedNode = mutation->mRelatedNode;
NS_IF_ADDREF(*aRelatedNode);
return NS_OK;
}
NS_IMETHODIMP
nsDOMMutationEvent::GetPrevValue(nsAString& aPrevValue)
{
if (mEvent) {
nsMutationEvent* mutation = NS_STATIC_CAST(nsMutationEvent*, mEvent);
if (mutation && mutation->mPrevAttrValue)
mutation->mPrevAttrValue->ToString(aPrevValue);
}
nsMutationEvent* mutation = NS_STATIC_CAST(nsMutationEvent*, mEvent);
if (mutation->mPrevAttrValue)
mutation->mPrevAttrValue->ToString(aPrevValue);
return NS_OK;
}
NS_IMETHODIMP
nsDOMMutationEvent::GetNewValue(nsAString& aNewValue)
{
if (mEvent) {
nsMutationEvent* mutation = NS_STATIC_CAST(nsMutationEvent*, mEvent);
if (mutation && mutation->mNewAttrValue)
nsMutationEvent* mutation = NS_STATIC_CAST(nsMutationEvent*, mEvent);
if (mutation->mNewAttrValue)
mutation->mNewAttrValue->ToString(aNewValue);
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMMutationEvent::GetAttrName(nsAString& aAttrName)
{
if (mEvent) {
nsMutationEvent* mutation = NS_STATIC_CAST(nsMutationEvent*, mEvent);
if (mutation && mutation->mAttrName)
nsMutationEvent* mutation = NS_STATIC_CAST(nsMutationEvent*, mEvent);
if (mutation->mAttrName)
mutation->mAttrName->ToString(aAttrName);
}
return NS_OK;
}
@ -133,45 +107,35 @@ NS_IMETHODIMP
nsDOMMutationEvent::GetAttrChange(PRUint16* aAttrChange)
{
*aAttrChange = 0;
if (mEvent) {
nsMutationEvent* mutation = NS_STATIC_CAST(nsMutationEvent*, mEvent);
if (mutation && mutation->mAttrChange)
nsMutationEvent* mutation = NS_STATIC_CAST(nsMutationEvent*, mEvent);
if (mutation->mAttrChange)
*aAttrChange = mutation->mAttrChange;
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMMutationEvent::InitMutationEvent(const nsAString& aTypeArg, PRBool aCanBubbleArg,
PRBool aCancelableArg, nsIDOMNode* aRelatedNodeArg,
const nsAString& aPrevValueArg,
const nsAString& aNewValueArg,
const nsAString& aAttrNameArg,
PRUint16 aAttrChangeArg)
nsDOMMutationEvent::InitMutationEvent(const nsAString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, nsIDOMNode* aRelatedNodeArg, const nsAString& aPrevValueArg, const nsAString& aNewValueArg, const nsAString& aAttrNameArg, PRUint16 aAttrChangeArg)
{
NS_ENSURE_SUCCESS(SetEventType(aTypeArg), NS_ERROR_FAILURE);
mEvent->flags |= aCanBubbleArg ? NS_EVENT_FLAG_NONE : NS_EVENT_FLAG_CANT_BUBBLE;
mEvent->flags |= aCancelableArg ? NS_EVENT_FLAG_NONE : NS_EVENT_FLAG_CANT_CANCEL;
nsresult rv = nsDOMEvent::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
NS_ENSURE_SUCCESS(rv, rv);
nsMutationEvent* mutation = NS_STATIC_CAST(nsMutationEvent*, mEvent);
if (mutation) {
mutation->mRelatedNode = aRelatedNodeArg;
if (!aPrevValueArg.IsEmpty())
mutation->mPrevAttrValue = do_GetAtom(aPrevValueArg);
if (!aNewValueArg.IsEmpty())
mutation->mNewAttrValue = do_GetAtom(aNewValueArg);
if (!aAttrNameArg.IsEmpty()) {
mutation->mAttrName = do_GetAtom(aAttrNameArg);
}
mutation->mAttrChange = aAttrChangeArg;
mutation->mRelatedNode = aRelatedNodeArg;
if (!aPrevValueArg.IsEmpty())
mutation->mPrevAttrValue = do_GetAtom(aPrevValueArg);
if (!aNewValueArg.IsEmpty())
mutation->mNewAttrValue = do_GetAtom(aNewValueArg);
if (!aAttrNameArg.IsEmpty()) {
mutation->mAttrName = do_GetAtom(aAttrNameArg);
}
mutation->mAttrChange = aAttrChangeArg;
return NS_OK;
}
nsresult NS_NewDOMMutationEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
nsEvent *aEvent)
nsMutationEvent *aEvent)
{
nsDOMMutationEvent* it = new nsDOMMutationEvent(aPresContext, aEvent);
if (nsnull == it) {

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

@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDOMMutationEvent_h__
#define nsDOMMutationEvent_h__
#include "nsCOMPtr.h"
#include "nsIDOMMutationEvent.h"
#include "nsDOMEvent.h"
#include "nsContentUtils.h"
class nsDOMMutationEvent : public nsIDOMMutationEvent,
public nsDOMEvent
{
public:
nsDOMMutationEvent(nsPresContext* aPresContext, nsMutationEvent* aEvent);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMMUTATIONEVENT
// Forward to base class
NS_FORWARD_TO_NSDOMEVENT
};
#endif // nsDOMMutationEvent_h__

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

@ -0,0 +1,159 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Steve Clark (buster@netscape.com)
* Ilya Konstantinov (mozilla-code@future.shiny.co.il)
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDOMPopupBlockedEvent.h"
#include "nsIURI.h"
#include "nsContentUtils.h"
nsDOMPopupBlockedEvent::nsDOMPopupBlockedEvent(nsPresContext* aPresContext, nsPopupBlockedEvent* aEvent)
: nsDOMEvent(aPresContext, aEvent ? aEvent : new nsPopupBlockedEvent())
{
NS_ASSERTION(mEvent->eventStructType == NS_POPUP_BLOCKED_EVENT, "event type mismatch");
if (aEvent) {
mEventIsInternal = PR_FALSE;
mEventIsTrusted = PR_TRUE;
}
else {
mEventIsInternal = PR_TRUE;
mEventIsTrusted = PR_FALSE;
mEvent->time = PR_Now();
}
}
nsDOMPopupBlockedEvent::~nsDOMPopupBlockedEvent()
{
if (mEventIsInternal) {
if (mEvent->eventStructType == NS_POPUPBLOCKED_EVENT) {
nsPopupBlockedEvent* event = NS_STATIC_CAST(nsPopupBlockedEvent*, mEvent);
NS_IF_RELEASE(event->mRequestingWindowURI);
NS_IF_RELEASE(event->mPopupWindowURI);
}
}
}
NS_IMPL_ADDREF_INHERITED(nsDOMPopupBlockedEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMPopupBlockedEvent, nsDOMEvent)
NS_INTERFACE_MAP_BEGIN(nsDOMPopupBlockedEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMPopupBlockedEvent)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(PopupBlockedEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
NS_IMETHODIMP
nsDOMPopupBlockedEvent::InitPopupBlockedEvent(const nsAString & aTypeArg,
PRBool aCanBubbleArg, PRBool aCancelableArg,
nsIURI *aRequestingWindowURI,
nsIURI *aPopupWindowURI,
const nsAString & aPopupWindowFeatures)
{
nsresult rv = nsDOMEvent::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
NS_ENSURE_SUCCESS(rv, rv);
switch (mEvent->eventStructType)
{
case NS_POPUPBLOCKED_EVENT:
{
nsPopupBlockedEvent* event = NS_STATIC_CAST(nsPopupBlockedEvent*, mEvent);
event->mRequestingWindowURI = aRequestingWindowURI;
event->mPopupWindowURI = aPopupWindowURI;
NS_IF_ADDREF(event->mRequestingWindowURI);
NS_IF_ADDREF(event->mPopupWindowURI);
event->mPopupWindowFeatures = aPopupWindowFeatures;
break;
}
default:
break;
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMPopupBlockedEvent::GetRequestingWindowURI(nsIURI **aRequestingWindowURI)
{
NS_ENSURE_ARG_POINTER(aRequestingWindowURI);
if (mEvent->eventStructType == NS_POPUPBLOCKED_EVENT) {
nsPopupBlockedEvent* event = NS_STATIC_CAST(nsPopupBlockedEvent*, mEvent);
*aRequestingWindowURI = event->mRequestingWindowURI;
NS_IF_ADDREF(*aRequestingWindowURI);
return NS_OK;
}
*aRequestingWindowURI = 0;
return NS_OK; // Don't throw an exception
}
NS_IMETHODIMP
nsDOMPopupBlockedEvent::GetPopupWindowURI(nsIURI **aPopupWindowURI)
{
NS_ENSURE_ARG_POINTER(aPopupWindowURI);
if (mEvent->eventStructType == NS_POPUPBLOCKED_EVENT) {
nsPopupBlockedEvent* event = NS_STATIC_CAST(nsPopupBlockedEvent*, mEvent);
*aPopupWindowURI = event->mPopupWindowURI;
NS_IF_ADDREF(*aPopupWindowURI);
return NS_OK;
}
*aPopupWindowURI = 0;
return NS_OK; // Don't throw an exception
}
NS_IMETHODIMP
nsDOMPopupBlockedEvent::GetPopupWindowFeatures(nsAString &aPopupWindowFeatures)
{
if (mEvent->eventStructType == NS_POPUPBLOCKED_EVENT) {
nsPopupBlockedEvent* event = NS_STATIC_CAST(nsPopupBlockedEvent*, mEvent);
aPopupWindowFeatures = event->mPopupWindowFeatures;
return NS_OK;
}
aPopupWindowFeatures.Truncate();
return NS_OK; // Don't throw an exception
}
nsresult NS_NewDOMPopupBlockedEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
nsPopupBlockedEvent *aEvent)
{
nsDOMPopupBlockedEvent* it = new nsDOMPopupBlockedEvent(aPresContext, aEvent);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return CallQueryInterface(it, aInstancePtrResult);
}

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

@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ilya Konstantinov (mozilla-code@future.shiny.co.il)
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDOMPopupBlockedEvent_h__
#define nsDOMPopupBlockedEvent_h__
#include "nsIDOMPopupBlockedEvent.h"
#include "nsDOMEvent.h"
class nsDOMPopupBlockedEvent : public nsIDOMPopupBlockedEvent,
public nsDOMEvent
{
public:
nsDOMPopupBlockedEvent(nsPresContext* aPresContext, nsPopupBlockedEvent* aEvent);
virtual ~nsDOMPopupBlockedEvent();
NS_DECL_ISUPPORTS_INHERITED
// Forward to nsDOMEvent
NS_FORWARD_NSIDOMEVENT(nsDOMEvent::)
// nsIDOMPopupBlockedEvent Interface
NS_DECL_NSIDOMPOPUPBLOCKEDEVENT
};
#endif // nsDOMPopupBlockedEvent_h__

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

@ -0,0 +1,142 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ilya Konstantinov (mozilla-code@future.shiny.co.il)
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDOMTextEvent.h"
#include "nsContentUtils.h"
#include "nsPrivateTextRange.h"
nsDOMTextEvent::nsDOMTextEvent(nsPresContext* aPresContext, nsTextEvent* aEvent)
: nsDOMUIEvent(aPresContext, aEvent ? aEvent : new nsTextEvent())
{
NS_ASSERTION(mEvent->eventStructType == NS_TEXT_EVENT, "event type mismatch");
if (aEvent) {
mEventIsInternal = PR_FALSE;
mEventIsTrusted = PR_TRUE;
}
else {
mEventIsInternal = PR_TRUE;
mEventIsTrusted = PR_FALSE;
mEvent->time = PR_Now();
}
//
// extract the IME composition string
//
nsTextEvent *te = NS_STATIC_CAST(nsTextEvent*, aEvent);
mText = te->theText;
//
// build the range list -- ranges need to be DOM-ified since the
// IME transaction will hold a ref, the widget representation
// isn't persistent
//
nsIPrivateTextRange** tempTextRangeList = new nsIPrivateTextRange*[te->rangeCount];
if (tempTextRangeList) {
PRUint16 i;
for(i = 0; i < te->rangeCount; i++) {
nsPrivateTextRange* tempPrivateTextRange = new
nsPrivateTextRange(te->rangeArray[i].mStartOffset,
te->rangeArray[i].mEndOffset,
te->rangeArray[i].mRangeType);
if (tempPrivateTextRange) {
NS_ADDREF(tempPrivateTextRange);
tempTextRangeList[i] = (nsIPrivateTextRange*)tempPrivateTextRange;
}
}
}
// We need to create mTextRange even rangeCount is 0.
// If rangeCount is 0, mac carbon will return 0 for new and
// tempTextRangeList will be null. but we should still create
// mTextRange, otherwise, we will crash it later when some code
// call GetInputRange and AddRef to the result
mTextRange = new nsPrivateTextRangeList(te->rangeCount ,tempTextRangeList);
}
NS_IMPL_ADDREF_INHERITED(nsDOMTextEvent, nsDOMUIEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMTextEvent, nsDOMUIEvent)
NS_INTERFACE_MAP_BEGIN(nsDOMTextEvent)
NS_INTERFACE_MAP_ENTRY(nsIPrivateTextEvent)
NS_INTERFACE_MAP_ENTRY(nsIPrivateCompositionEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
NS_METHOD nsDOMTextEvent::GetText(nsString& aText)
{
aText = mText;
return NS_OK;
}
NS_METHOD nsDOMTextEvent::GetInputRange(nsIPrivateTextRangeList** aInputRange)
{
if (mEvent->message == NS_TEXT_TEXT)
{
*aInputRange = mTextRange;
return NS_OK;
}
aInputRange = 0;
return NS_ERROR_FAILURE;
}
NS_METHOD nsDOMTextEvent::GetEventReply(nsTextEventReply** aReply)
{
if (mEvent->message == NS_TEXT_TEXT)
{
*aReply = &(NS_STATIC_CAST(nsTextEvent*, mEvent)->theReply);
return NS_OK;
}
aReply = 0;
return NS_ERROR_FAILURE;
}
nsresult NS_NewDOMTextEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
nsTextEvent *aEvent)
{
nsDOMTextEvent* it = new nsDOMTextEvent(aPresContext, aEvent);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return CallQueryInterface(it, aInstancePtrResult);
}

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

@ -0,0 +1,67 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ilya Konstantinov (mozilla-code@future.shiny.co.il)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDOMTextEvent_h__
#define nsDOMTextEvent_h__
#include "nsDOMUIEvent.h"
#include "nsIPrivateTextEvent.h"
#include "nsIPrivateTextRange.h"
class nsDOMTextEvent : public nsDOMUIEvent,
public nsIPrivateTextEvent
{
public:
nsDOMTextEvent(nsPresContext* aPresContext, nsTextEvent* aEvent);
NS_DECL_ISUPPORTS_INHERITED
// Forward to base class
NS_FORWARD_TO_NSDOMUIEVENT
// nsIPrivateTextEvent interface
NS_IMETHOD GetText(nsString& aText);
NS_IMETHOD GetInputRange(nsIPrivateTextRangeList** aInputRange);
NS_IMETHOD GetEventReply(nsTextEventReply** aReply);
protected:
nsString mText;
nsCOMPtr<nsIPrivateTextRangeList> mTextRange;
};
#endif // nsDOMTextEvent_h__

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

@ -0,0 +1,484 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Steve Clark (buster@netscape.com)
* Ilya Konstantinov (mozilla-code@future.shiny.co.il)
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsDOMUIEvent.h"
#include "nsIPresShell.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIDOMWindowInternal.h"
#include "nsIDOMAbstractView.h"
#include "nsIDOMNode.h"
#include "nsIContent.h"
#include "nsContentUtils.h"
#include "nsIViewManager.h"
#include "nsIScrollableView.h"
#include "nsIWidget.h"
#include "nsIPresShell.h"
#include "nsIEventStateManager.h"
#include "nsIFrame.h"
nsDOMUIEvent::nsDOMUIEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent)
: nsDOMEvent(aPresContext, aEvent)
{
if (aEvent) {
mEventIsInternal = PR_FALSE;
mEventIsTrusted = PR_TRUE;
}
else {
mEventIsInternal = PR_TRUE;
mEventIsTrusted = PR_FALSE;
mEvent->time = PR_Now();
}
// Fill mDetail and mView according to the mEvent (widget-generated event) we've got
switch(mEvent->eventStructType)
{
case NS_UI_EVENT:
{
nsUIEvent *event = NS_STATIC_CAST(nsUIEvent*, mEvent);
mDetail = event->detail;
break;
}
case NS_SCROLLPORT_EVENT:
{
nsScrollPortEvent* scrollEvent = NS_STATIC_CAST(nsScrollPortEvent*, mEvent);
mDetail = (PRInt32)scrollEvent->orient;
break;
}
default:
mDetail = 0;
break;
}
mView = nsnull;
if (mPresContext)
{
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
if (container)
{
nsCOMPtr<nsIDOMWindowInternal> window = do_GetInterface(container);
if (window)
mView = do_QueryInterface(window);
}
}
}
NS_IMPL_ADDREF_INHERITED(nsDOMUIEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMUIEvent, nsDOMEvent)
NS_INTERFACE_MAP_BEGIN(nsDOMUIEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMUIEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSUIEvent)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(UIEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
nsPoint nsDOMUIEvent::GetScreenPoint() {
if (!mEvent ||
(mEvent->eventStructType != NS_MOUSE_EVENT &&
mEvent->eventStructType != NS_POPUP_EVENT &&
!NS_IS_DRAG_EVENT(mEvent))) {
return nsPoint(0, 0);
}
if (!((nsGUIEvent*)mEvent)->widget ) {
return mEvent->refPoint;
}
nsRect bounds(mEvent->refPoint, nsSize(1, 1));
nsRect offset;
((nsGUIEvent*)mEvent)->widget->WidgetToScreen ( bounds, offset );
return offset.TopLeft();
}
nsPoint nsDOMUIEvent::GetClientPoint() {
if (!mEvent ||
(mEvent->eventStructType != NS_MOUSE_EVENT &&
mEvent->eventStructType != NS_POPUP_EVENT &&
!NS_IS_DRAG_EVENT(mEvent)) ||
!mPresContext) {
return nsPoint(0, 0);
}
if (!((nsGUIEvent*)mEvent)->widget ) {
return mEvent->point;
}
//My god, man, there *must* be a better way to do this.
nsCOMPtr<nsIWidget> docWidget;
nsIPresShell *presShell = mPresContext->GetPresShell();
if (presShell) {
nsIViewManager* vm = presShell->GetViewManager();
if (vm) {
vm->GetWidget(getter_AddRefs(docWidget));
}
}
nsPoint pt = mEvent->refPoint;
nsCOMPtr<nsIWidget> eventWidget = ((nsGUIEvent*)mEvent)->widget;
while (eventWidget && docWidget != eventWidget) {
nsWindowType windowType;
eventWidget->GetWindowType(windowType);
if (windowType == eWindowType_popup)
break;
nsRect bounds;
eventWidget->GetBounds(bounds);
pt += bounds.TopLeft();
eventWidget = dont_AddRef(eventWidget->GetParent());
}
if (eventWidget != docWidget) {
// docWidget wasn't on the chain from the event widget to the root
// of the widget tree (or the nearest popup). OK, so now pt is
// relative to eventWidget; to get it relative to docWidget, we
// need to subtract docWidget's offset from eventWidget.
while (docWidget && docWidget != eventWidget) {
nsWindowType windowType;
docWidget->GetWindowType(windowType);
if (windowType == eWindowType_popup) {
// oh dear. the doc and the event were in different popups?
// That shouldn't happen.
NS_NOTREACHED("doc widget and event widget are in different popups. That's dumb.");
break;
}
nsRect bounds;
docWidget->GetBounds(bounds);
pt -= bounds.TopLeft();
docWidget = docWidget->GetParent();
}
}
return pt;
}
NS_IMETHODIMP
nsDOMUIEvent::GetView(nsIDOMAbstractView** aView)
{
*aView = mView;
NS_IF_ADDREF(*aView);
return NS_OK;
}
NS_IMETHODIMP
nsDOMUIEvent::GetDetail(PRInt32* aDetail)
{
*aDetail = mDetail;
return NS_OK;
}
NS_IMETHODIMP
nsDOMUIEvent::InitUIEvent(const nsAString & typeArg, PRBool canBubbleArg, PRBool cancelableArg, nsIDOMAbstractView *viewArg, PRInt32 detailArg)
{
nsresult rv = nsDOMEvent::InitEvent(typeArg, canBubbleArg, cancelableArg);
NS_ENSURE_SUCCESS(rv, rv);
mDetail = detailArg;
mView = viewArg;
return NS_OK;
}
// ---- nsDOMNSUIEvent implementation -------------------
NS_IMETHODIMP
nsDOMUIEvent::GetPageX(PRInt32* aPageX)
{
NS_ENSURE_ARG_POINTER(aPageX);
nsresult ret = NS_OK;
PRInt32 scrollX = 0;
nsIScrollableView* view = nsnull;
float p2t, t2p;
GetScrollInfo(&view, &p2t, &t2p);
if(view) {
nscoord xPos, yPos;
ret = view->GetScrollPosition(xPos, yPos);
scrollX = NSTwipsToIntPixels(xPos, t2p);
}
if (NS_SUCCEEDED(ret)) {
*aPageX = GetClientPoint().x + scrollX;
}
return ret;
}
NS_IMETHODIMP
nsDOMUIEvent::GetPageY(PRInt32* aPageY)
{
NS_ENSURE_ARG_POINTER(aPageY);
nsresult ret = NS_OK;
PRInt32 scrollY = 0;
nsIScrollableView* view = nsnull;
float p2t, t2p;
GetScrollInfo(&view, &p2t, &t2p);
if(view) {
nscoord xPos, yPos;
ret = view->GetScrollPosition(xPos, yPos);
scrollY = NSTwipsToIntPixels(yPos, t2p);
}
if (NS_SUCCEEDED(ret)) {
*aPageY = GetClientPoint().y + scrollY;
}
return ret;
}
NS_IMETHODIMP
nsDOMUIEvent::GetWhich(PRUint32* aWhich)
{
NS_ENSURE_ARG_POINTER(aWhich);
// Usually we never reach here, as this is reimplemented for mouse and keyboard events.
*aWhich = 0;
return NS_OK;
}
NS_IMETHODIMP
nsDOMUIEvent::GetRangeParent(nsIDOMNode** aRangeParent)
{
NS_ENSURE_ARG_POINTER(aRangeParent);
nsIFrame* targetFrame = nsnull;
if (mPresContext) {
mPresContext->EventStateManager()->GetEventTarget(&targetFrame);
}
*aRangeParent = nsnull;
if (targetFrame) {
nsCOMPtr<nsIContent> parent;
PRInt32 offset, endOffset;
PRBool beginOfContent;
if (NS_SUCCEEDED(targetFrame->GetContentAndOffsetsFromPoint(mPresContext,
mEvent->point,
getter_AddRefs(parent),
offset,
endOffset,
beginOfContent))) {
if (parent) {
return CallQueryInterface(parent, aRangeParent);
}
}
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMUIEvent::GetRangeOffset(PRInt32* aRangeOffset)
{
NS_ENSURE_ARG_POINTER(aRangeOffset);
nsIFrame* targetFrame = nsnull;
if (mPresContext) {
mPresContext->EventStateManager()->GetEventTarget(&targetFrame);
}
if (targetFrame) {
nsIContent* parent = nsnull;
PRInt32 endOffset;
PRBool beginOfContent;
if (NS_SUCCEEDED(targetFrame->GetContentAndOffsetsFromPoint(mPresContext,
mEvent->point,
&parent,
*aRangeOffset,
endOffset,
beginOfContent))) {
NS_IF_RELEASE(parent);
return NS_OK;
}
}
*aRangeOffset = 0;
return NS_OK;
}
NS_IMETHODIMP
nsDOMUIEvent::GetCancelBubble(PRBool* aCancelBubble)
{
NS_ENSURE_ARG_POINTER(aCancelBubble);
if (mEvent->flags & NS_EVENT_FLAG_BUBBLE || mEvent->flags & NS_EVENT_FLAG_INIT) {
*aCancelBubble = (mEvent->flags &= NS_EVENT_FLAG_STOP_DISPATCH) ? PR_TRUE : PR_FALSE;
}
else {
*aCancelBubble = PR_FALSE;
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMUIEvent::SetCancelBubble(PRBool aCancelBubble)
{
if (mEvent->flags & NS_EVENT_FLAG_BUBBLE || mEvent->flags & NS_EVENT_FLAG_INIT) {
if (aCancelBubble) {
mEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH;
}
else {
mEvent->flags &= ~NS_EVENT_FLAG_STOP_DISPATCH;
}
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMUIEvent::GetLayerX(PRInt32* aLayerX)
{
NS_ENSURE_ARG_POINTER(aLayerX);
if (!mEvent || (mEvent->eventStructType != NS_MOUSE_EVENT) ||
!mPresContext) {
*aLayerX = 0;
return NS_OK;
}
float t2p;
t2p = mPresContext->TwipsToPixels();
*aLayerX = NSTwipsToIntPixels(mEvent->point.x, t2p);
return NS_OK;
}
NS_IMETHODIMP
nsDOMUIEvent::GetLayerY(PRInt32* aLayerY)
{
NS_ENSURE_ARG_POINTER(aLayerY);
if (!mEvent || (mEvent->eventStructType != NS_MOUSE_EVENT) ||
!mPresContext) {
*aLayerY = 0;
return NS_OK;
}
float t2p;
t2p = mPresContext->TwipsToPixels();
*aLayerY = NSTwipsToIntPixels(mEvent->point.y, t2p);
return NS_OK;
}
NS_IMETHODIMP
nsDOMUIEvent::GetIsChar(PRBool* aIsChar)
{
switch(mEvent->eventStructType)
{
case NS_KEY_EVENT:
*aIsChar = ((nsKeyEvent*)mEvent)->isChar;
return NS_OK;
case NS_TEXT_EVENT:
*aIsChar = ((nsTextEvent*)mEvent)->isChar;
return NS_OK;
default:
*aIsChar = PR_FALSE;
return NS_OK;
}
}
NS_IMETHODIMP
nsDOMUIEvent::GetPreventDefault(PRBool* aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = mEvent ?
((mEvent->flags & NS_EVENT_FLAG_NO_DEFAULT) ? PR_TRUE : PR_FALSE) :
PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsDOMUIEvent::GetScrollInfo(nsIScrollableView** aScrollableView,
float* aP2T, float* aT2P)
{
NS_ENSURE_ARG_POINTER(aScrollableView);
NS_ENSURE_ARG_POINTER(aP2T);
NS_ENSURE_ARG_POINTER(aT2P);
if (!mPresContext) {
*aScrollableView = nsnull;
return NS_ERROR_FAILURE;
}
*aP2T = mPresContext->PixelsToTwips();
*aT2P = mPresContext->TwipsToPixels();
nsIPresShell *presShell = mPresContext->GetPresShell();
if (presShell) {
nsIViewManager* vm = presShell->GetViewManager();
if(vm) {
return vm->GetRootScrollableView(aScrollableView);
}
}
return NS_OK;
}
NS_METHOD nsDOMUIEvent::GetCompositionReply(nsTextEventReply** aReply)
{
if((mEvent->eventStructType == NS_RECONVERSION_EVENT) ||
(mEvent->message == NS_COMPOSITION_START) ||
(mEvent->message == NS_COMPOSITION_QUERY))
{
*aReply = &(NS_STATIC_CAST(nsCompositionEvent*, mEvent)->theReply);
return NS_OK;
}
*aReply = nsnull;
return NS_ERROR_FAILURE;
}
NS_METHOD
nsDOMUIEvent::GetReconversionReply(nsReconversionEventReply** aReply)
{
if (mEvent->eventStructType == NS_RECONVERSION_EVENT)
{
*aReply = &(NS_STATIC_CAST(nsReconversionEvent*, mEvent)->theReply);
return NS_OK;
}
aReply = nsnull;
return NS_ERROR_FAILURE;
}
nsresult NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
nsGUIEvent *aEvent)
{
nsDOMUIEvent* it = new nsDOMUIEvent(aPresContext, aEvent);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return CallQueryInterface(it, aInstancePtrResult);
}

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

@ -0,0 +1,106 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ilya Konstantinov (mozilla-code@future.shiny.co.il)
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDOMUIEvent_h__
#define nsDOMUIEvent_h__
#include "nsIDOMUIEvent.h"
#include "nsIDOMNSUIEvent.h"
#include "nsIPrivateCompositionEvent.h"
#include "nsDOMEvent.h"
class nsDOMUIEvent : public nsIDOMUIEvent,
public nsIDOMNSUIEvent,
public nsIPrivateCompositionEvent,
public nsDOMEvent
{
public:
nsDOMUIEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent);
NS_DECL_ISUPPORTS_INHERITED
// nsIDOMUIEvent Interface
NS_DECL_NSIDOMUIEVENT
// nsIDOMNSUIEvent Interface
NS_DECL_NSIDOMNSUIEVENT
// nsIPrivateCompositionEvent interface
NS_IMETHOD GetCompositionReply(nsTextEventReply** aReply);
NS_IMETHOD GetReconversionReply(nsReconversionEventReply** aReply);
// Forward to nsDOMEvent
NS_FORWARD_NSIDOMEVENT(nsDOMEvent::)
protected:
// Internal helper functions
nsresult GetScrollInfo(nsIScrollableView** aScrollableView, float* aP2T,
float* aT2P);
nsPoint GetClientPoint();
nsPoint GetScreenPoint();
protected:
nsCOMPtr<nsIDOMAbstractView> mView;
PRInt32 mDetail;
};
#define NS_FORWARD_NSIDOMNSUIEVENT_NO_WHICH(_to) \
NS_IMETHOD GetPreventDefault(PRBool *_retval) { return _to GetPreventDefault(_retval); } \
NS_IMETHOD GetLayerX(PRInt32 *aLayerX) { return _to GetLayerX(aLayerX); } \
NS_IMETHOD GetLayerY(PRInt32 *aLayerY) { return _to GetLayerY(aLayerY); } \
NS_IMETHOD GetPageX(PRInt32 *aPageX) { return _to GetPageX(aPageX); } \
NS_IMETHOD GetPageY(PRInt32 *aPageY) { return _to GetPageY(aPageY); } \
NS_IMETHOD GetRangeParent(nsIDOMNode * *aRangeParent) { return _to GetRangeParent(aRangeParent); } \
NS_IMETHOD GetRangeOffset(PRInt32 *aRangeOffset) { return _to GetRangeOffset(aRangeOffset); } \
NS_IMETHOD GetCancelBubble(PRBool *aCancelBubble) { return _to GetCancelBubble(aCancelBubble); } \
NS_IMETHOD SetCancelBubble(PRBool aCancelBubble) { return _to SetCancelBubble(aCancelBubble); } \
NS_IMETHOD GetIsChar(PRBool *aIsChar) { return _to GetIsChar(aIsChar); }
#define NS_FORWARD_TO_NSDOMUIEVENT \
NS_FORWARD_NSIDOMUIEVENT(nsDOMUIEvent::) \
NS_FORWARD_NSIDOMNSUIEVENT(nsDOMUIEvent::) \
NS_FORWARD_TO_NSDOMEVENT
#define NS_FORWARD_TO_NSDOMUIEVENT_NO_WHICH \
NS_FORWARD_NSIDOMUIEVENT(nsDOMUIEvent::) \
NS_FORWARD_NSIDOMNSUIEVENT_NO_WHICH(nsDOMUIEvent::) \
NS_FORWARD_TO_NSDOMEVENT
#endif // nsDOMUIEvent_h__

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

@ -301,12 +301,12 @@ static const EventDispatchData sMutationEvents[] = {
};
static const EventDispatchData sUIEvents[] = {
{ NS_DOMUI_ACTIVATE, HANDLER(&nsIDOMUIListener::Activate),
NS_EVENT_BITS_DOMUI_ACTIVATE },
{ NS_DOMUI_FOCUSIN, HANDLER(&nsIDOMUIListener::FocusIn),
NS_EVENT_BITS_DOMUI_FOCUSIN },
{ NS_DOMUI_FOCUSOUT, HANDLER(&nsIDOMUIListener::FocusOut),
NS_EVENT_BITS_DOMUI_FOCUSOUT }
{ NS_UI_ACTIVATE, HANDLER(&nsIDOMUIListener::Activate),
NS_EVENT_BITS_UI_ACTIVATE },
{ NS_UI_FOCUSIN, HANDLER(&nsIDOMUIListener::FocusIn),
NS_EVENT_BITS_UI_FOCUSIN },
{ NS_UI_FOCUSOUT, HANDLER(&nsIDOMUIListener::FocusOut),
NS_EVENT_BITS_UI_FOCUSOUT }
};
#define IMPL_EVENTTYPEDATA(type) \
@ -979,15 +979,15 @@ nsEventListenerManager::GetIdentifiersForType(nsIAtom* aType,
}
else if (aType == nsLayoutAtoms::onDOMActivate) {
*aArrayType = eEventArrayType_DOMUI;
*aFlags = NS_EVENT_BITS_DOMUI_ACTIVATE;
*aFlags = NS_EVENT_BITS_UI_ACTIVATE;
}
else if (aType == nsLayoutAtoms::onDOMFocusIn) {
*aArrayType = eEventArrayType_DOMUI;
*aFlags = NS_EVENT_BITS_DOMUI_FOCUSIN;
*aFlags = NS_EVENT_BITS_UI_FOCUSIN;
}
else if (aType == nsLayoutAtoms::onDOMFocusOut) {
*aArrayType = eEventArrayType_DOMUI;
*aFlags = NS_EVENT_BITS_DOMUI_FOCUSOUT;
*aFlags = NS_EVENT_BITS_UI_FOCUSOUT;
}
else {
return NS_ERROR_FAILURE;
@ -1580,10 +1580,7 @@ nsresult nsEventListenerManager::HandleEvent(nsPresContext* aPresContext,
found:
if (listeners) {
if (!*aDOMEvent) {
if (aEvent->eventStructType == NS_MUTATION_EVENT)
ret = NS_NewDOMMutationEvent(aDOMEvent, aPresContext, aEvent);
else
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, EmptyString(), aEvent);
ret = CreateEvent(aPresContext, aEvent, EmptyString(), aDOMEvent);
}
if (NS_SUCCEEDED(ret)) {
@ -1627,22 +1624,55 @@ nsEventListenerManager::CreateEvent(nsPresContext* aPresContext,
{
*aDOMEvent = nsnull;
nsAutoString str(aEventType);
if (!aEvent && !str.LowerCaseEqualsLiteral("mouseevents") &&
!str.LowerCaseEqualsLiteral("keyevents") &&
!str.LowerCaseEqualsLiteral("htmlevents") &&
!str.LowerCaseEqualsLiteral("mutationevents") &&
!str.LowerCaseEqualsLiteral("mousescrollevents") &&
!str.LowerCaseEqualsLiteral("popupblockedevents") &&
!str.LowerCaseEqualsLiteral("uievents") &&
!str.LowerCaseEqualsLiteral("events")) {
if (aEvent)
{
switch(aEvent->eventStructType)
{
case NS_MUTATION_EVENT:
return NS_NewDOMMutationEvent(aDOMEvent, aPresContext, NS_STATIC_CAST(nsMutationEvent*,aEvent));
case NS_GUI_EVENT:
return NS_NewDOMUIEvent(aDOMEvent, aPresContext, NS_STATIC_CAST(nsGUIEvent*,aEvent));
case NS_KEY_EVENT:
return NS_NewDOMKeyboardEvent(aDOMEvent, aPresContext, NS_STATIC_CAST(nsKeyEvent*,aEvent));
case NS_MOUSE_EVENT:
case NS_MOUSE_SCROLL_EVENT:
return NS_NewDOMMouseEvent(aDOMEvent, aPresContext, NS_STATIC_CAST(nsInputEvent*,aEvent));
case NS_POPUP_EVENT:
return NS_NewDOMPopupBlockedEvent(aDOMEvent, aPresContext, NS_STATIC_CAST(nsPopupBlockedEvent*,aEvent));
case NS_TEXT_EVENT:
return NS_NewDOMTextEvent(aDOMEvent, aPresContext, NS_STATIC_CAST(nsTextEvent*,aEvent));
default:
return NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
}
}
else
{
nsAutoString str(aEventType);
if (str.EqualsIgnoreCase("MouseEvent") ||
str.EqualsIgnoreCase("MouseEvents") ||
str.EqualsIgnoreCase("MouseScrollEvents"))
return NS_NewDOMMouseEvent(aDOMEvent, aPresContext, NS_STATIC_CAST(nsMouseEvent*,aEvent));
if (str.EqualsIgnoreCase("KeyboardEvent") ||
str.EqualsIgnoreCase("KeyEvents"))
return NS_NewDOMMouseEvent(aDOMEvent, aPresContext, NS_STATIC_CAST(nsKeyEvent*,aEvent));
if (str.EqualsIgnoreCase("MutationEvent") ||
str.EqualsIgnoreCase("MutationEvents"))
return NS_NewDOMMutationEvent(aDOMEvent, aPresContext, NS_STATIC_CAST(nsMutationEvent*,aEvent));
if (str.EqualsIgnoreCase("TextEvent") ||
str.EqualsIgnoreCase("TextEvents"))
return NS_NewDOMTextEvent(aDOMEvent, aPresContext, NS_STATIC_CAST(nsTextEvent*,aEvent));
if (str.EqualsIgnoreCase("PopupBlockedEvents"))
return NS_NewDOMPopupBlockedEvent(aDOMEvent, aPresContext, NS_STATIC_CAST(nsPopupBlockedEvent*,aEvent));
if (str.EqualsIgnoreCase("UIEvent") ||
str.EqualsIgnoreCase("UIEvents"))
return NS_NewDOMUIEvent(aDOMEvent, aPresContext, NS_STATIC_CAST(nsGUIEvent*,aEvent));
if (str.EqualsIgnoreCase("Event") ||
str.EqualsIgnoreCase("Events") ||
str.EqualsIgnoreCase("HTMLEvents"))
return NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
if ((aEvent && aEvent->eventStructType == NS_MUTATION_EVENT) ||
(!aEvent && str.LowerCaseEqualsLiteral("mutationevents")))
return NS_NewDOMMutationEvent(aDOMEvent, aPresContext, aEvent);
return NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEventType, aEvent);
}
/**
@ -2000,7 +2030,7 @@ nsEventListenerManager::FixContextMenuEvent(nsPresContext* aPresContext,
// the client X/Y will be 0,0. We can make use of that if the widget is null.
if (aEvent->message == NS_CONTEXTMENU_KEY)
NS_IF_RELEASE(((nsGUIEvent*)aEvent)->widget); // nulls out widget
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, EmptyString(), aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, NS_STATIC_CAST(nsGUIEvent*,aEvent));
}
if (NS_SUCCEEDED(ret)) {

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

@ -339,9 +339,9 @@ protected:
#define NS_EVENT_BITS_CONTEXT_MENU 0x01
// nsIDOMUIListener
#define NS_EVENT_BITS_DOMUI_NONE 0x00
#define NS_EVENT_BITS_DOMUI_ACTIVATE 0x01
#define NS_EVENT_BITS_DOMUI_FOCUSIN 0x02
#define NS_EVENT_BITS_DOMUI_FOCUSOUT 0x04
#define NS_EVENT_BITS_UI_NONE 0x00
#define NS_EVENT_BITS_UI_ACTIVATE 0x01
#define NS_EVENT_BITS_UI_FOCUSIN 0x02
#define NS_EVENT_BITS_UI_FOCUSOUT 0x04
#endif // nsEventListenerManager_h__

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

@ -0,0 +1,141 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ilya Konstantinov (mozilla-code@future.shiny.co.il)
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsRecycled_h__
#define nsRecycled_h__
#include "nsAutoPtr.h"
#include "prtypes.h"
/*
* A simple one-object recycler.
* Derive from this class if usually only one heap-allocated instance of your class
* exists at a time. This class accelerates heap allocations by keeping around
* a pre-allocated buffer the size of a single instance of your class.
*
* The OwnerType template parameter is given to differentiate inheriting classes. For instance,
* nsFoo should inherit from nsRecycledSingle<nsFoo>. If a hierarchy inherits from nsFoo,
* the same preallocated buffer would be used for instances of all derived classes, so you
* should ensure that usually only one instance of any of those classes exists at a time.
*
* Example:
* class nsFoo : public nsIBar, nsRecycledSingle<nsFoo>
* {
* ...
* };
*
*/
template<class OwnerType>
class nsRecycledSingle
{
public:
/* Initializes the memory to 0. */
void* operator new(size_t sz) CPP_THROW_NEW
{
void* result = nsnull;
if (!gPoolInUse)
{
if (gPoolSize >= sz)
{
result = gPool;
}
else
{
// Original pool, if any, is deleted by this plain assignment.
result = ::operator new(sz);
gPool = (char*)result;
gPoolSize = sz;
}
gPoolInUse = PR_TRUE;
}
else
{
if (sz > gPoolSize)
{
// This would be a good opportunity to throw away our
// current pool and replace it with this, larger one.
// Original pool will die as a regular allocated buffer
// when its time is due.
gPool.forget();
result = ::operator new(sz);
gPool = (char*)result;
gPoolSize = sz;
}
else
{
result = ::operator new(sz);
}
}
if (result) {
memset(result, 0, sz);
}
return result;
}
void operator delete(void* aPtr)
{
if (gPool == aPtr)
{
gPoolInUse = PR_FALSE;
return;
}
else
{
::operator delete(aPtr);
}
}
protected:
static nsAutoPtr<char> gPool;
static size_t gPoolSize;
static PRBool gPoolInUse;
};
template<class OwnerType>
nsAutoPtr<char> nsRecycledSingle<OwnerType>::gPool;
template<class OwnerType>
size_t nsRecycledSingle<OwnerType>::gPoolSize = 0;
template<class OwnerType>
PRBool nsRecycledSingle<OwnerType>::gPoolInUse = PR_FALSE;
#endif // nsRecycled_h__

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

@ -1459,7 +1459,7 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsPresContext* aPresContext,
// The default action is simply to dispatch DOMActivate
nsIPresShell *shell = aPresContext->GetPresShell();
if (shell) {
nsDOMUIEvent actEvent(NS_DOMUI_ACTIVATE, 1); // single-click
nsUIEvent actEvent(NS_UI_ACTIVATE, 1); // single-click
nsEventStatus status = nsEventStatus_eIgnore;
ret = shell->HandleDOMEventWithTarget(this, &actEvent, &status);
@ -1471,7 +1471,7 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsPresContext* aPresContext,
}
break;
case NS_DOMUI_ACTIVATE:
case NS_UI_ACTIVATE:
if (nsEventStatus_eConsumeNoDefault != *aEventStatus) {
nsAutoString target;
nsCOMPtr<nsIURI> baseURI = GetBaseURI();

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

@ -379,7 +379,7 @@ nsHTMLButtonElement::HandleDOMEvent(nsPresContext* aPresContext,
{
nsIPresShell *presShell = aPresContext->GetPresShell();
if (presShell) {
nsDOMUIEvent event(NS_DOMUI_ACTIVATE, 1); // single-click
nsUIEvent event(NS_UI_ACTIVATE, 1); // single-click
nsEventStatus status = nsEventStatus_eIgnore;
presShell->HandleDOMEventWithTarget(this, &event, &status);
@ -388,7 +388,7 @@ nsHTMLButtonElement::HandleDOMEvent(nsPresContext* aPresContext,
}
break;
case NS_DOMUI_ACTIVATE:
case NS_UI_ACTIVATE:
{
if (mForm) {
if (mType == NS_FORM_BUTTON_SUBMIT || mType == NS_FORM_BUTTON_RESET) {
@ -468,7 +468,7 @@ nsHTMLButtonElement::HandleDOMEvent(nsPresContext* aPresContext,
}
} else {
switch (aEvent->message) {
case NS_DOMUI_ACTIVATE:
case NS_UI_ACTIVATE:
if (mForm && mType == NS_FORM_BUTTON_SUBMIT) {
// tell the form to flush a possible pending submission.
// the reason is that the script returned false (the event was
@ -476,7 +476,7 @@ nsHTMLButtonElement::HandleDOMEvent(nsPresContext* aPresContext,
// be submitted immediatelly.
mForm->FlushPendingSubmission();
}
break;// NS_DOMUI_ACTIVATE
break;// NS_UI_ACTIVATE
} //switch
} //if
} //if

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

@ -1276,7 +1276,7 @@ nsHTMLInputElement::HandleDOMEvent(nsPresContext* aPresContext,
// Track whether we're in the "outer" HandleDOMEvent invocation
PRBool clickOrExtActivate =
(aEvent->message == NS_MOUSE_LEFT_CLICK ||
(aEvent->message == NS_DOMUI_ACTIVATE &&
(aEvent->message == NS_UI_ACTIVATE &&
!GET_BOOLBIT(mBitField, BF_IN_INTERNAL_ACTIVATE)));
PRBool originalCheckedValue = PR_FALSE;
@ -1361,7 +1361,7 @@ nsHTMLInputElement::HandleDOMEvent(nsPresContext* aPresContext,
if (*aEventStatus != nsEventStatus_eConsumeNoDefault &&
!(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT) &&
aEvent->message == NS_MOUSE_LEFT_CLICK && mType != NS_FORM_INPUT_TEXT) {
nsDOMUIEvent actEvent(NS_DOMUI_ACTIVATE, 1);
nsUIEvent actEvent(NS_UI_ACTIVATE, 1);
nsIPresShell *shell = aPresContext->GetPresShell();
if (shell) {

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

@ -79,6 +79,10 @@ enum nsDOMClassInfoID {
// Event classes
eDOMClassInfo_Event_id,
eDOMClassInfo_MutationEvent_id,
eDOMClassInfo_UIEvent_id,
eDOMClassInfo_MouseEvent_id,
eDOMClassInfo_KeyboardEvent_id,
eDOMClassInfo_PopupBlockedEvent_id,
// HTML classes
eDOMClassInfo_HTMLDocument_id,

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

@ -197,6 +197,8 @@
#include "nsIDOMEntity.h"
#include "nsIDOMEntityReference.h"
#include "nsIDOMNotation.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMPopupBlockedEvent.h"
#include "nsIDOMMutationEvent.h"
@ -516,6 +518,14 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(MutationEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(UIEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(MouseEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(KeyboardEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(PopupBlockedEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
// Misc HTML classes
NS_DEFINE_CLASSINFO_DATA(HTMLDocument, nsHTMLDocumentSH,
@ -1345,6 +1355,15 @@ nsDOMClassInfo::RegisterExternalClasses()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) \
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
#define DOM_CLASSINFO_EVENT_MAP_ENTRIES \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent) \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEvent) \
#define DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMUIEvent) \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSUIEvent) \
DOM_CLASSINFO_EVENT_MAP_ENTRIES
#define DOM_CLASSINFO_MAP_END_WITH_XPATH \
xpathEvaluatorIID, \
DOM_CLASSINFO_MAP_END
@ -1547,17 +1566,33 @@ nsDOMClassInfo::Init()
nsIDOMStyleSheetList)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStyleSheetList)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(Event, nsIDOMEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMKeyEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
DOM_CLASSINFO_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(PopupBlockedEvent, nsIDOMPopupBlockedEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMPopupBlockedEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSUIEvent)
DOM_CLASSINFO_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(MutationEvent, nsIDOMMutationEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMutationEvent)
DOM_CLASSINFO_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(UIEvent, nsIDOMUIEvent)
DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(KeyboardEvent, nsIDOMKeyEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMKeyEvent)
DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(MouseEvent, nsIDOMMouseEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(HTMLDocument, nsIDOMHTMLDocument)

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

@ -89,7 +89,7 @@ class nsIURI;
#define NS_APPCOMMAND_EVENT 24
#define NS_POPUPBLOCKED_EVENT 25
#define NS_BEFORE_PAGE_UNLOAD_EVENT 26
#define NS_DOMUI_EVENT 27
#define NS_UI_EVENT 27
#define NS_EVENT_FLAG_NONE 0x0000
#define NS_EVENT_FLAG_INIT 0x0001
@ -102,6 +102,7 @@ class nsIURI;
#define NS_PRIV_EVENT_FLAG_SCRIPT 0x0080
#define NS_EVENT_FLAG_NO_CONTENT_DISPATCH 0x0100
#define NS_EVENT_FLAG_SYSTEM_EVENT 0x0200
#define NS_EVENT_FLAG_STOP_DISPATCH_IMMEDIATELY 0x0400 // @see nsIDOM3Event::stopImmediatePropagation()
#define NS_EVENT_CAPTURE_MASK (~(NS_EVENT_FLAG_INIT | 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))
@ -301,12 +302,12 @@ class nsIURI;
#define NS_TEXT_START 2400
#define NS_TEXT_TEXT (NS_TEXT_START)
// DOM UI events
#define NS_DOMUI_EVENT_START 2500
// UI events
#define NS_UI_EVENT_START 2500
// this is not to be confused with NS_ACTIVATE!
#define NS_DOMUI_ACTIVATE (NS_DOMUI_EVENT_START)
#define NS_DOMUI_FOCUSIN (NS_DOMUI_EVENT_START + 1)
#define NS_DOMUI_FOCUSOUT (NS_DOMUI_EVENT_START + 2)
#define NS_UI_ACTIVATE (NS_UI_EVENT_START)
#define NS_UI_FOCUSIN (NS_UI_EVENT_START + 1)
#define NS_UI_FOCUSOUT (NS_UI_EVENT_START + 2)
/**
* Return status for event processors, nsEventStatus, is defined in
@ -813,10 +814,10 @@ struct nsPopupBlockedEvent : public nsEvent
/**
* DOM UIEvent
*/
struct nsDOMUIEvent : public nsEvent {
nsDOMUIEvent(PRUint32 msg = 0,
struct nsUIEvent : public nsEvent {
nsUIEvent(PRUint32 msg = 0,
PRInt32 d = 0,
PRUint8 structType = NS_DOMUI_EVENT)
PRUint8 structType = NS_UI_EVENT)
: nsEvent(msg, structType),
detail(d)
{