Breaking nsIDOMEvent out into nsIDOMEvent and nsIDOMUIEvent.

This commit is contained in:
joki%netscape.com 1999-05-18 23:51:04 +00:00
parent 1ed1220ae6
commit 71e96012a3
32 changed files with 1895 additions and 1703 deletions

View File

@ -39,5 +39,6 @@ public:
};
extern nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext& aPresContext, nsEvent *aEvent);
extern nsresult NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext& aPresContext, nsEvent *aEvent);
#endif // nsIPrivateDOMEvent_h__

View File

@ -28,7 +28,8 @@ static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
static NS_DEFINE_IID(kIDOMEventIID, NS_IDOMEVENT_IID);
static NS_DEFINE_IID(kIDOMNSEventIID, NS_IDOMNSEVENT_IID);
static NS_DEFINE_IID(kIDOMUIEventIID, NS_IDOMUIEVENT_IID);
static NS_DEFINE_IID(kIDOMNSUIEventIID, NS_IDOMNSUIEVENT_IID);
static NS_DEFINE_IID(kIPrivateDOMEventIID, NS_IPRIVATEDOMEVENT_IID);
static char* mEventNames[] = {
@ -75,8 +76,13 @@ nsresult nsDOMEvent::QueryInterface(const nsIID& aIID,
AddRef();
return NS_OK;
}
if (aIID.Equals(kIDOMNSEventIID)) {
*aInstancePtrResult = (void*) ((nsIDOMNSEvent*)this);
if (aIID.Equals(kIDOMUIEventIID)) {
*aInstancePtrResult = (void*) ((nsIDOMUIEvent*)this);
AddRef();
return NS_OK;
}
if (aIID.Equals(kIDOMNSUIEventIID)) {
*aInstancePtrResult = (void*) ((nsIDOMNSUIEvent*)this);
AddRef();
return NS_OK;
}
@ -101,35 +107,6 @@ NS_METHOD nsDOMEvent::GetType(nsString& aType)
return NS_ERROR_FAILURE;
}
NS_METHOD nsDOMEvent::GetText(nsString& aText)
{
if (mEvent->message == NS_TEXT_EVENT) {
aText = *mText;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_METHOD nsDOMEvent::GetCommitText(PRBool* aCommitText)
{
if (mEvent->message == NS_TEXT_EVENT) {
*aCommitText = mCommitText;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_METHOD nsDOMEvent::SetCommitText(PRBool aCommitText)
{
return NS_ERROR_FAILURE;
}
NS_METHOD nsDOMEvent::SetType(const nsString& aType)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetTarget(nsIDOMNode** aTarget)
{
if (nsnull != mTarget) {
@ -158,34 +135,73 @@ NS_METHOD nsDOMEvent::GetTarget(nsIDOMNode** aTarget)
return NS_OK;
}
NS_METHOD nsDOMEvent::SetTarget(nsIDOMNode* aTarget)
NS_IMETHODIMP
nsDOMEvent::GetCurrentNode(nsIDOMNode** aCurrentNode)
{
if (mTarget != aTarget) {
NS_IF_RELEASE(mTarget);
NS_IF_ADDREF(aTarget);
mTarget = aTarget;
}
*aCurrentNode = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsDOMEvent::GetEventPhase(PRUint16* aEventPhase)
{
*aEventPhase = 0;
return NS_OK;
}
NS_IMETHODIMP
nsDOMEvent::PreventBubble()
{
return NS_OK;
}
NS_IMETHODIMP
nsDOMEvent::PreventCapture()
{
return NS_OK;
}
NS_IMETHODIMP
nsDOMEvent::PreventDefault()
{
return NS_OK;
}
NS_METHOD nsDOMEvent::GetText(nsString& aText)
{
if (mEvent->message == NS_TEXT_EVENT) {
aText = *mText;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_METHOD nsDOMEvent::GetCommitText(PRBool* aCommitText)
{
if (mEvent->message == NS_TEXT_EVENT) {
*aCommitText = mCommitText;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_METHOD nsDOMEvent::SetCommitText(PRBool aCommitText)
{
return NS_ERROR_FAILURE;
}
NS_METHOD nsDOMEvent::GetScreenX(PRInt32* aScreenX)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::SetScreenX(PRInt32 aScreenX)
{
return NS_ERROR_NOT_IMPLEMENTED;
*aScreenX = 0;
return NS_OK;
}
NS_METHOD nsDOMEvent::GetScreenY(PRInt32* aScreenY)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::SetScreenY(PRInt32 aScreenY)
{
return NS_ERROR_NOT_IMPLEMENTED;
*aScreenY = 0;
return NS_OK;
}
NS_METHOD nsDOMEvent::GetClientX(PRInt32* aClientX)
@ -196,11 +212,6 @@ NS_METHOD nsDOMEvent::GetClientX(PRInt32* aClientX)
return NS_OK;
}
NS_METHOD nsDOMEvent::SetClientX(PRInt32 aClientX)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetClientY(PRInt32* aClientY)
{
float t2p;
@ -209,54 +220,29 @@ NS_METHOD nsDOMEvent::GetClientY(PRInt32* aClientY)
return NS_OK;
}
NS_METHOD nsDOMEvent::SetClientY(PRInt32 aClientY)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetAltKey(PRBool* aIsDown)
{
*aIsDown = ((nsInputEvent*)mEvent)->isAlt;
return NS_OK;
}
NS_METHOD nsDOMEvent::SetAltKey(PRBool aAltKey)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetCtrlKey(PRBool* aIsDown)
{
*aIsDown = ((nsInputEvent*)mEvent)->isControl;
return NS_OK;
}
NS_METHOD nsDOMEvent::SetCtrlKey(PRBool aCtrlKey)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetShiftKey(PRBool* aIsDown)
{
*aIsDown = ((nsInputEvent*)mEvent)->isShift;
return NS_OK;
}
NS_METHOD nsDOMEvent::SetShiftKey(PRBool aShiftKey)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetMetaKey(PRBool* aIsDown)
{
return NS_OK;
}
NS_METHOD nsDOMEvent::SetMetaKey(PRBool aMetaKey)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetCharCode(PRUint32* aCharCode)
{
switch (mEvent->message) {
@ -270,16 +256,11 @@ NS_METHOD nsDOMEvent::GetCharCode(PRUint32* aCharCode)
#endif
break;
default:
return NS_ERROR_FAILURE;
break;
}
return NS_OK;
}
NS_METHOD nsDOMEvent::SetCharCode(PRUint32 aCharCode)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetKeyCode(PRUint32* aKeyCode)
{
switch (mEvent->message) {
@ -289,16 +270,11 @@ NS_METHOD nsDOMEvent::GetKeyCode(PRUint32* aKeyCode)
*aKeyCode = ((nsKeyEvent*)mEvent)->keyCode;
break;
default:
return NS_ERROR_FAILURE;
break;
}
return NS_OK;
}
NS_METHOD nsDOMEvent::SetKeyCode(PRUint32 aKeyCode)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetButton(PRUint32* aButton)
{
switch (mEvent->message) {
@ -321,65 +297,34 @@ NS_METHOD nsDOMEvent::GetButton(PRUint32* aButton)
*aButton = 3;
break;
default:
return NS_ERROR_FAILURE;
break;
}
return NS_OK;
}
NS_METHOD nsDOMEvent::SetButton(PRUint32 aButton)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetCancelBubble(PRBool* aCancelBubble)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::SetCancelBubble(PRBool aCancelBubble)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
// nsINSEventInterface
NS_METHOD nsDOMEvent::GetLayerX(PRInt32* aLayerX)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::SetLayerX(PRInt32 aLayerX)
{
return NS_ERROR_NOT_IMPLEMENTED;
*aLayerX = 0;
return NS_OK;
}
NS_METHOD nsDOMEvent::GetLayerY(PRInt32* aLayerY)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::SetLayerY(PRInt32 aLayerY)
{
return NS_ERROR_NOT_IMPLEMENTED;
*aLayerY = 0;
return NS_OK;
}
NS_METHOD nsDOMEvent::GetPageX(PRInt32* aPageX)
{
return GetClientX(aPageX);
}
NS_METHOD nsDOMEvent::SetPageX(PRInt32 aPageX)
{
return SetClientX(aPageX);
*aPageX = 0;
return NS_OK;
}
NS_METHOD nsDOMEvent::GetPageY(PRInt32* aPageY)
{
return GetClientY(aPageY);
}
NS_METHOD nsDOMEvent::SetPageY(PRInt32 aPageY)
{
return SetClientY(aPageY);
*aPageY = 0;
return NS_OK;
}
NS_METHOD nsDOMEvent::GetWhich(PRUint32* aWhich)
@ -390,18 +335,7 @@ NS_METHOD nsDOMEvent::GetWhich(PRUint32* aWhich)
case NS_MOUSE_EVENT:
return GetButton(aWhich);
}
return NS_ERROR_FAILURE;
}
NS_METHOD nsDOMEvent::SetWhich(PRUint32 aWhich)
{
switch (mEvent->eventStructType) {
case NS_KEY_EVENT:
return SetKeyCode(aWhich);
case NS_MOUSE_EVENT:
return SetButton(aWhich);
}
return NS_ERROR_FAILURE;
return NS_OK;
}
NS_METHOD nsDOMEvent::DuplicatePrivateData()
@ -465,7 +399,7 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
case NS_PAINT:
return mEventNames[eDOMEvents_paint];
case NS_TEXT_EVENT:
return mEventNames[eDOMEvents_text];
return mEventNames[eDOMEvents_text];
default:
break;
}
@ -490,7 +424,7 @@ nsDOMEvent::GetRc(nsIDOMRenderingContext** aRc)
return NS_OK;
}
nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext& aPresContext, nsEvent *aEvent)
nsresult NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext& aPresContext, nsEvent *aEvent)
{
nsDOMEvent* it = new nsDOMEvent(&aPresContext, aEvent);
if (nsnull == it) {
@ -499,3 +433,8 @@ nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext& aPresC
return it->QueryInterface(kIDOMEventIID, (void **) aInstancePtrResult);
}
nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext& aPresContext, nsEvent *aEvent)
{
return NS_ERROR_FAILURE;
}

View File

@ -19,8 +19,8 @@
#ifndef nsDOMEvent_h__
#define nsDOMEvent_h__
#include "nsIDOMEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMUIEvent.h"
#include "nsIDOMNSUIEvent.h"
#include "nsISupports.h"
#include "nsIPrivateDOMEvent.h"
@ -31,7 +31,7 @@ class nsIContent;
class nsIDOMRenderingContext;
class nsDOMEvent : public nsIDOMEvent, public nsIDOMNSEvent, public nsIPrivateDOMEvent {
class nsDOMEvent : public nsIDOMUIEvent, public nsIDOMNSUIEvent, public nsIPrivateDOMEvent {
public:
// Note: this enum must be kept in sync with mEventNames in nsDOMEvent.cpp
@ -66,67 +66,56 @@ public:
// nsIDOMEventInterface
NS_IMETHOD GetType(nsString& aType);
NS_IMETHOD SetType(const nsString& aType);
NS_IMETHOD GetText(nsString& aText);
NS_IMETHOD GetCommitText(PRBool* aCommitText);
NS_IMETHOD SetCommitText(PRBool aCommitText);
NS_IMETHOD GetTarget(nsIDOMNode** aTarget);
NS_IMETHOD SetTarget(nsIDOMNode* aTarget);
NS_IMETHOD GetCurrentNode(nsIDOMNode** aCurrentNode);
NS_IMETHOD GetEventPhase(PRUint16* aEventPhase);
NS_IMETHOD PreventBubble();
NS_IMETHOD PreventCapture();
NS_IMETHOD PreventDefault();
NS_IMETHOD GetText(nsString& aText);
NS_IMETHOD GetCommitText(PRBool* aCommitText);
NS_IMETHOD SetCommitText(PRBool aCommitText);
NS_IMETHOD GetScreenX(PRInt32* aScreenX);
NS_IMETHOD SetScreenX(PRInt32 aScreenX);
NS_IMETHOD GetScreenY(PRInt32* aScreenY);
NS_IMETHOD SetScreenY(PRInt32 aScreenY);
NS_IMETHOD GetClientX(PRInt32* aClientX);
NS_IMETHOD SetClientX(PRInt32 aClientX);
NS_IMETHOD GetClientY(PRInt32* aClientY);
NS_IMETHOD SetClientY(PRInt32 aClientY);
NS_IMETHOD GetAltKey(PRBool* aAltKey);
NS_IMETHOD SetAltKey(PRBool aAltKey);
NS_IMETHOD GetCtrlKey(PRBool* aCtrlKey);
NS_IMETHOD SetCtrlKey(PRBool aCtrlKey);
NS_IMETHOD GetShiftKey(PRBool* aShiftKey);
NS_IMETHOD SetShiftKey(PRBool aShiftKey);
NS_IMETHOD GetMetaKey(PRBool* aMetaKey);
NS_IMETHOD SetMetaKey(PRBool aMetaKey);
NS_IMETHOD GetCharCode(PRUint32* aCharCode);
NS_IMETHOD SetCharCode(PRUint32 aCharCode);
NS_IMETHOD GetKeyCode(PRUint32* aKeyCode);
NS_IMETHOD SetKeyCode(PRUint32 aKeyCode);
NS_IMETHOD GetButton(PRUint32* aButton);
NS_IMETHOD SetButton(PRUint32 aButton);
NS_IMETHOD GetCancelBubble(PRBool* aCancelBubble);
NS_IMETHOD SetCancelBubble(PRBool aCancelBubble);
// nsIDOMNSEvent interface
NS_IMETHOD GetLayerX(PRInt32* aLayerX);
NS_IMETHOD SetLayerX(PRInt32 aLayerX);
NS_IMETHOD GetLayerY(PRInt32* aLayerY);
NS_IMETHOD SetLayerY(PRInt32 aLayerY);
NS_IMETHOD GetPageX(PRInt32* aClientX);
NS_IMETHOD SetPageX(PRInt32 aClientX);
NS_IMETHOD GetPageY(PRInt32* aClientY);
NS_IMETHOD SetPageY(PRInt32 aClientY);
NS_IMETHOD GetWhich(PRUint32* aKeyCode);
NS_IMETHOD SetWhich(PRUint32 aKeyCode);
NS_IMETHOD GetRc(nsIDOMRenderingContext** aRc);

View File

@ -469,7 +469,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
case NS_MOUSE_EXIT:
if (nsnull != mMouseListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
if (NS_OK == ret) {
for (int i=0; i<mMouseListeners->Count(); i++) {
@ -571,7 +571,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
case NS_MOUSE_MOVE:
if (nsnull != mMouseMotionListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
if (NS_OK == ret) {
for (int i=0; i<mMouseMotionListeners->Count(); i++) {
@ -620,7 +620,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
#endif
if (nsnull != mCompositionListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent,aPresContext,aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent,aPresContext,aEvent);
}
if (NS_OK == ret) {
for(int i=0;i<mTextListeners->Count();i++) {
@ -671,7 +671,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
#endif
if (nsnull != mTextListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent,aPresContext,aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent,aPresContext,aEvent);
}
if (NS_OK == ret) {
for (int i=0; i<mTextListeners->Count(); i++) {
@ -706,7 +706,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
case NS_KEY_PRESS:
if (nsnull != mKeyListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
if (NS_OK == ret) {
for (int i=0; i<mKeyListeners->Count(); i++) {
@ -768,7 +768,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
case NS_BLUR_CONTENT:
if (nsnull != mFocusListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
if (NS_OK == ret) {
for (int i=0; i<mFocusListeners->Count(); i++) {
@ -823,7 +823,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
case NS_FORM_CHANGE:
if (nsnull != mFormListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
if (NS_OK == ret) {
for (int i=0; i<mFormListeners->Count(); i++) {
@ -885,7 +885,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
case NS_PAGE_UNLOAD:
if (nsnull != mLoadListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
if (NS_OK == ret) {
for (int i=0; i<mLoadListeners->Count(); i++) {
@ -938,7 +938,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
case NS_PAINT:
if (nsnull != mPaintListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
if (NS_OK == ret) {
for (int i=0; i<mPaintListeners->Count(); i++) {
@ -977,7 +977,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
case NS_DRAGDROP_DROP:
if (nsnull != mDragListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
if (NS_OK == ret) {
@ -1033,7 +1033,7 @@ nsresult nsEventListenerManager::CreateEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent)
{
return NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
return NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
/**

View File

@ -113,6 +113,9 @@ nsEventStateManager::PreHandleEvent(nsIPresContext& aPresContext,
case NS_GOTFOCUS:
//XXX Do we need window related focus change stuff here?
break;
case NS_LOSTFOCUS:
//XXX Do we need window related focus change stuff here?
break;
}
return NS_OK;
}

View File

@ -2238,7 +2238,7 @@ RDFElementImpl::HandleDOMEvent(nsIPresContext& aPresContext,
NS_ERROR("Menu/key event will fail without the ability to create the event early.");
return ret;
}
domEvent->SetTarget(this);
//domEvent->SetTarget(this);
}
}

View File

@ -33,6 +33,7 @@
#include "nsIDOMXULDocument.h"
#include "nsIDocument.h"
#include "nsIContent.h"
#include "nsIDOMUIEvent.h"
////////////////////////////////////////////////////////////////////////
@ -150,10 +151,17 @@ XULPopupListenerImpl::MouseDown(nsIDOMEvent* aMouseEvent)
{
PRUint32 button;
nsCOMPtr<nsIDOMUIEvent>uiEvent;
uiEvent = do_QueryInterface(aMouseEvent);
if (!uiEvent) {
//non-ui event passed in. bad things.
return NS_OK;
}
switch (popupType) {
case eXULPopupType_popup:
// Check for left mouse button down
aMouseEvent->GetButton(&button);
uiEvent->GetButton(&button);
if (button == 1) {
// Time to launch a popup menu.
LaunchPopup(aMouseEvent);
@ -161,7 +169,7 @@ XULPopupListenerImpl::MouseDown(nsIDOMEvent* aMouseEvent)
break;
case eXULPopupType_context:
// Check for right mouse button down
aMouseEvent->GetButton(&button);
uiEvent->GetButton(&button);
// XXX: Handle Mac
if (button == 3) {
// Time to launch a context menu.
@ -237,10 +245,19 @@ XULPopupListenerImpl::LaunchPopup(nsIDOMEvent* anEvent)
if (anchorAlignment == "") {
// We aren't anchored. Create on the point.
// Retrieve our x and y position.
PRInt32 xPos = 50;
PRInt32 yPos = 50; // For now, hardcode to (50,50), since screen doesn't work.
anEvent->GetScreenX(&xPos);
anEvent->GetScreenY(&yPos);
nsCOMPtr<nsIDOMUIEvent>uiEvent;
uiEvent = do_QueryInterface(anEvent);
if (!uiEvent) {
//non-ui event passed in. bad things.
return NS_OK;
}
PRInt32 xPos;
PRInt32 yPos;
uiEvent->GetScreenX(&xPos);
uiEvent->GetScreenY(&yPos);
xPos = 50; // For now, hardcode to (50,50), since screen doesn't work.
yPos = 50;
domWindow->CreatePopup(element, popupContent,
xPos, yPos,

View File

@ -3,7 +3,8 @@
#
nsIDOMEvent.h
nsIDOMNSEvent.h
nsIDOMUIEvent.h
nsIDOMNSUIEvent.h
nsIDOMEventListener.h
nsIDOMEventCapturer.h
nsIDOMEventReceiver.h

View File

@ -27,6 +27,7 @@ DEFINES += -D_IMPL_NS_DOM
EXPORTS = \
nsIDOMEvent.h \
nsIDOMUIEvent.h \
nsIDOMEventListener.h \
nsIDOMEventCapturer.h \
nsIDOMEventReceiver.h \
@ -38,7 +39,7 @@ EXPORTS = \
nsIDOMMouseMotionListener.h \
nsIDOMPaintListener.h \
nsIDOMDragListener.h \
nsIDOMNSEvent.h \
nsIDOMNSUIEvent.h \
nsIDOMEventTarget.h \
nsIDOMTextListener.h \
nsIDOMCompositionListener.h \

View File

@ -22,6 +22,7 @@ DEFINES=-D_IMPL_NS_DOM
EXPORTS = \
nsIDOMEvent.h \
nsIDOMUIEvent.h \
nsIDOMEventListener.h \
nsIDOMEventCapturer.h \
nsIDOMEventReceiver.h \
@ -33,7 +34,7 @@ EXPORTS = \
nsIDOMMouseMotionListener.h \
nsIDOMPaintListener.h \
nsIDOMDragListener.h \
nsIDOMNSEvent.h \
nsIDOMNSUIEvent.h \
nsIDOMEventTarget.h \
nsIDOMTextListener.h \
nsIDOMCompositionListener.h \

View File

@ -27,243 +27,53 @@
class nsIDOMNode;
#define NS_IDOMEVENT_IID \
{ 0xa6cf90c3, 0x15b3, 0x11d2, \
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
{ 0xa66b7b80, 0xff46, 0xbd97, \
{ 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0x8a, 0xdd, 0x32 } }
class nsIDOMEvent : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IDOMEVENT_IID; return iid; }
enum {
VK_CANCEL = 3,
VK_BACK = 8,
VK_TAB = 9,
VK_CLEAR = 12,
VK_RETURN = 13,
VK_ENTER = 14,
VK_SHIFT = 16,
VK_CONTROL = 17,
VK_ALT = 18,
VK_PAUSE = 19,
VK_CAPS_LOCK = 20,
VK_ESCAPE = 27,
VK_SPACE = 32,
VK_PAGE_UP = 33,
VK_PAGE_DOWN = 34,
VK_END = 35,
VK_HOME = 36,
VK_LEFT = 37,
VK_UP = 38,
VK_RIGHT = 39,
VK_DOWN = 40,
VK_PRINTSCREEN = 44,
VK_INSERT = 45,
VK_DELETE = 46,
VK_0 = 48,
VK_1 = 49,
VK_2 = 50,
VK_3 = 51,
VK_4 = 52,
VK_5 = 53,
VK_6 = 54,
VK_7 = 55,
VK_8 = 56,
VK_9 = 57,
VK_SEMICOLON = 59,
VK_EQUALS = 61,
VK_A = 65,
VK_B = 66,
VK_C = 67,
VK_D = 68,
VK_E = 69,
VK_F = 70,
VK_G = 71,
VK_H = 72,
VK_I = 73,
VK_J = 74,
VK_K = 75,
VK_L = 76,
VK_M = 77,
VK_N = 78,
VK_O = 79,
VK_P = 80,
VK_Q = 81,
VK_R = 82,
VK_S = 83,
VK_T = 84,
VK_U = 85,
VK_V = 86,
VK_W = 87,
VK_X = 88,
VK_Y = 89,
VK_Z = 90,
VK_NUMPAD0 = 96,
VK_NUMPAD1 = 97,
VK_NUMPAD2 = 98,
VK_NUMPAD3 = 99,
VK_NUMPAD4 = 100,
VK_NUMPAD5 = 101,
VK_NUMPAD6 = 102,
VK_NUMPAD7 = 103,
VK_NUMPAD8 = 104,
VK_NUMPAD9 = 105,
VK_MULTIPLY = 106,
VK_ADD = 107,
VK_SEPARATOR = 108,
VK_SUBTRACT = 109,
VK_DECIMAL = 110,
VK_DIVIDE = 111,
VK_F1 = 112,
VK_F2 = 113,
VK_F3 = 114,
VK_F4 = 115,
VK_F5 = 116,
VK_F6 = 117,
VK_F7 = 118,
VK_F8 = 119,
VK_F9 = 120,
VK_F10 = 121,
VK_F11 = 122,
VK_F12 = 123,
VK_F13 = 124,
VK_F14 = 125,
VK_F15 = 126,
VK_F16 = 127,
VK_F17 = 128,
VK_F18 = 129,
VK_F19 = 130,
VK_F20 = 131,
VK_F21 = 132,
VK_F22 = 133,
VK_F23 = 134,
VK_F24 = 135,
VK_NUM_LOCK = 144,
VK_SCROLL_LOCK = 145,
VK_COMMA = 188,
VK_PERIOD = 190,
VK_SLASH = 191,
VK_BACK_QUOTE = 192,
VK_OPEN_BRACKET = 219,
VK_BACK_SLASH = 220,
VK_CLOSE_BRACKET = 221,
VK_QUOTE = 222
BUBBLING_PHASE = 1,
CAPTURING_PHASE = 2,
AT_TARGET = 3
};
NS_IMETHOD GetType(nsString& aType)=0;
NS_IMETHOD SetType(const nsString& aType)=0;
NS_IMETHOD GetText(nsString& aText)=0;
NS_IMETHOD GetCommitText(PRBool* aCommitText)=0;
NS_IMETHOD SetCommitText(PRBool aCommitText)=0;
NS_IMETHOD GetTarget(nsIDOMNode** aTarget)=0;
NS_IMETHOD SetTarget(nsIDOMNode* aTarget)=0;
NS_IMETHOD GetScreenX(PRInt32* aScreenX)=0;
NS_IMETHOD SetScreenX(PRInt32 aScreenX)=0;
NS_IMETHOD GetCurrentNode(nsIDOMNode** aCurrentNode)=0;
NS_IMETHOD GetScreenY(PRInt32* aScreenY)=0;
NS_IMETHOD SetScreenY(PRInt32 aScreenY)=0;
NS_IMETHOD GetEventPhase(PRUint16* aEventPhase)=0;
NS_IMETHOD GetClientX(PRInt32* aClientX)=0;
NS_IMETHOD SetClientX(PRInt32 aClientX)=0;
NS_IMETHOD PreventBubble()=0;
NS_IMETHOD GetClientY(PRInt32* aClientY)=0;
NS_IMETHOD SetClientY(PRInt32 aClientY)=0;
NS_IMETHOD PreventCapture()=0;
NS_IMETHOD GetAltKey(PRBool* aAltKey)=0;
NS_IMETHOD SetAltKey(PRBool aAltKey)=0;
NS_IMETHOD GetCtrlKey(PRBool* aCtrlKey)=0;
NS_IMETHOD SetCtrlKey(PRBool aCtrlKey)=0;
NS_IMETHOD GetShiftKey(PRBool* aShiftKey)=0;
NS_IMETHOD SetShiftKey(PRBool aShiftKey)=0;
NS_IMETHOD GetMetaKey(PRBool* aMetaKey)=0;
NS_IMETHOD SetMetaKey(PRBool aMetaKey)=0;
NS_IMETHOD GetCancelBubble(PRBool* aCancelBubble)=0;
NS_IMETHOD SetCancelBubble(PRBool aCancelBubble)=0;
NS_IMETHOD GetCharCode(PRUint32* aCharCode)=0;
NS_IMETHOD SetCharCode(PRUint32 aCharCode)=0;
NS_IMETHOD GetKeyCode(PRUint32* aKeyCode)=0;
NS_IMETHOD SetKeyCode(PRUint32 aKeyCode)=0;
NS_IMETHOD GetButton(PRUint32* aButton)=0;
NS_IMETHOD SetButton(PRUint32 aButton)=0;
NS_IMETHOD PreventDefault()=0;
};
#define NS_DECL_IDOMEVENT \
NS_IMETHOD GetType(nsString& aType); \
NS_IMETHOD SetType(const nsString& aType); \
NS_IMETHOD GetText(nsString& aText); \
NS_IMETHOD GetCommitText(PRBool* aCommitText); \
NS_IMETHOD SetCommitText(PRBool aCommitText); \
NS_IMETHOD GetTarget(nsIDOMNode** aTarget); \
NS_IMETHOD SetTarget(nsIDOMNode* aTarget); \
NS_IMETHOD GetScreenX(PRInt32* aScreenX); \
NS_IMETHOD SetScreenX(PRInt32 aScreenX); \
NS_IMETHOD GetScreenY(PRInt32* aScreenY); \
NS_IMETHOD SetScreenY(PRInt32 aScreenY); \
NS_IMETHOD GetClientX(PRInt32* aClientX); \
NS_IMETHOD SetClientX(PRInt32 aClientX); \
NS_IMETHOD GetClientY(PRInt32* aClientY); \
NS_IMETHOD SetClientY(PRInt32 aClientY); \
NS_IMETHOD GetAltKey(PRBool* aAltKey); \
NS_IMETHOD SetAltKey(PRBool aAltKey); \
NS_IMETHOD GetCtrlKey(PRBool* aCtrlKey); \
NS_IMETHOD SetCtrlKey(PRBool aCtrlKey); \
NS_IMETHOD GetShiftKey(PRBool* aShiftKey); \
NS_IMETHOD SetShiftKey(PRBool aShiftKey); \
NS_IMETHOD GetMetaKey(PRBool* aMetaKey); \
NS_IMETHOD SetMetaKey(PRBool aMetaKey); \
NS_IMETHOD GetCancelBubble(PRBool* aCancelBubble); \
NS_IMETHOD SetCancelBubble(PRBool aCancelBubble); \
NS_IMETHOD GetCharCode(PRUint32* aCharCode); \
NS_IMETHOD SetCharCode(PRUint32 aCharCode); \
NS_IMETHOD GetKeyCode(PRUint32* aKeyCode); \
NS_IMETHOD SetKeyCode(PRUint32 aKeyCode); \
NS_IMETHOD GetButton(PRUint32* aButton); \
NS_IMETHOD SetButton(PRUint32 aButton); \
NS_IMETHOD GetCurrentNode(nsIDOMNode** aCurrentNode); \
NS_IMETHOD GetEventPhase(PRUint16* aEventPhase); \
NS_IMETHOD PreventBubble(); \
NS_IMETHOD PreventCapture(); \
NS_IMETHOD PreventDefault(); \
#define NS_FORWARD_IDOMEVENT(_to) \
NS_IMETHOD GetType(nsString& aType) { return _to GetType(aType); } \
NS_IMETHOD SetType(const nsString& aType) { return _to SetType(aType); } \
NS_IMETHOD GetText(nsString& aText) { return _to GetText(aText); } \
NS_IMETHOD GetCommitText(PRBool* aCommitText) { return _to GetCommitText(aCommitText); } \
NS_IMETHOD SetCommitText(PRBool aCommitText) { return _to SetCommitText(aCommitText); } \
NS_IMETHOD GetTarget(nsIDOMNode** aTarget) { return _to GetTarget(aTarget); } \
NS_IMETHOD SetTarget(nsIDOMNode* aTarget) { return _to SetTarget(aTarget); } \
NS_IMETHOD GetScreenX(PRInt32* aScreenX) { return _to GetScreenX(aScreenX); } \
NS_IMETHOD SetScreenX(PRInt32 aScreenX) { return _to SetScreenX(aScreenX); } \
NS_IMETHOD GetScreenY(PRInt32* aScreenY) { return _to GetScreenY(aScreenY); } \
NS_IMETHOD SetScreenY(PRInt32 aScreenY) { return _to SetScreenY(aScreenY); } \
NS_IMETHOD GetClientX(PRInt32* aClientX) { return _to GetClientX(aClientX); } \
NS_IMETHOD SetClientX(PRInt32 aClientX) { return _to SetClientX(aClientX); } \
NS_IMETHOD GetClientY(PRInt32* aClientY) { return _to GetClientY(aClientY); } \
NS_IMETHOD SetClientY(PRInt32 aClientY) { return _to SetClientY(aClientY); } \
NS_IMETHOD GetAltKey(PRBool* aAltKey) { return _to GetAltKey(aAltKey); } \
NS_IMETHOD SetAltKey(PRBool aAltKey) { return _to SetAltKey(aAltKey); } \
NS_IMETHOD GetCtrlKey(PRBool* aCtrlKey) { return _to GetCtrlKey(aCtrlKey); } \
NS_IMETHOD SetCtrlKey(PRBool aCtrlKey) { return _to SetCtrlKey(aCtrlKey); } \
NS_IMETHOD GetShiftKey(PRBool* aShiftKey) { return _to GetShiftKey(aShiftKey); } \
NS_IMETHOD SetShiftKey(PRBool aShiftKey) { return _to SetShiftKey(aShiftKey); } \
NS_IMETHOD GetMetaKey(PRBool* aMetaKey) { return _to GetMetaKey(aMetaKey); } \
NS_IMETHOD SetMetaKey(PRBool aMetaKey) { return _to SetMetaKey(aMetaKey); } \
NS_IMETHOD GetCancelBubble(PRBool* aCancelBubble) { return _to GetCancelBubble(aCancelBubble); } \
NS_IMETHOD SetCancelBubble(PRBool aCancelBubble) { return _to SetCancelBubble(aCancelBubble); } \
NS_IMETHOD GetCharCode(PRUint32* aCharCode) { return _to GetCharCode(aCharCode); } \
NS_IMETHOD SetCharCode(PRUint32 aCharCode) { return _to SetCharCode(aCharCode); } \
NS_IMETHOD GetKeyCode(PRUint32* aKeyCode) { return _to GetKeyCode(aKeyCode); } \
NS_IMETHOD SetKeyCode(PRUint32 aKeyCode) { return _to SetKeyCode(aKeyCode); } \
NS_IMETHOD GetButton(PRUint32* aButton) { return _to GetButton(aButton); } \
NS_IMETHOD SetButton(PRUint32 aButton) { return _to SetButton(aButton); } \
NS_IMETHOD GetCurrentNode(nsIDOMNode** aCurrentNode) { return _to GetCurrentNode(aCurrentNode); } \
NS_IMETHOD GetEventPhase(PRUint16* aEventPhase) { return _to GetEventPhase(aEventPhase); } \
NS_IMETHOD PreventBubble() { return _to PreventBubble(); } \
NS_IMETHOD PreventCapture() { return _to PreventCapture(); } \
NS_IMETHOD PreventDefault() { return _to PreventDefault(); } \
extern "C" NS_DOM nsresult NS_InitEventClass(nsIScriptContext *aContext, void **aPrototype);

View File

@ -106,17 +106,17 @@ public:
#define NS_FORWARD_IDOMNSEVENT(_to) \
NS_IMETHOD GetLayerX(PRInt32* aLayerX) { return _to GetLayerX(aLayerX); } \
NS_IMETHOD SetLayerX(PRInt32 aLayerX) { return _to SetLayerX(aLayerX); } \
NS_IMETHOD GetLayerY(PRInt32* aLayerY) { return _to GetLayerY(aLayerY); } \
NS_IMETHOD SetLayerY(PRInt32 aLayerY) { return _to SetLayerY(aLayerY); } \
NS_IMETHOD GetPageX(PRInt32* aPageX) { return _to GetPageX(aPageX); } \
NS_IMETHOD SetPageX(PRInt32 aPageX) { return _to SetPageX(aPageX); } \
NS_IMETHOD GetPageY(PRInt32* aPageY) { return _to GetPageY(aPageY); } \
NS_IMETHOD SetPageY(PRInt32 aPageY) { return _to SetPageY(aPageY); } \
NS_IMETHOD GetWhich(PRUint32* aWhich) { return _to GetWhich(aWhich); } \
NS_IMETHOD SetWhich(PRUint32 aWhich) { return _to SetWhich(aWhich); } \
NS_IMETHOD GetRc(nsIDOMRenderingContext** aRc) { return _to GetRc(aRc); } \
NS_IMETHOD GetLayerX(PRInt32* aLayerX) { return _to##GetLayerX(aLayerX); } \
NS_IMETHOD SetLayerX(PRInt32 aLayerX) { return _to##SetLayerX(aLayerX); } \
NS_IMETHOD GetLayerY(PRInt32* aLayerY) { return _to##GetLayerY(aLayerY); } \
NS_IMETHOD SetLayerY(PRInt32 aLayerY) { return _to##SetLayerY(aLayerY); } \
NS_IMETHOD GetPageX(PRInt32* aPageX) { return _to##GetPageX(aPageX); } \
NS_IMETHOD SetPageX(PRInt32 aPageX) { return _to##SetPageX(aPageX); } \
NS_IMETHOD GetPageY(PRInt32* aPageY) { return _to##GetPageY(aPageY); } \
NS_IMETHOD SetPageY(PRInt32 aPageY) { return _to##SetPageY(aPageY); } \
NS_IMETHOD GetWhich(PRUint32* aWhich) { return _to##GetWhich(aWhich); } \
NS_IMETHOD SetWhich(PRUint32 aWhich) { return _to##SetWhich(aWhich); } \
NS_IMETHOD GetRc(nsIDOMRenderingContext** aRc) { return _to##GetRc(aRc); } \
#endif // nsIDOMNSEvent_h__

View File

@ -0,0 +1,107 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#ifndef nsIDOMNSUIEvent_h__
#define nsIDOMNSUIEvent_h__
#include "nsISupports.h"
#include "nsString.h"
#include "nsIScriptContext.h"
class nsIDOMRenderingContext;
#define NS_IDOMNSUIEVENT_IID \
{ 0xa6cf90c4, 0x15b3, 0x11d2, \
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
class nsIDOMNSUIEvent : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IDOMNSUIEVENT_IID; return iid; }
enum {
EVENT_MOUSEDOWN = 1,
EVENT_MOUSEUP = 2,
EVENT_MOUSEOVER = 4,
EVENT_MOUSEOUT = 8,
EVENT_MOUSEMOVE = 16,
EVENT_MOUSEDRAG = 32,
EVENT_CLICK = 64,
EVENT_DBLCLICK = 128,
EVENT_KEYDOWN = 256,
EVENT_KEYUP = 512,
EVENT_KEYPRESS = 1024,
EVENT_DRAGDROP = 2048,
EVENT_FOCUS = 4096,
EVENT_BLUR = 8192,
EVENT_SELECT = 16384,
EVENT_CHANGE = 32768,
EVENT_RESET = 65536,
EVENT_SUBMIT = 131072,
EVENT_SCROLL = 262144,
EVENT_LOAD = 524288,
EVENT_UNLOAD = 1048576,
EVENT_XFER_DONE = 2097152,
EVENT_ABORT = 4194304,
EVENT_ERROR = 8388608,
EVENT_LOCATE = 16777216,
EVENT_MOVE = 33554432,
EVENT_RESIZE = 67108864,
EVENT_FORWARD = 134217728,
EVENT_HELP = 268435456,
EVENT_BACK = 536870912,
EVENT_TEXT = 1073741824,
EVENT_ALT_MASK = 1,
EVENT_CONTROL_MASK = 2,
EVENT_SHIFT_MASK = 4,
EVENT_META_MASK = 8
};
NS_IMETHOD GetLayerX(PRInt32* aLayerX)=0;
NS_IMETHOD GetLayerY(PRInt32* aLayerY)=0;
NS_IMETHOD GetPageX(PRInt32* aPageX)=0;
NS_IMETHOD GetPageY(PRInt32* aPageY)=0;
NS_IMETHOD GetWhich(PRUint32* aWhich)=0;
NS_IMETHOD GetRc(nsIDOMRenderingContext** aRc)=0;
};
#define NS_DECL_IDOMNSUIEVENT \
NS_IMETHOD GetLayerX(PRInt32* aLayerX); \
NS_IMETHOD GetLayerY(PRInt32* aLayerY); \
NS_IMETHOD GetPageX(PRInt32* aPageX); \
NS_IMETHOD GetPageY(PRInt32* aPageY); \
NS_IMETHOD GetWhich(PRUint32* aWhich); \
NS_IMETHOD GetRc(nsIDOMRenderingContext** aRc); \
#define NS_FORWARD_IDOMNSUIEVENT(_to) \
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 GetWhich(PRUint32* aWhich) { return _to GetWhich(aWhich); } \
NS_IMETHOD GetRc(nsIDOMRenderingContext** aRc) { return _to GetRc(aRc); } \
#endif // nsIDOMNSUIEvent_h__

View File

@ -0,0 +1,219 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#ifndef nsIDOMUIEvent_h__
#define nsIDOMUIEvent_h__
#include "nsISupports.h"
#include "nsString.h"
#include "nsIScriptContext.h"
#include "nsIDOMEvent.h"
#define NS_IDOMUIEVENT_IID \
{ 0xa6cf90c3, 0x15b3, 0x11d2, \
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
class nsIDOMUIEvent : public nsIDOMEvent {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IDOMUIEVENT_IID; return iid; }
enum {
VK_CANCEL = 3,
VK_BACK = 8,
VK_TAB = 9,
VK_CLEAR = 12,
VK_RETURN = 13,
VK_ENTER = 14,
VK_SHIFT = 16,
VK_CONTROL = 17,
VK_ALT = 18,
VK_PAUSE = 19,
VK_CAPS_LOCK = 20,
VK_ESCAPE = 27,
VK_SPACE = 32,
VK_PAGE_UP = 33,
VK_PAGE_DOWN = 34,
VK_END = 35,
VK_HOME = 36,
VK_LEFT = 37,
VK_UP = 38,
VK_RIGHT = 39,
VK_DOWN = 40,
VK_PRINTSCREEN = 44,
VK_INSERT = 45,
VK_DELETE = 46,
VK_0 = 48,
VK_1 = 49,
VK_2 = 50,
VK_3 = 51,
VK_4 = 52,
VK_5 = 53,
VK_6 = 54,
VK_7 = 55,
VK_8 = 56,
VK_9 = 57,
VK_SEMICOLON = 59,
VK_EQUALS = 61,
VK_A = 65,
VK_B = 66,
VK_C = 67,
VK_D = 68,
VK_E = 69,
VK_F = 70,
VK_G = 71,
VK_H = 72,
VK_I = 73,
VK_J = 74,
VK_K = 75,
VK_L = 76,
VK_M = 77,
VK_N = 78,
VK_O = 79,
VK_P = 80,
VK_Q = 81,
VK_R = 82,
VK_S = 83,
VK_T = 84,
VK_U = 85,
VK_V = 86,
VK_W = 87,
VK_X = 88,
VK_Y = 89,
VK_Z = 90,
VK_NUMPAD0 = 96,
VK_NUMPAD1 = 97,
VK_NUMPAD2 = 98,
VK_NUMPAD3 = 99,
VK_NUMPAD4 = 100,
VK_NUMPAD5 = 101,
VK_NUMPAD6 = 102,
VK_NUMPAD7 = 103,
VK_NUMPAD8 = 104,
VK_NUMPAD9 = 105,
VK_MULTIPLY = 106,
VK_ADD = 107,
VK_SEPARATOR = 108,
VK_SUBTRACT = 109,
VK_DECIMAL = 110,
VK_DIVIDE = 111,
VK_F1 = 112,
VK_F2 = 113,
VK_F3 = 114,
VK_F4 = 115,
VK_F5 = 116,
VK_F6 = 117,
VK_F7 = 118,
VK_F8 = 119,
VK_F9 = 120,
VK_F10 = 121,
VK_F11 = 122,
VK_F12 = 123,
VK_F13 = 124,
VK_F14 = 125,
VK_F15 = 126,
VK_F16 = 127,
VK_F17 = 128,
VK_F18 = 129,
VK_F19 = 130,
VK_F20 = 131,
VK_F21 = 132,
VK_F22 = 133,
VK_F23 = 134,
VK_F24 = 135,
VK_NUM_LOCK = 144,
VK_SCROLL_LOCK = 145,
VK_COMMA = 188,
VK_PERIOD = 190,
VK_SLASH = 191,
VK_BACK_QUOTE = 192,
VK_OPEN_BRACKET = 219,
VK_BACK_SLASH = 220,
VK_CLOSE_BRACKET = 221,
VK_QUOTE = 222
};
NS_IMETHOD GetText(nsString& aText)=0;
NS_IMETHOD GetCommitText(PRBool* aCommitText)=0;
NS_IMETHOD SetCommitText(PRBool aCommitText)=0;
NS_IMETHOD GetScreenX(PRInt32* aScreenX)=0;
NS_IMETHOD GetScreenY(PRInt32* aScreenY)=0;
NS_IMETHOD GetClientX(PRInt32* aClientX)=0;
NS_IMETHOD GetClientY(PRInt32* aClientY)=0;
NS_IMETHOD GetAltKey(PRBool* aAltKey)=0;
NS_IMETHOD GetCtrlKey(PRBool* aCtrlKey)=0;
NS_IMETHOD GetShiftKey(PRBool* aShiftKey)=0;
NS_IMETHOD GetMetaKey(PRBool* aMetaKey)=0;
NS_IMETHOD GetCharCode(PRUint32* aCharCode)=0;
NS_IMETHOD GetKeyCode(PRUint32* aKeyCode)=0;
NS_IMETHOD GetButton(PRUint32* aButton)=0;
};
#define NS_DECL_IDOMUIEVENT \
NS_IMETHOD GetText(nsString& aText); \
NS_IMETHOD GetCommitText(PRBool* aCommitText); \
NS_IMETHOD SetCommitText(PRBool aCommitText); \
NS_IMETHOD GetScreenX(PRInt32* aScreenX); \
NS_IMETHOD GetScreenY(PRInt32* aScreenY); \
NS_IMETHOD GetClientX(PRInt32* aClientX); \
NS_IMETHOD GetClientY(PRInt32* aClientY); \
NS_IMETHOD GetAltKey(PRBool* aAltKey); \
NS_IMETHOD GetCtrlKey(PRBool* aCtrlKey); \
NS_IMETHOD GetShiftKey(PRBool* aShiftKey); \
NS_IMETHOD GetMetaKey(PRBool* aMetaKey); \
NS_IMETHOD GetCharCode(PRUint32* aCharCode); \
NS_IMETHOD GetKeyCode(PRUint32* aKeyCode); \
NS_IMETHOD GetButton(PRUint32* aButton); \
#define NS_FORWARD_IDOMUIEVENT(_to) \
NS_IMETHOD GetText(nsString& aText) { return _to GetText(aText); } \
NS_IMETHOD GetCommitText(PRBool* aCommitText) { return _to GetCommitText(aCommitText); } \
NS_IMETHOD SetCommitText(PRBool aCommitText) { return _to SetCommitText(aCommitText); } \
NS_IMETHOD GetScreenX(PRInt32* aScreenX) { return _to GetScreenX(aScreenX); } \
NS_IMETHOD GetScreenY(PRInt32* aScreenY) { return _to GetScreenY(aScreenY); } \
NS_IMETHOD GetClientX(PRInt32* aClientX) { return _to GetClientX(aClientX); } \
NS_IMETHOD GetClientY(PRInt32* aClientY) { return _to GetClientY(aClientY); } \
NS_IMETHOD GetAltKey(PRBool* aAltKey) { return _to GetAltKey(aAltKey); } \
NS_IMETHOD GetCtrlKey(PRBool* aCtrlKey) { return _to GetCtrlKey(aCtrlKey); } \
NS_IMETHOD GetShiftKey(PRBool* aShiftKey) { return _to GetShiftKey(aShiftKey); } \
NS_IMETHOD GetMetaKey(PRBool* aMetaKey) { return _to GetMetaKey(aMetaKey); } \
NS_IMETHOD GetCharCode(PRUint32* aCharCode) { return _to GetCharCode(aCharCode); } \
NS_IMETHOD GetKeyCode(PRUint32* aKeyCode) { return _to GetKeyCode(aKeyCode); } \
NS_IMETHOD GetButton(PRUint32* aButton) { return _to GetButton(aButton); } \
extern "C" NS_DOM nsresult NS_InitUIEventClass(nsIScriptContext *aContext, void **aPrototype);
extern "C" NS_DOM nsresult NS_NewScriptUIEvent(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
#endif // nsIDOMUIEvent_h__

View File

@ -30,6 +30,7 @@ CPPSRCS = \
nsJSEventListener.cpp \
nsJSDOMEventListener.cpp \
nsJSEvent.cpp \
nsJSUIEvent.cpp \
$(NULL)
MODULE=dom

View File

@ -28,10 +28,11 @@ CPPSRCS = \
nsJSEventListener.cpp \
nsJSDOMEventListener.cpp \
nsJSEvent.cpp \
nsJSUIEvent.cpp \
$(NULL)
CPP_OBJS= \
.\$(OBJDIR)\nsJSEventListener.obj .\$(OBJDIR)\nsJSDOMEventListener.obj .\$(OBJDIR)\nsJSEvent.obj
.\$(OBJDIR)\nsJSEventListener.obj .\$(OBJDIR)\nsJSDOMEventListener.obj .\$(OBJDIR)\nsJSEvent.obj .\$(OBJDIR)\nsJSUIEvent.obj
LINCS=-I$(XPDIST)\public\xpcom -I$(XPDIST)\public\raptor -I$(XPDIST)\public\dom -I$(XPDIST)\public\js

File diff suppressed because it is too large Load Diff

View File

@ -89,7 +89,7 @@ nsresult nsJSEventListener::HandleEvent(nsIDOMEvent* aEvent)
}
nsIScriptContext *mScriptCX = (nsIScriptContext *)JS_GetContextPrivate(mContext);
if (NS_OK != NS_NewScriptEvent(mScriptCX, aEvent, nsnull, (void**)&mEventObj)) {
if (NS_OK != NS_NewScriptUIEvent(mScriptCX, aEvent, nsnull, (void**)&mEventObj)) {
return NS_ERROR_FAILURE;
}

View File

@ -19,7 +19,7 @@
#ifndef nsJSEventListener_h__
#define nsJSEventListener_h__
#include "nsIDOMEvent.h"
#include "nsIDOMUIEvent.h"
#include "nsIScriptEventListener.h"
#include "nsIDOMMouseListener.h"
#include "jsapi.h"

View File

@ -0,0 +1,934 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nsJSUtils.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMNSUIEvent.h"
#include "nsIDOMUIEvent.h"
#include "nsIDOMRenderingContext.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kINSUIEventIID, NS_IDOMNSUIEVENT_IID);
static NS_DEFINE_IID(kIUIEventIID, NS_IDOMUIEVENT_IID);
static NS_DEFINE_IID(kIRenderingContextIID, NS_IDOMRENDERINGCONTEXT_IID);
NS_DEF_PTR(nsIDOMNSUIEvent);
NS_DEF_PTR(nsIDOMUIEvent);
NS_DEF_PTR(nsIDOMRenderingContext);
//
// UIEvent property ids
//
enum UIEvent_slots {
UIEVENT_TEXT = -1,
UIEVENT_COMMITTEXT = -2,
UIEVENT_SCREENX = -3,
UIEVENT_SCREENY = -4,
UIEVENT_CLIENTX = -5,
UIEVENT_CLIENTY = -6,
UIEVENT_ALTKEY = -7,
UIEVENT_CTRLKEY = -8,
UIEVENT_SHIFTKEY = -9,
UIEVENT_METAKEY = -10,
UIEVENT_CHARCODE = -11,
UIEVENT_KEYCODE = -12,
UIEVENT_BUTTON = -13,
NSUIEVENT_LAYERX = -14,
NSUIEVENT_LAYERY = -15,
NSUIEVENT_PAGEX = -16,
NSUIEVENT_PAGEY = -17,
NSUIEVENT_WHICH = -18,
NSUIEVENT_RC = -19
};
/***********************************************************************/
//
// UIEvent Properties Getter
//
PR_STATIC_CALLBACK(JSBool)
GetUIEventProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMUIEvent *a = (nsIDOMUIEvent*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case UIEVENT_TEXT:
{
nsAutoString prop;
if (NS_OK == a->GetText(prop)) {
nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);
}
else {
return JS_FALSE;
}
break;
}
case UIEVENT_COMMITTEXT:
{
PRBool prop;
if (NS_OK == a->GetCommitText(&prop)) {
*vp = BOOLEAN_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
break;
}
case UIEVENT_SCREENX:
{
PRInt32 prop;
if (NS_OK == a->GetScreenX(&prop)) {
*vp = INT_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
break;
}
case UIEVENT_SCREENY:
{
PRInt32 prop;
if (NS_OK == a->GetScreenY(&prop)) {
*vp = INT_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
break;
}
case UIEVENT_CLIENTX:
{
PRInt32 prop;
if (NS_OK == a->GetClientX(&prop)) {
*vp = INT_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
break;
}
case UIEVENT_CLIENTY:
{
PRInt32 prop;
if (NS_OK == a->GetClientY(&prop)) {
*vp = INT_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
break;
}
case UIEVENT_ALTKEY:
{
PRBool prop;
if (NS_OK == a->GetAltKey(&prop)) {
*vp = BOOLEAN_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
break;
}
case UIEVENT_CTRLKEY:
{
PRBool prop;
if (NS_OK == a->GetCtrlKey(&prop)) {
*vp = BOOLEAN_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
break;
}
case UIEVENT_SHIFTKEY:
{
PRBool prop;
if (NS_OK == a->GetShiftKey(&prop)) {
*vp = BOOLEAN_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
break;
}
case UIEVENT_METAKEY:
{
PRBool prop;
if (NS_OK == a->GetMetaKey(&prop)) {
*vp = BOOLEAN_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
break;
}
case UIEVENT_CHARCODE:
{
PRUint32 prop;
if (NS_OK == a->GetCharCode(&prop)) {
*vp = INT_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
break;
}
case UIEVENT_KEYCODE:
{
PRUint32 prop;
if (NS_OK == a->GetKeyCode(&prop)) {
*vp = INT_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
break;
}
case UIEVENT_BUTTON:
{
PRUint32 prop;
if (NS_OK == a->GetButton(&prop)) {
*vp = INT_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
break;
}
case NSUIEVENT_LAYERX:
{
PRInt32 prop;
nsIDOMNSUIEvent* b;
if (NS_OK == a->QueryInterface(kINSUIEventIID, (void **)&b)) {
if(NS_OK == b->GetLayerX(&prop)) {
*vp = INT_TO_JSVAL(prop);
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSUIEvent");
return JS_FALSE;
}
break;
}
case NSUIEVENT_LAYERY:
{
PRInt32 prop;
nsIDOMNSUIEvent* b;
if (NS_OK == a->QueryInterface(kINSUIEventIID, (void **)&b)) {
if(NS_OK == b->GetLayerY(&prop)) {
*vp = INT_TO_JSVAL(prop);
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSUIEvent");
return JS_FALSE;
}
break;
}
case NSUIEVENT_PAGEX:
{
PRInt32 prop;
nsIDOMNSUIEvent* b;
if (NS_OK == a->QueryInterface(kINSUIEventIID, (void **)&b)) {
if(NS_OK == b->GetPageX(&prop)) {
*vp = INT_TO_JSVAL(prop);
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSUIEvent");
return JS_FALSE;
}
break;
}
case NSUIEVENT_PAGEY:
{
PRInt32 prop;
nsIDOMNSUIEvent* b;
if (NS_OK == a->QueryInterface(kINSUIEventIID, (void **)&b)) {
if(NS_OK == b->GetPageY(&prop)) {
*vp = INT_TO_JSVAL(prop);
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSUIEvent");
return JS_FALSE;
}
break;
}
case NSUIEVENT_WHICH:
{
PRUint32 prop;
nsIDOMNSUIEvent* b;
if (NS_OK == a->QueryInterface(kINSUIEventIID, (void **)&b)) {
if(NS_OK == b->GetWhich(&prop)) {
*vp = INT_TO_JSVAL(prop);
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSUIEvent");
return JS_FALSE;
}
break;
}
case NSUIEVENT_RC:
{
nsIDOMRenderingContext* prop;
nsIDOMNSUIEvent* b;
if (NS_OK == a->QueryInterface(kINSUIEventIID, (void **)&b)) {
if(NS_OK == b->GetRc(&prop)) {
// get the js object
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp);
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSUIEvent");
return JS_FALSE;
}
break;
}
default:
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
}
}
else {
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
}
return PR_TRUE;
}
/***********************************************************************/
//
// UIEvent Properties Setter
//
PR_STATIC_CALLBACK(JSBool)
SetUIEventProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMUIEvent *a = (nsIDOMUIEvent*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case UIEVENT_COMMITTEXT:
{
PRBool prop;
if (PR_FALSE == nsJSUtils::nsConvertJSValToBool(&prop, cx, *vp)) {
return JS_FALSE;
}
a->SetCommitText(prop);
break;
}
default:
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
}
}
else {
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
}
return PR_TRUE;
}
//
// UIEvent finalizer
//
PR_STATIC_CALLBACK(void)
FinalizeUIEvent(JSContext *cx, JSObject *obj)
{
nsJSUtils::nsGenericFinalize(cx, obj);
}
//
// UIEvent enumerate
//
PR_STATIC_CALLBACK(JSBool)
EnumerateUIEvent(JSContext *cx, JSObject *obj)
{
return nsJSUtils::nsGenericEnumerate(cx, obj);
}
//
// UIEvent resolve
//
PR_STATIC_CALLBACK(JSBool)
ResolveUIEvent(JSContext *cx, JSObject *obj, jsval id)
{
return nsJSUtils::nsGenericResolve(cx, obj, id);
}
/***********************************************************************/
//
// class for UIEvent
//
JSClass UIEventClass = {
"UIEvent",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetUIEventProperty,
SetUIEventProperty,
EnumerateUIEvent,
ResolveUIEvent,
JS_ConvertStub,
FinalizeUIEvent
};
//
// UIEvent class properties
//
static JSPropertySpec UIEventProperties[] =
{
{"text", UIEVENT_TEXT, JSPROP_ENUMERATE | JSPROP_READONLY},
{"commitText", UIEVENT_COMMITTEXT, JSPROP_ENUMERATE},
{"screenX", UIEVENT_SCREENX, JSPROP_ENUMERATE | JSPROP_READONLY},
{"screenY", UIEVENT_SCREENY, JSPROP_ENUMERATE | JSPROP_READONLY},
{"clientX", UIEVENT_CLIENTX, JSPROP_ENUMERATE | JSPROP_READONLY},
{"clientY", UIEVENT_CLIENTY, JSPROP_ENUMERATE | JSPROP_READONLY},
{"altKey", UIEVENT_ALTKEY, JSPROP_ENUMERATE | JSPROP_READONLY},
{"ctrlKey", UIEVENT_CTRLKEY, JSPROP_ENUMERATE | JSPROP_READONLY},
{"shiftKey", UIEVENT_SHIFTKEY, JSPROP_ENUMERATE | JSPROP_READONLY},
{"metaKey", UIEVENT_METAKEY, JSPROP_ENUMERATE | JSPROP_READONLY},
{"charCode", UIEVENT_CHARCODE, JSPROP_ENUMERATE | JSPROP_READONLY},
{"keyCode", UIEVENT_KEYCODE, JSPROP_ENUMERATE | JSPROP_READONLY},
{"button", UIEVENT_BUTTON, JSPROP_ENUMERATE | JSPROP_READONLY},
{"layerX", NSUIEVENT_LAYERX, JSPROP_ENUMERATE | JSPROP_READONLY},
{"layerY", NSUIEVENT_LAYERY, JSPROP_ENUMERATE | JSPROP_READONLY},
{"pageX", NSUIEVENT_PAGEX, JSPROP_ENUMERATE | JSPROP_READONLY},
{"pageY", NSUIEVENT_PAGEY, JSPROP_ENUMERATE | JSPROP_READONLY},
{"which", NSUIEVENT_WHICH, JSPROP_ENUMERATE | JSPROP_READONLY},
{"rc", NSUIEVENT_RC, JSPROP_ENUMERATE | JSPROP_READONLY},
{0}
};
//
// UIEvent class methods
//
static JSFunctionSpec UIEventMethods[] =
{
{0}
};
//
// UIEvent constructor
//
PR_STATIC_CALLBACK(JSBool)
UIEvent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_FALSE;
}
//
// UIEvent class initialization
//
extern "C" NS_DOM nsresult NS_InitUIEventClass(nsIScriptContext *aContext, void **aPrototype)
{
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
JSObject *proto = nsnull;
JSObject *constructor = nsnull;
JSObject *parent_proto = nsnull;
JSObject *global = JS_GetGlobalObject(jscontext);
jsval vp;
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "UIEvent", &vp)) ||
!JSVAL_IS_OBJECT(vp) ||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
!JSVAL_IS_OBJECT(vp)) {
if (NS_OK != NS_InitEventClass(aContext, (void **)&parent_proto)) {
return NS_ERROR_FAILURE;
}
proto = JS_InitClass(jscontext, // context
global, // global object
parent_proto, // parent proto
&UIEventClass, // JSClass
UIEvent, // JSNative ctor
0, // ctor args
UIEventProperties, // proto props
UIEventMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
return NS_ERROR_FAILURE;
}
if ((PR_TRUE == JS_LookupProperty(jscontext, global, "UIEvent", &vp)) &&
JSVAL_IS_OBJECT(vp) &&
((constructor = JSVAL_TO_OBJECT(vp)) != nsnull)) {
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_CANCEL);
JS_SetProperty(jscontext, constructor, "VK_CANCEL", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_BACK);
JS_SetProperty(jscontext, constructor, "VK_BACK", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_TAB);
JS_SetProperty(jscontext, constructor, "VK_TAB", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_CLEAR);
JS_SetProperty(jscontext, constructor, "VK_CLEAR", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_RETURN);
JS_SetProperty(jscontext, constructor, "VK_RETURN", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_ENTER);
JS_SetProperty(jscontext, constructor, "VK_ENTER", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_SHIFT);
JS_SetProperty(jscontext, constructor, "VK_SHIFT", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_CONTROL);
JS_SetProperty(jscontext, constructor, "VK_CONTROL", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_ALT);
JS_SetProperty(jscontext, constructor, "VK_ALT", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_PAUSE);
JS_SetProperty(jscontext, constructor, "VK_PAUSE", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_CAPS_LOCK);
JS_SetProperty(jscontext, constructor, "VK_CAPS_LOCK", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_ESCAPE);
JS_SetProperty(jscontext, constructor, "VK_ESCAPE", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_SPACE);
JS_SetProperty(jscontext, constructor, "VK_SPACE", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_PAGE_UP);
JS_SetProperty(jscontext, constructor, "VK_PAGE_UP", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_PAGE_DOWN);
JS_SetProperty(jscontext, constructor, "VK_PAGE_DOWN", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_END);
JS_SetProperty(jscontext, constructor, "VK_END", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_HOME);
JS_SetProperty(jscontext, constructor, "VK_HOME", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_LEFT);
JS_SetProperty(jscontext, constructor, "VK_LEFT", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_UP);
JS_SetProperty(jscontext, constructor, "VK_UP", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_RIGHT);
JS_SetProperty(jscontext, constructor, "VK_RIGHT", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_DOWN);
JS_SetProperty(jscontext, constructor, "VK_DOWN", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_PRINTSCREEN);
JS_SetProperty(jscontext, constructor, "VK_PRINTSCREEN", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_INSERT);
JS_SetProperty(jscontext, constructor, "VK_INSERT", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_DELETE);
JS_SetProperty(jscontext, constructor, "VK_DELETE", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_0);
JS_SetProperty(jscontext, constructor, "VK_0", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_1);
JS_SetProperty(jscontext, constructor, "VK_1", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_2);
JS_SetProperty(jscontext, constructor, "VK_2", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_3);
JS_SetProperty(jscontext, constructor, "VK_3", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_4);
JS_SetProperty(jscontext, constructor, "VK_4", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_5);
JS_SetProperty(jscontext, constructor, "VK_5", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_6);
JS_SetProperty(jscontext, constructor, "VK_6", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_7);
JS_SetProperty(jscontext, constructor, "VK_7", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_8);
JS_SetProperty(jscontext, constructor, "VK_8", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_9);
JS_SetProperty(jscontext, constructor, "VK_9", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_SEMICOLON);
JS_SetProperty(jscontext, constructor, "VK_SEMICOLON", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_EQUALS);
JS_SetProperty(jscontext, constructor, "VK_EQUALS", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_A);
JS_SetProperty(jscontext, constructor, "VK_A", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_B);
JS_SetProperty(jscontext, constructor, "VK_B", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_C);
JS_SetProperty(jscontext, constructor, "VK_C", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_D);
JS_SetProperty(jscontext, constructor, "VK_D", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_E);
JS_SetProperty(jscontext, constructor, "VK_E", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F);
JS_SetProperty(jscontext, constructor, "VK_F", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_G);
JS_SetProperty(jscontext, constructor, "VK_G", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_H);
JS_SetProperty(jscontext, constructor, "VK_H", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_I);
JS_SetProperty(jscontext, constructor, "VK_I", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_J);
JS_SetProperty(jscontext, constructor, "VK_J", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_K);
JS_SetProperty(jscontext, constructor, "VK_K", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_L);
JS_SetProperty(jscontext, constructor, "VK_L", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_M);
JS_SetProperty(jscontext, constructor, "VK_M", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_N);
JS_SetProperty(jscontext, constructor, "VK_N", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_O);
JS_SetProperty(jscontext, constructor, "VK_O", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_P);
JS_SetProperty(jscontext, constructor, "VK_P", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_Q);
JS_SetProperty(jscontext, constructor, "VK_Q", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_R);
JS_SetProperty(jscontext, constructor, "VK_R", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_S);
JS_SetProperty(jscontext, constructor, "VK_S", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_T);
JS_SetProperty(jscontext, constructor, "VK_T", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_U);
JS_SetProperty(jscontext, constructor, "VK_U", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_V);
JS_SetProperty(jscontext, constructor, "VK_V", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_W);
JS_SetProperty(jscontext, constructor, "VK_W", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_X);
JS_SetProperty(jscontext, constructor, "VK_X", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_Y);
JS_SetProperty(jscontext, constructor, "VK_Y", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_Z);
JS_SetProperty(jscontext, constructor, "VK_Z", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_NUMPAD0);
JS_SetProperty(jscontext, constructor, "VK_NUMPAD0", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_NUMPAD1);
JS_SetProperty(jscontext, constructor, "VK_NUMPAD1", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_NUMPAD2);
JS_SetProperty(jscontext, constructor, "VK_NUMPAD2", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_NUMPAD3);
JS_SetProperty(jscontext, constructor, "VK_NUMPAD3", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_NUMPAD4);
JS_SetProperty(jscontext, constructor, "VK_NUMPAD4", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_NUMPAD5);
JS_SetProperty(jscontext, constructor, "VK_NUMPAD5", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_NUMPAD6);
JS_SetProperty(jscontext, constructor, "VK_NUMPAD6", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_NUMPAD7);
JS_SetProperty(jscontext, constructor, "VK_NUMPAD7", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_NUMPAD8);
JS_SetProperty(jscontext, constructor, "VK_NUMPAD8", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_NUMPAD9);
JS_SetProperty(jscontext, constructor, "VK_NUMPAD9", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_MULTIPLY);
JS_SetProperty(jscontext, constructor, "VK_MULTIPLY", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_ADD);
JS_SetProperty(jscontext, constructor, "VK_ADD", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_SEPARATOR);
JS_SetProperty(jscontext, constructor, "VK_SEPARATOR", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_SUBTRACT);
JS_SetProperty(jscontext, constructor, "VK_SUBTRACT", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_DECIMAL);
JS_SetProperty(jscontext, constructor, "VK_DECIMAL", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_DIVIDE);
JS_SetProperty(jscontext, constructor, "VK_DIVIDE", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F1);
JS_SetProperty(jscontext, constructor, "VK_F1", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F2);
JS_SetProperty(jscontext, constructor, "VK_F2", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F3);
JS_SetProperty(jscontext, constructor, "VK_F3", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F4);
JS_SetProperty(jscontext, constructor, "VK_F4", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F5);
JS_SetProperty(jscontext, constructor, "VK_F5", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F6);
JS_SetProperty(jscontext, constructor, "VK_F6", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F7);
JS_SetProperty(jscontext, constructor, "VK_F7", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F8);
JS_SetProperty(jscontext, constructor, "VK_F8", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F9);
JS_SetProperty(jscontext, constructor, "VK_F9", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F10);
JS_SetProperty(jscontext, constructor, "VK_F10", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F11);
JS_SetProperty(jscontext, constructor, "VK_F11", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F12);
JS_SetProperty(jscontext, constructor, "VK_F12", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F13);
JS_SetProperty(jscontext, constructor, "VK_F13", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F14);
JS_SetProperty(jscontext, constructor, "VK_F14", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F15);
JS_SetProperty(jscontext, constructor, "VK_F15", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F16);
JS_SetProperty(jscontext, constructor, "VK_F16", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F17);
JS_SetProperty(jscontext, constructor, "VK_F17", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F18);
JS_SetProperty(jscontext, constructor, "VK_F18", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F19);
JS_SetProperty(jscontext, constructor, "VK_F19", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F20);
JS_SetProperty(jscontext, constructor, "VK_F20", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F21);
JS_SetProperty(jscontext, constructor, "VK_F21", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F22);
JS_SetProperty(jscontext, constructor, "VK_F22", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F23);
JS_SetProperty(jscontext, constructor, "VK_F23", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_F24);
JS_SetProperty(jscontext, constructor, "VK_F24", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_NUM_LOCK);
JS_SetProperty(jscontext, constructor, "VK_NUM_LOCK", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_SCROLL_LOCK);
JS_SetProperty(jscontext, constructor, "VK_SCROLL_LOCK", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_COMMA);
JS_SetProperty(jscontext, constructor, "VK_COMMA", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_PERIOD);
JS_SetProperty(jscontext, constructor, "VK_PERIOD", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_SLASH);
JS_SetProperty(jscontext, constructor, "VK_SLASH", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_BACK_QUOTE);
JS_SetProperty(jscontext, constructor, "VK_BACK_QUOTE", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_OPEN_BRACKET);
JS_SetProperty(jscontext, constructor, "VK_OPEN_BRACKET", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_BACK_SLASH);
JS_SetProperty(jscontext, constructor, "VK_BACK_SLASH", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_CLOSE_BRACKET);
JS_SetProperty(jscontext, constructor, "VK_CLOSE_BRACKET", &vp);
vp = INT_TO_JSVAL(nsIDOMUIEvent::VK_QUOTE);
JS_SetProperty(jscontext, constructor, "VK_QUOTE", &vp);
}
}
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
proto = JSVAL_TO_OBJECT(vp);
}
else {
return NS_ERROR_FAILURE;
}
if (aPrototype) {
*aPrototype = proto;
}
return NS_OK;
}
//
// Method for creating a new UIEvent JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptUIEvent(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptUIEvent");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
nsresult result = NS_OK;
nsIDOMUIEvent *aUIEvent;
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitUIEventClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
result = aSupports->QueryInterface(kIUIEventIID, (void **)&aUIEvent);
if (NS_OK != result) {
return result;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &UIEventClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aUIEvent);
}
else {
NS_RELEASE(aUIEvent);
return NS_ERROR_FAILURE;
}
return NS_OK;
}

View File

@ -29,6 +29,7 @@
#include "nsVoidArray.h"
#include "nsString.h"
#include "nsIStringStream.h"
#include "nsIDOMUIEvent.h"
// for testing only
#include "nsIHTMLEditor.h"
@ -150,34 +151,41 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
PRUint32 keyCode;
PRBool isShift;
PRBool ctrlKey;
if (NS_SUCCEEDED(aKeyEvent->GetKeyCode(&keyCode)) &&
NS_SUCCEEDED(aKeyEvent->GetShiftKey(&isShift)) &&
NS_SUCCEEDED(aKeyEvent->GetCtrlKey(&ctrlKey))
nsCOMPtr<nsIDOMUIEvent>uiEvent;
uiEvent = do_QueryInterface(aKeyEvent);
if (!uiEvent) {
//non-key event passed to keydown. bad things.
return NS_OK;
}
if (NS_SUCCEEDED(uiEvent->GetKeyCode(&keyCode)) &&
NS_SUCCEEDED(uiEvent->GetShiftKey(&isShift)) &&
NS_SUCCEEDED(uiEvent->GetCtrlKey(&ctrlKey))
) {
PRBool keyProcessed;
ProcessShortCutKeys(aKeyEvent, keyProcessed);
if (PR_FALSE==keyProcessed)
{
switch(keyCode) {
case nsIDOMEvent::VK_BACK:
case nsIDOMUIEvent::VK_BACK:
mEditor->DeleteSelection(nsIEditor::eDeleteLeft);
break;
case nsIDOMEvent::VK_DELETE:
case nsIDOMUIEvent::VK_DELETE:
mEditor->DeleteSelection(nsIEditor::eDeleteRight);
break;
case nsIDOMEvent::VK_RETURN:
//case nsIDOMEvent::VK_ENTER: // why does this not exist?
case nsIDOMUIEvent::VK_RETURN:
//case nsIDOMUIEvent::VK_ENTER: // why does this not exist?
// Need to implement creation of either <P> or <BR> nodes.
mEditor->InsertBreak();
break;
case nsIDOMEvent::VK_LEFT:
case nsIDOMEvent::VK_RIGHT:
case nsIDOMEvent::VK_UP:
case nsIDOMEvent::VK_DOWN:
case nsIDOMUIEvent::VK_LEFT:
case nsIDOMUIEvent::VK_RIGHT:
case nsIDOMUIEvent::VK_UP:
case nsIDOMUIEvent::VK_DOWN:
// these have already been handled in nsRangeList. Why are we getting them
// again here (Mac)? In switch to avoid putting in bogus chars.
@ -185,16 +193,16 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
return NS_OK;
break;
case nsIDOMEvent::VK_HOME:
case nsIDOMEvent::VK_END:
case nsIDOMUIEvent::VK_HOME:
case nsIDOMUIEvent::VK_END:
// who handles these?
#if DEBUG
printf("Key not handled\n");
#endif
break;
case nsIDOMEvent::VK_PAGE_UP:
case nsIDOMEvent::VK_PAGE_DOWN:
case nsIDOMUIEvent::VK_PAGE_UP:
case nsIDOMUIEvent::VK_PAGE_DOWN:
//return NS_OK to allow page scrolling.
return NS_OK;
break;
@ -205,7 +213,7 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
#ifdef HAVE_EVENT_CHARCODE
PRUint32 character;
// do we convert to Unicode here, or has this already been done? (sfraser)
if (NS_SUCCEEDED(aKeyEvent->GetCharCode(&character)))
if (NS_SUCCEEDED(uiEvent->GetCharCode(&character)))
{
key += character;
if (0!=character)
@ -263,18 +271,25 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
PRBool isShift;
PRBool ctrlKey;
PRBool altKey;
if (NS_SUCCEEDED(aKeyEvent->GetKeyCode(&keyCode)) &&
NS_SUCCEEDED(aKeyEvent->GetShiftKey(&isShift)) &&
NS_SUCCEEDED(aKeyEvent->GetCtrlKey(&ctrlKey)) &&
NS_SUCCEEDED(aKeyEvent->GetAltKey(&altKey))
nsCOMPtr<nsIDOMUIEvent>uiEvent;
uiEvent = do_QueryInterface(aKeyEvent);
if (!uiEvent) {
//non-key event passed in. bad things.
return NS_OK;
}
if (NS_SUCCEEDED(uiEvent->GetKeyCode(&keyCode)) &&
NS_SUCCEEDED(uiEvent->GetShiftKey(&isShift)) &&
NS_SUCCEEDED(uiEvent->GetCtrlKey(&ctrlKey)) &&
NS_SUCCEEDED(uiEvent->GetAltKey(&altKey))
)
{
// XXX: please please please get these mappings from an external source!
switch (keyCode)
{
// XXX: hard-coded select all
case nsIDOMEvent::VK_A:
case nsIDOMUIEvent::VK_A:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -284,7 +299,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// XXX: hard-coded cut
case nsIDOMEvent::VK_X:
case nsIDOMUIEvent::VK_X:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -294,7 +309,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// XXX: hard-coded copy
case nsIDOMEvent::VK_C:
case nsIDOMUIEvent::VK_C:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -313,7 +328,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
}
break;
case nsIDOMEvent::VK_OPEN_BRACKET:
case nsIDOMUIEvent::VK_OPEN_BRACKET:
// hard coded "Decrease wrap size"
if (PR_TRUE==altKey)
{
@ -334,7 +349,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
}
break;
case nsIDOMEvent::VK_CLOSE_BRACKET:
case nsIDOMUIEvent::VK_CLOSE_BRACKET:
// hard coded "Increase wrap size"
if (PR_TRUE==altKey)
{
@ -356,7 +371,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// XXX: hard-coded paste
case nsIDOMEvent::VK_V:
case nsIDOMUIEvent::VK_V:
if (PR_TRUE==ctrlKey)
{
printf("control-v\n");
@ -367,7 +382,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// XXX: hard-coded undo
case nsIDOMEvent::VK_Z:
case nsIDOMUIEvent::VK_Z:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -377,7 +392,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// XXX: hard-coded redo
case nsIDOMEvent::VK_Y:
case nsIDOMUIEvent::VK_Y:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -387,7 +402,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- italics
case nsIDOMEvent::VK_I:
case nsIDOMUIEvent::VK_I:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -425,7 +440,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- bold
case nsIDOMEvent::VK_B:
case nsIDOMUIEvent::VK_B:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -448,7 +463,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- underline
case nsIDOMEvent::VK_U:
case nsIDOMUIEvent::VK_U:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -472,7 +487,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- font color red
case nsIDOMEvent::VK_1:
case nsIDOMUIEvent::VK_1:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -497,7 +512,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- remove font color
case nsIDOMEvent::VK_2:
case nsIDOMUIEvent::VK_2:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -521,7 +536,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- font size +2
case nsIDOMEvent::VK_3:
case nsIDOMUIEvent::VK_3:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -540,7 +555,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- font size -2
case nsIDOMEvent::VK_4:
case nsIDOMUIEvent::VK_4:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -559,7 +574,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- font face helvetica
case nsIDOMEvent::VK_5:
case nsIDOMUIEvent::VK_5:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -578,7 +593,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- font face times
case nsIDOMEvent::VK_6:
case nsIDOMUIEvent::VK_6:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -597,7 +612,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded change structure test -- transform block H1
case nsIDOMEvent::VK_7:
case nsIDOMUIEvent::VK_7:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -616,7 +631,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded change structure test -- transform block H2
case nsIDOMEvent::VK_8:
case nsIDOMUIEvent::VK_8:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -635,7 +650,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded change structure test -- normal
case nsIDOMEvent::VK_9:
case nsIDOMUIEvent::VK_9:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -651,7 +666,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded change structure test -- GetParagraphStyle
case nsIDOMEvent::VK_0:
case nsIDOMUIEvent::VK_0:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -683,7 +698,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded change structure test -- block blockquote (indent)
case nsIDOMEvent::VK_COMMA:
case nsIDOMUIEvent::VK_COMMA:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -702,7 +717,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded change structure test -- un-BlockQuote
case nsIDOMEvent::VK_PERIOD:
case nsIDOMUIEvent::VK_PERIOD:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -723,7 +738,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
#ifdef NS_DEBUG
// hard-coded Text Editor Unit Test
case nsIDOMEvent::VK_T:
case nsIDOMUIEvent::VK_T:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -813,10 +828,17 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
if (!aMouseEvent)
return NS_OK; // NS_OK means "we didn't process the event". Go figure.
nsCOMPtr<nsIDOMUIEvent>uiEvent;
uiEvent = do_QueryInterface(aMouseEvent);
if (!uiEvent) {
//non-ui event passed in. bad things.
return NS_OK;
}
// We only do anything special for middle-mouse click (paste);
// ignore all other events.
PRUint32 button = 0;
aMouseEvent->GetButton(&button);
uiEvent->GetButton(&button);
if (button != 2)
return NS_OK;
@ -956,12 +978,18 @@ nsTextEditorTextListener::HandleText(nsIDOMEvent* aTextEvent)
nsString composedText;
nsresult result;
aTextEvent->GetText(composedText);
nsCOMPtr<nsIDOMUIEvent>uiEvent;
uiEvent = do_QueryInterface(aTextEvent);
if (!uiEvent) {
//non-ui event passed in. bad things.
return NS_OK;
}
uiEvent->GetText(composedText);
result = mEditor->SetCompositionString(composedText);
return result;
}
/*
* nsTextEditorDragListener implementation
*/

View File

@ -29,6 +29,7 @@
#include "nsVoidArray.h"
#include "nsString.h"
#include "nsIStringStream.h"
#include "nsIDOMUIEvent.h"
// for testing only
#include "nsIHTMLEditor.h"
@ -150,34 +151,41 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
PRUint32 keyCode;
PRBool isShift;
PRBool ctrlKey;
if (NS_SUCCEEDED(aKeyEvent->GetKeyCode(&keyCode)) &&
NS_SUCCEEDED(aKeyEvent->GetShiftKey(&isShift)) &&
NS_SUCCEEDED(aKeyEvent->GetCtrlKey(&ctrlKey))
nsCOMPtr<nsIDOMUIEvent>uiEvent;
uiEvent = do_QueryInterface(aKeyEvent);
if (!uiEvent) {
//non-key event passed to keydown. bad things.
return NS_OK;
}
if (NS_SUCCEEDED(uiEvent->GetKeyCode(&keyCode)) &&
NS_SUCCEEDED(uiEvent->GetShiftKey(&isShift)) &&
NS_SUCCEEDED(uiEvent->GetCtrlKey(&ctrlKey))
) {
PRBool keyProcessed;
ProcessShortCutKeys(aKeyEvent, keyProcessed);
if (PR_FALSE==keyProcessed)
{
switch(keyCode) {
case nsIDOMEvent::VK_BACK:
case nsIDOMUIEvent::VK_BACK:
mEditor->DeleteSelection(nsIEditor::eDeleteLeft);
break;
case nsIDOMEvent::VK_DELETE:
case nsIDOMUIEvent::VK_DELETE:
mEditor->DeleteSelection(nsIEditor::eDeleteRight);
break;
case nsIDOMEvent::VK_RETURN:
//case nsIDOMEvent::VK_ENTER: // why does this not exist?
case nsIDOMUIEvent::VK_RETURN:
//case nsIDOMUIEvent::VK_ENTER: // why does this not exist?
// Need to implement creation of either <P> or <BR> nodes.
mEditor->InsertBreak();
break;
case nsIDOMEvent::VK_LEFT:
case nsIDOMEvent::VK_RIGHT:
case nsIDOMEvent::VK_UP:
case nsIDOMEvent::VK_DOWN:
case nsIDOMUIEvent::VK_LEFT:
case nsIDOMUIEvent::VK_RIGHT:
case nsIDOMUIEvent::VK_UP:
case nsIDOMUIEvent::VK_DOWN:
// these have already been handled in nsRangeList. Why are we getting them
// again here (Mac)? In switch to avoid putting in bogus chars.
@ -185,16 +193,16 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
return NS_OK;
break;
case nsIDOMEvent::VK_HOME:
case nsIDOMEvent::VK_END:
case nsIDOMUIEvent::VK_HOME:
case nsIDOMUIEvent::VK_END:
// who handles these?
#if DEBUG
printf("Key not handled\n");
#endif
break;
case nsIDOMEvent::VK_PAGE_UP:
case nsIDOMEvent::VK_PAGE_DOWN:
case nsIDOMUIEvent::VK_PAGE_UP:
case nsIDOMUIEvent::VK_PAGE_DOWN:
//return NS_OK to allow page scrolling.
return NS_OK;
break;
@ -205,7 +213,7 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
#ifdef HAVE_EVENT_CHARCODE
PRUint32 character;
// do we convert to Unicode here, or has this already been done? (sfraser)
if (NS_SUCCEEDED(aKeyEvent->GetCharCode(&character)))
if (NS_SUCCEEDED(uiEvent->GetCharCode(&character)))
{
key += character;
if (0!=character)
@ -263,18 +271,25 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
PRBool isShift;
PRBool ctrlKey;
PRBool altKey;
if (NS_SUCCEEDED(aKeyEvent->GetKeyCode(&keyCode)) &&
NS_SUCCEEDED(aKeyEvent->GetShiftKey(&isShift)) &&
NS_SUCCEEDED(aKeyEvent->GetCtrlKey(&ctrlKey)) &&
NS_SUCCEEDED(aKeyEvent->GetAltKey(&altKey))
nsCOMPtr<nsIDOMUIEvent>uiEvent;
uiEvent = do_QueryInterface(aKeyEvent);
if (!uiEvent) {
//non-key event passed in. bad things.
return NS_OK;
}
if (NS_SUCCEEDED(uiEvent->GetKeyCode(&keyCode)) &&
NS_SUCCEEDED(uiEvent->GetShiftKey(&isShift)) &&
NS_SUCCEEDED(uiEvent->GetCtrlKey(&ctrlKey)) &&
NS_SUCCEEDED(uiEvent->GetAltKey(&altKey))
)
{
// XXX: please please please get these mappings from an external source!
switch (keyCode)
{
// XXX: hard-coded select all
case nsIDOMEvent::VK_A:
case nsIDOMUIEvent::VK_A:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -284,7 +299,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// XXX: hard-coded cut
case nsIDOMEvent::VK_X:
case nsIDOMUIEvent::VK_X:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -294,7 +309,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// XXX: hard-coded copy
case nsIDOMEvent::VK_C:
case nsIDOMUIEvent::VK_C:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -313,7 +328,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
}
break;
case nsIDOMEvent::VK_OPEN_BRACKET:
case nsIDOMUIEvent::VK_OPEN_BRACKET:
// hard coded "Decrease wrap size"
if (PR_TRUE==altKey)
{
@ -334,7 +349,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
}
break;
case nsIDOMEvent::VK_CLOSE_BRACKET:
case nsIDOMUIEvent::VK_CLOSE_BRACKET:
// hard coded "Increase wrap size"
if (PR_TRUE==altKey)
{
@ -356,7 +371,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// XXX: hard-coded paste
case nsIDOMEvent::VK_V:
case nsIDOMUIEvent::VK_V:
if (PR_TRUE==ctrlKey)
{
printf("control-v\n");
@ -367,7 +382,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// XXX: hard-coded undo
case nsIDOMEvent::VK_Z:
case nsIDOMUIEvent::VK_Z:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -377,7 +392,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// XXX: hard-coded redo
case nsIDOMEvent::VK_Y:
case nsIDOMUIEvent::VK_Y:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -387,7 +402,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- italics
case nsIDOMEvent::VK_I:
case nsIDOMUIEvent::VK_I:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -425,7 +440,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- bold
case nsIDOMEvent::VK_B:
case nsIDOMUIEvent::VK_B:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -448,7 +463,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- underline
case nsIDOMEvent::VK_U:
case nsIDOMUIEvent::VK_U:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -472,7 +487,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- font color red
case nsIDOMEvent::VK_1:
case nsIDOMUIEvent::VK_1:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -497,7 +512,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- remove font color
case nsIDOMEvent::VK_2:
case nsIDOMUIEvent::VK_2:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -521,7 +536,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- font size +2
case nsIDOMEvent::VK_3:
case nsIDOMUIEvent::VK_3:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -540,7 +555,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- font size -2
case nsIDOMEvent::VK_4:
case nsIDOMUIEvent::VK_4:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -559,7 +574,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- font face helvetica
case nsIDOMEvent::VK_5:
case nsIDOMUIEvent::VK_5:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -578,7 +593,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded ChangeTextAttributes test -- font face times
case nsIDOMEvent::VK_6:
case nsIDOMUIEvent::VK_6:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -597,7 +612,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded change structure test -- transform block H1
case nsIDOMEvent::VK_7:
case nsIDOMUIEvent::VK_7:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -616,7 +631,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded change structure test -- transform block H2
case nsIDOMEvent::VK_8:
case nsIDOMUIEvent::VK_8:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -635,7 +650,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded change structure test -- normal
case nsIDOMEvent::VK_9:
case nsIDOMUIEvent::VK_9:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -651,7 +666,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded change structure test -- GetParagraphStyle
case nsIDOMEvent::VK_0:
case nsIDOMUIEvent::VK_0:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -683,7 +698,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded change structure test -- block blockquote (indent)
case nsIDOMEvent::VK_COMMA:
case nsIDOMUIEvent::VK_COMMA:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -702,7 +717,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
break;
// hard-coded change structure test -- un-BlockQuote
case nsIDOMEvent::VK_PERIOD:
case nsIDOMUIEvent::VK_PERIOD:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -723,7 +738,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
#ifdef NS_DEBUG
// hard-coded Text Editor Unit Test
case nsIDOMEvent::VK_T:
case nsIDOMUIEvent::VK_T:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
@ -813,10 +828,17 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
if (!aMouseEvent)
return NS_OK; // NS_OK means "we didn't process the event". Go figure.
nsCOMPtr<nsIDOMUIEvent>uiEvent;
uiEvent = do_QueryInterface(aMouseEvent);
if (!uiEvent) {
//non-ui event passed in. bad things.
return NS_OK;
}
// We only do anything special for middle-mouse click (paste);
// ignore all other events.
PRUint32 button = 0;
aMouseEvent->GetButton(&button);
uiEvent->GetButton(&button);
if (button != 2)
return NS_OK;
@ -956,12 +978,18 @@ nsTextEditorTextListener::HandleText(nsIDOMEvent* aTextEvent)
nsString composedText;
nsresult result;
aTextEvent->GetText(composedText);
nsCOMPtr<nsIDOMUIEvent>uiEvent;
uiEvent = do_QueryInterface(aTextEvent);
if (!uiEvent) {
//non-ui event passed in. bad things.
return NS_OK;
}
uiEvent->GetText(composedText);
result = mEditor->SetCompositionString(composedText);
return result;
}
/*
* nsTextEditorDragListener implementation
*/

View File

@ -34,7 +34,7 @@
#include "nsCOMPtr.h"
#include "nsRange.h"
#include "nsISupportsArray.h"
#include "nsIDOMEvent.h"
#include "nsIDOMUIEvent.h"
#include "nsIDOMSelectionListener.h"
#include "nsIContentIterator.h"
@ -764,7 +764,7 @@ if (!aGuiEvent)
if (keyEvent->isControl)
amount = eSelectWord;
switch (keyEvent->keyCode){
case nsIDOMEvent::VK_LEFT :
case nsIDOMUIEvent::VK_LEFT :
//we need to look for the previous PAINTED location to move the cursor to.
#ifdef DEBUG_NAVIGATION
printf("debug vk left\n");
@ -789,7 +789,7 @@ if (!aGuiEvent)
}
}
break;
case nsIDOMEvent::VK_RIGHT :
case nsIDOMUIEvent::VK_RIGHT :
//we need to look for the previous PAINTED location to move the cursor to.
#ifdef DEBUG_NAVIGATION
printf("debug vk left\n");
@ -814,12 +814,12 @@ if (!aGuiEvent)
}
}
break;
case nsIDOMEvent::VK_UP :
case nsIDOMUIEvent::VK_UP :
#ifdef DEBUG_NAVIGATION
printf("debug vk up\n");
#endif
break;
case nsIDOMEvent::VK_DOWN :
case nsIDOMUIEvent::VK_DOWN :
#ifdef DEBUG_NAVIGATION
printf("debug vk down\n");
#endif

View File

@ -39,5 +39,6 @@ public:
};
extern nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext& aPresContext, nsEvent *aEvent);
extern nsresult NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext& aPresContext, nsEvent *aEvent);
#endif // nsIPrivateDOMEvent_h__

View File

@ -28,7 +28,8 @@ static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
static NS_DEFINE_IID(kIDOMEventIID, NS_IDOMEVENT_IID);
static NS_DEFINE_IID(kIDOMNSEventIID, NS_IDOMNSEVENT_IID);
static NS_DEFINE_IID(kIDOMUIEventIID, NS_IDOMUIEVENT_IID);
static NS_DEFINE_IID(kIDOMNSUIEventIID, NS_IDOMNSUIEVENT_IID);
static NS_DEFINE_IID(kIPrivateDOMEventIID, NS_IPRIVATEDOMEVENT_IID);
static char* mEventNames[] = {
@ -75,8 +76,13 @@ nsresult nsDOMEvent::QueryInterface(const nsIID& aIID,
AddRef();
return NS_OK;
}
if (aIID.Equals(kIDOMNSEventIID)) {
*aInstancePtrResult = (void*) ((nsIDOMNSEvent*)this);
if (aIID.Equals(kIDOMUIEventIID)) {
*aInstancePtrResult = (void*) ((nsIDOMUIEvent*)this);
AddRef();
return NS_OK;
}
if (aIID.Equals(kIDOMNSUIEventIID)) {
*aInstancePtrResult = (void*) ((nsIDOMNSUIEvent*)this);
AddRef();
return NS_OK;
}
@ -101,35 +107,6 @@ NS_METHOD nsDOMEvent::GetType(nsString& aType)
return NS_ERROR_FAILURE;
}
NS_METHOD nsDOMEvent::GetText(nsString& aText)
{
if (mEvent->message == NS_TEXT_EVENT) {
aText = *mText;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_METHOD nsDOMEvent::GetCommitText(PRBool* aCommitText)
{
if (mEvent->message == NS_TEXT_EVENT) {
*aCommitText = mCommitText;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_METHOD nsDOMEvent::SetCommitText(PRBool aCommitText)
{
return NS_ERROR_FAILURE;
}
NS_METHOD nsDOMEvent::SetType(const nsString& aType)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetTarget(nsIDOMNode** aTarget)
{
if (nsnull != mTarget) {
@ -158,34 +135,73 @@ NS_METHOD nsDOMEvent::GetTarget(nsIDOMNode** aTarget)
return NS_OK;
}
NS_METHOD nsDOMEvent::SetTarget(nsIDOMNode* aTarget)
NS_IMETHODIMP
nsDOMEvent::GetCurrentNode(nsIDOMNode** aCurrentNode)
{
if (mTarget != aTarget) {
NS_IF_RELEASE(mTarget);
NS_IF_ADDREF(aTarget);
mTarget = aTarget;
}
*aCurrentNode = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsDOMEvent::GetEventPhase(PRUint16* aEventPhase)
{
*aEventPhase = 0;
return NS_OK;
}
NS_IMETHODIMP
nsDOMEvent::PreventBubble()
{
return NS_OK;
}
NS_IMETHODIMP
nsDOMEvent::PreventCapture()
{
return NS_OK;
}
NS_IMETHODIMP
nsDOMEvent::PreventDefault()
{
return NS_OK;
}
NS_METHOD nsDOMEvent::GetText(nsString& aText)
{
if (mEvent->message == NS_TEXT_EVENT) {
aText = *mText;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_METHOD nsDOMEvent::GetCommitText(PRBool* aCommitText)
{
if (mEvent->message == NS_TEXT_EVENT) {
*aCommitText = mCommitText;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_METHOD nsDOMEvent::SetCommitText(PRBool aCommitText)
{
return NS_ERROR_FAILURE;
}
NS_METHOD nsDOMEvent::GetScreenX(PRInt32* aScreenX)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::SetScreenX(PRInt32 aScreenX)
{
return NS_ERROR_NOT_IMPLEMENTED;
*aScreenX = 0;
return NS_OK;
}
NS_METHOD nsDOMEvent::GetScreenY(PRInt32* aScreenY)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::SetScreenY(PRInt32 aScreenY)
{
return NS_ERROR_NOT_IMPLEMENTED;
*aScreenY = 0;
return NS_OK;
}
NS_METHOD nsDOMEvent::GetClientX(PRInt32* aClientX)
@ -196,11 +212,6 @@ NS_METHOD nsDOMEvent::GetClientX(PRInt32* aClientX)
return NS_OK;
}
NS_METHOD nsDOMEvent::SetClientX(PRInt32 aClientX)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetClientY(PRInt32* aClientY)
{
float t2p;
@ -209,54 +220,29 @@ NS_METHOD nsDOMEvent::GetClientY(PRInt32* aClientY)
return NS_OK;
}
NS_METHOD nsDOMEvent::SetClientY(PRInt32 aClientY)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetAltKey(PRBool* aIsDown)
{
*aIsDown = ((nsInputEvent*)mEvent)->isAlt;
return NS_OK;
}
NS_METHOD nsDOMEvent::SetAltKey(PRBool aAltKey)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetCtrlKey(PRBool* aIsDown)
{
*aIsDown = ((nsInputEvent*)mEvent)->isControl;
return NS_OK;
}
NS_METHOD nsDOMEvent::SetCtrlKey(PRBool aCtrlKey)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetShiftKey(PRBool* aIsDown)
{
*aIsDown = ((nsInputEvent*)mEvent)->isShift;
return NS_OK;
}
NS_METHOD nsDOMEvent::SetShiftKey(PRBool aShiftKey)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetMetaKey(PRBool* aIsDown)
{
return NS_OK;
}
NS_METHOD nsDOMEvent::SetMetaKey(PRBool aMetaKey)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetCharCode(PRUint32* aCharCode)
{
switch (mEvent->message) {
@ -270,16 +256,11 @@ NS_METHOD nsDOMEvent::GetCharCode(PRUint32* aCharCode)
#endif
break;
default:
return NS_ERROR_FAILURE;
break;
}
return NS_OK;
}
NS_METHOD nsDOMEvent::SetCharCode(PRUint32 aCharCode)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetKeyCode(PRUint32* aKeyCode)
{
switch (mEvent->message) {
@ -289,16 +270,11 @@ NS_METHOD nsDOMEvent::GetKeyCode(PRUint32* aKeyCode)
*aKeyCode = ((nsKeyEvent*)mEvent)->keyCode;
break;
default:
return NS_ERROR_FAILURE;
break;
}
return NS_OK;
}
NS_METHOD nsDOMEvent::SetKeyCode(PRUint32 aKeyCode)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetButton(PRUint32* aButton)
{
switch (mEvent->message) {
@ -321,65 +297,34 @@ NS_METHOD nsDOMEvent::GetButton(PRUint32* aButton)
*aButton = 3;
break;
default:
return NS_ERROR_FAILURE;
break;
}
return NS_OK;
}
NS_METHOD nsDOMEvent::SetButton(PRUint32 aButton)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::GetCancelBubble(PRBool* aCancelBubble)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::SetCancelBubble(PRBool aCancelBubble)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
// nsINSEventInterface
NS_METHOD nsDOMEvent::GetLayerX(PRInt32* aLayerX)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::SetLayerX(PRInt32 aLayerX)
{
return NS_ERROR_NOT_IMPLEMENTED;
*aLayerX = 0;
return NS_OK;
}
NS_METHOD nsDOMEvent::GetLayerY(PRInt32* aLayerY)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsDOMEvent::SetLayerY(PRInt32 aLayerY)
{
return NS_ERROR_NOT_IMPLEMENTED;
*aLayerY = 0;
return NS_OK;
}
NS_METHOD nsDOMEvent::GetPageX(PRInt32* aPageX)
{
return GetClientX(aPageX);
}
NS_METHOD nsDOMEvent::SetPageX(PRInt32 aPageX)
{
return SetClientX(aPageX);
*aPageX = 0;
return NS_OK;
}
NS_METHOD nsDOMEvent::GetPageY(PRInt32* aPageY)
{
return GetClientY(aPageY);
}
NS_METHOD nsDOMEvent::SetPageY(PRInt32 aPageY)
{
return SetClientY(aPageY);
*aPageY = 0;
return NS_OK;
}
NS_METHOD nsDOMEvent::GetWhich(PRUint32* aWhich)
@ -390,18 +335,7 @@ NS_METHOD nsDOMEvent::GetWhich(PRUint32* aWhich)
case NS_MOUSE_EVENT:
return GetButton(aWhich);
}
return NS_ERROR_FAILURE;
}
NS_METHOD nsDOMEvent::SetWhich(PRUint32 aWhich)
{
switch (mEvent->eventStructType) {
case NS_KEY_EVENT:
return SetKeyCode(aWhich);
case NS_MOUSE_EVENT:
return SetButton(aWhich);
}
return NS_ERROR_FAILURE;
return NS_OK;
}
NS_METHOD nsDOMEvent::DuplicatePrivateData()
@ -465,7 +399,7 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
case NS_PAINT:
return mEventNames[eDOMEvents_paint];
case NS_TEXT_EVENT:
return mEventNames[eDOMEvents_text];
return mEventNames[eDOMEvents_text];
default:
break;
}
@ -490,7 +424,7 @@ nsDOMEvent::GetRc(nsIDOMRenderingContext** aRc)
return NS_OK;
}
nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext& aPresContext, nsEvent *aEvent)
nsresult NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext& aPresContext, nsEvent *aEvent)
{
nsDOMEvent* it = new nsDOMEvent(&aPresContext, aEvent);
if (nsnull == it) {
@ -499,3 +433,8 @@ nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext& aPresC
return it->QueryInterface(kIDOMEventIID, (void **) aInstancePtrResult);
}
nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext& aPresContext, nsEvent *aEvent)
{
return NS_ERROR_FAILURE;
}

View File

@ -19,8 +19,8 @@
#ifndef nsDOMEvent_h__
#define nsDOMEvent_h__
#include "nsIDOMEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMUIEvent.h"
#include "nsIDOMNSUIEvent.h"
#include "nsISupports.h"
#include "nsIPrivateDOMEvent.h"
@ -31,7 +31,7 @@ class nsIContent;
class nsIDOMRenderingContext;
class nsDOMEvent : public nsIDOMEvent, public nsIDOMNSEvent, public nsIPrivateDOMEvent {
class nsDOMEvent : public nsIDOMUIEvent, public nsIDOMNSUIEvent, public nsIPrivateDOMEvent {
public:
// Note: this enum must be kept in sync with mEventNames in nsDOMEvent.cpp
@ -66,67 +66,56 @@ public:
// nsIDOMEventInterface
NS_IMETHOD GetType(nsString& aType);
NS_IMETHOD SetType(const nsString& aType);
NS_IMETHOD GetText(nsString& aText);
NS_IMETHOD GetCommitText(PRBool* aCommitText);
NS_IMETHOD SetCommitText(PRBool aCommitText);
NS_IMETHOD GetTarget(nsIDOMNode** aTarget);
NS_IMETHOD SetTarget(nsIDOMNode* aTarget);
NS_IMETHOD GetCurrentNode(nsIDOMNode** aCurrentNode);
NS_IMETHOD GetEventPhase(PRUint16* aEventPhase);
NS_IMETHOD PreventBubble();
NS_IMETHOD PreventCapture();
NS_IMETHOD PreventDefault();
NS_IMETHOD GetText(nsString& aText);
NS_IMETHOD GetCommitText(PRBool* aCommitText);
NS_IMETHOD SetCommitText(PRBool aCommitText);
NS_IMETHOD GetScreenX(PRInt32* aScreenX);
NS_IMETHOD SetScreenX(PRInt32 aScreenX);
NS_IMETHOD GetScreenY(PRInt32* aScreenY);
NS_IMETHOD SetScreenY(PRInt32 aScreenY);
NS_IMETHOD GetClientX(PRInt32* aClientX);
NS_IMETHOD SetClientX(PRInt32 aClientX);
NS_IMETHOD GetClientY(PRInt32* aClientY);
NS_IMETHOD SetClientY(PRInt32 aClientY);
NS_IMETHOD GetAltKey(PRBool* aAltKey);
NS_IMETHOD SetAltKey(PRBool aAltKey);
NS_IMETHOD GetCtrlKey(PRBool* aCtrlKey);
NS_IMETHOD SetCtrlKey(PRBool aCtrlKey);
NS_IMETHOD GetShiftKey(PRBool* aShiftKey);
NS_IMETHOD SetShiftKey(PRBool aShiftKey);
NS_IMETHOD GetMetaKey(PRBool* aMetaKey);
NS_IMETHOD SetMetaKey(PRBool aMetaKey);
NS_IMETHOD GetCharCode(PRUint32* aCharCode);
NS_IMETHOD SetCharCode(PRUint32 aCharCode);
NS_IMETHOD GetKeyCode(PRUint32* aKeyCode);
NS_IMETHOD SetKeyCode(PRUint32 aKeyCode);
NS_IMETHOD GetButton(PRUint32* aButton);
NS_IMETHOD SetButton(PRUint32 aButton);
NS_IMETHOD GetCancelBubble(PRBool* aCancelBubble);
NS_IMETHOD SetCancelBubble(PRBool aCancelBubble);
// nsIDOMNSEvent interface
NS_IMETHOD GetLayerX(PRInt32* aLayerX);
NS_IMETHOD SetLayerX(PRInt32 aLayerX);
NS_IMETHOD GetLayerY(PRInt32* aLayerY);
NS_IMETHOD SetLayerY(PRInt32 aLayerY);
NS_IMETHOD GetPageX(PRInt32* aClientX);
NS_IMETHOD SetPageX(PRInt32 aClientX);
NS_IMETHOD GetPageY(PRInt32* aClientY);
NS_IMETHOD SetPageY(PRInt32 aClientY);
NS_IMETHOD GetWhich(PRUint32* aKeyCode);
NS_IMETHOD SetWhich(PRUint32 aKeyCode);
NS_IMETHOD GetRc(nsIDOMRenderingContext** aRc);

View File

@ -469,7 +469,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
case NS_MOUSE_EXIT:
if (nsnull != mMouseListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
if (NS_OK == ret) {
for (int i=0; i<mMouseListeners->Count(); i++) {
@ -571,7 +571,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
case NS_MOUSE_MOVE:
if (nsnull != mMouseMotionListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
if (NS_OK == ret) {
for (int i=0; i<mMouseMotionListeners->Count(); i++) {
@ -620,7 +620,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
#endif
if (nsnull != mCompositionListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent,aPresContext,aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent,aPresContext,aEvent);
}
if (NS_OK == ret) {
for(int i=0;i<mTextListeners->Count();i++) {
@ -671,7 +671,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
#endif
if (nsnull != mTextListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent,aPresContext,aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent,aPresContext,aEvent);
}
if (NS_OK == ret) {
for (int i=0; i<mTextListeners->Count(); i++) {
@ -706,7 +706,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
case NS_KEY_PRESS:
if (nsnull != mKeyListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
if (NS_OK == ret) {
for (int i=0; i<mKeyListeners->Count(); i++) {
@ -768,7 +768,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
case NS_BLUR_CONTENT:
if (nsnull != mFocusListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
if (NS_OK == ret) {
for (int i=0; i<mFocusListeners->Count(); i++) {
@ -823,7 +823,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
case NS_FORM_CHANGE:
if (nsnull != mFormListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
if (NS_OK == ret) {
for (int i=0; i<mFormListeners->Count(); i++) {
@ -885,7 +885,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
case NS_PAGE_UNLOAD:
if (nsnull != mLoadListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
if (NS_OK == ret) {
for (int i=0; i<mLoadListeners->Count(); i++) {
@ -938,7 +938,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
case NS_PAINT:
if (nsnull != mPaintListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
if (NS_OK == ret) {
for (int i=0; i<mPaintListeners->Count(); i++) {
@ -977,7 +977,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
case NS_DRAGDROP_DROP:
if (nsnull != mDragListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
if (NS_OK == ret) {
@ -1033,7 +1033,7 @@ nsresult nsEventListenerManager::CreateEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent)
{
return NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
return NS_NewDOMUIEvent(aDOMEvent, aPresContext, aEvent);
}
/**

View File

@ -113,6 +113,9 @@ nsEventStateManager::PreHandleEvent(nsIPresContext& aPresContext,
case NS_GOTFOCUS:
//XXX Do we need window related focus change stuff here?
break;
case NS_LOSTFOCUS:
//XXX Do we need window related focus change stuff here?
break;
}
return NS_OK;
}

View File

@ -2238,7 +2238,7 @@ RDFElementImpl::HandleDOMEvent(nsIPresContext& aPresContext,
NS_ERROR("Menu/key event will fail without the ability to create the event early.");
return ret;
}
domEvent->SetTarget(this);
//domEvent->SetTarget(this);
}
}

View File

@ -2238,7 +2238,7 @@ RDFElementImpl::HandleDOMEvent(nsIPresContext& aPresContext,
NS_ERROR("Menu/key event will fail without the ability to create the event early.");
return ret;
}
domEvent->SetTarget(this);
//domEvent->SetTarget(this);
}
}

View File

@ -33,6 +33,7 @@
#include "nsIDOMXULDocument.h"
#include "nsIDocument.h"
#include "nsIContent.h"
#include "nsIDOMUIEvent.h"
////////////////////////////////////////////////////////////////////////
@ -150,10 +151,17 @@ XULPopupListenerImpl::MouseDown(nsIDOMEvent* aMouseEvent)
{
PRUint32 button;
nsCOMPtr<nsIDOMUIEvent>uiEvent;
uiEvent = do_QueryInterface(aMouseEvent);
if (!uiEvent) {
//non-ui event passed in. bad things.
return NS_OK;
}
switch (popupType) {
case eXULPopupType_popup:
// Check for left mouse button down
aMouseEvent->GetButton(&button);
uiEvent->GetButton(&button);
if (button == 1) {
// Time to launch a popup menu.
LaunchPopup(aMouseEvent);
@ -161,7 +169,7 @@ XULPopupListenerImpl::MouseDown(nsIDOMEvent* aMouseEvent)
break;
case eXULPopupType_context:
// Check for right mouse button down
aMouseEvent->GetButton(&button);
uiEvent->GetButton(&button);
// XXX: Handle Mac
if (button == 3) {
// Time to launch a context menu.
@ -237,10 +245,19 @@ XULPopupListenerImpl::LaunchPopup(nsIDOMEvent* anEvent)
if (anchorAlignment == "") {
// We aren't anchored. Create on the point.
// Retrieve our x and y position.
PRInt32 xPos = 50;
PRInt32 yPos = 50; // For now, hardcode to (50,50), since screen doesn't work.
anEvent->GetScreenX(&xPos);
anEvent->GetScreenY(&yPos);
nsCOMPtr<nsIDOMUIEvent>uiEvent;
uiEvent = do_QueryInterface(anEvent);
if (!uiEvent) {
//non-ui event passed in. bad things.
return NS_OK;
}
PRInt32 xPos;
PRInt32 yPos;
uiEvent->GetScreenX(&xPos);
uiEvent->GetScreenY(&yPos);
xPos = 50; // For now, hardcode to (50,50), since screen doesn't work.
yPos = 50;
domWindow->CreatePopup(element, popupContent,
xPos, yPos,

View File

@ -24,6 +24,7 @@
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMHTMLIFrameElement.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMUIEvent.h"
#include "nsIWebShell.h"
#include "nsIScriptContextOwner.h"
@ -35,6 +36,7 @@ static NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID);
static NS_DEFINE_IID(kIDOMKeyListenerIID, NS_IDOMKEYLISTENER_IID);
static NS_DEFINE_IID(kIDOMFormListenerIID, NS_IDOMFORMLISTENER_IID);
static NS_DEFINE_IID(kIDOMLoadListenerIID, NS_IDOMLOADLISTENER_IID);
static NS_DEFINE_IID(kIDOMUIEventIID, NS_IDOMUIEVENT_IID);
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kIScriptContextOwnerIID, NS_ISCRIPTCONTEXTOWNER_IID);
@ -155,24 +157,28 @@ nsresult nsBrowserController::KeyUp(nsIDOMEvent* aKeyEvent)
nsresult rv;
PRUint32 key;
rv = aKeyEvent->GetKeyCode(&key);
if (NS_SUCCEEDED(rv)) {
// If ENTER was pressed in the URL type-in then change to the new URL...
if (0x0d == key) {
nsIDOMUIEvent* uiEvent;
if (NS_SUCCEEDED(aKeyEvent->QueryInterface(kIDOMUIEventIID, (void**)&uiEvent))) {
rv = uiEvent->GetKeyCode(&key);
if (NS_SUCCEEDED(rv)) {
// If ENTER was pressed in the URL type-in then change to the new URL...
if (0x0d == key) {
if ((nsnull != mWebWindow) && (nsnull != mURLTypeIn)) {
nsIDOMHTMLInputElement* element;
rv = mURLTypeIn->QueryInterface(kIDOMHTMLInputElementIID, (void**) &element);
// Get the contents of the URL type-in...
if (NS_SUCCEEDED(rv)) {
nsAutoString name;
if ((nsnull != mWebWindow) && (nsnull != mURLTypeIn)) {
nsIDOMHTMLInputElement* element;
rv = mURLTypeIn->QueryInterface(kIDOMHTMLInputElementIID, (void**) &element);
// Get the contents of the URL type-in...
if (NS_SUCCEEDED(rv)) {
nsAutoString name;
element->GetValue(name);
mWebWindow->LoadURL(name.GetUnicode());
NS_RELEASE(element);
element->GetValue(name);
mWebWindow->LoadURL(name.GetUnicode());
NS_RELEASE(element);
}
}
}
}
NS_RELEASE(uiEvent);
}
return NS_OK;