From c79e9c67d2ff8eb7aaefe6ec01fe543d97c4544a Mon Sep 17 00:00:00 2001 From: "joki%netscape.com" Date: Wed, 3 Nov 1999 07:11:45 +0000 Subject: [PATCH] Changes to DOM events to accomodate the new breakdown of events into mouse and key events. This fixes a couple of bug, though the main one is 13406. Involves changes to multiple DOM generated file as well as fixing up usage of DOM event api usage in editor, rdf, and xul. r:vidur git-svn-id: svn://10.0.0.236/trunk@52691 18797224-902f-48f8-a5cc-f745e15eee43 --- .../events/public/nsIEventStateManager.h | 1 + .../events/public/nsIPrivateDOMEvent.h | 1 + mozilla/content/events/src/nsDOMEvent.cpp | 114 +- mozilla/content/events/src/nsDOMEvent.h | 54 +- .../events/src/nsEventListenerManager.h | 11 +- .../events/src/nsEventStateManager.cpp | 85 +- .../content/events/src/nsEventStateManager.h | 2 + .../xul/content/src/nsXULPopupListener.cpp | 32 +- mozilla/dom/public/base/MANIFEST | 1 + mozilla/dom/public/base/Makefile.in | 1 + mozilla/dom/public/base/makefile.win | 2 +- mozilla/dom/public/base/nsIDOMAbstractView.h | 50 + mozilla/dom/public/coreEvents/MANIFEST | 2 + mozilla/dom/public/coreEvents/Makefile.in | 2 + mozilla/dom/public/coreEvents/makefile.win | 2 + mozilla/dom/public/coreEvents/nsIDOMEvent.h | 12 + .../dom/public/coreEvents/nsIDOMKeyEvent.h | 266 ++++ .../dom/public/coreEvents/nsIDOMMouseEvent.h | 95 ++ .../dom/public/coreEvents/nsIDOMNSUIEvent.h | 4 + mozilla/dom/public/coreEvents/nsIDOMUIEvent.h | 169 +- mozilla/dom/public/idl/base/Window.idl | 7 + mozilla/dom/public/idl/events/Event.idl | 5 + .../dom/public/idl/events/MouseKeyEvent.idl | 243 +++ mozilla/dom/public/idl/events/UIEvent.idl | 147 +- mozilla/dom/public/idl/events/makefile.win | 1 + mozilla/dom/src/base/nsGlobalWindow.cpp | 6 + mozilla/dom/src/base/nsGlobalWindow.h | 3 +- mozilla/dom/src/base/nsJSWindow.cpp | 3 + mozilla/dom/src/events/Makefile.in | 1 + mozilla/dom/src/events/makefile.win | 3 +- .../dom/src/events/nsJSDOMEventListener.cpp | 2 +- mozilla/dom/src/events/nsJSDOMEventListener.h | 2 +- mozilla/dom/src/events/nsJSEvent.cpp | 100 +- mozilla/dom/src/events/nsJSEventListener.cpp | 2 +- mozilla/dom/src/events/nsJSEventListener.h | 2 +- mozilla/dom/src/events/nsJSKeyEvent.cpp | 1359 +++++++++++++++++ mozilla/dom/src/events/nsJSUIEvent.cpp | 709 ++------- .../editor/base/nsEditorEventListeners.cpp | 80 +- mozilla/editor/base/nsHTMLEditor.cpp | 10 +- mozilla/editor/base/nsHTMLEditor.h | 4 +- .../editor/libeditor/html/nsHTMLEditor.cpp | 10 +- mozilla/editor/libeditor/html/nsHTMLEditor.h | 4 +- .../libeditor/text/nsEditorEventListeners.cpp | 80 +- mozilla/editor/public/nsIHTMLEditor.h | 4 +- mozilla/layout/base/nsPresShell.cpp | 10 +- mozilla/layout/base/src/nsRangeList.cpp | 38 +- .../events/public/nsIEventStateManager.h | 1 + .../layout/events/public/nsIPrivateDOMEvent.h | 1 + mozilla/layout/events/src/nsDOMEvent.cpp | 114 +- mozilla/layout/events/src/nsDOMEvent.h | 54 +- .../events/src/nsEventListenerManager.h | 11 +- .../layout/events/src/nsEventStateManager.cpp | 85 +- .../layout/events/src/nsEventStateManager.h | 2 + mozilla/layout/forms/nsListControlFrame.cpp | 29 +- mozilla/layout/html/base/src/nsPresShell.cpp | 10 +- .../html/forms/src/nsGfxTextControlFrame.cpp | 109 +- .../html/forms/src/nsGfxTextControlFrame.h | 5 +- .../html/forms/src/nsListControlFrame.cpp | 29 +- .../layout/xul/base/src/nsMenuBarListener.cpp | 18 +- mozilla/layout/xul/base/src/nsSliderFrame.cpp | 8 +- .../layout/xul/base/src/nsSplitterFrame.cpp | 8 +- .../xul/base/src/nsToolbarDragListener.cpp | 8 +- mozilla/rdf/content/src/nsXULKeyListener.cpp | 22 +- .../rdf/content/src/nsXULPopupListener.cpp | 32 +- mozilla/widget/public/nsGUIEvent.h | 3 + 65 files changed, 3055 insertions(+), 1235 deletions(-) create mode 100644 mozilla/dom/public/base/nsIDOMAbstractView.h create mode 100644 mozilla/dom/public/coreEvents/nsIDOMKeyEvent.h create mode 100644 mozilla/dom/public/coreEvents/nsIDOMMouseEvent.h create mode 100644 mozilla/dom/public/idl/events/MouseKeyEvent.idl create mode 100644 mozilla/dom/src/events/nsJSKeyEvent.cpp diff --git a/mozilla/content/events/public/nsIEventStateManager.h b/mozilla/content/events/public/nsIEventStateManager.h index c7e161cbb95..81c879af2e3 100644 --- a/mozilla/content/events/public/nsIEventStateManager.h +++ b/mozilla/content/events/public/nsIEventStateManager.h @@ -59,6 +59,7 @@ public: NS_IMETHOD GetEventTarget(nsIFrame **aFrame) = 0; NS_IMETHOD GetEventTargetContent(nsIContent** aContent) = 0; + NS_IMETHOD GetEventRelatedContent(nsIContent** aContent) = 0; NS_IMETHOD GetContentState(nsIContent *aContent, PRInt32& aState) = 0; NS_IMETHOD SetContentState(nsIContent *aContent, PRInt32 aState) = 0; diff --git a/mozilla/content/events/public/nsIPrivateDOMEvent.h b/mozilla/content/events/public/nsIPrivateDOMEvent.h index 9041501d2a8..1c81d8cbb02 100644 --- a/mozilla/content/events/public/nsIPrivateDOMEvent.h +++ b/mozilla/content/events/public/nsIPrivateDOMEvent.h @@ -33,6 +33,7 @@ class nsIPresContext; {0xbd, 0x89, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4} } class nsIDOMNode; +class nsIDOMEvent; class nsIPrivateDOMEvent : public nsISupports { diff --git a/mozilla/content/events/src/nsDOMEvent.cpp b/mozilla/content/events/src/nsDOMEvent.cpp index 691e72db84f..b536a5aecf3 100644 --- a/mozilla/content/events/src/nsDOMEvent.cpp +++ b/mozilla/content/events/src/nsDOMEvent.cpp @@ -34,6 +34,8 @@ 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(kIDOMUIEventIID, NS_IDOMUIEVENT_IID); +static NS_DEFINE_IID(kIDOMKeyEventIID, NS_IDOMKEYEVENT_IID); +static NS_DEFINE_IID(kIDOMMouseEventIID, NS_IDOMMOUSEEVENT_IID); static NS_DEFINE_IID(kIDOMNSUIEventIID, NS_IDOMNSUIEVENT_IID); static NS_DEFINE_IID(kIPrivateDOMEventIID, NS_IPRIVATEDOMEVENT_IID); static NS_DEFINE_IID(kIPrivateTextEventIID, NS_IPRIVATETEXTEVENT_IID); @@ -105,12 +107,22 @@ nsresult nsDOMEvent::QueryInterface(const nsIID& aIID, return NS_ERROR_NULL_POINTER; } if (aIID.Equals(kIDOMEventIID)) { - *aInstancePtrResult = (void*) ((nsIDOMEvent*)this); + *aInstancePtrResult = (void*) ((nsIDOMEvent*)(nsIDOMUIEvent*)(nsIDOMMouseEvent*)this); AddRef(); return NS_OK; } if (aIID.Equals(kIDOMUIEventIID)) { - *aInstancePtrResult = (void*) ((nsIDOMUIEvent*)this); + *aInstancePtrResult = (void*) ((nsIDOMUIEvent*)(nsIDOMMouseEvent*)this); + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIDOMMouseEventIID)) { + *aInstancePtrResult = (void*) ((nsIDOMMouseEvent*)this); + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIDOMKeyEventIID)) { + *aInstancePtrResult = (void*) ((nsIDOMKeyEvent*)this); AddRef(); return NS_OK; } @@ -205,13 +217,13 @@ NS_IMETHODIMP nsDOMEvent::GetEventPhase(PRUint16* aEventPhase) { if (mEvent->flags & NS_EVENT_FLAG_CAPTURE) { - *aEventPhase = CAPTURING_PHASE; + *aEventPhase = nsIDOMMouseEvent::CAPTURING_PHASE; } else if (mEvent->flags & NS_EVENT_FLAG_BUBBLE) { - *aEventPhase = BUBBLING_PHASE; + *aEventPhase = nsIDOMMouseEvent::BUBBLING_PHASE; } else if (mEvent->flags & NS_EVENT_FLAG_INIT) { - *aEventPhase = AT_TARGET; + *aEventPhase = nsIDOMMouseEvent::AT_TARGET; } else { *aEventPhase = 0; @@ -220,6 +232,18 @@ nsDOMEvent::GetEventPhase(PRUint16* aEventPhase) return NS_OK; } +NS_IMETHODIMP +nsDOMEvent::GetBubbles(PRBool* aBubbles) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDOMEvent::GetCancelable(PRBool* aCancelable) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsDOMEvent::PreventBubble() { @@ -245,6 +269,18 @@ nsDOMEvent::PreventDefault() return NS_OK; } +NS_IMETHODIMP +nsDOMEvent::GetView(nsIDOMAbstractView** aView) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDOMEvent::GetDetail(PRInt32* aDetail) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_METHOD nsDOMEvent::GetText(nsString& aText) { if (mEvent->message == NS_TEXT_EVENT) { @@ -555,6 +591,28 @@ NS_METHOD nsDOMEvent::GetClickCount(PRUint16* aClickCount) return NS_OK; } +NS_METHOD nsDOMEvent::GetRelatedNode(nsIDOMNode** aRelatedNode) +{ + nsIEventStateManager *manager; + nsIContent *relatedContent; + nsresult ret = NS_OK; + + if (NS_OK == mPresContext->GetEventStateManager(&manager)) { + manager->GetEventRelatedContent(&relatedContent); + NS_RELEASE(manager); + } + + if (relatedContent) { + ret = relatedContent->QueryInterface(kIDOMNodeIID, (void**)aRelatedNode); + NS_RELEASE(relatedContent); + } + else { + *aRelatedNode = nsnull; + } + + return ret; +} + // nsINSEventInterface NS_METHOD nsDOMEvent::GetLayerX(PRInt32* aLayerX) { @@ -694,6 +752,52 @@ NS_METHOD nsDOMEvent::SetCancelBubble(PRBool aCancelBubble) return NS_OK; } +NS_METHOD nsDOMEvent::GetIsChar(PRBool* aIsChar) +{ + if (!mEvent) { + *aIsChar = PR_FALSE; + return NS_OK; + } + if (mEvent->eventStructType == NS_KEY_EVENT) { + *aIsChar = ((nsKeyEvent*)mEvent)->isChar; + return NS_OK; + } + if (mEvent->eventStructType == NS_TEXT_EVENT) { + *aIsChar = ((nsTextEvent*)mEvent)->isChar; + return NS_OK; + } + + *aIsChar = PR_FALSE; + return NS_OK; +} + +//XXX The following four methods are for custom event dispatch inside the DOM. +//They will be implemented post-beta +NS_IMETHODIMP +nsDOMEvent::InitEvent(const nsString& aEventTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDOMEvent::InitUIEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, nsIDOMAbstractView* aViewArg, PRInt32 aDetailArg) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDOMEvent::InitMouseEvent(const nsString& aTypeArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRInt32 aScreenXArg, PRInt32 aScreenYArg, PRInt32 aClientXArg, PRInt32 aClientYArg, PRUint16 aButtonArg, PRUint16 aDetailArg) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDOMEvent::InitKeyEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRUint32 aKeyCodeArg, PRUint32 aCharCodeArg, nsIDOMAbstractView* aViewArg) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + NS_METHOD nsDOMEvent::DuplicatePrivateData() { //XXX Write me! diff --git a/mozilla/content/events/src/nsDOMEvent.h b/mozilla/content/events/src/nsDOMEvent.h index 1be4fd111da..7d3219910c1 100644 --- a/mozilla/content/events/src/nsDOMEvent.h +++ b/mozilla/content/events/src/nsDOMEvent.h @@ -19,20 +19,27 @@ #ifndef nsDOMEvent_h__ #define nsDOMEvent_h__ -#include "nsIDOMUIEvent.h" +#include "nsIDOMKeyEvent.h" +#include "nsIDOMMouseEvent.h" #include "nsIDOMNSUIEvent.h" #include "nsISupports.h" #include "nsIPrivateDOMEvent.h" #include "nsIPrivateCompositionEvent.h" #include "nsIPrivateTextEvent.h" #include "nsIPrivateTextRange.h" +#include "nsIDOMEvent.h" #include "nsIPresContext.h" #include "nsPoint.h" #include "nsGUIEvent.h" class nsIContent; -class nsDOMEvent : public nsIDOMUIEvent, public nsIDOMNSUIEvent, public nsIPrivateDOMEvent, public nsIPrivateTextEvent, public nsIPrivateCompositionEvent { +class nsDOMEvent : public nsIDOMKeyEvent, + public nsIDOMMouseEvent, + public nsIDOMNSUIEvent, + public nsIPrivateDOMEvent, + public nsIPrivateTextEvent, + public nsIPrivateCompositionEvent { public: // Note: this enum must be kept in sync with mEventNames in nsDOMEvent.cpp @@ -77,62 +84,51 @@ public: NS_DECL_ISUPPORTS - // nsIDOMEventInterface + // nsIDOMEvent Interface NS_IMETHOD GetType(nsString& aType); - NS_IMETHOD GetTarget(nsIDOMNode** aTarget); - NS_IMETHOD GetCurrentNode(nsIDOMNode** aCurrentNode); - NS_IMETHOD GetEventPhase(PRUint16* aEventPhase); - + NS_IMETHOD GetBubbles(PRBool* aBubbles); + NS_IMETHOD GetCancelable(PRBool* aCancelable); NS_IMETHOD PreventBubble(); - NS_IMETHOD PreventCapture(); - NS_IMETHOD PreventDefault(); + NS_IMETHOD InitEvent(const nsString& aEventTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg); + // nsIDOMUIEvent Interface + NS_IMETHOD GetView(nsIDOMAbstractView** aView); + NS_IMETHOD GetDetail(PRInt32* aDetail); + NS_IMETHOD InitUIEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, nsIDOMAbstractView* aViewArg, PRInt32 aDetailArg); + + // nsIDOMMouseEvent Interface and nsIDOMKeyEvent Interface 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(PRUint16* aButton); - NS_IMETHOD GetClickCount(PRUint16* aClickCount); + NS_IMETHOD GetRelatedNode(nsIDOMNode** aRelatedNode); + NS_IMETHOD GetCharCode(PRUint32* aCharCode); + NS_IMETHOD GetKeyCode(PRUint32* aKeyCode); + NS_IMETHOD InitMouseEvent(const nsString& aTypeArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRInt32 aScreenXArg, PRInt32 aScreenYArg, PRInt32 aClientXArg, PRInt32 aClientYArg, PRUint16 aButtonArg, PRUint16 aDetailArg); + NS_IMETHOD InitKeyEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRUint32 aKeyCodeArg, PRUint32 aCharCodeArg, nsIDOMAbstractView* aViewArg); // nsIDOMNSUIEvent interface NS_IMETHOD GetLayerX(PRInt32* aLayerX); - NS_IMETHOD GetLayerY(PRInt32* aLayerY); - NS_IMETHOD GetPageX(PRInt32* aClientX); - NS_IMETHOD GetPageY(PRInt32* aClientY); - NS_IMETHOD GetWhich(PRUint32* aKeyCode); - NS_IMETHOD GetRangeParent(nsIDOMNode** aRangeParent); - NS_IMETHOD GetRangeOffset(PRInt32* aRangeOffset); - NS_IMETHOD GetCancelBubble(PRBool* aCancelBubble); NS_IMETHOD SetCancelBubble(PRBool aCancelBubble); + NS_IMETHOD GetIsChar(PRBool* aIsChar); // nsIPrivateDOMEvent interface NS_IMETHOD DuplicatePrivateData(); diff --git a/mozilla/content/events/src/nsEventListenerManager.h b/mozilla/content/events/src/nsEventListenerManager.h index 56c5bf51eb6..44c23e992f2 100644 --- a/mozilla/content/events/src/nsEventListenerManager.h +++ b/mozilla/content/events/src/nsEventListenerManager.h @@ -167,11 +167,12 @@ protected: #define NS_EVENT_BITS_LOAD_ERROR 0x08 //nsIDOMMenuListener -#define NS_EVENT_BITS_MENU_CREATE 0x00 -#define NS_EVENT_BITS_MENU_DESTROY 0x01 -#define NS_EVENT_BITS_MENU_ACTION 0x02 -#define NS_EVENT_BITS_XUL_BROADCAST 0x04 -#define NS_EVENT_BITS_XUL_COMMAND_UPDATE 0x08 +#define NS_EVENT_BITS_MENU_NONE 0x00 +#define NS_EVENT_BITS_MENU_CREATE 0x01 +#define NS_EVENT_BITS_MENU_DESTROY 0x02 +#define NS_EVENT_BITS_MENU_ACTION 0x04 +#define NS_EVENT_BITS_XUL_BROADCAST 0x08 +#define NS_EVENT_BITS_XUL_COMMAND_UPDATE 0x10 //nsIDOMDragListener #define NS_EVENT_BITS_DRAG_NONE 0x00 diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index eef70b3b90e..1bdd210e31b 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -63,6 +63,7 @@ nsEventStateManager::nsEventStateManager() mLastDragOverFrame = nsnull; mCurrentTarget = nsnull; mCurrentTargetContent = nsnull; + mCurrentRelatedContent = nsnull; mLastLeftMouseDownContent = nsnull; mLastMiddleMouseDownContent = nsnull; mLastRightMouseDownContent = nsnull; @@ -89,6 +90,7 @@ nsEventStateManager::nsEventStateManager() nsEventStateManager::~nsEventStateManager() { NS_IF_RELEASE(mCurrentTargetContent); + NS_IF_RELEASE(mCurrentRelatedContent); NS_IF_RELEASE(mLastLeftMouseDownContent); NS_IF_RELEASE(mLastMiddleMouseDownContent); @@ -551,6 +553,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext, } } } + return ret; } @@ -659,6 +662,9 @@ nsEventStateManager::UpdateCursor(nsIPresContext& aPresContext, nsPoint& aPoint, void nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIEvent* aEvent) { + //Hold onto old target content through the event and reset after. + nsCOMPtr targetBeforeEvent = mCurrentTargetContent; + switch(aEvent->message) { case NS_MOUSE_MOVE: { @@ -683,6 +689,11 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE //The frame has change but the content may not have. Check before dispatching to content mLastMouseOverFrame->GetContent(getter_AddRefs(lastContent)); + mCurrentTargetContent = lastContent; + NS_IF_ADDREF(mCurrentTargetContent); + mCurrentRelatedContent = targetContent; + NS_IF_ADDREF(mCurrentRelatedContent); + if (lastContent != targetContent) { //XXX This event should still go somewhere!! if (nsnull != lastContent) { @@ -695,6 +706,9 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE //XXX Get the new frame mLastMouseOverFrame->HandleEvent(aPresContext, &event, status); } + + NS_IF_RELEASE(mCurrentTargetContent); + NS_IF_RELEASE(mCurrentRelatedContent); } //fire mouseover @@ -707,6 +721,11 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE event.point = aEvent->point; event.refPoint = aEvent->refPoint; + mCurrentTargetContent = targetContent; + NS_IF_ADDREF(mCurrentTargetContent); + mCurrentRelatedContent = lastContent; + NS_IF_ADDREF(mCurrentRelatedContent); + //The frame has change but the content may not have. Check before dispatching to content if (lastContent != targetContent) { //XXX This event should still go somewhere!! @@ -725,14 +744,15 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE mCurrentTarget->HandleEvent(aPresContext, &event, status); } + NS_IF_RELEASE(mCurrentTargetContent); + NS_IF_RELEASE(mCurrentRelatedContent); mLastMouseOverFrame = mCurrentTarget; } } break; case NS_MOUSE_EXIT: { - //This is actually the window mouse exit event. Such a think does not - // yet exist but it will need to eventually. + //This is actually the window mouse exit event. if (nsnull != mLastMouseOverFrame) { //fire mouseout nsEventStatus status = nsEventStatus_eIgnore; @@ -747,6 +767,10 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE nsCOMPtr lastContent; mLastMouseOverFrame->GetContent(getter_AddRefs(lastContent)); + mCurrentTargetContent = lastContent; + NS_IF_ADDREF(mCurrentTargetContent); + mCurrentRelatedContent = nsnull; + if (lastContent) { lastContent->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status); @@ -762,16 +786,23 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE mLastMouseOverFrame->HandleEvent(aPresContext, &event, status); mLastMouseOverFrame = nsnull; } + + NS_IF_RELEASE(mCurrentTargetContent); } } break; } - + + //reset mCurretTargetContent to what it was + mCurrentTargetContent = targetBeforeEvent; } void nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext& aPresContext, nsGUIEvent* aEvent) { + //Hold onto old target content through the event and reset after. + nsCOMPtr targetBeforeEvent = mCurrentTargetContent; + switch(aEvent->message) { case NS_DRAGDROP_OVER: { @@ -795,6 +826,11 @@ nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext& aPresContext, nsG //The frame has change but the content may not have. Check before dispatching to content mLastDragOverFrame->GetContent(getter_AddRefs(lastContent)); + mCurrentTargetContent = lastContent; + NS_IF_ADDREF(mCurrentTargetContent); + mCurrentRelatedContent = targetContent; + NS_IF_ADDREF(mCurrentRelatedContent); + if ( lastContent != targetContent ) { //XXX This event should still go somewhere!! if (lastContent) @@ -806,8 +842,13 @@ nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext& aPresContext, nsG } // Finally dispatch exit to the frame - if ( mLastDragOverFrame ) + if ( mLastDragOverFrame ) { mLastDragOverFrame->HandleEvent(aPresContext, &event, status); + + NS_IF_RELEASE(mCurrentTargetContent); + NS_IF_RELEASE(mCurrentRelatedContent); + + } } //fire drag enter @@ -820,6 +861,11 @@ nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext& aPresContext, nsG event.point = aEvent->point; event.refPoint = aEvent->refPoint; + mCurrentTargetContent = targetContent; + NS_IF_ADDREF(mCurrentTargetContent); + mCurrentRelatedContent = lastContent; + NS_IF_ADDREF(mCurrentRelatedContent); + //The frame has change but the content may not have. Check before dispatching to content if ( lastContent != targetContent ) { //XXX This event should still go somewhere!! @@ -837,6 +883,8 @@ nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext& aPresContext, nsG mCurrentTarget->HandleEvent(aPresContext, &event, status); } + NS_IF_RELEASE(mCurrentTargetContent); + NS_IF_RELEASE(mCurrentRelatedContent); mLastDragOverFrame = mCurrentTarget; } } @@ -845,8 +893,7 @@ nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext& aPresContext, nsG case NS_DRAGDROP_DROP: case NS_DRAGDROP_EXIT: { - //This is actually the window mouse exit event. Such a think does not - // yet exist but it will need to eventually. + //This is actually the window mouse exit event. if ( mLastDragOverFrame ) { // fire mouseout @@ -862,6 +909,11 @@ nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext& aPresContext, nsG // dispatch to content via DOM nsCOMPtr lastContent; mLastDragOverFrame->GetContent(getter_AddRefs(lastContent)); + + mCurrentTargetContent = lastContent; + NS_IF_ADDREF(mCurrentTargetContent); + mCurrentRelatedContent = nsnull; + if ( lastContent ) { lastContent->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status); if ( status != nsEventStatus_eConsumeNoDefault ) @@ -874,11 +926,15 @@ nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext& aPresContext, nsG mLastDragOverFrame->HandleEvent(aPresContext, &event, status); mLastDragOverFrame = nsnull; } - } + + NS_IF_RELEASE(mCurrentTargetContent); + } } break; } - + + //reset mCurretTargetContent to what it was + mCurrentTargetContent = targetBeforeEvent; } NS_IMETHODIMP @@ -1325,6 +1381,19 @@ nsEventStateManager::GetEventTargetContent(nsIContent** aContent) return NS_OK; } +NS_IMETHODIMP +nsEventStateManager::GetEventRelatedContent(nsIContent** aContent) +{ + if (mCurrentRelatedContent) { + *aContent = mCurrentRelatedContent; + NS_IF_ADDREF(*aContent); + return NS_OK; + } + + *aContent = nsnull; + return NS_OK; +} + NS_IMETHODIMP nsEventStateManager::GetContentState(nsIContent *aContent, PRInt32& aState) { diff --git a/mozilla/content/events/src/nsEventStateManager.h b/mozilla/content/events/src/nsEventStateManager.h index 899a9f64634..de977f38deb 100644 --- a/mozilla/content/events/src/nsEventStateManager.h +++ b/mozilla/content/events/src/nsEventStateManager.h @@ -53,6 +53,7 @@ public: NS_IMETHOD GetEventTarget(nsIFrame **aFrame); NS_IMETHOD GetEventTargetContent(nsIContent** aContent); + NS_IMETHOD GetEventRelatedContent(nsIContent** aContent); NS_IMETHOD GetContentState(nsIContent *aContent, PRInt32& aState); NS_IMETHOD SetContentState(nsIContent *aContent, PRInt32 aState); @@ -84,6 +85,7 @@ protected: //Any frames here must be checked for validity in ClearFrameRefs nsIFrame* mCurrentTarget; nsIContent* mCurrentTargetContent; + nsIContent* mCurrentRelatedContent; nsIFrame* mLastMouseOverFrame; nsIFrame* mLastDragOverFrame; diff --git a/mozilla/content/xul/content/src/nsXULPopupListener.cpp b/mozilla/content/xul/content/src/nsXULPopupListener.cpp index ef4afba68f5..2e0e51908ec 100644 --- a/mozilla/content/xul/content/src/nsXULPopupListener.cpp +++ b/mozilla/content/xul/content/src/nsXULPopupListener.cpp @@ -34,7 +34,7 @@ #include "nsIDOMXULDocument.h" #include "nsIDocument.h" #include "nsIContent.h" -#include "nsIDOMUIEvent.h" +#include "nsIDOMMouseEvent.h" #include "nsITimer.h" @@ -188,16 +188,16 @@ XULPopupListenerImpl::MouseDown(nsIDOMEvent* aMouseEvent) { PRUint16 button; - nsCOMPtr uiEvent; - uiEvent = do_QueryInterface(aMouseEvent); - if (!uiEvent) { + nsCOMPtr mouseEvent; + mouseEvent = do_QueryInterface(aMouseEvent); + if (!mouseEvent) { //non-ui event passed in. bad things. return NS_OK; } // Get the node that was clicked on. nsCOMPtr targetNode; - uiEvent->GetTarget( getter_AddRefs( targetNode ) ); + mouseEvent->GetTarget( getter_AddRefs( targetNode ) ); // Get the document with the popup. nsCOMPtr document; @@ -221,7 +221,7 @@ XULPopupListenerImpl::MouseDown(nsIDOMEvent* aMouseEvent) switch (popupType) { case eXULPopupType_popup: // Check for left mouse button down - uiEvent->GetButton(&button); + mouseEvent->GetButton(&button); if (button == 1) { // Time to launch a popup menu. LaunchPopup(aMouseEvent); @@ -231,11 +231,11 @@ XULPopupListenerImpl::MouseDown(nsIDOMEvent* aMouseEvent) #ifdef XP_MAC // XXX: Handle Mac (currently checks if CTRL key is down) PRBool ctrlKey = PR_FALSE; - uiEvent->GetCtrlKey(&ctrlKey); + mouseEvent->GetCtrlKey(&ctrlKey); if (ctrlKey == PR_TRUE) #else // Check for right mouse button down - uiEvent->GetButton(&button); + mouseEvent->GetButton(&button); if (button == 3) #endif { @@ -266,15 +266,15 @@ XULPopupListenerImpl::MouseMove(nsIDOMEvent* aMouseEvent) if ( popupType != eXULPopupType_tooltip ) return NS_OK; - nsCOMPtr uiEvent ( do_QueryInterface(aMouseEvent) ); - if (!uiEvent) + nsCOMPtr mouseEvent ( do_QueryInterface(aMouseEvent) ); + if (!mouseEvent) return NS_OK; // stash the coordinates of the event so that we can still get back to it from within the // timer scallback. Also stash the node that started this so we can put it into the // document later on (if the timer ever fires). - uiEvent->GetClientX(&mMouseClientX); - uiEvent->GetClientY(&mMouseClientY); + mouseEvent->GetClientX(&mMouseClientX); + mouseEvent->GetClientY(&mMouseClientY); //XXX recognize when a popup is already up and immediately show the //XXX tooltip for the new item if the dom element is different than @@ -383,15 +383,15 @@ nsresult XULPopupListenerImpl::LaunchPopup ( nsIDOMEvent* anEvent ) { // Retrieve our x and y position. - nsCOMPtr uiEvent ( do_QueryInterface(anEvent) ); - if (!uiEvent) { + nsCOMPtr mouseEvent ( do_QueryInterface(anEvent) ); + if (!mouseEvent) { //non-ui event passed in. bad things. return NS_OK; } PRInt32 xPos, yPos; - uiEvent->GetClientX(&xPos); - uiEvent->GetClientY(&yPos); + mouseEvent->GetClientX(&xPos); + mouseEvent->GetClientY(&yPos); return LaunchPopup(xPos, yPos); } diff --git a/mozilla/dom/public/base/MANIFEST b/mozilla/dom/public/base/MANIFEST index 7f6f2bcbb52..47f791e6a74 100644 --- a/mozilla/dom/public/base/MANIFEST +++ b/mozilla/dom/public/base/MANIFEST @@ -30,3 +30,4 @@ nsIDOMPluginArray.h nsIDOMBarProp.h nsIDOMDOMException.h nsPIDOMWindow.h +nsIDOMAbstractView.h diff --git a/mozilla/dom/public/base/Makefile.in b/mozilla/dom/public/base/Makefile.in index 21300fb2776..79539a7f79b 100644 --- a/mozilla/dom/public/base/Makefile.in +++ b/mozilla/dom/public/base/Makefile.in @@ -39,6 +39,7 @@ EXPORTS = \ nsIDOMBarProp.h \ nsIDOMDOMException.h \ nsPIDOMWindow.h \ + nsIDOMAbstractView.h \ $(NULL) EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) diff --git a/mozilla/dom/public/base/makefile.win b/mozilla/dom/public/base/makefile.win index 994430bd7d3..ce281526b99 100644 --- a/mozilla/dom/public/base/makefile.win +++ b/mozilla/dom/public/base/makefile.win @@ -23,7 +23,7 @@ EXPORTS=nsIDOMWindow.h nsIDOMNavigator.h nsIDOMLocation.h nsIDOMNSLocation.h \ nsIDOMWindowCollection.h nsIDOMScreen.h nsIDOMHistory.h \ nsIDOMMimeType.h nsIDOMMimeTypeArray.h \ nsIDOMPlugin.h nsIDOMPluginArray.h nsIDOMBarProp.h \ - nsIDOMDOMException.h nsPIDOMWindow.h + nsIDOMDOMException.h nsPIDOMWindow.h nsIDOMAbstractView.h MODULE=dom diff --git a/mozilla/dom/public/base/nsIDOMAbstractView.h b/mozilla/dom/public/base/nsIDOMAbstractView.h new file mode 100644 index 00000000000..7694ec1762e --- /dev/null +++ b/mozilla/dom/public/base/nsIDOMAbstractView.h @@ -0,0 +1,50 @@ +/* -*- 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 nsIDOMAbstractView_h__ +#define nsIDOMAbstractView_h__ + +#include "nsISupports.h" +#include "nsString.h" +#include "nsIScriptContext.h" + +class nsIDOMDocument; + +#define NS_IDOMABSTRACTVIEW_IID \ + { 0xf51ebade, 0x8b1a, 0x11d3, \ + { 0xaa, 0xe7, 0x00, 0x10, 0x83, 0x01, 0x23, 0xb4 } } + +class nsIDOMAbstractView : public nsISupports { +public: + static const nsIID& GetIID() { static nsIID iid = NS_IDOMABSTRACTVIEW_IID; return iid; } + + NS_IMETHOD GetDocument(nsIDOMDocument** aDocument)=0; +}; + + +#define NS_DECL_IDOMABSTRACTVIEW \ + NS_IMETHOD GetDocument(nsIDOMDocument** aDocument); \ + + + +#define NS_FORWARD_IDOMABSTRACTVIEW(_to) \ + NS_IMETHOD GetDocument(nsIDOMDocument** aDocument) { return _to GetDocument(aDocument); } \ + + +#endif // nsIDOMAbstractView_h__ diff --git a/mozilla/dom/public/coreEvents/MANIFEST b/mozilla/dom/public/coreEvents/MANIFEST index 525eec2aef3..83a549c6a40 100644 --- a/mozilla/dom/public/coreEvents/MANIFEST +++ b/mozilla/dom/public/coreEvents/MANIFEST @@ -4,6 +4,8 @@ nsIDOMEvent.h nsIDOMUIEvent.h +nsIDOMKeyEvent.h +nsIDOMMouseEvent.h nsIDOMNSUIEvent.h nsIDOMEventListener.h nsIDOMEventCapturer.h diff --git a/mozilla/dom/public/coreEvents/Makefile.in b/mozilla/dom/public/coreEvents/Makefile.in index 57b3f9ffbee..a278687d244 100644 --- a/mozilla/dom/public/coreEvents/Makefile.in +++ b/mozilla/dom/public/coreEvents/Makefile.in @@ -27,6 +27,8 @@ MODULE = dom EXPORTS = \ nsIDOMEvent.h \ nsIDOMUIEvent.h \ + nsIDOMKeyEvent.h \ + nsIDOMMouseEvent.h \ nsIDOMEventListener.h \ nsIDOMEventCapturer.h \ nsIDOMEventReceiver.h \ diff --git a/mozilla/dom/public/coreEvents/makefile.win b/mozilla/dom/public/coreEvents/makefile.win index 81888c316f1..a62ebefe808 100644 --- a/mozilla/dom/public/coreEvents/makefile.win +++ b/mozilla/dom/public/coreEvents/makefile.win @@ -23,6 +23,8 @@ DEFINES=-D_IMPL_NS_DOM EXPORTS = \ nsIDOMEvent.h \ nsIDOMUIEvent.h \ + nsIDOMKeyEvent.h \ + nsIDOMMouseEvent.h \ nsIDOMEventListener.h \ nsIDOMEventCapturer.h \ nsIDOMEventReceiver.h \ diff --git a/mozilla/dom/public/coreEvents/nsIDOMEvent.h b/mozilla/dom/public/coreEvents/nsIDOMEvent.h index df5464383c8..ec9f83109a2 100644 --- a/mozilla/dom/public/coreEvents/nsIDOMEvent.h +++ b/mozilla/dom/public/coreEvents/nsIDOMEvent.h @@ -47,11 +47,17 @@ public: NS_IMETHOD GetEventPhase(PRUint16* aEventPhase)=0; + NS_IMETHOD GetBubbles(PRBool* aBubbles)=0; + + NS_IMETHOD GetCancelable(PRBool* aCancelable)=0; + NS_IMETHOD PreventBubble()=0; NS_IMETHOD PreventCapture()=0; NS_IMETHOD PreventDefault()=0; + + NS_IMETHOD InitEvent(const nsString& aEventTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg)=0; }; @@ -60,9 +66,12 @@ public: NS_IMETHOD GetTarget(nsIDOMNode** aTarget); \ NS_IMETHOD GetCurrentNode(nsIDOMNode** aCurrentNode); \ NS_IMETHOD GetEventPhase(PRUint16* aEventPhase); \ + NS_IMETHOD GetBubbles(PRBool* aBubbles); \ + NS_IMETHOD GetCancelable(PRBool* aCancelable); \ NS_IMETHOD PreventBubble(); \ NS_IMETHOD PreventCapture(); \ NS_IMETHOD PreventDefault(); \ + NS_IMETHOD InitEvent(const nsString& aEventTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg); \ @@ -71,9 +80,12 @@ public: NS_IMETHOD GetTarget(nsIDOMNode** aTarget) { return _to GetTarget(aTarget); } \ NS_IMETHOD GetCurrentNode(nsIDOMNode** aCurrentNode) { return _to GetCurrentNode(aCurrentNode); } \ NS_IMETHOD GetEventPhase(PRUint16* aEventPhase) { return _to GetEventPhase(aEventPhase); } \ + NS_IMETHOD GetBubbles(PRBool* aBubbles) { return _to GetBubbles(aBubbles); } \ + NS_IMETHOD GetCancelable(PRBool* aCancelable) { return _to GetCancelable(aCancelable); } \ NS_IMETHOD PreventBubble() { return _to PreventBubble(); } \ NS_IMETHOD PreventCapture() { return _to PreventCapture(); } \ NS_IMETHOD PreventDefault() { return _to PreventDefault(); } \ + NS_IMETHOD InitEvent(const nsString& aEventTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg) { return _to InitEvent(aEventTypeArg, aCanBubbleArg, aCancelableArg); } \ extern "C" NS_DOM nsresult NS_InitEventClass(nsIScriptContext *aContext, void **aPrototype); diff --git a/mozilla/dom/public/coreEvents/nsIDOMKeyEvent.h b/mozilla/dom/public/coreEvents/nsIDOMKeyEvent.h new file mode 100644 index 00000000000..ca4d9ae0cf9 --- /dev/null +++ b/mozilla/dom/public/coreEvents/nsIDOMKeyEvent.h @@ -0,0 +1,266 @@ +/* -*- 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 nsIDOMKeyEvent_h__ +#define nsIDOMKeyEvent_h__ + +#include "nsISupports.h" +#include "nsString.h" +#include "nsIScriptContext.h" +#include "nsIDOMUIEvent.h" + +class nsIDOMAbstractView; + +#define NS_IDOMKEYEVENT_IID \ + { 0x028e0e6e, 0x8b01, 0x11d3, \ + { 0xaa, 0xe7, 0x00, 0x10, 0x83, 0x8a, 0x31, 0x23 } } + +class nsIDOMKeyEvent : public nsIDOMUIEvent { +public: + static const nsIID& GetIID() { static nsIID iid = NS_IDOMKEYEVENT_IID; return iid; } + enum { + DOM_CHAR_UNDEFINED = 65535, + DOM_VK_0 = 48, + DOM_VK_1 = 49, + DOM_VK_2 = 50, + DOM_VK_3 = 51, + DOM_VK_4 = 52, + DOM_VK_5 = 53, + DOM_VK_6 = 54, + DOM_VK_7 = 55, + DOM_VK_8 = 56, + DOM_VK_9 = 57, + DOM_VK_A = 65, + DOM_VK_ACCEPT = 30, + DOM_VK_ADD = 107, + DOM_VK_AGAIN = 65481, + DOM_VK_ALL_CANDIDATES = 256, + DOM_VK_ALPHANUMERIC = 240, + DOM_VK_ALT = 18, + DOM_VK_ALT_GRAPH = 65406, + DOM_VK_AMPERSAND = 150, + DOM_VK_ASTERISK = 151, + DOM_VK_AT = 512, + DOM_VK_B = 66, + DOM_VK_BACK_QUOTE = 192, + DOM_VK_BACK_SLASH = 92, + DOM_VK_BACK_SPACE = 8, + DOM_VK_BRACELEFT = 161, + DOM_VK_BRACERIGHT = 162, + DOM_VK_C = 67, + DOM_VK_CANCEL = 3, + DOM_VK_CAPS_LOCK = 20, + DOM_VK_CIRCUMFLEX = 514, + DOM_VK_CLEAR = 12, + DOM_VK_CLOSE_BRACKET = 93, + DOM_VK_CODE_INPUT = 258, + DOM_VK_COLON = 513, + DOM_VK_COMMA = 44, + DOM_VK_COMPOSE = 65312, + DOM_VK_CONTROL = 17, + DOM_VK_CONVERT = 28, + DOM_VK_COPY = 65485, + DOM_VK_CUT = 65489, + DOM_VK_D = 68, + DOM_VK_DEAD_ABOVEDOT = 134, + DOM_VK_DEAD_ABOVERING = 136, + DOM_VK_DEAD_ACUTE = 129, + DOM_VK_DEAD_BREVE = 133, + DOM_VK_DEAD_CARON = 138, + DOM_VK_DEAD_CEDILLA = 139, + DOM_VK_DEAD_CIRCUMFLEX = 130, + DOM_VK_DEAD_DIAERESIS = 135, + DOM_VK_DEAD_DOUBLEACUTE = 137, + DOM_VK_DEAD_GRAVE = 128, + DOM_VK_DEAD_IOTA = 141, + DOM_VK_DEAD_MACRON = 132, + DOM_VK_DEAD_OGONEK = 140, + DOM_VK_DEAD_SEMIVOICED_SOUND = 143, + DOM_VK_DEAD_TILDE = 131, + DOM_VK_DEAD_VOICED_SOUND = 142, + DOM_VK_DECIMAL = 110, + DOM_VK_DELETE = 127, + DOM_VK_DIVIDE = 111, + DOM_VK_DOLLAR = 515, + DOM_VK_DOWN = 40, + DOM_VK_E = 69, + DOM_VK_END = 35, + DOM_VK_ENTER = 13, + DOM_VK_EQUALS = 61, + DOM_VK_ESCAPE = 27, + DOM_VK_EURO_SIGN = 516, + DOM_VK_EXCLAMATION_MARK = 517, + DOM_VK_F = 70, + DOM_VK_F1 = 112, + DOM_VK_F10 = 121, + DOM_VK_F11 = 122, + DOM_VK_F12 = 123, + DOM_VK_F13 = 61440, + DOM_VK_F14 = 61441, + DOM_VK_F15 = 61442, + DOM_VK_F16 = 61443, + DOM_VK_F17 = 61444, + DOM_VK_F18 = 61445, + DOM_VK_F19 = 61446, + DOM_VK_F2 = 113, + DOM_VK_F20 = 61447, + DOM_VK_F21 = 61448, + DOM_VK_F22 = 61449, + DOM_VK_F23 = 61450, + DOM_VK_F24 = 61451, + DOM_VK_F3 = 114, + DOM_VK_F4 = 115, + DOM_VK_F5 = 116, + DOM_VK_F6 = 117, + DOM_VK_F7 = 118, + DOM_VK_F8 = 119, + DOM_VK_F9 = 120, + DOM_VK_FINAL = 24, + DOM_VK_FIND = 65488, + DOM_VK_FULL_WIDTH = 243, + DOM_VK_G = 71, + DOM_VK_GREATER = 160, + DOM_VK_H = 72, + DOM_VK_HALF_WIDTH = 244, + DOM_VK_HELP = 156, + DOM_VK_HIRAGANA = 242, + DOM_VK_HOME = 36, + DOM_VK_I = 73, + DOM_VK_INSERT = 155, + DOM_VK_INVERTED_EXCLAMATION_MARK = 518, + DOM_VK_J = 74, + DOM_VK_JAPANESE_HIRAGANA = 260, + DOM_VK_JAPANESE_KATAKANA = 259, + DOM_VK_JAPANESE_ROMAN = 261, + DOM_VK_K = 75, + DOM_VK_KANA = 21, + DOM_VK_KANJI = 25, + DOM_VK_KATAKANA = 241, + DOM_VK_KP_DOWN = 225, + DOM_VK_KP_LEFT = 226, + DOM_VK_KP_RIGHT = 227, + DOM_VK_KP_UP = 224, + DOM_VK_L = 76, + DOM_VK_LEFT = 37, + DOM_VK_LEFT_PARENTHESIS = 519, + DOM_VK_LESS = 153, + DOM_VK_M = 77, + DOM_VK_META = 157, + DOM_VK_MINUS = 45, + DOM_VK_MODECHANGE = 31, + DOM_VK_MULTIPLY = 106, + DOM_VK_N = 78, + DOM_VK_NONCONVERT = 29, + DOM_VK_NUM_LOCK = 144, + DOM_VK_NUMBER_SIGN = 520, + DOM_VK_NUMPAD0 = 96, + DOM_VK_NUMPAD1 = 97, + DOM_VK_NUMPAD2 = 98, + DOM_VK_NUMPAD3 = 99, + DOM_VK_NUMPAD4 = 100, + DOM_VK_NUMPAD5 = 101, + DOM_VK_NUMPAD6 = 102, + DOM_VK_NUMPAD7 = 103, + DOM_VK_NUMPAD8 = 104, + DOM_VK_NUMPAD9 = 105, + DOM_VK_O = 79, + DOM_VK_OPEN_BRACKET = 91, + DOM_VK_P = 80, + DOM_VK_PAGE_DOWN = 34, + DOM_VK_PAGE_UP = 33, + DOM_VK_PASTE = 65487, + DOM_VK_PAUSE = 19, + DOM_VK_PERIOD = 46, + DOM_VK_PLUS = 521, + DOM_VK_PREVIOUS_CANDIDATE = 257, + DOM_VK_PRINTSCREEN = 154, + DOM_VK_PROPS = 65482, + DOM_VK_Q = 81, + DOM_VK_QUOTE = 222, + DOM_VK_QUOTEDBL = 152, + DOM_VK_R = 82, + DOM_VK_RETURN = 14, + DOM_VK_RIGHT = 39, + DOM_VK_RIGHT_PARENTHESIS = 522, + DOM_VK_ROMAN_CHARACTERS = 245, + DOM_VK_S = 83, + DOM_VK_SCROLL_LOCK = 145, + DOM_VK_SEMICOLON = 59, + DOM_VK_SEPARATER = 108, + DOM_VK_SHIFT = 16, + DOM_VK_SLASH = 47, + DOM_VK_SPACE = 32, + DOM_VK_STOP = 65480, + DOM_VK_SUBTRACT = 109, + DOM_VK_T = 84, + DOM_VK_TAB = 9, + DOM_VK_U = 85, + DOM_VK_UNDEFINED = 0, + DOM_VK_UNDERSCORE = 523, + DOM_VK_UNDO = 65483, + DOM_VK_UP = 38, + DOM_VK_V = 86, + DOM_VK_W = 87, + DOM_VK_X = 88, + DOM_VK_Y = 89, + DOM_VK_Z = 90 + }; + + NS_IMETHOD GetCharCode(PRUint32* aCharCode)=0; + + NS_IMETHOD GetKeyCode(PRUint32* aKeyCode)=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 InitKeyEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRUint32 aKeyCodeArg, PRUint32 aCharCodeArg, nsIDOMAbstractView* aViewArg)=0; +}; + + +#define NS_DECL_IDOMKEYEVENT \ + NS_IMETHOD GetCharCode(PRUint32* aCharCode); \ + NS_IMETHOD GetKeyCode(PRUint32* aKeyCode); \ + NS_IMETHOD GetAltKey(PRBool* aAltKey); \ + NS_IMETHOD GetCtrlKey(PRBool* aCtrlKey); \ + NS_IMETHOD GetShiftKey(PRBool* aShiftKey); \ + NS_IMETHOD GetMetaKey(PRBool* aMetaKey); \ + NS_IMETHOD InitKeyEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRUint32 aKeyCodeArg, PRUint32 aCharCodeArg, nsIDOMAbstractView* aViewArg); \ + + + +#define NS_FORWARD_IDOMKEYEVENT(_to) \ + NS_IMETHOD GetCharCode(PRUint32* aCharCode) { return _to GetCharCode(aCharCode); } \ + NS_IMETHOD GetKeyCode(PRUint32* aKeyCode) { return _to GetKeyCode(aKeyCode); } \ + 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 InitKeyEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRUint32 aKeyCodeArg, PRUint32 aCharCodeArg, nsIDOMAbstractView* aViewArg) { return _to InitKeyEvent(aTypeArg, aCanBubbleArg, aCancelableArg, aCtrlKeyArg, aAltKeyArg, aShiftKeyArg, aMetaKeyArg, aKeyCodeArg, aCharCodeArg, aViewArg); } \ + + +extern "C" NS_DOM nsresult NS_InitKeyEventClass(nsIScriptContext *aContext, void **aPrototype); + +extern "C" NS_DOM nsresult NS_NewScriptKeyEvent(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn); + +#endif // nsIDOMKeyEvent_h__ diff --git a/mozilla/dom/public/coreEvents/nsIDOMMouseEvent.h b/mozilla/dom/public/coreEvents/nsIDOMMouseEvent.h new file mode 100644 index 00000000000..899004ad3da --- /dev/null +++ b/mozilla/dom/public/coreEvents/nsIDOMMouseEvent.h @@ -0,0 +1,95 @@ +/* -*- 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 nsIDOMMouseEvent_h__ +#define nsIDOMMouseEvent_h__ + +#include "nsISupports.h" +#include "nsString.h" +#include "nsIScriptContext.h" +#include "nsIDOMUIEvent.h" + +class nsIDOMNode; + +#define NS_IDOMMOUSEEVENT_IID \ + { 0xff751edc, 0x8b02, 0xaae7, \ + { 0x00, 0x10, 0x83, 0x01, 0x83, 0x8a, 0x31, 0x23 } } + +class nsIDOMMouseEvent : public nsIDOMUIEvent { +public: + static const nsIID& GetIID() { static nsIID iid = NS_IDOMMOUSEEVENT_IID; return iid; } + + 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 GetButton(PRUint16* aButton)=0; + + NS_IMETHOD GetClickCount(PRUint16* aClickCount)=0; + + NS_IMETHOD GetRelatedNode(nsIDOMNode** aRelatedNode)=0; + + NS_IMETHOD InitMouseEvent(const nsString& aTypeArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRInt32 aScreenXArg, PRInt32 aScreenYArg, PRInt32 aClientXArg, PRInt32 aClientYArg, PRUint16 aButtonArg, PRUint16 aDetailArg)=0; +}; + + +#define NS_DECL_IDOMMOUSEEVENT \ + 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 GetButton(PRUint16* aButton); \ + NS_IMETHOD GetClickCount(PRUint16* aClickCount); \ + NS_IMETHOD GetRelatedNode(nsIDOMNode** aRelatedNode); \ + NS_IMETHOD InitMouseEvent(const nsString& aTypeArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRInt32 aScreenXArg, PRInt32 aScreenYArg, PRInt32 aClientXArg, PRInt32 aClientYArg, PRUint16 aButtonArg, PRUint16 aDetailArg); \ + + + +#define NS_FORWARD_IDOMMOUSEEVENT(_to) \ + 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 GetButton(PRUint16* aButton) { return _to GetButton(aButton); } \ + NS_IMETHOD GetClickCount(PRUint16* aClickCount) { return _to GetClickCount(aClickCount); } \ + NS_IMETHOD GetRelatedNode(nsIDOMNode** aRelatedNode) { return _to GetRelatedNode(aRelatedNode); } \ + NS_IMETHOD InitMouseEvent(const nsString& aTypeArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRInt32 aScreenXArg, PRInt32 aScreenYArg, PRInt32 aClientXArg, PRInt32 aClientYArg, PRUint16 aButtonArg, PRUint16 aDetailArg) { return _to InitMouseEvent(aTypeArg, aCtrlKeyArg, aAltKeyArg, aShiftKeyArg, aMetaKeyArg, aScreenXArg, aScreenYArg, aClientXArg, aClientYArg, aButtonArg, aDetailArg); } \ + + +#endif // nsIDOMMouseEvent_h__ diff --git a/mozilla/dom/public/coreEvents/nsIDOMNSUIEvent.h b/mozilla/dom/public/coreEvents/nsIDOMNSUIEvent.h index ca05667cae7..a43c2323c7b 100644 --- a/mozilla/dom/public/coreEvents/nsIDOMNSUIEvent.h +++ b/mozilla/dom/public/coreEvents/nsIDOMNSUIEvent.h @@ -87,6 +87,8 @@ public: NS_IMETHOD GetCancelBubble(PRBool* aCancelBubble)=0; NS_IMETHOD SetCancelBubble(PRBool aCancelBubble)=0; + + NS_IMETHOD GetIsChar(PRBool* aIsChar)=0; }; @@ -100,6 +102,7 @@ public: NS_IMETHOD GetRangeOffset(PRInt32* aRangeOffset); \ NS_IMETHOD GetCancelBubble(PRBool* aCancelBubble); \ NS_IMETHOD SetCancelBubble(PRBool aCancelBubble); \ + NS_IMETHOD GetIsChar(PRBool* aIsChar); \ @@ -113,6 +116,7 @@ public: NS_IMETHOD GetRangeOffset(PRInt32* aRangeOffset) { return _to GetRangeOffset(aRangeOffset); } \ NS_IMETHOD GetCancelBubble(PRBool* aCancelBubble) { return _to GetCancelBubble(aCancelBubble); } \ NS_IMETHOD SetCancelBubble(PRBool aCancelBubble) { return _to SetCancelBubble(aCancelBubble); } \ + NS_IMETHOD GetIsChar(PRBool* aIsChar) { return _to GetIsChar(aIsChar); } \ #endif // nsIDOMNSUIEvent_h__ diff --git a/mozilla/dom/public/coreEvents/nsIDOMUIEvent.h b/mozilla/dom/public/coreEvents/nsIDOMUIEvent.h index 07ec8f24418..af59adb6ca7 100644 --- a/mozilla/dom/public/coreEvents/nsIDOMUIEvent.h +++ b/mozilla/dom/public/coreEvents/nsIDOMUIEvent.h @@ -25,6 +25,7 @@ #include "nsIScriptContext.h" #include "nsIDOMEvent.h" +class nsIDOMAbstractView; #define NS_IDOMUIEVENT_IID \ { 0xa6cf90c3, 0x15b3, 0x11d2, \ @@ -33,176 +34,26 @@ class nsIDOMUIEvent : public nsIDOMEvent { public: static const nsIID& GetIID() { static nsIID iid = NS_IDOMUIEVENT_IID; return iid; } - enum { - DOM_VK_CANCEL = 3, - DOM_VK_BACK = 8, - DOM_VK_TAB = 9, - DOM_VK_CLEAR = 12, - DOM_VK_RETURN = 13, - DOM_VK_ENTER = 14, - DOM_VK_SHIFT = 16, - DOM_VK_CONTROL = 17, - DOM_VK_ALT = 18, - DOM_VK_PAUSE = 19, - DOM_VK_CAPS_LOCK = 20, - DOM_VK_ESCAPE = 27, - DOM_VK_SPACE = 32, - DOM_VK_PAGE_UP = 33, - DOM_VK_PAGE_DOWN = 34, - DOM_VK_END = 35, - DOM_VK_HOME = 36, - DOM_VK_LEFT = 37, - DOM_VK_UP = 38, - DOM_VK_RIGHT = 39, - DOM_VK_DOWN = 40, - DOM_VK_PRINTSCREEN = 44, - DOM_VK_INSERT = 45, - DOM_VK_DELETE = 46, - DOM_VK_0 = 48, - DOM_VK_1 = 49, - DOM_VK_2 = 50, - DOM_VK_3 = 51, - DOM_VK_4 = 52, - DOM_VK_5 = 53, - DOM_VK_6 = 54, - DOM_VK_7 = 55, - DOM_VK_8 = 56, - DOM_VK_9 = 57, - DOM_VK_SEMICOLON = 59, - DOM_VK_EQUALS = 61, - DOM_VK_A = 65, - DOM_VK_B = 66, - DOM_VK_C = 67, - DOM_VK_D = 68, - DOM_VK_E = 69, - DOM_VK_F = 70, - DOM_VK_G = 71, - DOM_VK_H = 72, - DOM_VK_I = 73, - DOM_VK_J = 74, - DOM_VK_K = 75, - DOM_VK_L = 76, - DOM_VK_M = 77, - DOM_VK_N = 78, - DOM_VK_O = 79, - DOM_VK_P = 80, - DOM_VK_Q = 81, - DOM_VK_R = 82, - DOM_VK_S = 83, - DOM_VK_T = 84, - DOM_VK_U = 85, - DOM_VK_V = 86, - DOM_VK_W = 87, - DOM_VK_X = 88, - DOM_VK_Y = 89, - DOM_VK_Z = 90, - DOM_VK_NUMPAD0 = 96, - DOM_VK_NUMPAD1 = 97, - DOM_VK_NUMPAD2 = 98, - DOM_VK_NUMPAD3 = 99, - DOM_VK_NUMPAD4 = 100, - DOM_VK_NUMPAD5 = 101, - DOM_VK_NUMPAD6 = 102, - DOM_VK_NUMPAD7 = 103, - DOM_VK_NUMPAD8 = 104, - DOM_VK_NUMPAD9 = 105, - DOM_VK_MULTIPLY = 106, - DOM_VK_ADD = 107, - DOM_VK_SEPARATOR = 108, - DOM_VK_SUBTRACT = 109, - DOM_VK_DECIMAL = 110, - DOM_VK_DIVIDE = 111, - DOM_VK_F1 = 112, - DOM_VK_F2 = 113, - DOM_VK_F3 = 114, - DOM_VK_F4 = 115, - DOM_VK_F5 = 116, - DOM_VK_F6 = 117, - DOM_VK_F7 = 118, - DOM_VK_F8 = 119, - DOM_VK_F9 = 120, - DOM_VK_F10 = 121, - DOM_VK_F11 = 122, - DOM_VK_F12 = 123, - DOM_VK_F13 = 124, - DOM_VK_F14 = 125, - DOM_VK_F15 = 126, - DOM_VK_F16 = 127, - DOM_VK_F17 = 128, - DOM_VK_F18 = 129, - DOM_VK_F19 = 130, - DOM_VK_F20 = 131, - DOM_VK_F21 = 132, - DOM_VK_F22 = 133, - DOM_VK_F23 = 134, - DOM_VK_F24 = 135, - DOM_VK_NUM_LOCK = 144, - DOM_VK_SCROLL_LOCK = 145, - DOM_VK_COMMA = 188, - DOM_VK_PERIOD = 190, - DOM_VK_SLASH = 191, - DOM_VK_BACK_QUOTE = 192, - DOM_VK_OPEN_BRACKET = 219, - DOM_VK_BACK_SLASH = 220, - DOM_VK_CLOSE_BRACKET = 221, - DOM_VK_QUOTE = 222 - }; - NS_IMETHOD GetScreenX(PRInt32* aScreenX)=0; + NS_IMETHOD GetView(nsIDOMAbstractView** aView)=0; - NS_IMETHOD GetScreenY(PRInt32* aScreenY)=0; + NS_IMETHOD GetDetail(PRInt32* aDetail)=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(PRUint16* aButton)=0; - - NS_IMETHOD GetClickCount(PRUint16* aClickCount)=0; + NS_IMETHOD InitUIEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, nsIDOMAbstractView* aViewArg, PRInt32 aDetailArg)=0; }; #define NS_DECL_IDOMUIEVENT \ - 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(PRUint16* aButton); \ - NS_IMETHOD GetClickCount(PRUint16* aClickCount); \ + NS_IMETHOD GetView(nsIDOMAbstractView** aView); \ + NS_IMETHOD GetDetail(PRInt32* aDetail); \ + NS_IMETHOD InitUIEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, nsIDOMAbstractView* aViewArg, PRInt32 aDetailArg); \ #define NS_FORWARD_IDOMUIEVENT(_to) \ - 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(PRUint16* aButton) { return _to GetButton(aButton); } \ - NS_IMETHOD GetClickCount(PRUint16* aClickCount) { return _to GetClickCount(aClickCount); } \ + NS_IMETHOD GetView(nsIDOMAbstractView** aView) { return _to GetView(aView); } \ + NS_IMETHOD GetDetail(PRInt32* aDetail) { return _to GetDetail(aDetail); } \ + NS_IMETHOD InitUIEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, nsIDOMAbstractView* aViewArg, PRInt32 aDetailArg) { return _to InitUIEvent(aTypeArg, aCanBubbleArg, aCancelableArg, aViewArg, aDetailArg); } \ extern "C" NS_DOM nsresult NS_InitUIEventClass(nsIScriptContext *aContext, void **aPrototype); diff --git a/mozilla/dom/public/idl/base/Window.idl b/mozilla/dom/public/idl/base/Window.idl index 33057426346..ff141a93c8d 100644 --- a/mozilla/dom/public/idl/base/Window.idl +++ b/mozilla/dom/public/idl/base/Window.idl @@ -84,3 +84,10 @@ void addEventListener(in DOMString type, in function EventListener listener, in boolean useCapture); void removeEventListener(in DOMString type, in function EventListener listener, in boolean useCapture); }; + + interface AbstractView { + /* IID: { 0xf51ebade, 0x8b1a, 0x11d3, \ + { 0xaa, 0xe7, 0x00, 0x10, 0x83, 0x01, 0x23, 0xb4 } } */ + + noscript readonly attribute Document document; + }; diff --git a/mozilla/dom/public/idl/events/Event.idl b/mozilla/dom/public/idl/events/Event.idl index 4baa4538ffb..3df9f89622c 100644 --- a/mozilla/dom/public/idl/events/Event.idl +++ b/mozilla/dom/public/idl/events/Event.idl @@ -11,9 +11,14 @@ readonly attribute Node target; readonly attribute Node currentNode; readonly attribute unsigned short eventPhase; + readonly attribute boolean bubbles; + readonly attribute boolean cancelable; void preventBubble(); void preventCapture(); void preventDefault(); + void initEvent(in wstring eventTypeArg, + in boolean canBubbleArg, + in boolean cancelableArg); }; diff --git a/mozilla/dom/public/idl/events/MouseKeyEvent.idl b/mozilla/dom/public/idl/events/MouseKeyEvent.idl new file mode 100644 index 00000000000..9cf89db5e30 --- /dev/null +++ b/mozilla/dom/public/idl/events/MouseKeyEvent.idl @@ -0,0 +1,243 @@ + interface KeyEvent : UIEvent { + /* IID: { 0x028e0e6e, 0x8b01, 0x11d3, \ + { 0xaa, 0xe7, 0x00, 0x10, 0x83, 0x8a, 0x31, 0x23 } } */ + + const unsigned long DOM_CHAR_UNDEFINED = 0x0FFFF; + const unsigned long DOM_VK_0 = 0x30; + const unsigned long DOM_VK_1 = 0x31; + const unsigned long DOM_VK_2 = 0x32; + const unsigned long DOM_VK_3 = 0x33; + const unsigned long DOM_VK_4 = 0x34; + const unsigned long DOM_VK_5 = 0x35; + const unsigned long DOM_VK_6 = 0x36; + const unsigned long DOM_VK_7 = 0x37; + const unsigned long DOM_VK_8 = 0x38; + const unsigned long DOM_VK_9 = 0x39; + const unsigned long DOM_VK_A = 0x41; + const unsigned long DOM_VK_ACCEPT = 0x1E; + const unsigned long DOM_VK_ADD = 0x6B; + const unsigned long DOM_VK_AGAIN = 0xFFC9; + const unsigned long DOM_VK_ALL_CANDIDATES = 0x0100; + const unsigned long DOM_VK_ALPHANUMERIC = 0x00F0; + const unsigned long DOM_VK_ALT = 0x12; + const unsigned long DOM_VK_ALT_GRAPH = 0xFF7E; + const unsigned long DOM_VK_AMPERSAND = 0x96; + const unsigned long DOM_VK_ASTERISK = 0x97; + const unsigned long DOM_VK_AT = 0x0200; + const unsigned long DOM_VK_B = 0x42; + const unsigned long DOM_VK_BACK_QUOTE = 0xC0; + const unsigned long DOM_VK_BACK_SLASH = 0x5C; + const unsigned long DOM_VK_BACK_SPACE = 0x08; + const unsigned long DOM_VK_BRACELEFT = 0xA1; + const unsigned long DOM_VK_BRACERIGHT = 0xA2; + const unsigned long DOM_VK_C = 0x43; + const unsigned long DOM_VK_CANCEL = 0x03; + const unsigned long DOM_VK_CAPS_LOCK = 0x14; + const unsigned long DOM_VK_CIRCUMFLEX = 0x0202; + const unsigned long DOM_VK_CLEAR = 0x0C; + const unsigned long DOM_VK_CLOSE_BRACKET = 0x5D; + const unsigned long DOM_VK_CODE_INPUT = 0x0102; + const unsigned long DOM_VK_COLON = 0x0201; + const unsigned long DOM_VK_COMMA = 0x2C; + const unsigned long DOM_VK_COMPOSE = 0xFF20; + const unsigned long DOM_VK_CONTROL = 0x11; + const unsigned long DOM_VK_CONVERT = 0x1C; + const unsigned long DOM_VK_COPY = 0xFFCD; + const unsigned long DOM_VK_CUT = 0xFFD1; + const unsigned long DOM_VK_D = 0x44; + const unsigned long DOM_VK_DEAD_ABOVEDOT = 0x86; + const unsigned long DOM_VK_DEAD_ABOVERING = 0x88; + const unsigned long DOM_VK_DEAD_ACUTE = 0x81; + const unsigned long DOM_VK_DEAD_BREVE = 0x85; + const unsigned long DOM_VK_DEAD_CARON = 0x8A; + const unsigned long DOM_VK_DEAD_CEDILLA = 0x8B; + const unsigned long DOM_VK_DEAD_CIRCUMFLEX = 0x82; + const unsigned long DOM_VK_DEAD_DIAERESIS = 0x87; + const unsigned long DOM_VK_DEAD_DOUBLEACUTE = 0x89; + const unsigned long DOM_VK_DEAD_GRAVE = 0x80; + const unsigned long DOM_VK_DEAD_IOTA = 0x8D; + const unsigned long DOM_VK_DEAD_MACRON = 0x84; + const unsigned long DOM_VK_DEAD_OGONEK = 0x8C; + const unsigned long DOM_VK_DEAD_SEMIVOICED_SOUND = 0x8F; + const unsigned long DOM_VK_DEAD_TILDE = 0x83; + const unsigned long DOM_VK_DEAD_VOICED_SOUND = 0x8E; + const unsigned long DOM_VK_DECIMAL = 0x6E; + const unsigned long DOM_VK_DELETE = 0x7F; + const unsigned long DOM_VK_DIVIDE = 0x6F; + const unsigned long DOM_VK_DOLLAR = 0x0203; + const unsigned long DOM_VK_DOWN = 0x28; + const unsigned long DOM_VK_E = 0x45; + const unsigned long DOM_VK_END = 0x23; + const unsigned long DOM_VK_ENTER = 0x0D; + const unsigned long DOM_VK_EQUALS = 0x3D; + const unsigned long DOM_VK_ESCAPE = 0x1B; + const unsigned long DOM_VK_EURO_SIGN = 0x0204; + const unsigned long DOM_VK_EXCLAMATION_MARK = 0x0205; + const unsigned long DOM_VK_F = 0x46; + const unsigned long DOM_VK_F1 = 0x70; + const unsigned long DOM_VK_F10 = 0x79; + const unsigned long DOM_VK_F11 = 0x7A; + const unsigned long DOM_VK_F12 = 0x7B; + const unsigned long DOM_VK_F13 = 0xF000; + const unsigned long DOM_VK_F14 = 0xF001; + const unsigned long DOM_VK_F15 = 0xF002; + const unsigned long DOM_VK_F16 = 0xF003; + const unsigned long DOM_VK_F17 = 0xF004; + const unsigned long DOM_VK_F18 = 0xF005; + const unsigned long DOM_VK_F19 = 0xF006; + const unsigned long DOM_VK_F2 = 0x71; + const unsigned long DOM_VK_F20 = 0xF007; + const unsigned long DOM_VK_F21 = 0xF008; + const unsigned long DOM_VK_F22 = 0xF009; + const unsigned long DOM_VK_F23 = 0xF00A; + const unsigned long DOM_VK_F24 = 0xF00B; + const unsigned long DOM_VK_F3 = 0x72; + const unsigned long DOM_VK_F4 = 0x73; + const unsigned long DOM_VK_F5 = 0x74; + const unsigned long DOM_VK_F6 = 0x75; + const unsigned long DOM_VK_F7 = 0x76; + const unsigned long DOM_VK_F8 = 0x77; + const unsigned long DOM_VK_F9 = 0x78; + const unsigned long DOM_VK_FINAL = 0x18; + const unsigned long DOM_VK_FIND = 0xFFD0; + const unsigned long DOM_VK_FULL_WIDTH = 0x00F3; + const unsigned long DOM_VK_G = 0x47; + const unsigned long DOM_VK_GREATER = 0xA0; + const unsigned long DOM_VK_H = 0x48; + const unsigned long DOM_VK_HALF_WIDTH = 0x00F4; + const unsigned long DOM_VK_HELP = 0x9C; + const unsigned long DOM_VK_HIRAGANA = 0x00F2; + const unsigned long DOM_VK_HOME = 0x24; + const unsigned long DOM_VK_I = 0x49; + const unsigned long DOM_VK_INSERT = 0x9B; + const unsigned long DOM_VK_INVERTED_EXCLAMATION_MARK = 0x0206; + const unsigned long DOM_VK_J = 0x4A; + const unsigned long DOM_VK_JAPANESE_HIRAGANA = 0x0104; + const unsigned long DOM_VK_JAPANESE_KATAKANA = 0x0103; + const unsigned long DOM_VK_JAPANESE_ROMAN = 0x0105; + const unsigned long DOM_VK_K = 0x4B; + const unsigned long DOM_VK_KANA = 0x15; + const unsigned long DOM_VK_KANJI = 0x19; + const unsigned long DOM_VK_KATAKANA = 0x00F1; + const unsigned long DOM_VK_KP_DOWN = 0xE1; + const unsigned long DOM_VK_KP_LEFT = 0xE2; + const unsigned long DOM_VK_KP_RIGHT = 0xE3; + const unsigned long DOM_VK_KP_UP = 0xE0; + const unsigned long DOM_VK_L = 0x4C; + const unsigned long DOM_VK_LEFT = 0x25; + const unsigned long DOM_VK_LEFT_PARENTHESIS = 0x0207; + const unsigned long DOM_VK_LESS = 0x99; + const unsigned long DOM_VK_M = 0x4D; + const unsigned long DOM_VK_META = 0x9D; + const unsigned long DOM_VK_MINUS = 0x2D; + const unsigned long DOM_VK_MODECHANGE = 0x1F; + const unsigned long DOM_VK_MULTIPLY = 0x6A; + const unsigned long DOM_VK_N = 0x4E; + const unsigned long DOM_VK_NONCONVERT = 0x1D; + const unsigned long DOM_VK_NUM_LOCK = 0x90; + const unsigned long DOM_VK_NUMBER_SIGN = 0x0208; + const unsigned long DOM_VK_NUMPAD0 = 0x60; + const unsigned long DOM_VK_NUMPAD1 = 0x61; + const unsigned long DOM_VK_NUMPAD2 = 0x62; + const unsigned long DOM_VK_NUMPAD3 = 0x63; + const unsigned long DOM_VK_NUMPAD4 = 0x64; + const unsigned long DOM_VK_NUMPAD5 = 0x65; + const unsigned long DOM_VK_NUMPAD6 = 0x66; + const unsigned long DOM_VK_NUMPAD7 = 0x67; + const unsigned long DOM_VK_NUMPAD8 = 0x68; + const unsigned long DOM_VK_NUMPAD9 = 0x69; + const unsigned long DOM_VK_O = 0x4F; + const unsigned long DOM_VK_OPEN_BRACKET = 0x5B; + const unsigned long DOM_VK_P = 0x50; + const unsigned long DOM_VK_PAGE_DOWN = 0x22; + const unsigned long DOM_VK_PAGE_UP = 0x21; + const unsigned long DOM_VK_PASTE = 0xFFCF; + const unsigned long DOM_VK_PAUSE = 0x13; + const unsigned long DOM_VK_PERIOD = 0x2E; + const unsigned long DOM_VK_PLUS = 0x0209; + const unsigned long DOM_VK_PREVIOUS_CANDIDATE = 0x0101; + const unsigned long DOM_VK_PRINTSCREEN = 0x9A; + const unsigned long DOM_VK_PROPS = 0xFFCA; + const unsigned long DOM_VK_Q = 0x51; + const unsigned long DOM_VK_QUOTE = 0xDE; + const unsigned long DOM_VK_QUOTEDBL = 0x98; + const unsigned long DOM_VK_R = 0x52; + const unsigned long DOM_VK_RETURN = 0x0E; + const unsigned long DOM_VK_RIGHT = 0x27; + const unsigned long DOM_VK_RIGHT_PARENTHESIS = 0x020A; + const unsigned long DOM_VK_ROMAN_CHARACTERS = 0x00F5; + const unsigned long DOM_VK_S = 0x53; + const unsigned long DOM_VK_SCROLL_LOCK = 0x91; + const unsigned long DOM_VK_SEMICOLON = 0x3B; + const unsigned long DOM_VK_SEPARATER = 0x6C; + const unsigned long DOM_VK_SHIFT = 0x10; + const unsigned long DOM_VK_SLASH = 0x2F; + const unsigned long DOM_VK_SPACE = 0x20; + const unsigned long DOM_VK_STOP = 0xFFC8; + const unsigned long DOM_VK_SUBTRACT = 0x6D; + const unsigned long DOM_VK_T = 0x54; + const unsigned long DOM_VK_TAB = 0x09; + const unsigned long DOM_VK_U = 0x55; + const unsigned long DOM_VK_UNDEFINED = 0x0; + const unsigned long DOM_VK_UNDERSCORE = 0x020B; + const unsigned long DOM_VK_UNDO = 0xFFCB; + const unsigned long DOM_VK_UP = 0x26; + const unsigned long DOM_VK_V = 0x56; + const unsigned long DOM_VK_W = 0x57; + const unsigned long DOM_VK_X = 0x58; + const unsigned long DOM_VK_Y = 0x59; + const unsigned long DOM_VK_Z = 0x5A; + + readonly attribute unsigned long charCode; + readonly attribute unsigned long keyCode; + + readonly attribute boolean altKey; + readonly attribute boolean ctrlKey; + readonly attribute boolean shiftKey; + readonly attribute boolean metaKey; + + void initKeyEvent(in DOMString typeArg, + in boolean canBubbleArg, + in boolean cancelableArg, + in boolean ctrlKeyArg, + in boolean altKeyArg, + in boolean shiftKeyArg, + in boolean metaKeyArg, + in unsigned long keyCodeArg, + in unsigned long charCodeArg, + in AbstractView viewArg); + }; + + interface MouseEvent : UIEvent { + /* IID: { 0xff751edc, 0x8b02, 0xaae7, \ + { 0x00, 0x10, 0x83, 0x01, 0x83, 0x8a, 0x31, 0x23 } } */ + + + readonly attribute int screenX; + readonly attribute int screenY; + + readonly attribute int clientX; + readonly attribute int clientY; + + noscript readonly attribute boolean altKey; + noscript readonly attribute boolean ctrlKey; + noscript readonly attribute boolean shiftKey; + noscript readonly attribute boolean metaKey; + + readonly attribute unsigned short button; + readonly attribute unsigned short clickCount; + readonly attribute Node relatedNode; + + void initMouseEvent(in DOMString typeArg, + in boolean ctrlKeyArg, + in boolean altKeyArg, + in boolean shiftKeyArg, + in boolean metaKeyArg, + in long screenXArg, + in long screenYArg, + in long clientXArg, + in long clientYArg, + in unsigned short buttonArg, + in unsigned short detailArg); + }; + diff --git a/mozilla/dom/public/idl/events/UIEvent.idl b/mozilla/dom/public/idl/events/UIEvent.idl index 7005423ae54..38705cbeb90 100644 --- a/mozilla/dom/public/idl/events/UIEvent.idl +++ b/mozilla/dom/public/idl/events/UIEvent.idl @@ -1,144 +1,13 @@ interface UIEvent : Event { /* IID: { 0xa6cf90c3, 0x15b3, 0x11d2, \ { 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } */ - - const int DOM_VK_CANCEL = 0x03; - const int DOM_VK_BACK = 0x08; - const int DOM_VK_TAB = 0x09; - const int DOM_VK_CLEAR = 0x0C; - const int DOM_VK_RETURN = 0x0D; - const int DOM_VK_ENTER = 0x0E; - const int DOM_VK_SHIFT = 0x10; - const int DOM_VK_CONTROL = 0x11; - const int DOM_VK_ALT = 0x12; - const int DOM_VK_PAUSE = 0x13; - const int DOM_VK_CAPS_LOCK = 0x14; - const int DOM_VK_ESCAPE = 0x1B; - const int DOM_VK_SPACE = 0x20; - const int DOM_VK_PAGE_UP = 0x21; - const int DOM_VK_PAGE_DOWN = 0x22; - const int DOM_VK_END = 0x23; - const int DOM_VK_HOME = 0x24; - const int DOM_VK_LEFT = 0x25; - const int DOM_VK_UP = 0x26; - const int DOM_VK_RIGHT = 0x27; - const int DOM_VK_DOWN = 0x28; - const int DOM_VK_PRINTSCREEN = 0x2C; - const int DOM_VK_INSERT = 0x2D; - const int DOM_VK_DELETE = 0x2E; - - // DOM_VK_0 - DOM_VK_9 match their ascii values - const int DOM_VK_0 = 0x30; - const int DOM_VK_1 = 0x31; - const int DOM_VK_2 = 0x32; - const int DOM_VK_3 = 0x33; - const int DOM_VK_4 = 0x34; - const int DOM_VK_5 = 0x35; - const int DOM_VK_6 = 0x36; - const int DOM_VK_7 = 0x37; - const int DOM_VK_8 = 0x38; - const int DOM_VK_9 = 0x39; - - const int DOM_VK_SEMICOLON = 0x3B; - const int DOM_VK_EQUALS = 0x3D; - - // DOM_VK_A - DOM_VK_Z match their ascii values - const int DOM_VK_A = 0x41; - const int DOM_VK_B = 0x42; - const int DOM_VK_C = 0x43; - const int DOM_VK_D = 0x44; - const int DOM_VK_E = 0x45; - const int DOM_VK_F = 0x46; - const int DOM_VK_G = 0x47; - const int DOM_VK_H = 0x48; - const int DOM_VK_I = 0x49; - const int DOM_VK_J = 0x4A; - const int DOM_VK_K = 0x4B; - const int DOM_VK_L = 0x4C; - const int DOM_VK_M = 0x4D; - const int DOM_VK_N = 0x4E; - const int DOM_VK_O = 0x4F; - const int DOM_VK_P = 0x50; - const int DOM_VK_Q = 0x51; - const int DOM_VK_R = 0x52; - const int DOM_VK_S = 0x53; - const int DOM_VK_T = 0x54; - const int DOM_VK_U = 0x55; - const int DOM_VK_V = 0x56; - const int DOM_VK_W = 0x57; - const int DOM_VK_X = 0x58; - const int DOM_VK_Y = 0x59; - const int DOM_VK_Z = 0x5A; - - const int DOM_VK_NUMPAD0 = 0x60; - const int DOM_VK_NUMPAD1 = 0x61; - const int DOM_VK_NUMPAD2 = 0x62; - const int DOM_VK_NUMPAD3 = 0x63; - const int DOM_VK_NUMPAD4 = 0x64; - const int DOM_VK_NUMPAD5 = 0x65; - const int DOM_VK_NUMPAD6 = 0x66; - const int DOM_VK_NUMPAD7 = 0x67; - const int DOM_VK_NUMPAD8 = 0x68; - const int DOM_VK_NUMPAD9 = 0x69; - const int DOM_VK_MULTIPLY = 0x6A; - const int DOM_VK_ADD = 0x6B; - const int DOM_VK_SEPARATOR = 0x6C; - const int DOM_VK_SUBTRACT = 0x6D; - const int DOM_VK_DECIMAL = 0x6E; - const int DOM_VK_DIVIDE = 0x6F; - const int DOM_VK_F1 = 0x70; - const int DOM_VK_F2 = 0x71; - const int DOM_VK_F3 = 0x72; - const int DOM_VK_F4 = 0x73; - const int DOM_VK_F5 = 0x74; - const int DOM_VK_F6 = 0x75; - const int DOM_VK_F7 = 0x76; - const int DOM_VK_F8 = 0x77; - const int DOM_VK_F9 = 0x78; - const int DOM_VK_F10 = 0x79; - const int DOM_VK_F11 = 0x7A; - const int DOM_VK_F12 = 0x7B; - const int DOM_VK_F13 = 0x7C; - const int DOM_VK_F14 = 0x7D; - const int DOM_VK_F15 = 0x7E; - const int DOM_VK_F16 = 0x7F; - const int DOM_VK_F17 = 0x80; - const int DOM_VK_F18 = 0x81; - const int DOM_VK_F19 = 0x82; - const int DOM_VK_F20 = 0x83; - const int DOM_VK_F21 = 0x84; - const int DOM_VK_F22 = 0x85; - const int DOM_VK_F23 = 0x86; - const int DOM_VK_F24 = 0x87; - - const int DOM_VK_NUM_LOCK = 0x90; - const int DOM_VK_SCROLL_LOCK = 0x91; - - const int DOM_VK_COMMA = 0xBC; - const int DOM_VK_PERIOD = 0xBE; - const int DOM_VK_SLASH = 0xBF; - const int DOM_VK_BACK_QUOTE = 0xC0; - const int DOM_VK_OPEN_BRACKET = 0xDB; - const int DOM_VK_BACK_SLASH = 0xDC; - const int DOM_VK_CLOSE_BRACKET = 0xDD; - const int DOM_VK_QUOTE = 0xDE; - - readonly attribute int screenX; - readonly attribute int screenY; - - readonly attribute int clientX; - readonly attribute int clientY; - - readonly attribute boolean altKey; - readonly attribute boolean ctrlKey; - readonly attribute boolean shiftKey; - readonly attribute boolean metaKey; - - - readonly attribute unsigned long charCode; - readonly attribute unsigned long keyCode; - readonly attribute unsigned short button; - readonly attribute unsigned short clickCount; + readonly attribute AbstractView view; + readonly attribute long detail; + void initUIEvent(in DOMString typeArg, + in boolean canBubbleArg, + in boolean cancelableArg, + in AbstractView viewArg, + in long detailArg); }; interface NSUIEvent { @@ -192,4 +61,6 @@ attribute boolean cancelBubble; + readonly attribute boolean isChar; + }; diff --git a/mozilla/dom/public/idl/events/makefile.win b/mozilla/dom/public/idl/events/makefile.win index fbd4d8594ed..61c2becfb89 100644 --- a/mozilla/dom/public/idl/events/makefile.win +++ b/mozilla/dom/public/idl/events/makefile.win @@ -23,6 +23,7 @@ MODULE=raptor IDLSRCS = \ Event.idl \ UIEvent.idl \ + MouseKeyEvent.idl \ XPCOM_DESTDIR=$(DEPTH)\dom\public\coreEvents JSSTUB_DESTDIR=$(DEPTH)\dom\src\events diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index 630d97ce223..8d844eb1a69 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -103,6 +103,7 @@ static NS_DEFINE_IID(kIBrowserWindowIID, NS_IBROWSER_WINDOW_IID); static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID); static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID); static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); +static NS_DEFINE_IID(kIDOMAbstractViewIID, NS_IDOMABSTRACTVIEW_IID); static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID); static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); @@ -214,6 +215,11 @@ GlobalWindowImpl::QueryInterface(const nsIID& aIID, AddRef(); return NS_OK; } + if (aIID.Equals(kIDOMAbstractViewIID)) { + *aInstancePtrResult = (void*)(nsISupports*)(nsIDOMAbstractView*)this; + AddRef(); + return NS_OK; + } return NS_NOINTERFACE; } diff --git a/mozilla/dom/src/base/nsGlobalWindow.h b/mozilla/dom/src/base/nsGlobalWindow.h index 1326ef29ac2..59305624934 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.h +++ b/mozilla/dom/src/base/nsGlobalWindow.h @@ -41,6 +41,7 @@ #include "nsIDOMEventTarget.h" #include "nsIControllers.h" #include "nsPIDOMWindow.h" +#include "nsIDOMAbstractView.h" #define DEFAULT_HOME_PAGE "www.mozilla.org" #define PREF_BROWSER_STARTUP_HOMEPAGE "browser.startup.homepage" @@ -68,7 +69,7 @@ class HistoryImpl; // Global object for scripting class GlobalWindowImpl : public nsIScriptObjectOwner, public nsIScriptGlobalObject, public nsIDOMWindow, public nsIJSScriptObject, public nsIScriptGlobalObjectData, public nsIDOMEventReceiver, - public nsPIDOMWindow + public nsPIDOMWindow, public nsIDOMAbstractView { public: GlobalWindowImpl(); diff --git a/mozilla/dom/src/base/nsJSWindow.cpp b/mozilla/dom/src/base/nsJSWindow.cpp index cf5d3b87375..4bba1087ad3 100644 --- a/mozilla/dom/src/base/nsJSWindow.cpp +++ b/mozilla/dom/src/base/nsJSWindow.cpp @@ -33,6 +33,7 @@ #include "nsIDOMElement.h" #include "nsIDOMDocument.h" #include "nsIDOMBarProp.h" +#include "nsIDOMAbstractView.h" #include "nsIDOMScreen.h" #include "nsIDOMHistory.h" #include "nsIDOMEventListener.h" @@ -50,6 +51,7 @@ static NS_DEFINE_IID(kINavigatorIID, NS_IDOMNAVIGATOR_IID); static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID); static NS_DEFINE_IID(kIDocumentIID, NS_IDOMDOCUMENT_IID); static NS_DEFINE_IID(kIBarPropIID, NS_IDOMBARPROP_IID); +static NS_DEFINE_IID(kIAbstractViewIID, NS_IDOMABSTRACTVIEW_IID); static NS_DEFINE_IID(kIScreenIID, NS_IDOMSCREEN_IID); static NS_DEFINE_IID(kIHistoryIID, NS_IDOMHISTORY_IID); static NS_DEFINE_IID(kIEventListenerIID, NS_IDOMEVENTLISTENER_IID); @@ -63,6 +65,7 @@ NS_DEF_PTR(nsIDOMNavigator); NS_DEF_PTR(nsIDOMElement); NS_DEF_PTR(nsIDOMDocument); NS_DEF_PTR(nsIDOMBarProp); +NS_DEF_PTR(nsIDOMAbstractView); NS_DEF_PTR(nsIDOMScreen); NS_DEF_PTR(nsIDOMHistory); NS_DEF_PTR(nsIDOMEventListener); diff --git a/mozilla/dom/src/events/Makefile.in b/mozilla/dom/src/events/Makefile.in index fc74279f15d..42129ab93ad 100644 --- a/mozilla/dom/src/events/Makefile.in +++ b/mozilla/dom/src/events/Makefile.in @@ -32,6 +32,7 @@ CPPSRCS = \ nsJSDOMEventListener.cpp \ nsJSEvent.cpp \ nsJSUIEvent.cpp \ + nsJSKeyEvent.cpp \ $(NULL) # we don't want the shared lib, but we want to force the creation of a static lib. diff --git a/mozilla/dom/src/events/makefile.win b/mozilla/dom/src/events/makefile.win index 5228a93ea4f..1b74d0b03e4 100644 --- a/mozilla/dom/src/events/makefile.win +++ b/mozilla/dom/src/events/makefile.win @@ -29,10 +29,11 @@ CPPSRCS = \ nsJSDOMEventListener.cpp \ nsJSEvent.cpp \ nsJSUIEvent.cpp \ + nsJSKeyEvent.cpp \ $(NULL) CPP_OBJS= \ - .\$(OBJDIR)\nsJSEventListener.obj .\$(OBJDIR)\nsJSDOMEventListener.obj .\$(OBJDIR)\nsJSEvent.obj .\$(OBJDIR)\nsJSUIEvent.obj + .\$(OBJDIR)\nsJSEventListener.obj .\$(OBJDIR)\nsJSDOMEventListener.obj .\$(OBJDIR)\nsJSEvent.obj .\$(OBJDIR)\nsJSUIEvent.obj .\$(OBJDIR)\nsJSKeyEvent.obj LINCS=-I$(XPDIST)\public\xpcom -I$(XPDIST)\public\raptor -I$(XPDIST)\public\dom -I$(XPDIST)\public\js diff --git a/mozilla/dom/src/events/nsJSDOMEventListener.cpp b/mozilla/dom/src/events/nsJSDOMEventListener.cpp index ed24b48780f..17633957052 100644 --- a/mozilla/dom/src/events/nsJSDOMEventListener.cpp +++ b/mozilla/dom/src/events/nsJSDOMEventListener.cpp @@ -72,7 +72,7 @@ nsresult nsJSDOMEventListener::HandleEvent(nsIDOMEvent* aEvent) JSObject *eventObj; nsIScriptContext *mScriptCX = (nsIScriptContext *)JS_GetContextPrivate(mContext); - if (NS_OK != NS_NewScriptUIEvent(mScriptCX, aEvent, nsnull, (void**)&eventObj)) { + if (NS_OK != NS_NewScriptKeyEvent(mScriptCX, aEvent, nsnull, (void**)&eventObj)) { return NS_ERROR_FAILURE; } diff --git a/mozilla/dom/src/events/nsJSDOMEventListener.h b/mozilla/dom/src/events/nsJSDOMEventListener.h index fc005b9a9e7..09a9f8dba58 100644 --- a/mozilla/dom/src/events/nsJSDOMEventListener.h +++ b/mozilla/dom/src/events/nsJSDOMEventListener.h @@ -19,7 +19,7 @@ #ifndef nsJSEventListener_h__ #define nsJSEventListener_h__ -#include "nsIDOMUIEvent.h" +#include "nsIDOMKeyEvent.h" #include "nsIScriptEventListener.h" #include "nsIDOMMouseListener.h" #include "jsapi.h" diff --git a/mozilla/dom/src/events/nsJSEvent.cpp b/mozilla/dom/src/events/nsJSEvent.cpp index 9b88cabdaac..f794c70f76d 100644 --- a/mozilla/dom/src/events/nsJSEvent.cpp +++ b/mozilla/dom/src/events/nsJSEvent.cpp @@ -49,7 +49,9 @@ enum Event_slots { EVENT_TYPE = -1, EVENT_TARGET = -2, EVENT_CURRENTNODE = -3, - EVENT_EVENTPHASE = -4 + EVENT_EVENTPHASE = -4, + EVENT_BUBBLES = -5, + EVENT_CANCELABLE = -6 }; /***********************************************************************/ @@ -147,6 +149,42 @@ GetEventProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) } break; } + case EVENT_BUBBLES: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, "event.bubbles", PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + PRBool prop; + nsresult result = NS_OK; + result = a->GetBubbles(&prop); + if (NS_SUCCEEDED(result)) { + *vp = BOOLEAN_TO_JSVAL(prop); + } + else { + return nsJSUtils::nsReportError(cx, result); + } + break; + } + case EVENT_CANCELABLE: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, "event.cancelable", PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + PRBool prop; + nsresult result = NS_OK; + result = a->GetCancelable(&prop); + if (NS_SUCCEEDED(result)) { + *vp = BOOLEAN_TO_JSVAL(prop); + } + else { + return nsJSUtils::nsReportError(cx, result); + } + break; + } default: return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp); } @@ -351,6 +389,63 @@ EventPreventDefault(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval } +// +// Native method InitEvent +// +PR_STATIC_CALLBACK(JSBool) +EventInitEvent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMEvent *nativeThis = (nsIDOMEvent*)nsJSUtils::nsGetNativeThis(cx, obj); + nsresult result = NS_OK; + nsAutoString b0; + PRBool b1; + PRBool b2; + + *rval = JSVAL_NULL; + + nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx); + nsCOMPtr secMan; + if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECMAN_ERR); + } + { + PRBool ok; + secMan->CheckScriptAccess(scriptCX, obj, "event.initevent",PR_FALSE , &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + } + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == nativeThis) { + return JS_TRUE; + } + + { + if (argc < 3) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR); + } + + nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]); + if (!nsJSUtils::nsConvertJSValToBool(&b1, cx, argv[1])) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + if (!nsJSUtils::nsConvertJSValToBool(&b2, cx, argv[2])) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + + result = nativeThis->InitEvent(b0, b1, b2); + if (NS_FAILED(result)) { + return nsJSUtils::nsReportError(cx, result); + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + /***********************************************************************/ // // class for Event @@ -378,6 +473,8 @@ static JSPropertySpec EventProperties[] = {"target", EVENT_TARGET, JSPROP_ENUMERATE | JSPROP_READONLY}, {"currentNode", EVENT_CURRENTNODE, JSPROP_ENUMERATE | JSPROP_READONLY}, {"eventPhase", EVENT_EVENTPHASE, JSPROP_ENUMERATE | JSPROP_READONLY}, + {"bubbles", EVENT_BUBBLES, JSPROP_ENUMERATE | JSPROP_READONLY}, + {"cancelable", EVENT_CANCELABLE, JSPROP_ENUMERATE | JSPROP_READONLY}, {0} }; @@ -390,6 +487,7 @@ static JSFunctionSpec EventMethods[] = {"preventBubble", EventPreventBubble, 0}, {"preventCapture", EventPreventCapture, 0}, {"preventDefault", EventPreventDefault, 0}, + {"initEvent", EventInitEvent, 3}, {0} }; diff --git a/mozilla/dom/src/events/nsJSEventListener.cpp b/mozilla/dom/src/events/nsJSEventListener.cpp index 2079dfd72b8..0235a12b903 100644 --- a/mozilla/dom/src/events/nsJSEventListener.cpp +++ b/mozilla/dom/src/events/nsJSEventListener.cpp @@ -92,7 +92,7 @@ nsresult nsJSEventListener::HandleEvent(nsIDOMEvent* aEvent) } nsIScriptContext *mScriptCX = (nsIScriptContext *)JS_GetContextPrivate(mContext); - if (NS_OK != NS_NewScriptUIEvent(mScriptCX, aEvent, nsnull, (void**)&eventObj)) { + if (NS_OK != NS_NewScriptKeyEvent(mScriptCX, aEvent, nsnull, (void**)&eventObj)) { return NS_ERROR_FAILURE; } diff --git a/mozilla/dom/src/events/nsJSEventListener.h b/mozilla/dom/src/events/nsJSEventListener.h index f2721a26afd..77e478aa604 100644 --- a/mozilla/dom/src/events/nsJSEventListener.h +++ b/mozilla/dom/src/events/nsJSEventListener.h @@ -19,7 +19,7 @@ #ifndef nsJSEventListener_h__ #define nsJSEventListener_h__ -#include "nsIDOMUIEvent.h" +#include "nsIDOMKeyEvent.h" #include "nsIScriptEventListener.h" #include "nsIDOMMouseListener.h" #include "jsapi.h" diff --git a/mozilla/dom/src/events/nsJSKeyEvent.cpp b/mozilla/dom/src/events/nsJSKeyEvent.cpp new file mode 100644 index 00000000000..36f6b643671 --- /dev/null +++ b/mozilla/dom/src/events/nsJSKeyEvent.cpp @@ -0,0 +1,1359 @@ +/* -*- 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 "nsDOMError.h" +#include "nscore.h" +#include "nsIScriptContext.h" +#include "nsIScriptSecurityManager.h" +#include "nsIJSScriptObject.h" +#include "nsIScriptObjectOwner.h" +#include "nsIScriptGlobalObject.h" +#include "nsCOMPtr.h" +#include "nsIPtr.h" +#include "nsString.h" +#include "nsIDOMMouseEvent.h" +#include "nsIDOMKeyEvent.h" +#include "nsIDOMAbstractView.h" +#include "nsIDOMNode.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(kIMouseEventIID, NS_IDOMMOUSEEVENT_IID); +static NS_DEFINE_IID(kIKeyEventIID, NS_IDOMKEYEVENT_IID); +static NS_DEFINE_IID(kIAbstractViewIID, NS_IDOMABSTRACTVIEW_IID); +static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID); + +NS_DEF_PTR(nsIDOMMouseEvent); +NS_DEF_PTR(nsIDOMKeyEvent); +NS_DEF_PTR(nsIDOMAbstractView); +NS_DEF_PTR(nsIDOMNode); + +// +// KeyEvent property ids +// +enum KeyEvent_slots { + KEYEVENT_CHARCODE = -1, + KEYEVENT_KEYCODE = -2, + KEYEVENT_ALTKEY = -3, + KEYEVENT_CTRLKEY = -4, + KEYEVENT_SHIFTKEY = -5, + KEYEVENT_METAKEY = -6, + MOUSEEVENT_SCREENX = -7, + MOUSEEVENT_SCREENY = -8, + MOUSEEVENT_CLIENTX = -9, + MOUSEEVENT_CLIENTY = -10, + MOUSEEVENT_BUTTON = -11, + MOUSEEVENT_CLICKCOUNT = -12, + MOUSEEVENT_RELATEDNODE = -13 +}; + +/***********************************************************************/ +// +// KeyEvent Properties Getter +// +PR_STATIC_CALLBACK(JSBool) +GetKeyEventProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMKeyEvent *a = (nsIDOMKeyEvent*)nsJSUtils::nsGetNativeThis(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)) { + nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx); + nsCOMPtr secMan; + if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECMAN_ERR); + } + switch(JSVAL_TO_INT(id)) { + case KEYEVENT_CHARCODE: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, "keyevent.charcode", PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + PRUint32 prop; + nsresult result = NS_OK; + result = a->GetCharCode(&prop); + if (NS_SUCCEEDED(result)) { + *vp = INT_TO_JSVAL(prop); + } + else { + return nsJSUtils::nsReportError(cx, result); + } + break; + } + case KEYEVENT_KEYCODE: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, "keyevent.keycode", PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + PRUint32 prop; + nsresult result = NS_OK; + result = a->GetKeyCode(&prop); + if (NS_SUCCEEDED(result)) { + *vp = INT_TO_JSVAL(prop); + } + else { + return nsJSUtils::nsReportError(cx, result); + } + break; + } + case KEYEVENT_ALTKEY: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, "keyevent.altkey", PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + PRBool prop; + nsresult result = NS_OK; + result = a->GetAltKey(&prop); + if (NS_SUCCEEDED(result)) { + *vp = BOOLEAN_TO_JSVAL(prop); + } + else { + return nsJSUtils::nsReportError(cx, result); + } + break; + } + case KEYEVENT_CTRLKEY: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, "keyevent.ctrlkey", PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + PRBool prop; + nsresult result = NS_OK; + result = a->GetCtrlKey(&prop); + if (NS_SUCCEEDED(result)) { + *vp = BOOLEAN_TO_JSVAL(prop); + } + else { + return nsJSUtils::nsReportError(cx, result); + } + break; + } + case KEYEVENT_SHIFTKEY: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, "keyevent.shiftkey", PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + PRBool prop; + nsresult result = NS_OK; + result = a->GetShiftKey(&prop); + if (NS_SUCCEEDED(result)) { + *vp = BOOLEAN_TO_JSVAL(prop); + } + else { + return nsJSUtils::nsReportError(cx, result); + } + break; + } + case KEYEVENT_METAKEY: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, "keyevent.metakey", PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + PRBool prop; + nsresult result = NS_OK; + result = a->GetMetaKey(&prop); + if (NS_SUCCEEDED(result)) { + *vp = BOOLEAN_TO_JSVAL(prop); + } + else { + return nsJSUtils::nsReportError(cx, result); + } + break; + } + case MOUSEEVENT_SCREENX: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, "mouseevent.screenx", PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + PRInt32 prop; + nsIDOMMouseEvent* b; + if (NS_OK == a->QueryInterface(kIMouseEventIID, (void **)&b)) { + nsresult result = NS_OK; + result = b->GetScreenX(&prop); + if(NS_SUCCEEDED(result)) { + *vp = INT_TO_JSVAL(prop); + NS_RELEASE(b); + } + else { + NS_RELEASE(b); + return nsJSUtils::nsReportError(cx, result); + } + } + else { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_WRONG_TYPE_ERR); + } + break; + } + case MOUSEEVENT_SCREENY: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, "mouseevent.screeny", PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + PRInt32 prop; + nsIDOMMouseEvent* b; + if (NS_OK == a->QueryInterface(kIMouseEventIID, (void **)&b)) { + nsresult result = NS_OK; + result = b->GetScreenY(&prop); + if(NS_SUCCEEDED(result)) { + *vp = INT_TO_JSVAL(prop); + NS_RELEASE(b); + } + else { + NS_RELEASE(b); + return nsJSUtils::nsReportError(cx, result); + } + } + else { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_WRONG_TYPE_ERR); + } + break; + } + case MOUSEEVENT_CLIENTX: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, "mouseevent.clientx", PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + PRInt32 prop; + nsIDOMMouseEvent* b; + if (NS_OK == a->QueryInterface(kIMouseEventIID, (void **)&b)) { + nsresult result = NS_OK; + result = b->GetClientX(&prop); + if(NS_SUCCEEDED(result)) { + *vp = INT_TO_JSVAL(prop); + NS_RELEASE(b); + } + else { + NS_RELEASE(b); + return nsJSUtils::nsReportError(cx, result); + } + } + else { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_WRONG_TYPE_ERR); + } + break; + } + case MOUSEEVENT_CLIENTY: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, "mouseevent.clienty", PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + PRInt32 prop; + nsIDOMMouseEvent* b; + if (NS_OK == a->QueryInterface(kIMouseEventIID, (void **)&b)) { + nsresult result = NS_OK; + result = b->GetClientY(&prop); + if(NS_SUCCEEDED(result)) { + *vp = INT_TO_JSVAL(prop); + NS_RELEASE(b); + } + else { + NS_RELEASE(b); + return nsJSUtils::nsReportError(cx, result); + } + } + else { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_WRONG_TYPE_ERR); + } + break; + } + case MOUSEEVENT_BUTTON: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, "mouseevent.button", PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + PRUint16 prop; + nsIDOMMouseEvent* b; + if (NS_OK == a->QueryInterface(kIMouseEventIID, (void **)&b)) { + nsresult result = NS_OK; + result = b->GetButton(&prop); + if(NS_SUCCEEDED(result)) { + *vp = INT_TO_JSVAL(prop); + NS_RELEASE(b); + } + else { + NS_RELEASE(b); + return nsJSUtils::nsReportError(cx, result); + } + } + else { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_WRONG_TYPE_ERR); + } + break; + } + case MOUSEEVENT_CLICKCOUNT: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, "mouseevent.clickcount", PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + PRUint16 prop; + nsIDOMMouseEvent* b; + if (NS_OK == a->QueryInterface(kIMouseEventIID, (void **)&b)) { + nsresult result = NS_OK; + result = b->GetClickCount(&prop); + if(NS_SUCCEEDED(result)) { + *vp = INT_TO_JSVAL(prop); + NS_RELEASE(b); + } + else { + NS_RELEASE(b); + return nsJSUtils::nsReportError(cx, result); + } + } + else { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_WRONG_TYPE_ERR); + } + break; + } + case MOUSEEVENT_RELATEDNODE: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, "mouseevent.relatednode", PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + nsIDOMNode* prop; + nsIDOMMouseEvent* b; + if (NS_OK == a->QueryInterface(kIMouseEventIID, (void **)&b)) { + nsresult result = NS_OK; + result = b->GetRelatedNode(&prop); + if(NS_SUCCEEDED(result)) { + // get the js object + nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp); + NS_RELEASE(b); + } + else { + NS_RELEASE(b); + return nsJSUtils::nsReportError(cx, result); + } + } + else { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_WRONG_TYPE_ERR); + } + break; + } + default: + return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp); + } + } + else { + return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp); + } + + return PR_TRUE; +} + +/***********************************************************************/ +// +// KeyEvent Properties Setter +// +PR_STATIC_CALLBACK(JSBool) +SetKeyEventProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMKeyEvent *a = (nsIDOMKeyEvent*)nsJSUtils::nsGetNativeThis(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)) { + nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx); + nsCOMPtr secMan; + if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECMAN_ERR); + } + switch(JSVAL_TO_INT(id)) { + case 0: + default: + return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp); + } + } + else { + return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp); + } + + return PR_TRUE; +} + + +// +// KeyEvent finalizer +// +PR_STATIC_CALLBACK(void) +FinalizeKeyEvent(JSContext *cx, JSObject *obj) +{ + nsJSUtils::nsGenericFinalize(cx, obj); +} + + +// +// KeyEvent enumerate +// +PR_STATIC_CALLBACK(JSBool) +EnumerateKeyEvent(JSContext *cx, JSObject *obj) +{ + return nsJSUtils::nsGenericEnumerate(cx, obj); +} + + +// +// KeyEvent resolve +// +PR_STATIC_CALLBACK(JSBool) +ResolveKeyEvent(JSContext *cx, JSObject *obj, jsval id) +{ + return nsJSUtils::nsGenericResolve(cx, obj, id); +} + + +// +// Native method InitKeyEvent +// +PR_STATIC_CALLBACK(JSBool) +KeyEventInitKeyEvent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMKeyEvent *nativeThis = (nsIDOMKeyEvent*)nsJSUtils::nsGetNativeThis(cx, obj); + nsresult result = NS_OK; + nsAutoString b0; + PRBool b1; + PRBool b2; + PRBool b3; + PRBool b4; + PRBool b5; + PRBool b6; + PRUint32 b7; + PRUint32 b8; + nsIDOMAbstractViewPtr b9; + + *rval = JSVAL_NULL; + + nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx); + nsCOMPtr secMan; + if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECMAN_ERR); + } + { + PRBool ok; + secMan->CheckScriptAccess(scriptCX, obj, "keyevent.initkeyevent",PR_FALSE , &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + } + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == nativeThis) { + return JS_TRUE; + } + + { + if (argc < 10) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR); + } + + nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]); + if (!nsJSUtils::nsConvertJSValToBool(&b1, cx, argv[1])) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + if (!nsJSUtils::nsConvertJSValToBool(&b2, cx, argv[2])) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + if (!nsJSUtils::nsConvertJSValToBool(&b3, cx, argv[3])) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + if (!nsJSUtils::nsConvertJSValToBool(&b4, cx, argv[4])) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + if (!nsJSUtils::nsConvertJSValToBool(&b5, cx, argv[5])) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + if (!nsJSUtils::nsConvertJSValToBool(&b6, cx, argv[6])) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + if (!JS_ValueToInt32(cx, argv[7], (int32 *)&b7)) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_NUMBER_ERR); + } + if (!JS_ValueToInt32(cx, argv[8], (int32 *)&b8)) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_NUMBER_ERR); + } + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b9, + kIAbstractViewIID, + "AbstractView", + cx, + argv[9])) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_OBJECT_ERR); + } + + result = nativeThis->InitKeyEvent(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9); + if (NS_FAILED(result)) { + return nsJSUtils::nsReportError(cx, result); + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method InitMouseEvent +// +PR_STATIC_CALLBACK(JSBool) +MouseEventInitMouseEvent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMKeyEvent *privateThis = (nsIDOMKeyEvent*)nsJSUtils::nsGetNativeThis(cx, obj); + nsIDOMMouseEvent *nativeThis = nsnull; + nsresult result = NS_OK; + if (NS_OK != privateThis->QueryInterface(kIMouseEventIID, (void **)&nativeThis)) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_WRONG_TYPE_ERR); + } + + nsAutoString b0; + PRBool b1; + PRBool b2; + PRBool b3; + PRBool b4; + PRInt32 b5; + PRInt32 b6; + PRInt32 b7; + PRInt32 b8; + PRUint32 b9; + PRUint32 b10; + + *rval = JSVAL_NULL; + + nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx); + nsCOMPtr secMan; + if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECMAN_ERR); + } + { + PRBool ok; + secMan->CheckScriptAccess(scriptCX, obj, "mouseevent.initmouseevent",PR_FALSE , &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + } + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == nativeThis) { + return JS_TRUE; + } + + { + if (argc < 11) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR); + } + + nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]); + if (!nsJSUtils::nsConvertJSValToBool(&b1, cx, argv[1])) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + if (!nsJSUtils::nsConvertJSValToBool(&b2, cx, argv[2])) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + if (!nsJSUtils::nsConvertJSValToBool(&b3, cx, argv[3])) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + if (!nsJSUtils::nsConvertJSValToBool(&b4, cx, argv[4])) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + if (!JS_ValueToInt32(cx, argv[5], (int32 *)&b5)) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_NUMBER_ERR); + } + if (!JS_ValueToInt32(cx, argv[6], (int32 *)&b6)) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_NUMBER_ERR); + } + if (!JS_ValueToInt32(cx, argv[7], (int32 *)&b7)) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_NUMBER_ERR); + } + if (!JS_ValueToInt32(cx, argv[8], (int32 *)&b8)) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_NUMBER_ERR); + } + if (!JS_ValueToInt32(cx, argv[9], (int32 *)&b9)) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_NUMBER_ERR); + } + if (!JS_ValueToInt32(cx, argv[10], (int32 *)&b10)) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_NUMBER_ERR); + } + + result = nativeThis->InitMouseEvent(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10); + if (NS_FAILED(result)) { + return nsJSUtils::nsReportError(cx, result); + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +/***********************************************************************/ +// +// class for KeyEvent +// +JSClass KeyEventClass = { + "KeyEvent", + JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS, + JS_PropertyStub, + JS_PropertyStub, + GetKeyEventProperty, + SetKeyEventProperty, + EnumerateKeyEvent, + ResolveKeyEvent, + JS_ConvertStub, + FinalizeKeyEvent +}; + + +// +// KeyEvent class properties +// +static JSPropertySpec KeyEventProperties[] = +{ + {"charCode", KEYEVENT_CHARCODE, JSPROP_ENUMERATE | JSPROP_READONLY}, + {"keyCode", KEYEVENT_KEYCODE, JSPROP_ENUMERATE | JSPROP_READONLY}, + {"altKey", KEYEVENT_ALTKEY, JSPROP_ENUMERATE | JSPROP_READONLY}, + {"ctrlKey", KEYEVENT_CTRLKEY, JSPROP_ENUMERATE | JSPROP_READONLY}, + {"shiftKey", KEYEVENT_SHIFTKEY, JSPROP_ENUMERATE | JSPROP_READONLY}, + {"metaKey", KEYEVENT_METAKEY, JSPROP_ENUMERATE | JSPROP_READONLY}, + {"screenX", MOUSEEVENT_SCREENX, JSPROP_ENUMERATE | JSPROP_READONLY}, + {"screenY", MOUSEEVENT_SCREENY, JSPROP_ENUMERATE | JSPROP_READONLY}, + {"clientX", MOUSEEVENT_CLIENTX, JSPROP_ENUMERATE | JSPROP_READONLY}, + {"clientY", MOUSEEVENT_CLIENTY, JSPROP_ENUMERATE | JSPROP_READONLY}, + {"button", MOUSEEVENT_BUTTON, JSPROP_ENUMERATE | JSPROP_READONLY}, + {"clickCount", MOUSEEVENT_CLICKCOUNT, JSPROP_ENUMERATE | JSPROP_READONLY}, + {"relatedNode", MOUSEEVENT_RELATEDNODE, JSPROP_ENUMERATE | JSPROP_READONLY}, + {0} +}; + + +// +// KeyEvent class methods +// +static JSFunctionSpec KeyEventMethods[] = +{ + {"initKeyEvent", KeyEventInitKeyEvent, 10}, + {"initMouseEvent", MouseEventInitMouseEvent, 11}, + {0} +}; + + +// +// KeyEvent constructor +// +PR_STATIC_CALLBACK(JSBool) +KeyEvent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + return JS_FALSE; +} + + +// +// KeyEvent class initialization +// +extern "C" NS_DOM nsresult NS_InitKeyEventClass(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, "KeyEvent", &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_InitUIEventClass(aContext, (void **)&parent_proto)) { + return NS_ERROR_FAILURE; + } + proto = JS_InitClass(jscontext, // context + global, // global object + parent_proto, // parent proto + &KeyEventClass, // JSClass + KeyEvent, // JSNative ctor + 0, // ctor args + KeyEventProperties, // proto props + KeyEventMethods, // proto funcs + nsnull, // ctor props (static) + nsnull); // ctor funcs (static) + if (nsnull == proto) { + return NS_ERROR_FAILURE; + } + + if ((PR_TRUE == JS_LookupProperty(jscontext, global, "KeyEvent", &vp)) && + JSVAL_IS_OBJECT(vp) && + ((constructor = JSVAL_TO_OBJECT(vp)) != nsnull)) { + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_CHAR_UNDEFINED); + JS_SetProperty(jscontext, constructor, "DOM_CHAR_UNDEFINED", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_0); + JS_SetProperty(jscontext, constructor, "DOM_VK_0", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_1); + JS_SetProperty(jscontext, constructor, "DOM_VK_1", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_2); + JS_SetProperty(jscontext, constructor, "DOM_VK_2", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_3); + JS_SetProperty(jscontext, constructor, "DOM_VK_3", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_4); + JS_SetProperty(jscontext, constructor, "DOM_VK_4", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_5); + JS_SetProperty(jscontext, constructor, "DOM_VK_5", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_6); + JS_SetProperty(jscontext, constructor, "DOM_VK_6", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_7); + JS_SetProperty(jscontext, constructor, "DOM_VK_7", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_8); + JS_SetProperty(jscontext, constructor, "DOM_VK_8", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_9); + JS_SetProperty(jscontext, constructor, "DOM_VK_9", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_A); + JS_SetProperty(jscontext, constructor, "DOM_VK_A", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_ACCEPT); + JS_SetProperty(jscontext, constructor, "DOM_VK_ACCEPT", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_ADD); + JS_SetProperty(jscontext, constructor, "DOM_VK_ADD", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_AGAIN); + JS_SetProperty(jscontext, constructor, "DOM_VK_AGAIN", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_ALL_CANDIDATES); + JS_SetProperty(jscontext, constructor, "DOM_VK_ALL_CANDIDATES", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_ALPHANUMERIC); + JS_SetProperty(jscontext, constructor, "DOM_VK_ALPHANUMERIC", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_ALT); + JS_SetProperty(jscontext, constructor, "DOM_VK_ALT", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_ALT_GRAPH); + JS_SetProperty(jscontext, constructor, "DOM_VK_ALT_GRAPH", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_AMPERSAND); + JS_SetProperty(jscontext, constructor, "DOM_VK_AMPERSAND", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_ASTERISK); + JS_SetProperty(jscontext, constructor, "DOM_VK_ASTERISK", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_AT); + JS_SetProperty(jscontext, constructor, "DOM_VK_AT", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_B); + JS_SetProperty(jscontext, constructor, "DOM_VK_B", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_BACK_QUOTE); + JS_SetProperty(jscontext, constructor, "DOM_VK_BACK_QUOTE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_BACK_SLASH); + JS_SetProperty(jscontext, constructor, "DOM_VK_BACK_SLASH", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_BACK_SPACE); + JS_SetProperty(jscontext, constructor, "DOM_VK_BACK_SPACE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_BRACELEFT); + JS_SetProperty(jscontext, constructor, "DOM_VK_BRACELEFT", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_BRACERIGHT); + JS_SetProperty(jscontext, constructor, "DOM_VK_BRACERIGHT", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_C); + JS_SetProperty(jscontext, constructor, "DOM_VK_C", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_CANCEL); + JS_SetProperty(jscontext, constructor, "DOM_VK_CANCEL", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_CAPS_LOCK); + JS_SetProperty(jscontext, constructor, "DOM_VK_CAPS_LOCK", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_CIRCUMFLEX); + JS_SetProperty(jscontext, constructor, "DOM_VK_CIRCUMFLEX", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_CLEAR); + JS_SetProperty(jscontext, constructor, "DOM_VK_CLEAR", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_CLOSE_BRACKET); + JS_SetProperty(jscontext, constructor, "DOM_VK_CLOSE_BRACKET", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_CODE_INPUT); + JS_SetProperty(jscontext, constructor, "DOM_VK_CODE_INPUT", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_COLON); + JS_SetProperty(jscontext, constructor, "DOM_VK_COLON", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_COMMA); + JS_SetProperty(jscontext, constructor, "DOM_VK_COMMA", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_COMPOSE); + JS_SetProperty(jscontext, constructor, "DOM_VK_COMPOSE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_CONTROL); + JS_SetProperty(jscontext, constructor, "DOM_VK_CONTROL", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_CONVERT); + JS_SetProperty(jscontext, constructor, "DOM_VK_CONVERT", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_COPY); + JS_SetProperty(jscontext, constructor, "DOM_VK_COPY", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_CUT); + JS_SetProperty(jscontext, constructor, "DOM_VK_CUT", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_D); + JS_SetProperty(jscontext, constructor, "DOM_VK_D", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DEAD_ABOVEDOT); + JS_SetProperty(jscontext, constructor, "DOM_VK_DEAD_ABOVEDOT", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DEAD_ABOVERING); + JS_SetProperty(jscontext, constructor, "DOM_VK_DEAD_ABOVERING", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DEAD_ACUTE); + JS_SetProperty(jscontext, constructor, "DOM_VK_DEAD_ACUTE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DEAD_BREVE); + JS_SetProperty(jscontext, constructor, "DOM_VK_DEAD_BREVE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DEAD_CARON); + JS_SetProperty(jscontext, constructor, "DOM_VK_DEAD_CARON", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DEAD_CEDILLA); + JS_SetProperty(jscontext, constructor, "DOM_VK_DEAD_CEDILLA", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DEAD_CIRCUMFLEX); + JS_SetProperty(jscontext, constructor, "DOM_VK_DEAD_CIRCUMFLEX", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DEAD_DIAERESIS); + JS_SetProperty(jscontext, constructor, "DOM_VK_DEAD_DIAERESIS", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DEAD_DOUBLEACUTE); + JS_SetProperty(jscontext, constructor, "DOM_VK_DEAD_DOUBLEACUTE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DEAD_GRAVE); + JS_SetProperty(jscontext, constructor, "DOM_VK_DEAD_GRAVE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DEAD_IOTA); + JS_SetProperty(jscontext, constructor, "DOM_VK_DEAD_IOTA", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DEAD_MACRON); + JS_SetProperty(jscontext, constructor, "DOM_VK_DEAD_MACRON", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DEAD_OGONEK); + JS_SetProperty(jscontext, constructor, "DOM_VK_DEAD_OGONEK", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DEAD_SEMIVOICED_SOUND); + JS_SetProperty(jscontext, constructor, "DOM_VK_DEAD_SEMIVOICED_SOUND", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DEAD_TILDE); + JS_SetProperty(jscontext, constructor, "DOM_VK_DEAD_TILDE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DEAD_VOICED_SOUND); + JS_SetProperty(jscontext, constructor, "DOM_VK_DEAD_VOICED_SOUND", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DECIMAL); + JS_SetProperty(jscontext, constructor, "DOM_VK_DECIMAL", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DELETE); + JS_SetProperty(jscontext, constructor, "DOM_VK_DELETE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DIVIDE); + JS_SetProperty(jscontext, constructor, "DOM_VK_DIVIDE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DOLLAR); + JS_SetProperty(jscontext, constructor, "DOM_VK_DOLLAR", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DOWN); + JS_SetProperty(jscontext, constructor, "DOM_VK_DOWN", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_E); + JS_SetProperty(jscontext, constructor, "DOM_VK_E", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_END); + JS_SetProperty(jscontext, constructor, "DOM_VK_END", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_ENTER); + JS_SetProperty(jscontext, constructor, "DOM_VK_ENTER", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_EQUALS); + JS_SetProperty(jscontext, constructor, "DOM_VK_EQUALS", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_ESCAPE); + JS_SetProperty(jscontext, constructor, "DOM_VK_ESCAPE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_EURO_SIGN); + JS_SetProperty(jscontext, constructor, "DOM_VK_EURO_SIGN", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_EXCLAMATION_MARK); + JS_SetProperty(jscontext, constructor, "DOM_VK_EXCLAMATION_MARK", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F); + JS_SetProperty(jscontext, constructor, "DOM_VK_F", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F1); + JS_SetProperty(jscontext, constructor, "DOM_VK_F1", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F10); + JS_SetProperty(jscontext, constructor, "DOM_VK_F10", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F11); + JS_SetProperty(jscontext, constructor, "DOM_VK_F11", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F12); + JS_SetProperty(jscontext, constructor, "DOM_VK_F12", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F13); + JS_SetProperty(jscontext, constructor, "DOM_VK_F13", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F14); + JS_SetProperty(jscontext, constructor, "DOM_VK_F14", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F15); + JS_SetProperty(jscontext, constructor, "DOM_VK_F15", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F16); + JS_SetProperty(jscontext, constructor, "DOM_VK_F16", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F17); + JS_SetProperty(jscontext, constructor, "DOM_VK_F17", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F18); + JS_SetProperty(jscontext, constructor, "DOM_VK_F18", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F19); + JS_SetProperty(jscontext, constructor, "DOM_VK_F19", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F2); + JS_SetProperty(jscontext, constructor, "DOM_VK_F2", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F20); + JS_SetProperty(jscontext, constructor, "DOM_VK_F20", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F21); + JS_SetProperty(jscontext, constructor, "DOM_VK_F21", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F22); + JS_SetProperty(jscontext, constructor, "DOM_VK_F22", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F23); + JS_SetProperty(jscontext, constructor, "DOM_VK_F23", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F24); + JS_SetProperty(jscontext, constructor, "DOM_VK_F24", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F3); + JS_SetProperty(jscontext, constructor, "DOM_VK_F3", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F4); + JS_SetProperty(jscontext, constructor, "DOM_VK_F4", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F5); + JS_SetProperty(jscontext, constructor, "DOM_VK_F5", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F6); + JS_SetProperty(jscontext, constructor, "DOM_VK_F6", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F7); + JS_SetProperty(jscontext, constructor, "DOM_VK_F7", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F8); + JS_SetProperty(jscontext, constructor, "DOM_VK_F8", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F9); + JS_SetProperty(jscontext, constructor, "DOM_VK_F9", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_FINAL); + JS_SetProperty(jscontext, constructor, "DOM_VK_FINAL", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_FIND); + JS_SetProperty(jscontext, constructor, "DOM_VK_FIND", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_FULL_WIDTH); + JS_SetProperty(jscontext, constructor, "DOM_VK_FULL_WIDTH", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_G); + JS_SetProperty(jscontext, constructor, "DOM_VK_G", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_GREATER); + JS_SetProperty(jscontext, constructor, "DOM_VK_GREATER", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_H); + JS_SetProperty(jscontext, constructor, "DOM_VK_H", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_HALF_WIDTH); + JS_SetProperty(jscontext, constructor, "DOM_VK_HALF_WIDTH", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_HELP); + JS_SetProperty(jscontext, constructor, "DOM_VK_HELP", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_HIRAGANA); + JS_SetProperty(jscontext, constructor, "DOM_VK_HIRAGANA", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_HOME); + JS_SetProperty(jscontext, constructor, "DOM_VK_HOME", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_I); + JS_SetProperty(jscontext, constructor, "DOM_VK_I", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_INSERT); + JS_SetProperty(jscontext, constructor, "DOM_VK_INSERT", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_INVERTED_EXCLAMATION_MARK); + JS_SetProperty(jscontext, constructor, "DOM_VK_INVERTED_EXCLAMATION_MARK", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_J); + JS_SetProperty(jscontext, constructor, "DOM_VK_J", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_JAPANESE_HIRAGANA); + JS_SetProperty(jscontext, constructor, "DOM_VK_JAPANESE_HIRAGANA", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_JAPANESE_KATAKANA); + JS_SetProperty(jscontext, constructor, "DOM_VK_JAPANESE_KATAKANA", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_JAPANESE_ROMAN); + JS_SetProperty(jscontext, constructor, "DOM_VK_JAPANESE_ROMAN", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_K); + JS_SetProperty(jscontext, constructor, "DOM_VK_K", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_KANA); + JS_SetProperty(jscontext, constructor, "DOM_VK_KANA", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_KANJI); + JS_SetProperty(jscontext, constructor, "DOM_VK_KANJI", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_KATAKANA); + JS_SetProperty(jscontext, constructor, "DOM_VK_KATAKANA", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_KP_DOWN); + JS_SetProperty(jscontext, constructor, "DOM_VK_KP_DOWN", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_KP_LEFT); + JS_SetProperty(jscontext, constructor, "DOM_VK_KP_LEFT", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_KP_RIGHT); + JS_SetProperty(jscontext, constructor, "DOM_VK_KP_RIGHT", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_KP_UP); + JS_SetProperty(jscontext, constructor, "DOM_VK_KP_UP", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_L); + JS_SetProperty(jscontext, constructor, "DOM_VK_L", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_LEFT); + JS_SetProperty(jscontext, constructor, "DOM_VK_LEFT", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_LEFT_PARENTHESIS); + JS_SetProperty(jscontext, constructor, "DOM_VK_LEFT_PARENTHESIS", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_LESS); + JS_SetProperty(jscontext, constructor, "DOM_VK_LESS", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_M); + JS_SetProperty(jscontext, constructor, "DOM_VK_M", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_META); + JS_SetProperty(jscontext, constructor, "DOM_VK_META", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_MINUS); + JS_SetProperty(jscontext, constructor, "DOM_VK_MINUS", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_MODECHANGE); + JS_SetProperty(jscontext, constructor, "DOM_VK_MODECHANGE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_MULTIPLY); + JS_SetProperty(jscontext, constructor, "DOM_VK_MULTIPLY", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_N); + JS_SetProperty(jscontext, constructor, "DOM_VK_N", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NONCONVERT); + JS_SetProperty(jscontext, constructor, "DOM_VK_NONCONVERT", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUM_LOCK); + JS_SetProperty(jscontext, constructor, "DOM_VK_NUM_LOCK", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMBER_SIGN); + JS_SetProperty(jscontext, constructor, "DOM_VK_NUMBER_SIGN", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD0); + JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD0", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD1); + JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD1", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD2); + JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD2", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD3); + JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD3", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD4); + JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD4", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD5); + JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD5", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD6); + JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD6", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD7); + JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD7", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD8); + JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD8", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD9); + JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD9", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_O); + JS_SetProperty(jscontext, constructor, "DOM_VK_O", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_OPEN_BRACKET); + JS_SetProperty(jscontext, constructor, "DOM_VK_OPEN_BRACKET", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_P); + JS_SetProperty(jscontext, constructor, "DOM_VK_P", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_PAGE_DOWN); + JS_SetProperty(jscontext, constructor, "DOM_VK_PAGE_DOWN", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_PAGE_UP); + JS_SetProperty(jscontext, constructor, "DOM_VK_PAGE_UP", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_PASTE); + JS_SetProperty(jscontext, constructor, "DOM_VK_PASTE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_PAUSE); + JS_SetProperty(jscontext, constructor, "DOM_VK_PAUSE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_PERIOD); + JS_SetProperty(jscontext, constructor, "DOM_VK_PERIOD", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_PLUS); + JS_SetProperty(jscontext, constructor, "DOM_VK_PLUS", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_PREVIOUS_CANDIDATE); + JS_SetProperty(jscontext, constructor, "DOM_VK_PREVIOUS_CANDIDATE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_PRINTSCREEN); + JS_SetProperty(jscontext, constructor, "DOM_VK_PRINTSCREEN", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_PROPS); + JS_SetProperty(jscontext, constructor, "DOM_VK_PROPS", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_Q); + JS_SetProperty(jscontext, constructor, "DOM_VK_Q", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_QUOTE); + JS_SetProperty(jscontext, constructor, "DOM_VK_QUOTE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_QUOTEDBL); + JS_SetProperty(jscontext, constructor, "DOM_VK_QUOTEDBL", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_R); + JS_SetProperty(jscontext, constructor, "DOM_VK_R", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_RETURN); + JS_SetProperty(jscontext, constructor, "DOM_VK_RETURN", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_RIGHT); + JS_SetProperty(jscontext, constructor, "DOM_VK_RIGHT", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_RIGHT_PARENTHESIS); + JS_SetProperty(jscontext, constructor, "DOM_VK_RIGHT_PARENTHESIS", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_ROMAN_CHARACTERS); + JS_SetProperty(jscontext, constructor, "DOM_VK_ROMAN_CHARACTERS", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_S); + JS_SetProperty(jscontext, constructor, "DOM_VK_S", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_SCROLL_LOCK); + JS_SetProperty(jscontext, constructor, "DOM_VK_SCROLL_LOCK", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_SEMICOLON); + JS_SetProperty(jscontext, constructor, "DOM_VK_SEMICOLON", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_SEPARATER); + JS_SetProperty(jscontext, constructor, "DOM_VK_SEPARATER", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_SHIFT); + JS_SetProperty(jscontext, constructor, "DOM_VK_SHIFT", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_SLASH); + JS_SetProperty(jscontext, constructor, "DOM_VK_SLASH", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_SPACE); + JS_SetProperty(jscontext, constructor, "DOM_VK_SPACE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_STOP); + JS_SetProperty(jscontext, constructor, "DOM_VK_STOP", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_SUBTRACT); + JS_SetProperty(jscontext, constructor, "DOM_VK_SUBTRACT", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_T); + JS_SetProperty(jscontext, constructor, "DOM_VK_T", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_TAB); + JS_SetProperty(jscontext, constructor, "DOM_VK_TAB", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_U); + JS_SetProperty(jscontext, constructor, "DOM_VK_U", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_UNDEFINED); + JS_SetProperty(jscontext, constructor, "DOM_VK_UNDEFINED", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_UNDERSCORE); + JS_SetProperty(jscontext, constructor, "DOM_VK_UNDERSCORE", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_UNDO); + JS_SetProperty(jscontext, constructor, "DOM_VK_UNDO", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_UP); + JS_SetProperty(jscontext, constructor, "DOM_VK_UP", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_V); + JS_SetProperty(jscontext, constructor, "DOM_VK_V", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_W); + JS_SetProperty(jscontext, constructor, "DOM_VK_W", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_X); + JS_SetProperty(jscontext, constructor, "DOM_VK_X", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_Y); + JS_SetProperty(jscontext, constructor, "DOM_VK_Y", &vp); + + vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_Z); + JS_SetProperty(jscontext, constructor, "DOM_VK_Z", &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 KeyEvent JavaScript object +// +extern "C" NS_DOM nsresult NS_NewScriptKeyEvent(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn) +{ + NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptKeyEvent"); + JSObject *proto; + JSObject *parent; + nsIScriptObjectOwner *owner; + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + nsresult result = NS_OK; + nsIDOMKeyEvent *aKeyEvent; + + 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_InitKeyEventClass(aContext, (void **)&proto)) { + return NS_ERROR_FAILURE; + } + + result = aSupports->QueryInterface(kIKeyEventIID, (void **)&aKeyEvent); + if (NS_OK != result) { + return result; + } + + // create a js object for this class + *aReturn = JS_NewObject(jscontext, &KeyEventClass, proto, parent); + if (nsnull != *aReturn) { + // connect the native object to the js object + JS_SetPrivate(jscontext, (JSObject *)*aReturn, aKeyEvent); + } + else { + NS_RELEASE(aKeyEvent); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} diff --git a/mozilla/dom/src/events/nsJSUIEvent.cpp b/mozilla/dom/src/events/nsJSUIEvent.cpp index 57f228ce8a9..f30a220b8fb 100644 --- a/mozilla/dom/src/events/nsJSUIEvent.cpp +++ b/mozilla/dom/src/events/nsJSUIEvent.cpp @@ -29,6 +29,7 @@ #include "nsCOMPtr.h" #include "nsIPtr.h" #include "nsString.h" +#include "nsIDOMAbstractView.h" #include "nsIDOMNSUIEvent.h" #include "nsIDOMNode.h" #include "nsIDOMUIEvent.h" @@ -37,10 +38,12 @@ 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(kIAbstractViewIID, NS_IDOMABSTRACTVIEW_IID); static NS_DEFINE_IID(kINSUIEventIID, NS_IDOMNSUIEVENT_IID); static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID); static NS_DEFINE_IID(kIUIEventIID, NS_IDOMUIEVENT_IID); +NS_DEF_PTR(nsIDOMAbstractView); NS_DEF_PTR(nsIDOMNSUIEvent); NS_DEF_PTR(nsIDOMNode); NS_DEF_PTR(nsIDOMUIEvent); @@ -49,26 +52,17 @@ NS_DEF_PTR(nsIDOMUIEvent); // UIEvent property ids // enum UIEvent_slots { - UIEVENT_SCREENX = -1, - UIEVENT_SCREENY = -2, - UIEVENT_CLIENTX = -3, - UIEVENT_CLIENTY = -4, - UIEVENT_ALTKEY = -5, - UIEVENT_CTRLKEY = -6, - UIEVENT_SHIFTKEY = -7, - UIEVENT_METAKEY = -8, - UIEVENT_CHARCODE = -9, - UIEVENT_KEYCODE = -10, - UIEVENT_BUTTON = -11, - UIEVENT_CLICKCOUNT = -12, - NSUIEVENT_LAYERX = -13, - NSUIEVENT_LAYERY = -14, - NSUIEVENT_PAGEX = -15, - NSUIEVENT_PAGEY = -16, - NSUIEVENT_WHICH = -17, - NSUIEVENT_RANGEPARENT = -18, - NSUIEVENT_RANGEOFFSET = -19, - NSUIEVENT_CANCELBUBBLE = -20 + UIEVENT_VIEW = -1, + UIEVENT_DETAIL = -2, + NSUIEVENT_LAYERX = -3, + NSUIEVENT_LAYERY = -4, + NSUIEVENT_PAGEX = -5, + NSUIEVENT_PAGEY = -6, + NSUIEVENT_WHICH = -7, + NSUIEVENT_RANGEPARENT = -8, + NSUIEVENT_RANGEOFFSET = -9, + NSUIEVENT_CANCELBUBBLE = -10, + NSUIEVENT_ISCHAR = -11 }; /***********************************************************************/ @@ -92,214 +86,35 @@ GetUIEventProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECMAN_ERR); } switch(JSVAL_TO_INT(id)) { - case UIEVENT_SCREENX: + case UIEVENT_VIEW: { PRBool ok = PR_FALSE; - secMan->CheckScriptAccess(scriptCX, obj, "uievent.screenx", PR_FALSE, &ok); + secMan->CheckScriptAccess(scriptCX, obj, "uievent.view", PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + nsIDOMAbstractView* prop; + nsresult result = NS_OK; + result = a->GetView(&prop); + if (NS_SUCCEEDED(result)) { + // get the js object + nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, result); + } + break; + } + case UIEVENT_DETAIL: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, "uievent.detail", PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } PRInt32 prop; nsresult result = NS_OK; - result = a->GetScreenX(&prop); - if (NS_SUCCEEDED(result)) { - *vp = INT_TO_JSVAL(prop); - } - else { - return nsJSUtils::nsReportError(cx, result); - } - break; - } - case UIEVENT_SCREENY: - { - PRBool ok = PR_FALSE; - secMan->CheckScriptAccess(scriptCX, obj, "uievent.screeny", PR_FALSE, &ok); - if (!ok) { - return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); - } - PRInt32 prop; - nsresult result = NS_OK; - result = a->GetScreenY(&prop); - if (NS_SUCCEEDED(result)) { - *vp = INT_TO_JSVAL(prop); - } - else { - return nsJSUtils::nsReportError(cx, result); - } - break; - } - case UIEVENT_CLIENTX: - { - PRBool ok = PR_FALSE; - secMan->CheckScriptAccess(scriptCX, obj, "uievent.clientx", PR_FALSE, &ok); - if (!ok) { - return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); - } - PRInt32 prop; - nsresult result = NS_OK; - result = a->GetClientX(&prop); - if (NS_SUCCEEDED(result)) { - *vp = INT_TO_JSVAL(prop); - } - else { - return nsJSUtils::nsReportError(cx, result); - } - break; - } - case UIEVENT_CLIENTY: - { - PRBool ok = PR_FALSE; - secMan->CheckScriptAccess(scriptCX, obj, "uievent.clienty", PR_FALSE, &ok); - if (!ok) { - return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); - } - PRInt32 prop; - nsresult result = NS_OK; - result = a->GetClientY(&prop); - if (NS_SUCCEEDED(result)) { - *vp = INT_TO_JSVAL(prop); - } - else { - return nsJSUtils::nsReportError(cx, result); - } - break; - } - case UIEVENT_ALTKEY: - { - PRBool ok = PR_FALSE; - secMan->CheckScriptAccess(scriptCX, obj, "uievent.altkey", PR_FALSE, &ok); - if (!ok) { - return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); - } - PRBool prop; - nsresult result = NS_OK; - result = a->GetAltKey(&prop); - if (NS_SUCCEEDED(result)) { - *vp = BOOLEAN_TO_JSVAL(prop); - } - else { - return nsJSUtils::nsReportError(cx, result); - } - break; - } - case UIEVENT_CTRLKEY: - { - PRBool ok = PR_FALSE; - secMan->CheckScriptAccess(scriptCX, obj, "uievent.ctrlkey", PR_FALSE, &ok); - if (!ok) { - return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); - } - PRBool prop; - nsresult result = NS_OK; - result = a->GetCtrlKey(&prop); - if (NS_SUCCEEDED(result)) { - *vp = BOOLEAN_TO_JSVAL(prop); - } - else { - return nsJSUtils::nsReportError(cx, result); - } - break; - } - case UIEVENT_SHIFTKEY: - { - PRBool ok = PR_FALSE; - secMan->CheckScriptAccess(scriptCX, obj, "uievent.shiftkey", PR_FALSE, &ok); - if (!ok) { - return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); - } - PRBool prop; - nsresult result = NS_OK; - result = a->GetShiftKey(&prop); - if (NS_SUCCEEDED(result)) { - *vp = BOOLEAN_TO_JSVAL(prop); - } - else { - return nsJSUtils::nsReportError(cx, result); - } - break; - } - case UIEVENT_METAKEY: - { - PRBool ok = PR_FALSE; - secMan->CheckScriptAccess(scriptCX, obj, "uievent.metakey", PR_FALSE, &ok); - if (!ok) { - return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); - } - PRBool prop; - nsresult result = NS_OK; - result = a->GetMetaKey(&prop); - if (NS_SUCCEEDED(result)) { - *vp = BOOLEAN_TO_JSVAL(prop); - } - else { - return nsJSUtils::nsReportError(cx, result); - } - break; - } - case UIEVENT_CHARCODE: - { - PRBool ok = PR_FALSE; - secMan->CheckScriptAccess(scriptCX, obj, "uievent.charcode", PR_FALSE, &ok); - if (!ok) { - return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); - } - PRUint32 prop; - nsresult result = NS_OK; - result = a->GetCharCode(&prop); - if (NS_SUCCEEDED(result)) { - *vp = INT_TO_JSVAL(prop); - } - else { - return nsJSUtils::nsReportError(cx, result); - } - break; - } - case UIEVENT_KEYCODE: - { - PRBool ok = PR_FALSE; - secMan->CheckScriptAccess(scriptCX, obj, "uievent.keycode", PR_FALSE, &ok); - if (!ok) { - return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); - } - PRUint32 prop; - nsresult result = NS_OK; - result = a->GetKeyCode(&prop); - if (NS_SUCCEEDED(result)) { - *vp = INT_TO_JSVAL(prop); - } - else { - return nsJSUtils::nsReportError(cx, result); - } - break; - } - case UIEVENT_BUTTON: - { - PRBool ok = PR_FALSE; - secMan->CheckScriptAccess(scriptCX, obj, "uievent.button", PR_FALSE, &ok); - if (!ok) { - return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); - } - PRUint16 prop; - nsresult result = NS_OK; - result = a->GetButton(&prop); - if (NS_SUCCEEDED(result)) { - *vp = INT_TO_JSVAL(prop); - } - else { - return nsJSUtils::nsReportError(cx, result); - } - break; - } - case UIEVENT_CLICKCOUNT: - { - PRBool ok = PR_FALSE; - secMan->CheckScriptAccess(scriptCX, obj, "uievent.clickcount", PR_FALSE, &ok); - if (!ok) { - return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); - } - PRUint16 prop; - nsresult result = NS_OK; - result = a->GetClickCount(&prop); + result = a->GetDetail(&prop); if (NS_SUCCEEDED(result)) { *vp = INT_TO_JSVAL(prop); } @@ -517,6 +332,32 @@ GetUIEventProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) } break; } + case NSUIEVENT_ISCHAR: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, "nsuievent.ischar", PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + PRBool prop; + nsIDOMNSUIEvent* b; + if (NS_OK == a->QueryInterface(kINSUIEventIID, (void **)&b)) { + nsresult result = NS_OK; + result = b->GetIsChar(&prop); + if(NS_SUCCEEDED(result)) { + *vp = BOOLEAN_TO_JSVAL(prop); + NS_RELEASE(b); + } + else { + NS_RELEASE(b); + return nsJSUtils::nsReportError(cx, result); + } + } + else { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_WRONG_TYPE_ERR); + } + break; + } default: return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp); } @@ -615,6 +456,75 @@ ResolveUIEvent(JSContext *cx, JSObject *obj, jsval id) } +// +// Native method InitUIEvent +// +PR_STATIC_CALLBACK(JSBool) +UIEventInitUIEvent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMUIEvent *nativeThis = (nsIDOMUIEvent*)nsJSUtils::nsGetNativeThis(cx, obj); + nsresult result = NS_OK; + nsAutoString b0; + PRBool b1; + PRBool b2; + nsIDOMAbstractViewPtr b3; + PRInt32 b4; + + *rval = JSVAL_NULL; + + nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx); + nsCOMPtr secMan; + if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECMAN_ERR); + } + { + PRBool ok; + secMan->CheckScriptAccess(scriptCX, obj, "uievent.inituievent",PR_FALSE , &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + } + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == nativeThis) { + return JS_TRUE; + } + + { + if (argc < 5) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR); + } + + nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]); + if (!nsJSUtils::nsConvertJSValToBool(&b1, cx, argv[1])) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + if (!nsJSUtils::nsConvertJSValToBool(&b2, cx, argv[2])) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b3, + kIAbstractViewIID, + "AbstractView", + cx, + argv[3])) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_OBJECT_ERR); + } + if (!JS_ValueToInt32(cx, argv[4], (int32 *)&b4)) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_NUMBER_ERR); + } + + result = nativeThis->InitUIEvent(b0, b1, b2, b3, b4); + if (NS_FAILED(result)) { + return nsJSUtils::nsReportError(cx, result); + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + /***********************************************************************/ // // class for UIEvent @@ -638,18 +548,8 @@ JSClass UIEventClass = { // static JSPropertySpec UIEventProperties[] = { - {"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}, - {"clickCount", UIEVENT_CLICKCOUNT, JSPROP_ENUMERATE | JSPROP_READONLY}, + {"view", UIEVENT_VIEW, JSPROP_ENUMERATE | JSPROP_READONLY}, + {"detail", UIEVENT_DETAIL, 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}, @@ -658,6 +558,7 @@ static JSPropertySpec UIEventProperties[] = {"rangeParent", NSUIEVENT_RANGEPARENT, JSPROP_ENUMERATE | JSPROP_READONLY}, {"rangeOffset", NSUIEVENT_RANGEOFFSET, JSPROP_ENUMERATE | JSPROP_READONLY}, {"cancelBubble", NSUIEVENT_CANCELBUBBLE, JSPROP_ENUMERATE}, + {"isChar", NSUIEVENT_ISCHAR, JSPROP_ENUMERATE | JSPROP_READONLY}, {0} }; @@ -667,6 +568,7 @@ static JSPropertySpec UIEventProperties[] = // static JSFunctionSpec UIEventMethods[] = { + {"initUIEvent", UIEventInitUIEvent, 5}, {0} }; @@ -716,347 +618,6 @@ extern "C" NS_DOM nsresult NS_InitUIEventClass(nsIScriptContext *aContext, void 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::DOM_VK_CANCEL); - JS_SetProperty(jscontext, constructor, "DOM_VK_CANCEL", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_BACK); - JS_SetProperty(jscontext, constructor, "DOM_VK_BACK", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_TAB); - JS_SetProperty(jscontext, constructor, "DOM_VK_TAB", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_CLEAR); - JS_SetProperty(jscontext, constructor, "DOM_VK_CLEAR", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_RETURN); - JS_SetProperty(jscontext, constructor, "DOM_VK_RETURN", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_ENTER); - JS_SetProperty(jscontext, constructor, "DOM_VK_ENTER", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_SHIFT); - JS_SetProperty(jscontext, constructor, "DOM_VK_SHIFT", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_CONTROL); - JS_SetProperty(jscontext, constructor, "DOM_VK_CONTROL", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_ALT); - JS_SetProperty(jscontext, constructor, "DOM_VK_ALT", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_PAUSE); - JS_SetProperty(jscontext, constructor, "DOM_VK_PAUSE", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_CAPS_LOCK); - JS_SetProperty(jscontext, constructor, "DOM_VK_CAPS_LOCK", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_ESCAPE); - JS_SetProperty(jscontext, constructor, "DOM_VK_ESCAPE", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_SPACE); - JS_SetProperty(jscontext, constructor, "DOM_VK_SPACE", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_PAGE_UP); - JS_SetProperty(jscontext, constructor, "DOM_VK_PAGE_UP", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_PAGE_DOWN); - JS_SetProperty(jscontext, constructor, "DOM_VK_PAGE_DOWN", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_END); - JS_SetProperty(jscontext, constructor, "DOM_VK_END", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_HOME); - JS_SetProperty(jscontext, constructor, "DOM_VK_HOME", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_LEFT); - JS_SetProperty(jscontext, constructor, "DOM_VK_LEFT", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_UP); - JS_SetProperty(jscontext, constructor, "DOM_VK_UP", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_RIGHT); - JS_SetProperty(jscontext, constructor, "DOM_VK_RIGHT", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_DOWN); - JS_SetProperty(jscontext, constructor, "DOM_VK_DOWN", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_PRINTSCREEN); - JS_SetProperty(jscontext, constructor, "DOM_VK_PRINTSCREEN", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_INSERT); - JS_SetProperty(jscontext, constructor, "DOM_VK_INSERT", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_DELETE); - JS_SetProperty(jscontext, constructor, "DOM_VK_DELETE", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_0); - JS_SetProperty(jscontext, constructor, "DOM_VK_0", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_1); - JS_SetProperty(jscontext, constructor, "DOM_VK_1", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_2); - JS_SetProperty(jscontext, constructor, "DOM_VK_2", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_3); - JS_SetProperty(jscontext, constructor, "DOM_VK_3", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_4); - JS_SetProperty(jscontext, constructor, "DOM_VK_4", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_5); - JS_SetProperty(jscontext, constructor, "DOM_VK_5", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_6); - JS_SetProperty(jscontext, constructor, "DOM_VK_6", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_7); - JS_SetProperty(jscontext, constructor, "DOM_VK_7", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_8); - JS_SetProperty(jscontext, constructor, "DOM_VK_8", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_9); - JS_SetProperty(jscontext, constructor, "DOM_VK_9", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_SEMICOLON); - JS_SetProperty(jscontext, constructor, "DOM_VK_SEMICOLON", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_EQUALS); - JS_SetProperty(jscontext, constructor, "DOM_VK_EQUALS", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_A); - JS_SetProperty(jscontext, constructor, "DOM_VK_A", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_B); - JS_SetProperty(jscontext, constructor, "DOM_VK_B", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_C); - JS_SetProperty(jscontext, constructor, "DOM_VK_C", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_D); - JS_SetProperty(jscontext, constructor, "DOM_VK_D", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_E); - JS_SetProperty(jscontext, constructor, "DOM_VK_E", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F); - JS_SetProperty(jscontext, constructor, "DOM_VK_F", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_G); - JS_SetProperty(jscontext, constructor, "DOM_VK_G", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_H); - JS_SetProperty(jscontext, constructor, "DOM_VK_H", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_I); - JS_SetProperty(jscontext, constructor, "DOM_VK_I", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_J); - JS_SetProperty(jscontext, constructor, "DOM_VK_J", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_K); - JS_SetProperty(jscontext, constructor, "DOM_VK_K", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_L); - JS_SetProperty(jscontext, constructor, "DOM_VK_L", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_M); - JS_SetProperty(jscontext, constructor, "DOM_VK_M", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_N); - JS_SetProperty(jscontext, constructor, "DOM_VK_N", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_O); - JS_SetProperty(jscontext, constructor, "DOM_VK_O", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_P); - JS_SetProperty(jscontext, constructor, "DOM_VK_P", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_Q); - JS_SetProperty(jscontext, constructor, "DOM_VK_Q", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_R); - JS_SetProperty(jscontext, constructor, "DOM_VK_R", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_S); - JS_SetProperty(jscontext, constructor, "DOM_VK_S", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_T); - JS_SetProperty(jscontext, constructor, "DOM_VK_T", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_U); - JS_SetProperty(jscontext, constructor, "DOM_VK_U", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_V); - JS_SetProperty(jscontext, constructor, "DOM_VK_V", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_W); - JS_SetProperty(jscontext, constructor, "DOM_VK_W", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_X); - JS_SetProperty(jscontext, constructor, "DOM_VK_X", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_Y); - JS_SetProperty(jscontext, constructor, "DOM_VK_Y", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_Z); - JS_SetProperty(jscontext, constructor, "DOM_VK_Z", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_NUMPAD0); - JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD0", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_NUMPAD1); - JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD1", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_NUMPAD2); - JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD2", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_NUMPAD3); - JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD3", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_NUMPAD4); - JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD4", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_NUMPAD5); - JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD5", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_NUMPAD6); - JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD6", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_NUMPAD7); - JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD7", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_NUMPAD8); - JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD8", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_NUMPAD9); - JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD9", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_MULTIPLY); - JS_SetProperty(jscontext, constructor, "DOM_VK_MULTIPLY", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_ADD); - JS_SetProperty(jscontext, constructor, "DOM_VK_ADD", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_SEPARATOR); - JS_SetProperty(jscontext, constructor, "DOM_VK_SEPARATOR", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_SUBTRACT); - JS_SetProperty(jscontext, constructor, "DOM_VK_SUBTRACT", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_DECIMAL); - JS_SetProperty(jscontext, constructor, "DOM_VK_DECIMAL", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_DIVIDE); - JS_SetProperty(jscontext, constructor, "DOM_VK_DIVIDE", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F1); - JS_SetProperty(jscontext, constructor, "DOM_VK_F1", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F2); - JS_SetProperty(jscontext, constructor, "DOM_VK_F2", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F3); - JS_SetProperty(jscontext, constructor, "DOM_VK_F3", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F4); - JS_SetProperty(jscontext, constructor, "DOM_VK_F4", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F5); - JS_SetProperty(jscontext, constructor, "DOM_VK_F5", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F6); - JS_SetProperty(jscontext, constructor, "DOM_VK_F6", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F7); - JS_SetProperty(jscontext, constructor, "DOM_VK_F7", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F8); - JS_SetProperty(jscontext, constructor, "DOM_VK_F8", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F9); - JS_SetProperty(jscontext, constructor, "DOM_VK_F9", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F10); - JS_SetProperty(jscontext, constructor, "DOM_VK_F10", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F11); - JS_SetProperty(jscontext, constructor, "DOM_VK_F11", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F12); - JS_SetProperty(jscontext, constructor, "DOM_VK_F12", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F13); - JS_SetProperty(jscontext, constructor, "DOM_VK_F13", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F14); - JS_SetProperty(jscontext, constructor, "DOM_VK_F14", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F15); - JS_SetProperty(jscontext, constructor, "DOM_VK_F15", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F16); - JS_SetProperty(jscontext, constructor, "DOM_VK_F16", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F17); - JS_SetProperty(jscontext, constructor, "DOM_VK_F17", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F18); - JS_SetProperty(jscontext, constructor, "DOM_VK_F18", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F19); - JS_SetProperty(jscontext, constructor, "DOM_VK_F19", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F20); - JS_SetProperty(jscontext, constructor, "DOM_VK_F20", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F21); - JS_SetProperty(jscontext, constructor, "DOM_VK_F21", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F22); - JS_SetProperty(jscontext, constructor, "DOM_VK_F22", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F23); - JS_SetProperty(jscontext, constructor, "DOM_VK_F23", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_F24); - JS_SetProperty(jscontext, constructor, "DOM_VK_F24", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_NUM_LOCK); - JS_SetProperty(jscontext, constructor, "DOM_VK_NUM_LOCK", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_SCROLL_LOCK); - JS_SetProperty(jscontext, constructor, "DOM_VK_SCROLL_LOCK", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_COMMA); - JS_SetProperty(jscontext, constructor, "DOM_VK_COMMA", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_PERIOD); - JS_SetProperty(jscontext, constructor, "DOM_VK_PERIOD", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_SLASH); - JS_SetProperty(jscontext, constructor, "DOM_VK_SLASH", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_BACK_QUOTE); - JS_SetProperty(jscontext, constructor, "DOM_VK_BACK_QUOTE", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_OPEN_BRACKET); - JS_SetProperty(jscontext, constructor, "DOM_VK_OPEN_BRACKET", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_BACK_SLASH); - JS_SetProperty(jscontext, constructor, "DOM_VK_BACK_SLASH", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_CLOSE_BRACKET); - JS_SetProperty(jscontext, constructor, "DOM_VK_CLOSE_BRACKET", &vp); - - vp = INT_TO_JSVAL(nsIDOMUIEvent::DOM_VK_QUOTE); - JS_SetProperty(jscontext, constructor, "DOM_VK_QUOTE", &vp); - - } - } else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) { proto = JSVAL_TO_OBJECT(vp); diff --git a/mozilla/editor/base/nsEditorEventListeners.cpp b/mozilla/editor/base/nsEditorEventListeners.cpp index 36a35a46361..d5025f83a06 100644 --- a/mozilla/editor/base/nsEditorEventListeners.cpp +++ b/mozilla/editor/base/nsEditorEventListeners.cpp @@ -29,7 +29,8 @@ #include "nsIEditProperty.h" #include "nsISupportsArray.h" #include "nsIStringStream.h" -#include "nsIDOMUIEvent.h" +#include "nsIDOMKeyEvent.h" +#include "nsIDOMMouseEvent.h" #include "nsIDOMNSUIEvent.h" #include "nsIPrivateTextEvent.h" #include "nsIPrivateCompositionEvent.h" @@ -125,13 +126,13 @@ nsresult nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent) { PRUint32 keyCode; - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aKeyEvent); - if (uiEvent) + nsCOMPtrkeyEvent; + keyEvent = do_QueryInterface(aKeyEvent); + if (keyEvent) { - if (NS_SUCCEEDED(uiEvent->GetKeyCode(&keyCode))) + if (NS_SUCCEEDED(keyEvent->GetKeyCode(&keyCode))) { - if (nsIDOMUIEvent::DOM_VK_TAB==keyCode) + if (nsIDOMKeyEvent::DOM_VK_TAB==keyCode) { nsCOMPtr htmlEditor = do_QueryInterface(mEditor); PRUint32 flags=0; @@ -140,7 +141,7 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent) return NS_OK; // let it be used for focus switching // else we insert the tab straight through - htmlEditor->EditorKeyPress(uiEvent); + htmlEditor->EditorKeyPress(keyEvent); ScrollSelectionIntoView(); return NS_ERROR_BASE; // "I handled the event, don't do default processing" } @@ -160,9 +161,9 @@ nsTextEditorKeyListener::KeyUp(nsIDOMEvent* aKeyEvent) nsresult nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) { - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aKeyEvent); - if (!uiEvent) + nsCOMPtrkeyEvent; + keyEvent = do_QueryInterface(aKeyEvent); + if (!keyEvent) { //non-key event passed to keydown. bad things. return NS_OK; @@ -176,7 +177,7 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) if (PR_FALSE==keyProcessed) { PRUint32 keyCode; - uiEvent->GetKeyCode(&keyCode); + keyEvent->GetKeyCode(&keyCode); nsCOMPtr htmlEditor = do_QueryInterface(mEditor); if (!htmlEditor) return NS_ERROR_NO_INTERFACE; @@ -185,23 +186,23 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) // so look for special keys using keyCode if (0 != keyCode) { - if (nsIDOMUIEvent::DOM_VK_SHIFT==keyCode - || nsIDOMUIEvent::DOM_VK_CONTROL==keyCode - || nsIDOMUIEvent::DOM_VK_ALT==keyCode) + if (nsIDOMKeyEvent::DOM_VK_SHIFT==keyCode + || nsIDOMKeyEvent::DOM_VK_CONTROL==keyCode + || nsIDOMKeyEvent::DOM_VK_ALT==keyCode) return NS_ERROR_BASE; // consumed - if (nsIDOMUIEvent::DOM_VK_BACK==keyCode) + if (nsIDOMKeyEvent::DOM_VK_BACK_SPACE==keyCode) { mEditor->DeleteSelection(nsIEditor::eDeletePrevious); ScrollSelectionIntoView(); return NS_ERROR_BASE; // consumed } - if (nsIDOMUIEvent::DOM_VK_DELETE==keyCode) + if (nsIDOMKeyEvent::DOM_VK_DELETE==keyCode) { mEditor->DeleteSelection(nsIEditor::eDeleteNext); ScrollSelectionIntoView(); return NS_ERROR_BASE; // consumed } - if (nsIDOMUIEvent::DOM_VK_TAB==keyCode) + if (nsIDOMKeyEvent::DOM_VK_TAB==keyCode) { PRUint32 flags=0; mEditor->GetFlags(&flags); @@ -209,18 +210,18 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) return NS_OK; // let it be used for focus switching // else we insert the tab straight through - htmlEditor->EditorKeyPress(uiEvent); + htmlEditor->EditorKeyPress(keyEvent); ScrollSelectionIntoView(); return NS_ERROR_BASE; // "I handled the event, don't do default processing" } - if (nsIDOMUIEvent::DOM_VK_RETURN==keyCode) + if (nsIDOMKeyEvent::DOM_VK_RETURN==keyCode) { PRUint32 flags=0; mEditor->GetFlags(&flags); if (!(flags & nsIHTMLEditor::eEditorSingleLineMask)) { //htmlEditor->InsertBreak(); - htmlEditor->EditorKeyPress(uiEvent); + htmlEditor->EditorKeyPress(keyEvent); ScrollSelectionIntoView(); return NS_ERROR_BASE; // consumed } @@ -233,13 +234,13 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) #if 0 // XXX: this must change. DOM_VK_tab must be handled here, not in keyDown - if (nsIDOMUIEvent::DOM_VK_TAB==keyCode) + if (nsIDOMKeyEvent::DOM_VK_TAB==keyCode) { return NS_OK; // ignore tabs here, they're handled in keyDown if at all } #endif - htmlEditor->EditorKeyPress(uiEvent); + htmlEditor->EditorKeyPress(keyEvent); ScrollSelectionIntoView(); } else @@ -258,18 +259,18 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr PRBool ctrlKey; PRBool isAltKey, isMetaKey, isShiftKey; - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aKeyEvent); - if (!uiEvent) { + nsCOMPtrkeyEvent; + keyEvent = do_QueryInterface(aKeyEvent); + if (!keyEvent) { //non-key event passed in. bad things. return NS_OK; } - if (NS_SUCCEEDED(uiEvent->GetCharCode(&charCode)) && - NS_SUCCEEDED(uiEvent->GetAltKey(&isAltKey)) && - NS_SUCCEEDED(uiEvent->GetMetaKey(&isMetaKey)) && - NS_SUCCEEDED(uiEvent->GetShiftKey(&isShiftKey)) && - NS_SUCCEEDED(uiEvent->GetCtrlKey(&ctrlKey)) ) + if (NS_SUCCEEDED(keyEvent->GetCharCode(&charCode)) && + NS_SUCCEEDED(keyEvent->GetAltKey(&isAltKey)) && + NS_SUCCEEDED(keyEvent->GetMetaKey(&isMetaKey)) && + NS_SUCCEEDED(keyEvent->GetShiftKey(&isShiftKey)) && + NS_SUCCEEDED(keyEvent->GetCtrlKey(&ctrlKey)) ) { #ifdef XP_MAC // hack to make Mac work for hard-coded keybindings @@ -486,9 +487,9 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent) if (!aMouseEvent) return NS_OK; // NS_OK means "we didn't process the event". Go figure. - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aMouseEvent); - if (!uiEvent) { + nsCOMPtrmouseEvent; + mouseEvent = do_QueryInterface(aMouseEvent); + if (!mouseEvent) { //non-ui event passed in. bad things. return NS_OK; } @@ -505,7 +506,7 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent) if (!doc) { return NS_OK; } PRUint16 button = 0; - uiEvent->GetButton(&button); + mouseEvent->GetButton(&button); // left button click might be a drag-start if (1==button) { @@ -586,15 +587,15 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent) { // Set the selection to the point under the mouse cursor: - nsCOMPtr mouseEvent (do_QueryInterface(aMouseEvent)); + nsCOMPtr nsuiEvent (do_QueryInterface(aMouseEvent)); - if (!mouseEvent) + if (!nsuiEvent) return NS_ERROR_BASE; // NS_ERROR_BASE means "We did process the event". nsCOMPtr parent; - if (!NS_SUCCEEDED(mouseEvent->GetRangeParent(getter_AddRefs(parent)))) + if (!NS_SUCCEEDED(nsuiEvent->GetRangeParent(getter_AddRefs(parent)))) return NS_ERROR_BASE; // NS_ERROR_BASE means "We did process the event". PRInt32 offset = 0; - if (!NS_SUCCEEDED(mouseEvent->GetRangeOffset(&offset))) + if (!NS_SUCCEEDED(nsuiEvent->GetRangeOffset(&offset))) return NS_ERROR_BASE; // NS_ERROR_BASE means "We did process the event". nsCOMPtr selection; @@ -603,8 +604,9 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent) // If the ctrl key is pressed, we'll do paste as quotation. // Would've used the alt key, but the kde wmgr treats alt-middle specially. + nsCOMPtr mouseEvent (do_QueryInterface(aMouseEvent)); PRBool ctrlKey = PR_FALSE; - uiEvent->GetCtrlKey(&ctrlKey); + mouseEvent->GetCtrlKey(&ctrlKey); if (ctrlKey) { diff --git a/mozilla/editor/base/nsHTMLEditor.cpp b/mozilla/editor/base/nsHTMLEditor.cpp index 29f695fd3ae..a668b80f867 100644 --- a/mozilla/editor/base/nsHTMLEditor.cpp +++ b/mozilla/editor/base/nsHTMLEditor.cpp @@ -28,7 +28,7 @@ #include "nsIDOMDocument.h" #include "nsIDocument.h" #include "nsIDOMEventReceiver.h" -#include "nsIDOMUIEvent.h" +#include "nsIDOMKeyEvent.h" #include "nsIDOMKeyListener.h" #include "nsIDOMMouseListener.h" #include "nsIDOMSelection.h" @@ -600,7 +600,7 @@ void nsHTMLEditor::InitRules() #pragma mark - #endif -NS_IMETHODIMP nsHTMLEditor::EditorKeyPress(nsIDOMUIEvent* aKeyEvent) +NS_IMETHODIMP nsHTMLEditor::EditorKeyPress(nsIDOMKeyEvent* aKeyEvent) { PRUint32 keyCode, character; PRBool isShift, ctrlKey, altKey, metaKey; @@ -617,17 +617,17 @@ NS_IMETHODIMP nsHTMLEditor::EditorKeyPress(nsIDOMUIEvent* aKeyEvent) // this royally blows: because tabs come in from keyDowns instead // of keyPress, and because GetCharCode refuses to work for keyDown // i have to play games. - if (keyCode == nsIDOMUIEvent::DOM_VK_TAB) character = '\t'; + if (keyCode == nsIDOMKeyEvent::DOM_VK_TAB) character = '\t'; else aKeyEvent->GetCharCode(&character); - if (keyCode == nsIDOMUIEvent::DOM_VK_TAB && !(mFlags&eEditorPlaintextBit)) + if (keyCode == nsIDOMKeyEvent::DOM_VK_TAB && !(mFlags&eEditorPlaintextBit)) { PRBool bHandled = PR_FALSE; res = TabInTable(isShift, &bHandled); if (NS_FAILED(res)) return res; if (bHandled) return res; } - else if (keyCode == nsIDOMUIEvent::DOM_VK_RETURN) + else if (keyCode == nsIDOMKeyEvent::DOM_VK_RETURN) { nsAutoString empty; if (isShift && !(mFlags&eEditorPlaintextBit)) diff --git a/mozilla/editor/base/nsHTMLEditor.h b/mozilla/editor/base/nsHTMLEditor.h index 5a4cc9538cf..6e80bd8d30e 100644 --- a/mozilla/editor/base/nsHTMLEditor.h +++ b/mozilla/editor/base/nsHTMLEditor.h @@ -35,6 +35,8 @@ #include "TypeInState.h" #include "nsEditRules.h" +class nsIDOMKeyEvent; + /** * The HTML editor implementation.
* Use to edit HTML document represented as a DOM tree. @@ -61,7 +63,7 @@ public: /* ------------ nsIHTMLEditor methods -------------- */ - NS_IMETHOD EditorKeyPress(nsIDOMUIEvent* aKeyEvent); + NS_IMETHOD EditorKeyPress(nsIDOMKeyEvent* aKeyEvent); NS_IMETHOD TypedText(const nsString& aString, PRInt32 aAction); NS_IMETHOD GetDocumentIsEmpty(PRBool *aDocumentIsEmpty); diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index 29f695fd3ae..a668b80f867 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -28,7 +28,7 @@ #include "nsIDOMDocument.h" #include "nsIDocument.h" #include "nsIDOMEventReceiver.h" -#include "nsIDOMUIEvent.h" +#include "nsIDOMKeyEvent.h" #include "nsIDOMKeyListener.h" #include "nsIDOMMouseListener.h" #include "nsIDOMSelection.h" @@ -600,7 +600,7 @@ void nsHTMLEditor::InitRules() #pragma mark - #endif -NS_IMETHODIMP nsHTMLEditor::EditorKeyPress(nsIDOMUIEvent* aKeyEvent) +NS_IMETHODIMP nsHTMLEditor::EditorKeyPress(nsIDOMKeyEvent* aKeyEvent) { PRUint32 keyCode, character; PRBool isShift, ctrlKey, altKey, metaKey; @@ -617,17 +617,17 @@ NS_IMETHODIMP nsHTMLEditor::EditorKeyPress(nsIDOMUIEvent* aKeyEvent) // this royally blows: because tabs come in from keyDowns instead // of keyPress, and because GetCharCode refuses to work for keyDown // i have to play games. - if (keyCode == nsIDOMUIEvent::DOM_VK_TAB) character = '\t'; + if (keyCode == nsIDOMKeyEvent::DOM_VK_TAB) character = '\t'; else aKeyEvent->GetCharCode(&character); - if (keyCode == nsIDOMUIEvent::DOM_VK_TAB && !(mFlags&eEditorPlaintextBit)) + if (keyCode == nsIDOMKeyEvent::DOM_VK_TAB && !(mFlags&eEditorPlaintextBit)) { PRBool bHandled = PR_FALSE; res = TabInTable(isShift, &bHandled); if (NS_FAILED(res)) return res; if (bHandled) return res; } - else if (keyCode == nsIDOMUIEvent::DOM_VK_RETURN) + else if (keyCode == nsIDOMKeyEvent::DOM_VK_RETURN) { nsAutoString empty; if (isShift && !(mFlags&eEditorPlaintextBit)) diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.h b/mozilla/editor/libeditor/html/nsHTMLEditor.h index 5a4cc9538cf..6e80bd8d30e 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.h +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.h @@ -35,6 +35,8 @@ #include "TypeInState.h" #include "nsEditRules.h" +class nsIDOMKeyEvent; + /** * The HTML editor implementation.
* Use to edit HTML document represented as a DOM tree. @@ -61,7 +63,7 @@ public: /* ------------ nsIHTMLEditor methods -------------- */ - NS_IMETHOD EditorKeyPress(nsIDOMUIEvent* aKeyEvent); + NS_IMETHOD EditorKeyPress(nsIDOMKeyEvent* aKeyEvent); NS_IMETHOD TypedText(const nsString& aString, PRInt32 aAction); NS_IMETHOD GetDocumentIsEmpty(PRBool *aDocumentIsEmpty); diff --git a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp index 36a35a46361..d5025f83a06 100644 --- a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp +++ b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp @@ -29,7 +29,8 @@ #include "nsIEditProperty.h" #include "nsISupportsArray.h" #include "nsIStringStream.h" -#include "nsIDOMUIEvent.h" +#include "nsIDOMKeyEvent.h" +#include "nsIDOMMouseEvent.h" #include "nsIDOMNSUIEvent.h" #include "nsIPrivateTextEvent.h" #include "nsIPrivateCompositionEvent.h" @@ -125,13 +126,13 @@ nsresult nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent) { PRUint32 keyCode; - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aKeyEvent); - if (uiEvent) + nsCOMPtrkeyEvent; + keyEvent = do_QueryInterface(aKeyEvent); + if (keyEvent) { - if (NS_SUCCEEDED(uiEvent->GetKeyCode(&keyCode))) + if (NS_SUCCEEDED(keyEvent->GetKeyCode(&keyCode))) { - if (nsIDOMUIEvent::DOM_VK_TAB==keyCode) + if (nsIDOMKeyEvent::DOM_VK_TAB==keyCode) { nsCOMPtr htmlEditor = do_QueryInterface(mEditor); PRUint32 flags=0; @@ -140,7 +141,7 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent) return NS_OK; // let it be used for focus switching // else we insert the tab straight through - htmlEditor->EditorKeyPress(uiEvent); + htmlEditor->EditorKeyPress(keyEvent); ScrollSelectionIntoView(); return NS_ERROR_BASE; // "I handled the event, don't do default processing" } @@ -160,9 +161,9 @@ nsTextEditorKeyListener::KeyUp(nsIDOMEvent* aKeyEvent) nsresult nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) { - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aKeyEvent); - if (!uiEvent) + nsCOMPtrkeyEvent; + keyEvent = do_QueryInterface(aKeyEvent); + if (!keyEvent) { //non-key event passed to keydown. bad things. return NS_OK; @@ -176,7 +177,7 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) if (PR_FALSE==keyProcessed) { PRUint32 keyCode; - uiEvent->GetKeyCode(&keyCode); + keyEvent->GetKeyCode(&keyCode); nsCOMPtr htmlEditor = do_QueryInterface(mEditor); if (!htmlEditor) return NS_ERROR_NO_INTERFACE; @@ -185,23 +186,23 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) // so look for special keys using keyCode if (0 != keyCode) { - if (nsIDOMUIEvent::DOM_VK_SHIFT==keyCode - || nsIDOMUIEvent::DOM_VK_CONTROL==keyCode - || nsIDOMUIEvent::DOM_VK_ALT==keyCode) + if (nsIDOMKeyEvent::DOM_VK_SHIFT==keyCode + || nsIDOMKeyEvent::DOM_VK_CONTROL==keyCode + || nsIDOMKeyEvent::DOM_VK_ALT==keyCode) return NS_ERROR_BASE; // consumed - if (nsIDOMUIEvent::DOM_VK_BACK==keyCode) + if (nsIDOMKeyEvent::DOM_VK_BACK_SPACE==keyCode) { mEditor->DeleteSelection(nsIEditor::eDeletePrevious); ScrollSelectionIntoView(); return NS_ERROR_BASE; // consumed } - if (nsIDOMUIEvent::DOM_VK_DELETE==keyCode) + if (nsIDOMKeyEvent::DOM_VK_DELETE==keyCode) { mEditor->DeleteSelection(nsIEditor::eDeleteNext); ScrollSelectionIntoView(); return NS_ERROR_BASE; // consumed } - if (nsIDOMUIEvent::DOM_VK_TAB==keyCode) + if (nsIDOMKeyEvent::DOM_VK_TAB==keyCode) { PRUint32 flags=0; mEditor->GetFlags(&flags); @@ -209,18 +210,18 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) return NS_OK; // let it be used for focus switching // else we insert the tab straight through - htmlEditor->EditorKeyPress(uiEvent); + htmlEditor->EditorKeyPress(keyEvent); ScrollSelectionIntoView(); return NS_ERROR_BASE; // "I handled the event, don't do default processing" } - if (nsIDOMUIEvent::DOM_VK_RETURN==keyCode) + if (nsIDOMKeyEvent::DOM_VK_RETURN==keyCode) { PRUint32 flags=0; mEditor->GetFlags(&flags); if (!(flags & nsIHTMLEditor::eEditorSingleLineMask)) { //htmlEditor->InsertBreak(); - htmlEditor->EditorKeyPress(uiEvent); + htmlEditor->EditorKeyPress(keyEvent); ScrollSelectionIntoView(); return NS_ERROR_BASE; // consumed } @@ -233,13 +234,13 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) #if 0 // XXX: this must change. DOM_VK_tab must be handled here, not in keyDown - if (nsIDOMUIEvent::DOM_VK_TAB==keyCode) + if (nsIDOMKeyEvent::DOM_VK_TAB==keyCode) { return NS_OK; // ignore tabs here, they're handled in keyDown if at all } #endif - htmlEditor->EditorKeyPress(uiEvent); + htmlEditor->EditorKeyPress(keyEvent); ScrollSelectionIntoView(); } else @@ -258,18 +259,18 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr PRBool ctrlKey; PRBool isAltKey, isMetaKey, isShiftKey; - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aKeyEvent); - if (!uiEvent) { + nsCOMPtrkeyEvent; + keyEvent = do_QueryInterface(aKeyEvent); + if (!keyEvent) { //non-key event passed in. bad things. return NS_OK; } - if (NS_SUCCEEDED(uiEvent->GetCharCode(&charCode)) && - NS_SUCCEEDED(uiEvent->GetAltKey(&isAltKey)) && - NS_SUCCEEDED(uiEvent->GetMetaKey(&isMetaKey)) && - NS_SUCCEEDED(uiEvent->GetShiftKey(&isShiftKey)) && - NS_SUCCEEDED(uiEvent->GetCtrlKey(&ctrlKey)) ) + if (NS_SUCCEEDED(keyEvent->GetCharCode(&charCode)) && + NS_SUCCEEDED(keyEvent->GetAltKey(&isAltKey)) && + NS_SUCCEEDED(keyEvent->GetMetaKey(&isMetaKey)) && + NS_SUCCEEDED(keyEvent->GetShiftKey(&isShiftKey)) && + NS_SUCCEEDED(keyEvent->GetCtrlKey(&ctrlKey)) ) { #ifdef XP_MAC // hack to make Mac work for hard-coded keybindings @@ -486,9 +487,9 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent) if (!aMouseEvent) return NS_OK; // NS_OK means "we didn't process the event". Go figure. - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aMouseEvent); - if (!uiEvent) { + nsCOMPtrmouseEvent; + mouseEvent = do_QueryInterface(aMouseEvent); + if (!mouseEvent) { //non-ui event passed in. bad things. return NS_OK; } @@ -505,7 +506,7 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent) if (!doc) { return NS_OK; } PRUint16 button = 0; - uiEvent->GetButton(&button); + mouseEvent->GetButton(&button); // left button click might be a drag-start if (1==button) { @@ -586,15 +587,15 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent) { // Set the selection to the point under the mouse cursor: - nsCOMPtr mouseEvent (do_QueryInterface(aMouseEvent)); + nsCOMPtr nsuiEvent (do_QueryInterface(aMouseEvent)); - if (!mouseEvent) + if (!nsuiEvent) return NS_ERROR_BASE; // NS_ERROR_BASE means "We did process the event". nsCOMPtr parent; - if (!NS_SUCCEEDED(mouseEvent->GetRangeParent(getter_AddRefs(parent)))) + if (!NS_SUCCEEDED(nsuiEvent->GetRangeParent(getter_AddRefs(parent)))) return NS_ERROR_BASE; // NS_ERROR_BASE means "We did process the event". PRInt32 offset = 0; - if (!NS_SUCCEEDED(mouseEvent->GetRangeOffset(&offset))) + if (!NS_SUCCEEDED(nsuiEvent->GetRangeOffset(&offset))) return NS_ERROR_BASE; // NS_ERROR_BASE means "We did process the event". nsCOMPtr selection; @@ -603,8 +604,9 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent) // If the ctrl key is pressed, we'll do paste as quotation. // Would've used the alt key, but the kde wmgr treats alt-middle specially. + nsCOMPtr mouseEvent (do_QueryInterface(aMouseEvent)); PRBool ctrlKey = PR_FALSE; - uiEvent->GetCtrlKey(&ctrlKey); + mouseEvent->GetCtrlKey(&ctrlKey); if (ctrlKey) { diff --git a/mozilla/editor/public/nsIHTMLEditor.h b/mozilla/editor/public/nsIHTMLEditor.h index 2ac55a5a530..6a2208fc9a5 100644 --- a/mozilla/editor/public/nsIHTMLEditor.h +++ b/mozilla/editor/public/nsIHTMLEditor.h @@ -33,7 +33,7 @@ class nsStringArray; class nsIAtom; class nsIDOMNode; class nsIDOMElement; -class nsIDOMUIEvent; +class nsIDOMKeyEvent; class nsIHTMLEditor : public nsISupports @@ -152,7 +152,7 @@ public: * EditorKeyPress consumes a keyevent. * @param aKeyEvent key event to consume */ - NS_IMETHOD EditorKeyPress(nsIDOMUIEvent* aKeyEvent)=0; + NS_IMETHOD EditorKeyPress(nsIDOMKeyEvent* aKeyEvent)=0; /** * TypedText responds to user typing. Provides a logging bottleneck for typing. diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index fa00682063d..a4ebad5f086 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -2133,7 +2133,15 @@ nsIFrame* PresShell::GetCurrentEventFrame() { if (!mCurrentEventFrame && mCurrentEventContent) { - GetPrimaryFrameFor(mCurrentEventContent, &mCurrentEventFrame); + // Make sure the content still has a document reference. If not, + // then we assume it is no longer in the content tree and the + // frame shouldn't get an event, nor should we even assume its + // safe to try and find the frame. + nsCOMPtr doc; + nsresult result = mCurrentEventContent->GetDocument(*getter_AddRefs(doc)); + if (NS_SUCCEEDED(result) && doc) { + GetPrimaryFrameFor(mCurrentEventContent, &mCurrentEventFrame); + } } return mCurrentEventFrame; diff --git a/mozilla/layout/base/src/nsRangeList.cpp b/mozilla/layout/base/src/nsRangeList.cpp index 8659eb38cfb..8bf407dc8e1 100644 --- a/mozilla/layout/base/src/nsRangeList.cpp +++ b/mozilla/layout/base/src/nsRangeList.cpp @@ -34,7 +34,7 @@ #include "nsCOMPtr.h" #include "nsRange.h" #include "nsISupportsArray.h" -#include "nsIDOMUIEvent.h" +#include "nsIDOMKeyEvent.h" #include "nsIDOMSelectionListener.h" #include "nsIContentIterator.h" @@ -857,12 +857,12 @@ nsRangeList::HandleKeyEvent(nsIPresContext* aPresContext, nsGUIEvent *aGuiEvent) nsKeyEvent *keyEvent = (nsKeyEvent *)aGuiEvent; //this is ok. It really is a keyevent switch (keyEvent->keyCode) { - case nsIDOMUIEvent::DOM_VK_LEFT : - case nsIDOMUIEvent::DOM_VK_UP : - case nsIDOMUIEvent::DOM_VK_DOWN : - case nsIDOMUIEvent::DOM_VK_RIGHT : - case nsIDOMUIEvent::DOM_VK_HOME : - case nsIDOMUIEvent::DOM_VK_END : + case nsIDOMKeyEvent::DOM_VK_LEFT : + case nsIDOMKeyEvent::DOM_VK_UP : + case nsIDOMKeyEvent::DOM_VK_DOWN : + case nsIDOMKeyEvent::DOM_VK_RIGHT : + case nsIDOMKeyEvent::DOM_VK_HOME : + case nsIDOMKeyEvent::DOM_VK_END : break; default: return NS_ERROR_FAILURE; @@ -879,7 +879,7 @@ nsRangeList::HandleKeyEvent(nsIPresContext* aPresContext, nsGUIEvent *aGuiEvent) result = mDomSelections[SELECTION_NORMAL]->GetIsCollapsed(&isCollapsed); if (NS_FAILED(result)) return result; - if (keyEvent->keyCode == nsIDOMUIEvent::DOM_VK_UP || keyEvent->keyCode == nsIDOMUIEvent::DOM_VK_DOWN) + if (keyEvent->keyCode == nsIDOMKeyEvent::DOM_VK_UP || keyEvent->keyCode == nsIDOMKeyEvent::DOM_VK_DOWN) { desiredX= FetchDesiredX(); SetDesiredX(desiredX); @@ -887,8 +887,8 @@ nsRangeList::HandleKeyEvent(nsIPresContext* aPresContext, nsGUIEvent *aGuiEvent) if (!isCollapsed && !keyEvent->isShift) { switch (keyEvent->keyCode){ - case nsIDOMUIEvent::DOM_VK_LEFT : - case nsIDOMUIEvent::DOM_VK_UP : { + case nsIDOMKeyEvent::DOM_VK_LEFT : + case nsIDOMKeyEvent::DOM_VK_UP : { if ((mDomSelections[SELECTION_NORMAL]->GetDirection() == eDirPrevious)) { //f,a offsetused = mDomSelections[SELECTION_NORMAL]->FetchFocusOffset(); weakNodeUsed = mDomSelections[SELECTION_NORMAL]->FetchFocusNode(); @@ -900,8 +900,8 @@ nsRangeList::HandleKeyEvent(nsIPresContext* aPresContext, nsGUIEvent *aGuiEvent) result = mDomSelections[SELECTION_NORMAL]->Collapse(weakNodeUsed,offsetused); return NS_OK; } break; - case nsIDOMUIEvent::DOM_VK_RIGHT : - case nsIDOMUIEvent::DOM_VK_DOWN : { + case nsIDOMKeyEvent::DOM_VK_RIGHT : + case nsIDOMKeyEvent::DOM_VK_DOWN : { if ((mDomSelections[SELECTION_NORMAL]->GetDirection() == eDirPrevious)) { //f,a offsetused = mDomSelections[SELECTION_NORMAL]->FetchAnchorOffset(); weakNodeUsed = mDomSelections[SELECTION_NORMAL]->FetchAnchorNode(); @@ -915,7 +915,7 @@ nsRangeList::HandleKeyEvent(nsIPresContext* aPresContext, nsGUIEvent *aGuiEvent) } break; } -// if (keyEvent->keyCode == nsIDOMUIEvent::DOM_VK_UP || keyEvent->keyCode == nsIDOMUIEvent::DOM_VK_DOWN) +// if (keyEvent->keyCode == nsIDOMKeyEvent::DOM_VK_UP || keyEvent->keyCode == nsIDOMKeyEvent::DOM_VK_DOWN) // SetDesiredX(desiredX); } @@ -929,29 +929,29 @@ nsRangeList::HandleKeyEvent(nsIPresContext* aPresContext, nsGUIEvent *aGuiEvent) nsPeekOffsetStruct pos; pos.SetData(mTracker, desiredX, amount, eDirPrevious, offsetused, PR_FALSE,PR_TRUE, PR_TRUE); switch (keyEvent->keyCode){ - case nsIDOMUIEvent::DOM_VK_RIGHT : + case nsIDOMKeyEvent::DOM_VK_RIGHT : InvalidateDesiredX(); pos.mDirection = eDirNext; mHint = HINTLEFT;//stick to this line break; - case nsIDOMUIEvent::DOM_VK_LEFT : //no break + case nsIDOMKeyEvent::DOM_VK_LEFT : //no break InvalidateDesiredX(); mHint = HINTRIGHT;//stick to opposite of movement break; - case nsIDOMUIEvent::DOM_VK_DOWN : + case nsIDOMKeyEvent::DOM_VK_DOWN : pos.mAmount = eSelectLine; pos.mDirection = eDirNext;//no break here break; - case nsIDOMUIEvent::DOM_VK_UP : + case nsIDOMKeyEvent::DOM_VK_UP : pos.mAmount = eSelectLine; break; - case nsIDOMUIEvent::DOM_VK_HOME : + case nsIDOMKeyEvent::DOM_VK_HOME : InvalidateDesiredX(); pos.mAmount = eSelectBeginLine; InvalidateDesiredX(); mHint = HINTRIGHT;//stick to opposite of movement break; - case nsIDOMUIEvent::DOM_VK_END : + case nsIDOMKeyEvent::DOM_VK_END : InvalidateDesiredX(); pos.mAmount = eSelectEndLine; InvalidateDesiredX(); diff --git a/mozilla/layout/events/public/nsIEventStateManager.h b/mozilla/layout/events/public/nsIEventStateManager.h index c7e161cbb95..81c879af2e3 100644 --- a/mozilla/layout/events/public/nsIEventStateManager.h +++ b/mozilla/layout/events/public/nsIEventStateManager.h @@ -59,6 +59,7 @@ public: NS_IMETHOD GetEventTarget(nsIFrame **aFrame) = 0; NS_IMETHOD GetEventTargetContent(nsIContent** aContent) = 0; + NS_IMETHOD GetEventRelatedContent(nsIContent** aContent) = 0; NS_IMETHOD GetContentState(nsIContent *aContent, PRInt32& aState) = 0; NS_IMETHOD SetContentState(nsIContent *aContent, PRInt32 aState) = 0; diff --git a/mozilla/layout/events/public/nsIPrivateDOMEvent.h b/mozilla/layout/events/public/nsIPrivateDOMEvent.h index 9041501d2a8..1c81d8cbb02 100644 --- a/mozilla/layout/events/public/nsIPrivateDOMEvent.h +++ b/mozilla/layout/events/public/nsIPrivateDOMEvent.h @@ -33,6 +33,7 @@ class nsIPresContext; {0xbd, 0x89, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4} } class nsIDOMNode; +class nsIDOMEvent; class nsIPrivateDOMEvent : public nsISupports { diff --git a/mozilla/layout/events/src/nsDOMEvent.cpp b/mozilla/layout/events/src/nsDOMEvent.cpp index 691e72db84f..b536a5aecf3 100644 --- a/mozilla/layout/events/src/nsDOMEvent.cpp +++ b/mozilla/layout/events/src/nsDOMEvent.cpp @@ -34,6 +34,8 @@ 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(kIDOMUIEventIID, NS_IDOMUIEVENT_IID); +static NS_DEFINE_IID(kIDOMKeyEventIID, NS_IDOMKEYEVENT_IID); +static NS_DEFINE_IID(kIDOMMouseEventIID, NS_IDOMMOUSEEVENT_IID); static NS_DEFINE_IID(kIDOMNSUIEventIID, NS_IDOMNSUIEVENT_IID); static NS_DEFINE_IID(kIPrivateDOMEventIID, NS_IPRIVATEDOMEVENT_IID); static NS_DEFINE_IID(kIPrivateTextEventIID, NS_IPRIVATETEXTEVENT_IID); @@ -105,12 +107,22 @@ nsresult nsDOMEvent::QueryInterface(const nsIID& aIID, return NS_ERROR_NULL_POINTER; } if (aIID.Equals(kIDOMEventIID)) { - *aInstancePtrResult = (void*) ((nsIDOMEvent*)this); + *aInstancePtrResult = (void*) ((nsIDOMEvent*)(nsIDOMUIEvent*)(nsIDOMMouseEvent*)this); AddRef(); return NS_OK; } if (aIID.Equals(kIDOMUIEventIID)) { - *aInstancePtrResult = (void*) ((nsIDOMUIEvent*)this); + *aInstancePtrResult = (void*) ((nsIDOMUIEvent*)(nsIDOMMouseEvent*)this); + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIDOMMouseEventIID)) { + *aInstancePtrResult = (void*) ((nsIDOMMouseEvent*)this); + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIDOMKeyEventIID)) { + *aInstancePtrResult = (void*) ((nsIDOMKeyEvent*)this); AddRef(); return NS_OK; } @@ -205,13 +217,13 @@ NS_IMETHODIMP nsDOMEvent::GetEventPhase(PRUint16* aEventPhase) { if (mEvent->flags & NS_EVENT_FLAG_CAPTURE) { - *aEventPhase = CAPTURING_PHASE; + *aEventPhase = nsIDOMMouseEvent::CAPTURING_PHASE; } else if (mEvent->flags & NS_EVENT_FLAG_BUBBLE) { - *aEventPhase = BUBBLING_PHASE; + *aEventPhase = nsIDOMMouseEvent::BUBBLING_PHASE; } else if (mEvent->flags & NS_EVENT_FLAG_INIT) { - *aEventPhase = AT_TARGET; + *aEventPhase = nsIDOMMouseEvent::AT_TARGET; } else { *aEventPhase = 0; @@ -220,6 +232,18 @@ nsDOMEvent::GetEventPhase(PRUint16* aEventPhase) return NS_OK; } +NS_IMETHODIMP +nsDOMEvent::GetBubbles(PRBool* aBubbles) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDOMEvent::GetCancelable(PRBool* aCancelable) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsDOMEvent::PreventBubble() { @@ -245,6 +269,18 @@ nsDOMEvent::PreventDefault() return NS_OK; } +NS_IMETHODIMP +nsDOMEvent::GetView(nsIDOMAbstractView** aView) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDOMEvent::GetDetail(PRInt32* aDetail) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_METHOD nsDOMEvent::GetText(nsString& aText) { if (mEvent->message == NS_TEXT_EVENT) { @@ -555,6 +591,28 @@ NS_METHOD nsDOMEvent::GetClickCount(PRUint16* aClickCount) return NS_OK; } +NS_METHOD nsDOMEvent::GetRelatedNode(nsIDOMNode** aRelatedNode) +{ + nsIEventStateManager *manager; + nsIContent *relatedContent; + nsresult ret = NS_OK; + + if (NS_OK == mPresContext->GetEventStateManager(&manager)) { + manager->GetEventRelatedContent(&relatedContent); + NS_RELEASE(manager); + } + + if (relatedContent) { + ret = relatedContent->QueryInterface(kIDOMNodeIID, (void**)aRelatedNode); + NS_RELEASE(relatedContent); + } + else { + *aRelatedNode = nsnull; + } + + return ret; +} + // nsINSEventInterface NS_METHOD nsDOMEvent::GetLayerX(PRInt32* aLayerX) { @@ -694,6 +752,52 @@ NS_METHOD nsDOMEvent::SetCancelBubble(PRBool aCancelBubble) return NS_OK; } +NS_METHOD nsDOMEvent::GetIsChar(PRBool* aIsChar) +{ + if (!mEvent) { + *aIsChar = PR_FALSE; + return NS_OK; + } + if (mEvent->eventStructType == NS_KEY_EVENT) { + *aIsChar = ((nsKeyEvent*)mEvent)->isChar; + return NS_OK; + } + if (mEvent->eventStructType == NS_TEXT_EVENT) { + *aIsChar = ((nsTextEvent*)mEvent)->isChar; + return NS_OK; + } + + *aIsChar = PR_FALSE; + return NS_OK; +} + +//XXX The following four methods are for custom event dispatch inside the DOM. +//They will be implemented post-beta +NS_IMETHODIMP +nsDOMEvent::InitEvent(const nsString& aEventTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDOMEvent::InitUIEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, nsIDOMAbstractView* aViewArg, PRInt32 aDetailArg) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDOMEvent::InitMouseEvent(const nsString& aTypeArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRInt32 aScreenXArg, PRInt32 aScreenYArg, PRInt32 aClientXArg, PRInt32 aClientYArg, PRUint16 aButtonArg, PRUint16 aDetailArg) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDOMEvent::InitKeyEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRUint32 aKeyCodeArg, PRUint32 aCharCodeArg, nsIDOMAbstractView* aViewArg) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + NS_METHOD nsDOMEvent::DuplicatePrivateData() { //XXX Write me! diff --git a/mozilla/layout/events/src/nsDOMEvent.h b/mozilla/layout/events/src/nsDOMEvent.h index 1be4fd111da..7d3219910c1 100644 --- a/mozilla/layout/events/src/nsDOMEvent.h +++ b/mozilla/layout/events/src/nsDOMEvent.h @@ -19,20 +19,27 @@ #ifndef nsDOMEvent_h__ #define nsDOMEvent_h__ -#include "nsIDOMUIEvent.h" +#include "nsIDOMKeyEvent.h" +#include "nsIDOMMouseEvent.h" #include "nsIDOMNSUIEvent.h" #include "nsISupports.h" #include "nsIPrivateDOMEvent.h" #include "nsIPrivateCompositionEvent.h" #include "nsIPrivateTextEvent.h" #include "nsIPrivateTextRange.h" +#include "nsIDOMEvent.h" #include "nsIPresContext.h" #include "nsPoint.h" #include "nsGUIEvent.h" class nsIContent; -class nsDOMEvent : public nsIDOMUIEvent, public nsIDOMNSUIEvent, public nsIPrivateDOMEvent, public nsIPrivateTextEvent, public nsIPrivateCompositionEvent { +class nsDOMEvent : public nsIDOMKeyEvent, + public nsIDOMMouseEvent, + public nsIDOMNSUIEvent, + public nsIPrivateDOMEvent, + public nsIPrivateTextEvent, + public nsIPrivateCompositionEvent { public: // Note: this enum must be kept in sync with mEventNames in nsDOMEvent.cpp @@ -77,62 +84,51 @@ public: NS_DECL_ISUPPORTS - // nsIDOMEventInterface + // nsIDOMEvent Interface NS_IMETHOD GetType(nsString& aType); - NS_IMETHOD GetTarget(nsIDOMNode** aTarget); - NS_IMETHOD GetCurrentNode(nsIDOMNode** aCurrentNode); - NS_IMETHOD GetEventPhase(PRUint16* aEventPhase); - + NS_IMETHOD GetBubbles(PRBool* aBubbles); + NS_IMETHOD GetCancelable(PRBool* aCancelable); NS_IMETHOD PreventBubble(); - NS_IMETHOD PreventCapture(); - NS_IMETHOD PreventDefault(); + NS_IMETHOD InitEvent(const nsString& aEventTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg); + // nsIDOMUIEvent Interface + NS_IMETHOD GetView(nsIDOMAbstractView** aView); + NS_IMETHOD GetDetail(PRInt32* aDetail); + NS_IMETHOD InitUIEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, nsIDOMAbstractView* aViewArg, PRInt32 aDetailArg); + + // nsIDOMMouseEvent Interface and nsIDOMKeyEvent Interface 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(PRUint16* aButton); - NS_IMETHOD GetClickCount(PRUint16* aClickCount); + NS_IMETHOD GetRelatedNode(nsIDOMNode** aRelatedNode); + NS_IMETHOD GetCharCode(PRUint32* aCharCode); + NS_IMETHOD GetKeyCode(PRUint32* aKeyCode); + NS_IMETHOD InitMouseEvent(const nsString& aTypeArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRInt32 aScreenXArg, PRInt32 aScreenYArg, PRInt32 aClientXArg, PRInt32 aClientYArg, PRUint16 aButtonArg, PRUint16 aDetailArg); + NS_IMETHOD InitKeyEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRUint32 aKeyCodeArg, PRUint32 aCharCodeArg, nsIDOMAbstractView* aViewArg); // nsIDOMNSUIEvent interface NS_IMETHOD GetLayerX(PRInt32* aLayerX); - NS_IMETHOD GetLayerY(PRInt32* aLayerY); - NS_IMETHOD GetPageX(PRInt32* aClientX); - NS_IMETHOD GetPageY(PRInt32* aClientY); - NS_IMETHOD GetWhich(PRUint32* aKeyCode); - NS_IMETHOD GetRangeParent(nsIDOMNode** aRangeParent); - NS_IMETHOD GetRangeOffset(PRInt32* aRangeOffset); - NS_IMETHOD GetCancelBubble(PRBool* aCancelBubble); NS_IMETHOD SetCancelBubble(PRBool aCancelBubble); + NS_IMETHOD GetIsChar(PRBool* aIsChar); // nsIPrivateDOMEvent interface NS_IMETHOD DuplicatePrivateData(); diff --git a/mozilla/layout/events/src/nsEventListenerManager.h b/mozilla/layout/events/src/nsEventListenerManager.h index 56c5bf51eb6..44c23e992f2 100644 --- a/mozilla/layout/events/src/nsEventListenerManager.h +++ b/mozilla/layout/events/src/nsEventListenerManager.h @@ -167,11 +167,12 @@ protected: #define NS_EVENT_BITS_LOAD_ERROR 0x08 //nsIDOMMenuListener -#define NS_EVENT_BITS_MENU_CREATE 0x00 -#define NS_EVENT_BITS_MENU_DESTROY 0x01 -#define NS_EVENT_BITS_MENU_ACTION 0x02 -#define NS_EVENT_BITS_XUL_BROADCAST 0x04 -#define NS_EVENT_BITS_XUL_COMMAND_UPDATE 0x08 +#define NS_EVENT_BITS_MENU_NONE 0x00 +#define NS_EVENT_BITS_MENU_CREATE 0x01 +#define NS_EVENT_BITS_MENU_DESTROY 0x02 +#define NS_EVENT_BITS_MENU_ACTION 0x04 +#define NS_EVENT_BITS_XUL_BROADCAST 0x08 +#define NS_EVENT_BITS_XUL_COMMAND_UPDATE 0x10 //nsIDOMDragListener #define NS_EVENT_BITS_DRAG_NONE 0x00 diff --git a/mozilla/layout/events/src/nsEventStateManager.cpp b/mozilla/layout/events/src/nsEventStateManager.cpp index eef70b3b90e..1bdd210e31b 100644 --- a/mozilla/layout/events/src/nsEventStateManager.cpp +++ b/mozilla/layout/events/src/nsEventStateManager.cpp @@ -63,6 +63,7 @@ nsEventStateManager::nsEventStateManager() mLastDragOverFrame = nsnull; mCurrentTarget = nsnull; mCurrentTargetContent = nsnull; + mCurrentRelatedContent = nsnull; mLastLeftMouseDownContent = nsnull; mLastMiddleMouseDownContent = nsnull; mLastRightMouseDownContent = nsnull; @@ -89,6 +90,7 @@ nsEventStateManager::nsEventStateManager() nsEventStateManager::~nsEventStateManager() { NS_IF_RELEASE(mCurrentTargetContent); + NS_IF_RELEASE(mCurrentRelatedContent); NS_IF_RELEASE(mLastLeftMouseDownContent); NS_IF_RELEASE(mLastMiddleMouseDownContent); @@ -551,6 +553,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext, } } } + return ret; } @@ -659,6 +662,9 @@ nsEventStateManager::UpdateCursor(nsIPresContext& aPresContext, nsPoint& aPoint, void nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIEvent* aEvent) { + //Hold onto old target content through the event and reset after. + nsCOMPtr targetBeforeEvent = mCurrentTargetContent; + switch(aEvent->message) { case NS_MOUSE_MOVE: { @@ -683,6 +689,11 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE //The frame has change but the content may not have. Check before dispatching to content mLastMouseOverFrame->GetContent(getter_AddRefs(lastContent)); + mCurrentTargetContent = lastContent; + NS_IF_ADDREF(mCurrentTargetContent); + mCurrentRelatedContent = targetContent; + NS_IF_ADDREF(mCurrentRelatedContent); + if (lastContent != targetContent) { //XXX This event should still go somewhere!! if (nsnull != lastContent) { @@ -695,6 +706,9 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE //XXX Get the new frame mLastMouseOverFrame->HandleEvent(aPresContext, &event, status); } + + NS_IF_RELEASE(mCurrentTargetContent); + NS_IF_RELEASE(mCurrentRelatedContent); } //fire mouseover @@ -707,6 +721,11 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE event.point = aEvent->point; event.refPoint = aEvent->refPoint; + mCurrentTargetContent = targetContent; + NS_IF_ADDREF(mCurrentTargetContent); + mCurrentRelatedContent = lastContent; + NS_IF_ADDREF(mCurrentRelatedContent); + //The frame has change but the content may not have. Check before dispatching to content if (lastContent != targetContent) { //XXX This event should still go somewhere!! @@ -725,14 +744,15 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE mCurrentTarget->HandleEvent(aPresContext, &event, status); } + NS_IF_RELEASE(mCurrentTargetContent); + NS_IF_RELEASE(mCurrentRelatedContent); mLastMouseOverFrame = mCurrentTarget; } } break; case NS_MOUSE_EXIT: { - //This is actually the window mouse exit event. Such a think does not - // yet exist but it will need to eventually. + //This is actually the window mouse exit event. if (nsnull != mLastMouseOverFrame) { //fire mouseout nsEventStatus status = nsEventStatus_eIgnore; @@ -747,6 +767,10 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE nsCOMPtr lastContent; mLastMouseOverFrame->GetContent(getter_AddRefs(lastContent)); + mCurrentTargetContent = lastContent; + NS_IF_ADDREF(mCurrentTargetContent); + mCurrentRelatedContent = nsnull; + if (lastContent) { lastContent->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status); @@ -762,16 +786,23 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE mLastMouseOverFrame->HandleEvent(aPresContext, &event, status); mLastMouseOverFrame = nsnull; } + + NS_IF_RELEASE(mCurrentTargetContent); } } break; } - + + //reset mCurretTargetContent to what it was + mCurrentTargetContent = targetBeforeEvent; } void nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext& aPresContext, nsGUIEvent* aEvent) { + //Hold onto old target content through the event and reset after. + nsCOMPtr targetBeforeEvent = mCurrentTargetContent; + switch(aEvent->message) { case NS_DRAGDROP_OVER: { @@ -795,6 +826,11 @@ nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext& aPresContext, nsG //The frame has change but the content may not have. Check before dispatching to content mLastDragOverFrame->GetContent(getter_AddRefs(lastContent)); + mCurrentTargetContent = lastContent; + NS_IF_ADDREF(mCurrentTargetContent); + mCurrentRelatedContent = targetContent; + NS_IF_ADDREF(mCurrentRelatedContent); + if ( lastContent != targetContent ) { //XXX This event should still go somewhere!! if (lastContent) @@ -806,8 +842,13 @@ nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext& aPresContext, nsG } // Finally dispatch exit to the frame - if ( mLastDragOverFrame ) + if ( mLastDragOverFrame ) { mLastDragOverFrame->HandleEvent(aPresContext, &event, status); + + NS_IF_RELEASE(mCurrentTargetContent); + NS_IF_RELEASE(mCurrentRelatedContent); + + } } //fire drag enter @@ -820,6 +861,11 @@ nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext& aPresContext, nsG event.point = aEvent->point; event.refPoint = aEvent->refPoint; + mCurrentTargetContent = targetContent; + NS_IF_ADDREF(mCurrentTargetContent); + mCurrentRelatedContent = lastContent; + NS_IF_ADDREF(mCurrentRelatedContent); + //The frame has change but the content may not have. Check before dispatching to content if ( lastContent != targetContent ) { //XXX This event should still go somewhere!! @@ -837,6 +883,8 @@ nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext& aPresContext, nsG mCurrentTarget->HandleEvent(aPresContext, &event, status); } + NS_IF_RELEASE(mCurrentTargetContent); + NS_IF_RELEASE(mCurrentRelatedContent); mLastDragOverFrame = mCurrentTarget; } } @@ -845,8 +893,7 @@ nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext& aPresContext, nsG case NS_DRAGDROP_DROP: case NS_DRAGDROP_EXIT: { - //This is actually the window mouse exit event. Such a think does not - // yet exist but it will need to eventually. + //This is actually the window mouse exit event. if ( mLastDragOverFrame ) { // fire mouseout @@ -862,6 +909,11 @@ nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext& aPresContext, nsG // dispatch to content via DOM nsCOMPtr lastContent; mLastDragOverFrame->GetContent(getter_AddRefs(lastContent)); + + mCurrentTargetContent = lastContent; + NS_IF_ADDREF(mCurrentTargetContent); + mCurrentRelatedContent = nsnull; + if ( lastContent ) { lastContent->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status); if ( status != nsEventStatus_eConsumeNoDefault ) @@ -874,11 +926,15 @@ nsEventStateManager::GenerateDragDropEnterExit(nsIPresContext& aPresContext, nsG mLastDragOverFrame->HandleEvent(aPresContext, &event, status); mLastDragOverFrame = nsnull; } - } + + NS_IF_RELEASE(mCurrentTargetContent); + } } break; } - + + //reset mCurretTargetContent to what it was + mCurrentTargetContent = targetBeforeEvent; } NS_IMETHODIMP @@ -1325,6 +1381,19 @@ nsEventStateManager::GetEventTargetContent(nsIContent** aContent) return NS_OK; } +NS_IMETHODIMP +nsEventStateManager::GetEventRelatedContent(nsIContent** aContent) +{ + if (mCurrentRelatedContent) { + *aContent = mCurrentRelatedContent; + NS_IF_ADDREF(*aContent); + return NS_OK; + } + + *aContent = nsnull; + return NS_OK; +} + NS_IMETHODIMP nsEventStateManager::GetContentState(nsIContent *aContent, PRInt32& aState) { diff --git a/mozilla/layout/events/src/nsEventStateManager.h b/mozilla/layout/events/src/nsEventStateManager.h index 899a9f64634..de977f38deb 100644 --- a/mozilla/layout/events/src/nsEventStateManager.h +++ b/mozilla/layout/events/src/nsEventStateManager.h @@ -53,6 +53,7 @@ public: NS_IMETHOD GetEventTarget(nsIFrame **aFrame); NS_IMETHOD GetEventTargetContent(nsIContent** aContent); + NS_IMETHOD GetEventRelatedContent(nsIContent** aContent); NS_IMETHOD GetContentState(nsIContent *aContent, PRInt32& aState); NS_IMETHOD SetContentState(nsIContent *aContent, PRInt32 aState); @@ -84,6 +85,7 @@ protected: //Any frames here must be checked for validity in ClearFrameRefs nsIFrame* mCurrentTarget; nsIContent* mCurrentTargetContent; + nsIContent* mCurrentRelatedContent; nsIFrame* mLastMouseOverFrame; nsIFrame* mLastDragOverFrame; diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index f1e72136194..5c1da2215a2 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -40,7 +40,8 @@ #include "nsHTMLParts.h" #include "nsIDOMEventReceiver.h" #include "nsIEventStateManager.h" -#include "nsIDOMUIEvent.h" +#include "nsIDOMKeyEvent.h" +#include "nsIDOMMouseEvent.h" #include "nsIPrivateDOMEvent.h" #include "nsIStatefulFrame.h" #include "nsISupportsArray.h" @@ -823,11 +824,11 @@ nsListControlFrame::HandleListSelection(nsIDOMEvent* aEvent) PRBool multipleSelections = PR_FALSE; GetMultiple(&multipleSelections); if (multipleSelections) { - nsCOMPtr uiEvent = do_QueryInterface(aEvent); + nsCOMPtr mouseEvent = do_QueryInterface(aEvent); PRBool isShift; PRBool isControl; - uiEvent->GetCtrlKey(&isControl); - uiEvent->GetShiftKey(&isShift); + mouseEvent->GetCtrlKey(&isControl); + mouseEvent->GetShiftKey(&isShift); MultipleSelection(isShift, isControl); } else { SingleSelection(); @@ -2352,11 +2353,11 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent) stateManager->GetEventTarget(&frame); nsCOMPtr listFrame(do_QueryInterface(frame)); if (listFrame) { - nsCOMPtr uiEvent(do_QueryInterface(aMouseEvent)); + nsCOMPtr mouseEvent(do_QueryInterface(aMouseEvent)); PRInt32 scrX; PRInt32 scrY; - uiEvent->GetScreenX(&scrX); - uiEvent->GetScreenY(&scrY); + mouseEvent->GetScreenX(&scrX); + mouseEvent->GetScreenY(&scrY); nsRect rect; mComboboxFrame->GetAbsoluteRect(&rect); if (!rect.Contains(scrX, scrY)) { @@ -2425,12 +2426,12 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent) nsresult nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent) { - nsCOMPtr uiEvent = do_QueryInterface(aKeyEvent); - if (uiEvent) { + nsCOMPtr keyEvent = do_QueryInterface(aKeyEvent); + if (keyEvent) { PRUint32 code; //uiEvent->GetCharCode(&code); //printf("%c %d ", code, code); - uiEvent->GetKeyCode(&code); + keyEvent->GetKeyCode(&code); //printf("%c %d\n", code, code); nsresult rv = NS_ERROR_FAILURE; @@ -2443,7 +2444,7 @@ nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent) if (numOptions == 0) { rv = NS_OK; } else { - if (code == nsIDOMUIEvent::DOM_VK_UP) { + if (code == nsIDOMKeyEvent::DOM_VK_UP) { printf("DOM_VK_UP mSelectedIndex: %d ", mSelectedIndex); if (mSelectedIndex > 0) { mOldSelectedIndex = mSelectedIndex; @@ -2454,7 +2455,7 @@ nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent) } } printf(" After: %d\n", mSelectedIndex); - } if (code == nsIDOMUIEvent::DOM_VK_DOWN) { + } if (code == nsIDOMKeyEvent::DOM_VK_DOWN) { printf("DOM_VK_DOWN mSelectedIndex: %d ", mSelectedIndex); if ((mSelectedIndex+1) < (PRInt32)numOptions) { mOldSelectedIndex = mSelectedIndex; @@ -2465,13 +2466,13 @@ nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent) } } printf(" After: %d\n", mSelectedIndex); - } if (code == nsIDOMUIEvent::DOM_VK_RETURN) { + } if (code == nsIDOMKeyEvent::DOM_VK_RETURN) { if (IsInDropDownMode() == PR_TRUE && mComboboxFrame) { mComboboxFrame->ListWasSelected(mPresContext); } else { UpdateSelection(PR_TRUE, PR_FALSE, mContent); } - } if (code == nsIDOMUIEvent::DOM_VK_ESCAPE) { + } if (code == nsIDOMKeyEvent::DOM_VK_ESCAPE) { if (IsInDropDownMode() == PR_TRUE && mComboboxFrame) { ResetSelectedItem(); mComboboxFrame->ListWasSelected(mPresContext); diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index fa00682063d..a4ebad5f086 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -2133,7 +2133,15 @@ nsIFrame* PresShell::GetCurrentEventFrame() { if (!mCurrentEventFrame && mCurrentEventContent) { - GetPrimaryFrameFor(mCurrentEventContent, &mCurrentEventFrame); + // Make sure the content still has a document reference. If not, + // then we assume it is no longer in the content tree and the + // frame shouldn't get an event, nor should we even assume its + // safe to try and find the frame. + nsCOMPtr doc; + nsresult result = mCurrentEventContent->GetDocument(*getter_AddRefs(doc)); + if (NS_SUCCEEDED(result) && doc) { + GetPrimaryFrameFor(mCurrentEventContent, &mCurrentEventFrame); + } } return mCurrentEventFrame; diff --git a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp index bc2e2f6a1df..69bcb9e0150 100644 --- a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp @@ -68,7 +68,6 @@ #include "nsIDocument.h" #include "nsIDOMDocument.h" #include "nsIDOMEventReceiver.h" -#include "nsIDOMUIEvent.h" #include "nsIPresShell.h" #include "nsIEventStateManager.h" #include "nsStyleUtil.h" @@ -2697,9 +2696,9 @@ nsEnderEventListener::HandleEvent(nsIDOMEvent* aEvent) nsresult nsEnderEventListener::KeyDown(nsIDOMEvent* aKeyEvent) { - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aKeyEvent); - if (!uiEvent) { //non-key event passed to keydown. bad things. + nsCOMPtrkeyEvent; + keyEvent = do_QueryInterface(aKeyEvent); + if (!keyEvent) { //non-key event passed to keydown. bad things. return NS_OK; } @@ -2714,12 +2713,12 @@ nsEnderEventListener::KeyDown(nsIDOMEvent* aKeyEvent) event.widget = nsnull; event.message = NS_KEY_DOWN; event.flags = NS_EVENT_FLAG_INIT; - uiEvent->GetKeyCode(&(event.keyCode)); + keyEvent->GetKeyCode(&(event.keyCode)); event.charCode = 0; - uiEvent->GetShiftKey(&(event.isShift)); - uiEvent->GetCtrlKey(&(event.isControl)); - uiEvent->GetAltKey(&(event.isAlt)); - uiEvent->GetMetaKey(&(event.isMeta)); + keyEvent->GetShiftKey(&(event.isShift)); + keyEvent->GetCtrlKey(&(event.isControl)); + keyEvent->GetAltKey(&(event.isAlt)); + keyEvent->GetMetaKey(&(event.isMeta)); nsIEventStateManager *manager=nsnull; result = mContext->GetEventStateManager(&manager); @@ -2749,9 +2748,9 @@ nsEnderEventListener::KeyDown(nsIDOMEvent* aKeyEvent) nsresult nsEnderEventListener::KeyUp(nsIDOMEvent* aKeyEvent) { - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aKeyEvent); - if (!uiEvent) { //non-key event passed to keydown. bad things. + nsCOMPtrkeyEvent; + keyEvent = do_QueryInterface(aKeyEvent); + if (!keyEvent) { //non-key event passed to keydown. bad things. return NS_OK; } @@ -2766,12 +2765,12 @@ nsEnderEventListener::KeyUp(nsIDOMEvent* aKeyEvent) event.widget = nsnull; event.message = NS_KEY_UP; event.flags = NS_EVENT_FLAG_INIT; - uiEvent->GetKeyCode(&(event.keyCode)); + keyEvent->GetKeyCode(&(event.keyCode)); event.charCode = 0; - uiEvent->GetShiftKey(&(event.isShift)); - uiEvent->GetCtrlKey(&(event.isControl)); - uiEvent->GetAltKey(&(event.isAlt)); - uiEvent->GetMetaKey(&(event.isMeta)); + keyEvent->GetShiftKey(&(event.isShift)); + keyEvent->GetCtrlKey(&(event.isControl)); + keyEvent->GetAltKey(&(event.isAlt)); + keyEvent->GetMetaKey(&(event.isMeta)); nsIEventStateManager *manager=nsnull; result = mContext->GetEventStateManager(&manager); @@ -2801,9 +2800,9 @@ nsEnderEventListener::KeyUp(nsIDOMEvent* aKeyEvent) nsresult nsEnderEventListener::KeyPress(nsIDOMEvent* aKeyEvent) { - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aKeyEvent); - if (!uiEvent) { //non-key event passed to keydown. bad things. + nsCOMPtrkeyEvent; + keyEvent = do_QueryInterface(aKeyEvent); + if (!keyEvent) { //non-key event passed to keydown. bad things. return NS_OK; } @@ -2818,12 +2817,12 @@ nsEnderEventListener::KeyPress(nsIDOMEvent* aKeyEvent) event.widget = nsnull; event.message = NS_KEY_PRESS; event.flags = NS_EVENT_FLAG_INIT; - uiEvent->GetKeyCode(&(event.keyCode)); - uiEvent->GetCharCode(&(event.charCode)); - uiEvent->GetShiftKey(&(event.isShift)); - uiEvent->GetCtrlKey(&(event.isControl)); - uiEvent->GetAltKey(&(event.isAlt)); - uiEvent->GetMetaKey(&(event.isMeta)); + keyEvent->GetKeyCode(&(event.keyCode)); + keyEvent->GetCharCode(&(event.charCode)); + keyEvent->GetShiftKey(&(event.isShift)); + keyEvent->GetCtrlKey(&(event.isControl)); + keyEvent->GetAltKey(&(event.isAlt)); + keyEvent->GetMetaKey(&(event.isMeta)); nsIEventStateManager *manager=nsnull; result = mContext->GetEventStateManager(&manager); @@ -2867,7 +2866,7 @@ void GetWidgetForView(nsIView *aView, nsIWidget *&aWidget) } nsresult -nsEnderEventListener::DispatchMouseEvent(nsIDOMUIEvent *aEvent, PRInt32 aEventType) +nsEnderEventListener::DispatchMouseEvent(nsIDOMMouseEvent *aEvent, PRInt32 aEventType) { nsresult result = NS_OK; if (aEvent) @@ -2923,9 +2922,9 @@ nsEnderEventListener::DispatchMouseEvent(nsIDOMUIEvent *aEvent, PRInt32 aEventTy nsresult nsEnderEventListener::MouseDown(nsIDOMEvent* aEvent) { - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aEvent); - if (!uiEvent) { //non-key event passed in. bad things. + nsCOMPtrmouseEvent; + mouseEvent = do_QueryInterface(aEvent); + if (!mouseEvent) { //non-key event passed in. bad things. return NS_OK; } @@ -2934,7 +2933,7 @@ nsEnderEventListener::MouseDown(nsIDOMEvent* aEvent) if (mContent && mContext && mView) { PRUint16 button; - uiEvent->GetButton(&button); + mouseEvent->GetButton(&button); PRInt32 eventType; switch(button) { @@ -2951,7 +2950,7 @@ nsEnderEventListener::MouseDown(nsIDOMEvent* aEvent) NS_ASSERTION(0, "bad button type"); return NS_OK; } - result = DispatchMouseEvent(uiEvent, eventType); + result = DispatchMouseEvent(mouseEvent, eventType); } return result; } @@ -2959,9 +2958,9 @@ nsEnderEventListener::MouseDown(nsIDOMEvent* aEvent) nsresult nsEnderEventListener::MouseUp(nsIDOMEvent* aEvent) { - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aEvent); - if (!uiEvent) { //non-key event passed in. bad things. + nsCOMPtrmouseEvent; + mouseEvent = do_QueryInterface(aEvent); + if (!mouseEvent) { //non-key event passed in. bad things. return NS_OK; } @@ -2970,7 +2969,7 @@ nsEnderEventListener::MouseUp(nsIDOMEvent* aEvent) if (mContent && mContext && mView) { PRUint16 button; - uiEvent->GetButton(&button); + mouseEvent->GetButton(&button); PRInt32 eventType; switch(button) { @@ -2987,7 +2986,7 @@ nsEnderEventListener::MouseUp(nsIDOMEvent* aEvent) NS_ASSERTION(0, "bad button type"); return NS_OK; } - result = DispatchMouseEvent(uiEvent, eventType); + result = DispatchMouseEvent(mouseEvent, eventType); } return result; } @@ -2995,9 +2994,9 @@ nsEnderEventListener::MouseUp(nsIDOMEvent* aEvent) nsresult nsEnderEventListener::MouseClick(nsIDOMEvent* aEvent) { - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aEvent); - if (!uiEvent) { //non-key event passed in. bad things. + nsCOMPtrmouseEvent; + mouseEvent = do_QueryInterface(aEvent); + if (!mouseEvent) { //non-key event passed in. bad things. return NS_OK; } @@ -3007,7 +3006,7 @@ nsEnderEventListener::MouseClick(nsIDOMEvent* aEvent) { // Dispatch the event PRUint16 button; - uiEvent->GetButton(&button); + mouseEvent->GetButton(&button); PRInt32 eventType; switch(button) { @@ -3024,7 +3023,7 @@ nsEnderEventListener::MouseClick(nsIDOMEvent* aEvent) NS_ASSERTION(0, "bad button type"); return NS_OK; } - result = DispatchMouseEvent(uiEvent, eventType); + result = DispatchMouseEvent(mouseEvent, eventType); } return result; } @@ -3032,9 +3031,9 @@ nsEnderEventListener::MouseClick(nsIDOMEvent* aEvent) nsresult nsEnderEventListener::MouseDblClick(nsIDOMEvent* aEvent) { - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aEvent); - if (!uiEvent) { //non-key event passed in. bad things. + nsCOMPtrmouseEvent; + mouseEvent = do_QueryInterface(aEvent); + if (!mouseEvent) { //non-key event passed in. bad things. return NS_OK; } @@ -3044,7 +3043,7 @@ nsEnderEventListener::MouseDblClick(nsIDOMEvent* aEvent) { // Dispatch the event PRUint16 button; - uiEvent->GetButton(&button); + mouseEvent->GetButton(&button); PRInt32 eventType; switch(button) { @@ -3061,7 +3060,7 @@ nsEnderEventListener::MouseDblClick(nsIDOMEvent* aEvent) NS_ASSERTION(0, "bad button type"); return NS_OK; } - result = DispatchMouseEvent(uiEvent, eventType); + result = DispatchMouseEvent(mouseEvent, eventType); } return result; @@ -3070,9 +3069,9 @@ nsEnderEventListener::MouseDblClick(nsIDOMEvent* aEvent) nsresult nsEnderEventListener::MouseOver(nsIDOMEvent* aEvent) { - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aEvent); - if (!uiEvent) { //non-key event passed in. bad things. + nsCOMPtrmouseEvent; + mouseEvent = do_QueryInterface(aEvent); + if (!mouseEvent) { //non-key event passed in. bad things. return NS_OK; } @@ -3081,7 +3080,7 @@ nsEnderEventListener::MouseOver(nsIDOMEvent* aEvent) if (mContent && mContext && mView) { // XXX: Need to synthesize MouseEnter here - result = DispatchMouseEvent(uiEvent, NS_MOUSE_MOVE); + result = DispatchMouseEvent(mouseEvent, NS_MOUSE_MOVE); } return result; @@ -3090,9 +3089,9 @@ nsEnderEventListener::MouseOver(nsIDOMEvent* aEvent) nsresult nsEnderEventListener::MouseOut(nsIDOMEvent* aEvent) { - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aEvent); - if (!uiEvent) { //non-key event passed in. bad things. + nsCOMPtrmouseEvent; + mouseEvent = do_QueryInterface(aEvent); + if (!mouseEvent) { //non-key event passed in. bad things. return NS_OK; } @@ -3100,7 +3099,7 @@ nsEnderEventListener::MouseOut(nsIDOMEvent* aEvent) if (mContent && mContext && mView) { - result = DispatchMouseEvent(uiEvent, NS_MOUSE_EXIT); + result = DispatchMouseEvent(mouseEvent, NS_MOUSE_EXIT); } return result; diff --git a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.h b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.h index 1d3fd157403..33ced2d1f43 100644 --- a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.h +++ b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.h @@ -33,8 +33,9 @@ #include "nsIDOMDocument.h" #include "nsIPresContext.h" #include "nsIContent.h" +#include "nsIDOMMouseEvent.h" +#include "nsIDOMKeyEvent.h" #include "nsITextContent.h" -#include "nsIDOMUIEvent.h" #include "nsHTMLValue.h" class nsIFrame; @@ -270,7 +271,7 @@ protected: nsEnderEventListener(); /** mouse event dispatch helper */ - nsresult DispatchMouseEvent(nsIDOMUIEvent *aEvent, PRInt32 aEventType); + nsresult DispatchMouseEvent(nsIDOMMouseEvent *aEvent, PRInt32 aEventType); protected: diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.cpp b/mozilla/layout/html/forms/src/nsListControlFrame.cpp index f1e72136194..5c1da2215a2 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -40,7 +40,8 @@ #include "nsHTMLParts.h" #include "nsIDOMEventReceiver.h" #include "nsIEventStateManager.h" -#include "nsIDOMUIEvent.h" +#include "nsIDOMKeyEvent.h" +#include "nsIDOMMouseEvent.h" #include "nsIPrivateDOMEvent.h" #include "nsIStatefulFrame.h" #include "nsISupportsArray.h" @@ -823,11 +824,11 @@ nsListControlFrame::HandleListSelection(nsIDOMEvent* aEvent) PRBool multipleSelections = PR_FALSE; GetMultiple(&multipleSelections); if (multipleSelections) { - nsCOMPtr uiEvent = do_QueryInterface(aEvent); + nsCOMPtr mouseEvent = do_QueryInterface(aEvent); PRBool isShift; PRBool isControl; - uiEvent->GetCtrlKey(&isControl); - uiEvent->GetShiftKey(&isShift); + mouseEvent->GetCtrlKey(&isControl); + mouseEvent->GetShiftKey(&isShift); MultipleSelection(isShift, isControl); } else { SingleSelection(); @@ -2352,11 +2353,11 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent) stateManager->GetEventTarget(&frame); nsCOMPtr listFrame(do_QueryInterface(frame)); if (listFrame) { - nsCOMPtr uiEvent(do_QueryInterface(aMouseEvent)); + nsCOMPtr mouseEvent(do_QueryInterface(aMouseEvent)); PRInt32 scrX; PRInt32 scrY; - uiEvent->GetScreenX(&scrX); - uiEvent->GetScreenY(&scrY); + mouseEvent->GetScreenX(&scrX); + mouseEvent->GetScreenY(&scrY); nsRect rect; mComboboxFrame->GetAbsoluteRect(&rect); if (!rect.Contains(scrX, scrY)) { @@ -2425,12 +2426,12 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent) nsresult nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent) { - nsCOMPtr uiEvent = do_QueryInterface(aKeyEvent); - if (uiEvent) { + nsCOMPtr keyEvent = do_QueryInterface(aKeyEvent); + if (keyEvent) { PRUint32 code; //uiEvent->GetCharCode(&code); //printf("%c %d ", code, code); - uiEvent->GetKeyCode(&code); + keyEvent->GetKeyCode(&code); //printf("%c %d\n", code, code); nsresult rv = NS_ERROR_FAILURE; @@ -2443,7 +2444,7 @@ nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent) if (numOptions == 0) { rv = NS_OK; } else { - if (code == nsIDOMUIEvent::DOM_VK_UP) { + if (code == nsIDOMKeyEvent::DOM_VK_UP) { printf("DOM_VK_UP mSelectedIndex: %d ", mSelectedIndex); if (mSelectedIndex > 0) { mOldSelectedIndex = mSelectedIndex; @@ -2454,7 +2455,7 @@ nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent) } } printf(" After: %d\n", mSelectedIndex); - } if (code == nsIDOMUIEvent::DOM_VK_DOWN) { + } if (code == nsIDOMKeyEvent::DOM_VK_DOWN) { printf("DOM_VK_DOWN mSelectedIndex: %d ", mSelectedIndex); if ((mSelectedIndex+1) < (PRInt32)numOptions) { mOldSelectedIndex = mSelectedIndex; @@ -2465,13 +2466,13 @@ nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent) } } printf(" After: %d\n", mSelectedIndex); - } if (code == nsIDOMUIEvent::DOM_VK_RETURN) { + } if (code == nsIDOMKeyEvent::DOM_VK_RETURN) { if (IsInDropDownMode() == PR_TRUE && mComboboxFrame) { mComboboxFrame->ListWasSelected(mPresContext); } else { UpdateSelection(PR_TRUE, PR_FALSE, mContent); } - } if (code == nsIDOMUIEvent::DOM_VK_ESCAPE) { + } if (code == nsIDOMKeyEvent::DOM_VK_ESCAPE) { if (IsInDropDownMode() == PR_TRUE && mComboboxFrame) { ResetSelectedItem(); mComboboxFrame->ListWasSelected(mPresContext); diff --git a/mozilla/layout/xul/base/src/nsMenuBarListener.cpp b/mozilla/layout/xul/base/src/nsMenuBarListener.cpp index 2be90aabd7f..9c888040ff5 100644 --- a/mozilla/layout/xul/base/src/nsMenuBarListener.cpp +++ b/mozilla/layout/xul/base/src/nsMenuBarListener.cpp @@ -27,7 +27,7 @@ #include "nsIServiceManager.h" #include "nsWidgetsCID.h" #include "nsCOMPtr.h" -#include "nsIDOMUIEvent.h" +#include "nsIDOMKeyEvent.h" #include "nsIPresContext.h" #include "nsIContent.h" #include "nsIDOMNode.h" @@ -95,9 +95,9 @@ nsMenuBarListener::KeyUp(nsIDOMEvent* aKeyEvent) // On a press of the ALT key by itself, we toggle the menu's // active/inactive state. // Get the ascii key code. - nsCOMPtr theEvent = do_QueryInterface(aKeyEvent); + nsCOMPtr keyEvent = do_QueryInterface(aKeyEvent); PRUint32 theChar; - theEvent->GetKeyCode(&theChar); + keyEvent->GetKeyCode(&theChar); if (theChar == NS_VK_ALT && mAltKeyDown) { // The ALT key was down and is now up. mAltKeyDown = PR_FALSE; @@ -116,9 +116,9 @@ nsMenuBarListener::KeyDown(nsIDOMEvent* aKeyEvent) { PRBool active = mMenuBarFrame->IsActive(); - nsCOMPtr theEvent = do_QueryInterface(aKeyEvent); + nsCOMPtr keyEvent = do_QueryInterface(aKeyEvent); PRUint32 theChar; - theEvent->GetKeyCode(&theChar); + keyEvent->GetKeyCode(&theChar); if (theChar == NS_VK_ALT) { // The ALT key just went down. Track this. mAltKeyDown = PR_TRUE; @@ -150,11 +150,11 @@ nsMenuBarListener::KeyDown(nsIDOMEvent* aKeyEvent) } else if (active || altKeyWasDown) { // Get the character code. - nsCOMPtr uiEvent = do_QueryInterface(aKeyEvent); - if (uiEvent) { + nsCOMPtr keyEvent = do_QueryInterface(aKeyEvent); + if (keyEvent) { // See if a letter was pressed. PRUint32 charCode; - uiEvent->GetKeyCode(&charCode); + keyEvent->GetKeyCode(&charCode); // Do shortcut navigation. // A letter was pressed. We want to see if a shortcut gets matched. If @@ -171,7 +171,7 @@ nsMenuBarListener::KeyDown(nsIDOMEvent* aKeyEvent) nsresult nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent) { - nsCOMPtr theEvent = do_QueryInterface(aKeyEvent); + nsCOMPtr keyEvent = do_QueryInterface(aKeyEvent); PRBool active = mMenuBarFrame->IsActive(); diff --git a/mozilla/layout/xul/base/src/nsSliderFrame.cpp b/mozilla/layout/xul/base/src/nsSliderFrame.cpp index 76f25986a62..dbd4d421ba9 100644 --- a/mozilla/layout/xul/base/src/nsSliderFrame.cpp +++ b/mozilla/layout/xul/base/src/nsSliderFrame.cpp @@ -42,7 +42,7 @@ #include "nsHTMLAtoms.h" #include "nsIDOMEventReceiver.h" #include "nsIViewManager.h" -#include "nsIDOMUIEvent.h" +#include "nsIDOMMouseEvent.h" #include "nsDocument.h" #include "nsTitledButtonFrame.h" #include "nsScrollbarButtonFrame.h" @@ -766,15 +766,15 @@ nsSliderFrame::MouseDown(nsIDOMEvent* aMouseEvent) nsIContent* scrollbar = GetScrollBar(); PRBool isHorizontal = IsHorizontal(scrollbar); - nsCOMPtr uiEvent(do_QueryInterface(aMouseEvent)); + nsCOMPtr mouseEvent(do_QueryInterface(aMouseEvent)); RemoveListener(); DragThumb(mPresContext, PR_TRUE); PRInt32 c = 0; if (isHorizontal) - uiEvent->GetClientX(&c); + mouseEvent->GetClientX(&c); else - uiEvent->GetClientY(&c); + mouseEvent->GetClientY(&c); mDragStartPx = c; nsIFrame* thumbFrame = mFrames.FirstChild(); diff --git a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp index 8300f9cc055..672013ff442 100644 --- a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp +++ b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp @@ -39,7 +39,7 @@ #include "nsIView.h" #include "nsIViewManager.h" #include "nsIScrollableView.h" -#include "nsIDOMUIEvent.h" +#include "nsIDOMMouseEvent.h" #include "nsIPresShell.h" #include "nsFrameNavigator.h" #include "nsHTMLParts.h" @@ -767,7 +767,7 @@ nsSplitterFrameImpl::MouseDown(nsIDOMEvent* aMouseEvent) if (resizeAfter == Grow) mChildInfosAfterCount = 0; - nsCOMPtr uiEvent(do_QueryInterface(aMouseEvent)); + nsCOMPtr mouseEvent(do_QueryInterface(aMouseEvent)); nsRect vr(0,0,0,0); nsIView *v; @@ -776,11 +776,11 @@ nsSplitterFrameImpl::MouseDown(nsIDOMEvent* aMouseEvent) PRInt32 c = 0; if (isHorizontal) { - uiEvent->GetClientX(&c); + mouseEvent->GetClientX(&c); mSplitterPos = mSplitter->mRect.x; mSplitterViewPos = vr.x; } else { - uiEvent->GetClientY(&c); + mouseEvent->GetClientY(&c); mSplitterPos = mSplitter->mRect.y; mSplitterViewPos = vr.y; } diff --git a/mozilla/layout/xul/base/src/nsToolbarDragListener.cpp b/mozilla/layout/xul/base/src/nsToolbarDragListener.cpp index 6ec569933b1..adb40a89c51 100644 --- a/mozilla/layout/xul/base/src/nsToolbarDragListener.cpp +++ b/mozilla/layout/xul/base/src/nsToolbarDragListener.cpp @@ -21,7 +21,7 @@ #include "nsToolbarFrame.h" #include "nsCOMPtr.h" -#include "nsIDOMUIEvent.h" +#include "nsIDOMMouseEvent.h" #include "nsIPresContext.h" #include "nsIContent.h" #include "nsIDOMElement.h" @@ -157,10 +157,10 @@ nsToolbarDragListener :: ItemMouseIsOver ( nsIDOMEvent* aDragEvent, nscoord* out // // get mouse coordinates and translate them into twips - nsCOMPtr uiEvent(do_QueryInterface(aDragEvent)); + nsCOMPtr mouseEvent(do_QueryInterface(aDragEvent)); PRInt32 x,y = 0; - uiEvent->GetClientX(&x); - uiEvent->GetClientY(&y); + mouseEvent->GetClientX(&x); + mouseEvent->GetClientY(&y); float p2t; mPresContext->GetScaledPixelsToTwips(&p2t); nscoord onePixel = NSIntPixelsToTwips(1, p2t); diff --git a/mozilla/rdf/content/src/nsXULKeyListener.cpp b/mozilla/rdf/content/src/nsXULKeyListener.cpp index f19dcdc4355..aba214423a7 100644 --- a/mozilla/rdf/content/src/nsXULKeyListener.cpp +++ b/mozilla/rdf/content/src/nsXULKeyListener.cpp @@ -23,7 +23,7 @@ #include "nsIDOMFocusListener.h" #include "nsIDOMKeyListener.h" #include "nsIDOMMouseListener.h" -#include "nsIDOMUIEvent.h" +#include "nsIDOMKeyEvent.h" #include "nsIDOMWindow.h" #include "nsIDOMXULDocument.h" #include "nsINSEvent.h" @@ -346,8 +346,8 @@ nsresult nsXULKeyListenerImpl::DoKey(nsIDOMEvent* aKeyEvent, eEventType aEventTy nsIDOMNode* target = nsnull; aKeyEvent->GetTarget(&target); - nsIDOMUIEvent * theEvent; - aKeyEvent->QueryInterface(kIDomUIEventIID, (void**)&theEvent); + nsIDOMKeyEvent * keyEvent; + aKeyEvent->QueryInterface(kIDomUIEventIID, (void**)&keyEvent); // Find a keyset node // locate the window element which holds the top level key bindings @@ -423,18 +423,18 @@ nsresult nsXULKeyListenerImpl::DoKey(nsIDOMEvent* aKeyEvent, eEventType aEventTy if(code.IsEmpty()) { // HACK for temporary compatibility if(aEventType == eKeyPress) - theEvent->GetCharCode(&theChar); + keyEvent->GetCharCode(&theChar); else - theEvent->GetKeyCode(&theChar); + keyEvent->GetKeyCode(&theChar); } else { // We want a keycode - theEvent->GetKeyCode(&theChar); + keyEvent->GetKeyCode(&theChar); gotKeyCode = PR_TRUE; } } else { // We want a charcode - theEvent->GetCharCode(&theChar); + keyEvent->GetCharCode(&theChar); gotCharCode = PR_TRUE; } @@ -485,8 +485,8 @@ nsresult nsXULKeyListenerImpl::DoKey(nsIDOMEvent* aKeyEvent, eEventType aEventTy // Test Command attribute PRBool isCommand = PR_FALSE; PRBool isControl = PR_FALSE; - theEvent->GetMetaKey(&isCommand); - theEvent->GetCtrlKey(&isControl); + keyEvent->GetMetaKey(&isCommand); + keyEvent->GetCtrlKey(&isControl); if (((isCommand && (modCommand==0)) || (!isCommand && (modCommand==1))) || ((isControl && (modControl==0)) || @@ -516,7 +516,7 @@ nsresult nsXULKeyListenerImpl::DoKey(nsIDOMEvent* aKeyEvent, eEventType aEventTy modShift = 0; PRBool isShift = PR_FALSE; - theEvent->GetShiftKey(&isShift); + keyEvent->GetShiftKey(&isShift); if ((isShift && (modShift==0)) || (!isShift && (modShift==1))) { @@ -533,7 +533,7 @@ nsresult nsXULKeyListenerImpl::DoKey(nsIDOMEvent* aKeyEvent, eEventType aEventTy modAlt = 0; PRBool isAlt = PR_FALSE; - theEvent->GetAltKey(&isAlt); + keyEvent->GetAltKey(&isAlt); if ((isAlt && (modAlt==0)) || (!isAlt && (modAlt==1))) { diff --git a/mozilla/rdf/content/src/nsXULPopupListener.cpp b/mozilla/rdf/content/src/nsXULPopupListener.cpp index ef4afba68f5..2e0e51908ec 100644 --- a/mozilla/rdf/content/src/nsXULPopupListener.cpp +++ b/mozilla/rdf/content/src/nsXULPopupListener.cpp @@ -34,7 +34,7 @@ #include "nsIDOMXULDocument.h" #include "nsIDocument.h" #include "nsIContent.h" -#include "nsIDOMUIEvent.h" +#include "nsIDOMMouseEvent.h" #include "nsITimer.h" @@ -188,16 +188,16 @@ XULPopupListenerImpl::MouseDown(nsIDOMEvent* aMouseEvent) { PRUint16 button; - nsCOMPtr uiEvent; - uiEvent = do_QueryInterface(aMouseEvent); - if (!uiEvent) { + nsCOMPtr mouseEvent; + mouseEvent = do_QueryInterface(aMouseEvent); + if (!mouseEvent) { //non-ui event passed in. bad things. return NS_OK; } // Get the node that was clicked on. nsCOMPtr targetNode; - uiEvent->GetTarget( getter_AddRefs( targetNode ) ); + mouseEvent->GetTarget( getter_AddRefs( targetNode ) ); // Get the document with the popup. nsCOMPtr document; @@ -221,7 +221,7 @@ XULPopupListenerImpl::MouseDown(nsIDOMEvent* aMouseEvent) switch (popupType) { case eXULPopupType_popup: // Check for left mouse button down - uiEvent->GetButton(&button); + mouseEvent->GetButton(&button); if (button == 1) { // Time to launch a popup menu. LaunchPopup(aMouseEvent); @@ -231,11 +231,11 @@ XULPopupListenerImpl::MouseDown(nsIDOMEvent* aMouseEvent) #ifdef XP_MAC // XXX: Handle Mac (currently checks if CTRL key is down) PRBool ctrlKey = PR_FALSE; - uiEvent->GetCtrlKey(&ctrlKey); + mouseEvent->GetCtrlKey(&ctrlKey); if (ctrlKey == PR_TRUE) #else // Check for right mouse button down - uiEvent->GetButton(&button); + mouseEvent->GetButton(&button); if (button == 3) #endif { @@ -266,15 +266,15 @@ XULPopupListenerImpl::MouseMove(nsIDOMEvent* aMouseEvent) if ( popupType != eXULPopupType_tooltip ) return NS_OK; - nsCOMPtr uiEvent ( do_QueryInterface(aMouseEvent) ); - if (!uiEvent) + nsCOMPtr mouseEvent ( do_QueryInterface(aMouseEvent) ); + if (!mouseEvent) return NS_OK; // stash the coordinates of the event so that we can still get back to it from within the // timer scallback. Also stash the node that started this so we can put it into the // document later on (if the timer ever fires). - uiEvent->GetClientX(&mMouseClientX); - uiEvent->GetClientY(&mMouseClientY); + mouseEvent->GetClientX(&mMouseClientX); + mouseEvent->GetClientY(&mMouseClientY); //XXX recognize when a popup is already up and immediately show the //XXX tooltip for the new item if the dom element is different than @@ -383,15 +383,15 @@ nsresult XULPopupListenerImpl::LaunchPopup ( nsIDOMEvent* anEvent ) { // Retrieve our x and y position. - nsCOMPtr uiEvent ( do_QueryInterface(anEvent) ); - if (!uiEvent) { + nsCOMPtr mouseEvent ( do_QueryInterface(anEvent) ); + if (!mouseEvent) { //non-ui event passed in. bad things. return NS_OK; } PRInt32 xPos, yPos; - uiEvent->GetClientX(&xPos); - uiEvent->GetClientY(&yPos); + mouseEvent->GetClientX(&xPos); + mouseEvent->GetClientY(&yPos); return LaunchPopup(xPos, yPos); } diff --git a/mozilla/widget/public/nsGUIEvent.h b/mozilla/widget/public/nsGUIEvent.h index 34ca89647f7..8c2a3b1a99f 100644 --- a/mozilla/widget/public/nsGUIEvent.h +++ b/mozilla/widget/public/nsGUIEvent.h @@ -136,6 +136,8 @@ struct nsKeyEvent : public nsInputEvent { PRUint32 keyCode; /// OS translated Unicode char PRUint32 charCode; + // indicates whether the event signifies a printable character + PRBool isChar; }; /** @@ -162,6 +164,7 @@ struct nsTextEvent : public nsInputEvent { nsTextEventReply theReply; PRUint32 rangeCount; nsTextRangeArray rangeArray; + PRBool isChar; }; struct nsCompositionEvent : public nsInputEvent {