remove nsIMouseListener interface. b=452118 r=smaug sr=roc

This commit is contained in:
Josh Aas 2008-08-25 20:02:26 -04:00
parent 0cf05ab4dc
commit 594704d36f
18 changed files with 23 additions and 293 deletions

View File

@ -3491,7 +3491,7 @@ nsPluginInstanceOwner::MouseMove(nsIDOMEvent* aMouseEvent)
return NS_OK;
}
/*=============== nsIMouseListener ======================*/
/*=============== nsIDOMMouseListener ======================*/
nsresult
nsPluginInstanceOwner::MouseDown(nsIDOMEvent* aMouseEvent)

View File

@ -52,7 +52,6 @@ EXPORTS = \
nsIWidget.h \
nsGUIEvent.h \
nsEvent.h \
nsIMouseListener.h \
nsIEventListener.h \
nsWidgetsCID.h \
nsILookAndFeel.h \

View File

@ -1,92 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIMouseListener_h__
#define nsIMouseListener_h__
#include "nsEvent.h"
#include "nsISupports.h"
/**
*
* Mouse up/down/move event listener
*
*/
// {c83f6b81-d7ce-11d2-8360-c4c894c4917c}
#define NS_IMOUSELISTENER_IID \
{ 0xc83f6b81, 0xd7ce, 0x11d2, { 0x83, 0x60, 0xc4, 0xc8, 0x94, 0xc4, 0x91, 0x7c } }
class nsIMouseListener : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IMOUSELISTENER_IID)
/**
* Processes a mouse pressed event
* @param aMouseEvent See nsGUIEvent.h
* @return whether the event was consumed or ignored. See nsEventStatus
*/
virtual nsEventStatus MousePressed(const nsGUIEvent & aMouseEvent) = 0;
/**
* Processes a mouse release event
* @param aMouseEvent See nsGUIEvent.h
* @return whether the event was consumed or ignored. See nsEventStatus
*/
virtual nsEventStatus MouseReleased(const nsGUIEvent & aMouseEvent) = 0;
/**
* Processes a mouse clicked event
* @param aMouseEvent See nsGUIEvent.h
* @return whether the event was consumed or ignored. See nsEventStatus
*
*/
virtual nsEventStatus MouseClicked(const nsGUIEvent & aMouseEvent) = 0;
/**
* Processes a mouse moved event
* @param aMouseEvent See nsGUIEvent.h
* @return whether the event was consumed or ignored. See nsEventStatus
*/
virtual nsEventStatus MouseMoved(const nsGUIEvent & aMouseEvent) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIMouseListener, NS_IMOUSELISTENER_IID)
#endif // nsIMouseListener_h__

View File

@ -61,7 +61,6 @@ class nsGUIEvent;
struct nsColorMap;
class imgIContainer;
class gfxASurface;
class nsIMouseListener;
class nsIContent;
/**
@ -756,15 +755,6 @@ class nsIWidget : public nsISupports {
NS_IMETHOD Update() = 0;
/**
* Adds a mouse listener to this widget
* Any existing mouse listener is replaced
*
* @param aListener mouse listener to add to this widget.
*/
NS_IMETHOD AddMouseListener(nsIMouseListener * aListener) = 0;
/**
* Adds an event listener to this widget
* Any existing event listener is replaced

View File

@ -2630,7 +2630,7 @@ PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType, nsPoint aPoint, PRUint3
PRUint16 aButton)
{
PRBool result = PR_FALSE;
if (nsnull != mEventCallback || nsnull != mMouseListener)
if (nsnull != mEventCallback)
{
nsMouseEvent event(PR_TRUE, aEventType, this, nsMouseEvent::eReal);
InitEvent (event, &aPoint);
@ -2642,31 +2642,9 @@ PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType, nsPoint aPoint, PRUint3
event.button = aButton;
// call the event callback
if (nsnull != mEventCallback)
{
result = DispatchWindowEvent(&event);
NS_RELEASE(event.widget);
return result;
}
else
{
switch(aEventType)
{
case NS_MOUSE_MOVE :
result = ConvertStatus(mMouseListener->MouseMoved(event));
break;
case NS_MOUSE_BUTTON_DOWN :
result = ConvertStatus(mMouseListener->MousePressed(event));
break;
case NS_MOUSE_BUTTON_UP :
result = ConvertStatus(mMouseListener->MouseReleased(event)) && ConvertStatus(mMouseListener->MouseClicked(event));
break;
}
NS_RELEASE(event.widget);
return result;
}
result = DispatchWindowEvent(&event);
NS_RELEASE(event.widget);
return result;
}
return PR_FALSE;

View File

@ -48,7 +48,6 @@
#include "nsIWidget.h"
#include "nsIMouseListener.h"
#include "nsIEventListener.h"
#include "nsString.h"
#include "nsRegion.h"

View File

@ -42,7 +42,6 @@
#include "nsIAppShell.h"
#include "nsIEventListener.h"
#include "nsILookAndFeel.h"
#include "nsIMouseListener.h"
#include "nsIToolkit.h"
#include "nsIWidget.h"

View File

@ -56,7 +56,6 @@
#include "nsIWidget.h"
#include "nsIAppShell.h"
#include "nsIMouseListener.h"
#include "nsIEventListener.h"
#include "nsString.h"
#include "nsIDragService.h"
@ -310,7 +309,6 @@ public:
static PRBool ConvertStatus(nsEventStatus aStatus)
{ return aStatus == nsEventStatus_eConsumeNoDefault; }
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
virtual PRBool DispatchMouseEvent(nsMouseEvent &aEvent);
NS_IMETHOD Update();

View File

@ -1825,39 +1825,6 @@ PRBool nsChildView::DispatchWindowEvent(nsGUIEvent &event)
}
// Deal with all sort of mouse event
PRBool nsChildView::DispatchMouseEvent(nsMouseEvent &aEvent)
{
PRBool result = PR_FALSE;
// call the event callback
if (mEventCallback)
return DispatchWindowEvent(aEvent);
if (mMouseListener) {
nsCOMPtr<nsIWidget> kungFuDeathGrip(this);
switch (aEvent.message) {
case NS_MOUSE_MOVE:
result = ConvertStatus(mMouseListener->MouseMoved(aEvent));
break;
case NS_MOUSE_BUTTON_DOWN:
result = ConvertStatus(mMouseListener->MousePressed(aEvent));
break;
case NS_MOUSE_BUTTON_UP: {
result = ConvertStatus(mMouseListener->MouseReleased(aEvent));
if (mMouseListener)
result = ConvertStatus(mMouseListener->MouseClicked(aEvent));
break;
}
} // switch
}
return result;
}
#pragma mark -
@ -3117,7 +3084,7 @@ NSEvent* gLastDragEvent = nil;
macEvent.modifiers = ::GetCurrentEventKeyModifiers();
geckoEvent.nativeMsg = &macEvent;
mGeckoChild->DispatchMouseEvent(geckoEvent);
mGeckoChild->DispatchWindowEvent(geckoEvent);
// XXX maybe call markedTextSelectionChanged:client: here?
@ -3153,7 +3120,7 @@ NSEvent* gLastDragEvent = nil;
macEvent.modifiers = ::GetCurrentEventKeyModifiers();
geckoEvent.nativeMsg = &macEvent;
mGeckoChild->DispatchMouseEvent(geckoEvent);
mGeckoChild->DispatchWindowEvent(geckoEvent);
NS_OBJC_END_TRY_ABORT_BLOCK;
}
@ -3319,7 +3286,7 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
macEvent.modifiers = ::GetCurrentEventKeyModifiers();
geckoEvent.nativeMsg = &macEvent;
mGeckoChild->DispatchMouseEvent(geckoEvent);
mGeckoChild->DispatchWindowEvent(geckoEvent);
NS_OBJC_END_TRY_ABORT_BLOCK;
}
@ -3356,7 +3323,7 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
macEvent.modifiers = btnState | ::GetCurrentEventKeyModifiers();
geckoEvent.nativeMsg = &macEvent;
mGeckoChild->DispatchMouseEvent(geckoEvent);
mGeckoChild->DispatchWindowEvent(geckoEvent);
// Note, sending the above event might have destroyed our widget since we didn't retain.
// Fine so long as we don't access any local variables from here on.
@ -3397,7 +3364,7 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
macEvent.modifiers = controlKey; // fake a context menu click
geckoEvent.nativeMsg = &macEvent;
PRBool handled = mGeckoChild->DispatchMouseEvent(geckoEvent);
PRBool handled = mGeckoChild->DispatchWindowEvent(geckoEvent);
if (!mGeckoChild)
return;
@ -3433,7 +3400,7 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
geckoEvent.nativeMsg = &macEvent;
nsAutoRetainCocoaObject kungFuDeathGrip(self);
mGeckoChild->DispatchMouseEvent(geckoEvent);
mGeckoChild->DispatchWindowEvent(geckoEvent);
NS_OBJC_END_TRY_ABORT_BLOCK;
}
@ -3453,7 +3420,7 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
// send event into Gecko by going directly to the
// the widget.
mGeckoChild->DispatchMouseEvent(geckoEvent);
mGeckoChild->DispatchWindowEvent(geckoEvent);
}
@ -3477,7 +3444,7 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
geckoEvent.button = nsMouseEvent::eMiddleButton;
geckoEvent.clickCount = [theEvent clickCount];
mGeckoChild->DispatchMouseEvent(geckoEvent);
mGeckoChild->DispatchWindowEvent(geckoEvent);
NS_OBJC_END_TRY_ABORT_BLOCK;
}
@ -3492,7 +3459,7 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
[self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
geckoEvent.button = nsMouseEvent::eMiddleButton;
mGeckoChild->DispatchMouseEvent(geckoEvent);
mGeckoChild->DispatchWindowEvent(geckoEvent);
}
@ -3507,7 +3474,7 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
// send event into Gecko by going directly to the
// the widget.
mGeckoChild->DispatchMouseEvent(geckoEvent);
mGeckoChild->DispatchWindowEvent(geckoEvent);
}
@ -3647,7 +3614,7 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
nsMouseEvent geckoEvent(PR_TRUE, NS_CONTEXTMENU, nsnull, nsMouseEvent::eReal);
[self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
geckoEvent.button = nsMouseEvent::eRightButton;
mGeckoChild->DispatchMouseEvent(geckoEvent);
mGeckoChild->DispatchWindowEvent(geckoEvent);
if (!mGeckoChild)
return nil;

View File

@ -205,7 +205,6 @@ public:
NS_IMETHOD Show(PRBool aState);
virtual nsIWidget* GetSheetWindowParent(void);
NS_IMETHOD AddMouseListener(nsIMouseListener * aListener);
NS_IMETHOD AddEventListener(nsIEventListener * aListener);
NS_IMETHOD Enable(PRBool aState);
NS_IMETHOD IsEnabled(PRBool *aState);

View File

@ -809,11 +809,11 @@ void nsCocoaWindow::MakeBackgroundTransparent(PRBool aTransparent)
nsTransparencyMode nsCocoaWindow::GetTransparencyMode()
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
return [mWindow isOpaque] ? eTransparencyOpaque : eTransparencyTransparent;
NS_OBJC_END_TRY_ABORT_BLOCK;
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(eTransparencyOpaque);
}
@ -842,17 +842,6 @@ void nsCocoaWindow::SetTransparencyMode(nsTransparencyMode aMode)
}
NS_METHOD nsCocoaWindow::AddMouseListener(nsIMouseListener * aListener)
{
nsBaseWidget::AddMouseListener(aListener);
if (mPopupContentView)
mPopupContentView->AddMouseListener(aListener);
return NS_OK;
}
NS_METHOD nsCocoaWindow::AddEventListener(nsIEventListener * aListener)
{
nsBaseWidget::AddEventListener(aListener);

View File

@ -3214,7 +3214,7 @@ PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType, MPARAM mp1, MPARAM mp2,
{
PRBool result = PR_FALSE;
if (nsnull == mEventCallback && nsnull == mMouseListener) {
if (nsnull == mEventCallback) {
return result;
}
@ -3337,33 +3337,6 @@ PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType, MPARAM mp1, MPARAM mp2,
return DispatchWindowEvent(&event);
}
if (nsnull != mMouseListener) {
switch (aEventType) {
case NS_MOUSE_MOVE: {
result = ConvertStatus(mMouseListener->MouseMoved(event));
nsRect rect;
GetBounds(rect);
if (rect.Contains(event.refPoint.x, event.refPoint.y)) {
if (gCurrentWindow == NULL || gCurrentWindow != this) {
gCurrentWindow = this;
}
}
} break;
case NS_MOUSE_BUTTON_DOWN:
result = ConvertStatus(mMouseListener->MousePressed(event));
break;
case NS_MOUSE_BUTTON_UP:
result = ConvertStatus(mMouseListener->MouseReleased(event));
break;
case NS_MOUSE_CLICK:
result = ConvertStatus(mMouseListener->MouseClicked(event));
break;
} // switch
}
return result;
}

View File

@ -721,39 +721,15 @@ void nsWidget::InitMouseEvent(PhPointerEvent_t *aPhButtonEvent,
PRBool nsWidget::DispatchMouseEvent( nsMouseEvent& aEvent ) {
PRBool result = PR_FALSE;
if (nsnull == mEventCallback && nsnull == mMouseListener) return result;
// call the event callback
if (nsnull != mEventCallback) {
result = DispatchWindowEvent(&aEvent);
return result;
}
}
if (nsnull != mMouseListener) {
switch (aEvent.message) {
case NS_MOUSE_BUTTON_DOWN:
result = ConvertStatus(mMouseListener->MousePressed(aEvent));
break;
case NS_MOUSE_BUTTON_UP:
result = ConvertStatus(mMouseListener->MouseReleased(aEvent));
result = ConvertStatus(mMouseListener->MouseClicked(aEvent));
break;
case NS_DRAGDROP_DROP:
break;
case NS_MOUSE_MOVE:
break;
default:
break;
} // switch
}
return result;
}
}
struct nsKeyConverter {
PRUint32 vkCode; // Platform independent key code

View File

@ -47,7 +47,6 @@ struct nsRect;
class nsIAppShell;
class nsIEventListener;
class nsILookAndFeel;
class nsIMouseListener;
class nsIToolkit;
class nsIWidget;
class nsITooltipWidget;

View File

@ -5937,7 +5937,7 @@ PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType, WPARAM wParam,
{
PRBool result = PR_FALSE;
if (nsnull == mEventCallback && nsnull == mMouseListener) {
if (!mEventCallback) {
return result;
}
@ -6145,31 +6145,6 @@ PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType, WPARAM wParam,
return result;
}
if (nsnull != mMouseListener) {
switch (aEventType) {
case NS_MOUSE_MOVE:
{
result = ConvertStatus(mMouseListener->MouseMoved(event));
nsRect rect;
GetBounds(rect);
if (rect.Contains(event.refPoint)) {
if (gCurrentWindow == NULL || gCurrentWindow != this) {
gCurrentWindow = this;
}
}
}
break;
case NS_MOUSE_BUTTON_DOWN:
result = ConvertStatus(mMouseListener->MousePressed(event));
break;
case NS_MOUSE_BUTTON_UP:
result = ConvertStatus(mMouseListener->MouseReleased(event));
result = ConvertStatus(mMouseListener->MouseClicked(event));
break;
} // switch
}
return result;
}
@ -6282,7 +6257,7 @@ PRBool ChildWindow::DispatchMouseEvent(PRUint32 aEventType, WPARAM wParam, LPARA
{
PRBool result = PR_FALSE;
if (nsnull == mEventCallback && nsnull == mMouseListener) {
if (nsnull == mEventCallback) {
return result;
}

View File

@ -50,7 +50,6 @@
#include "nsIWidget.h"
#include "nsIMouseListener.h"
#include "nsIEventListener.h"
#include "nsString.h"

View File

@ -95,7 +95,6 @@ nsBaseWidget::nsBaseWidget()
, mEventCallback(nsnull)
, mContext(nsnull)
, mToolkit(nsnull)
, mMouseListener(nsnull)
, mEventListener(nsnull)
, mCursor(eCursor_standard)
, mWindowType(eWindowType_child)
@ -263,7 +262,6 @@ NS_METHOD nsBaseWidget::Destroy()
parent->RemoveChild(this);
}
// disconnect listeners.
NS_IF_RELEASE(mMouseListener);
NS_IF_RELEASE(mEventListener);
return NS_OK;
@ -705,19 +703,6 @@ NS_METHOD nsBaseWidget::SetBorderStyle(nsBorderStyle aBorderStyle)
}
/**
* Processes a mouse pressed event
*
**/
NS_METHOD nsBaseWidget::AddMouseListener(nsIMouseListener * aListener)
{
NS_PRECONDITION(mMouseListener == nsnull, "Null mouse listener");
NS_IF_RELEASE(mMouseListener);
NS_ADDREF(aListener);
mMouseListener = aListener;
return NS_OK;
}
/**
* Processes a mouse pressed event
*

View File

@ -39,7 +39,6 @@
#include "nsRect.h"
#include "nsIWidget.h"
#include "nsIMouseListener.h"
#include "nsIEventListener.h"
#include "nsIToolkit.h"
#include "nsIAppShell.h"
@ -117,7 +116,6 @@ public:
PRBool *aForWindow);
NS_IMETHOD SetWindowClass(const nsAString& xulWinType);
NS_IMETHOD SetBorderStyle(nsBorderStyle aBorderStyle);
NS_IMETHOD AddMouseListener(nsIMouseListener * aListener);
NS_IMETHOD AddEventListener(nsIEventListener * aListener);
NS_IMETHOD SetBounds(const nsRect &aRect);
NS_IMETHOD GetBounds(nsRect &aRect);
@ -178,7 +176,6 @@ protected:
EVENT_CALLBACK mEventCallback;
nsIDeviceContext *mContext;
nsIToolkit *mToolkit;
nsIMouseListener *mMouseListener;
nsIEventListener *mEventListener;
nscolor mBackground;
nscolor mForeground;