From 94f13ebbb188178a789a3de7fd9280df3729f3c7 Mon Sep 17 00:00:00 2001 From: "joshmoz@gmail.com" Date: Tue, 9 Oct 2007 11:46:30 -0700 Subject: [PATCH] remove nsIEventSink and all of its usage. b=399047 r=smorgan sr=roc a=roc --- widget/public/Makefile.in | 3 +- widget/public/nsIEventSink.idl | 94 --------------------------------- widget/src/cocoa/nsChildView.h | 5 +- widget/src/cocoa/nsChildView.mm | 93 ++++++-------------------------- 4 files changed, 18 insertions(+), 177 deletions(-) delete mode 100644 widget/public/nsIEventSink.idl diff --git a/widget/public/Makefile.in b/widget/public/Makefile.in index fdf79361dd92..e7185f4f6470 100644 --- a/widget/public/Makefile.in +++ b/widget/public/Makefile.in @@ -115,8 +115,7 @@ XPIDLSRCS += nsIPrintSettingsWin.idl endif ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa) -XPIDLSRCS += nsIEventSink.idl \ - nsIPrintSettingsX.idl \ +XPIDLSRCS += nsIPrintSettingsX.idl \ nsIPrintSessionX.idl endif diff --git a/widget/public/nsIEventSink.idl b/widget/public/nsIEventSink.idl deleted file mode 100644 index f4ed9a4b026a..000000000000 --- a/widget/public/nsIEventSink.idl +++ /dev/null @@ -1,94 +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 ***** */ - - -#include "nsISupports.idl" - -/* THIS IS A PUBLIC EMBEDDING API */ - -/** - * The nsIEventSink is implemented internally by Gecko as the conduit - * through which native events travel into Gecko. You obtain an - * event sink by QI'ing the top-level nsIWidget, usually a window. - * - * @status UNDER_REVIEW - */ - -[uuid(c0d3a7c8-1dd1-11b2-8903-adcd22d004ab)] -interface nsIEventSink : nsISupports -{ - /** - * Entry point for native events into Gecko. - * - * @return PR_TRUE if event was handled - * PR_FALSE if not handled - * - * On Mac, anEvent is a native EventRecord*. - */ - boolean dispatchEvent ( in voidPtr anEvent ) ; - - /** - * Alerts gecko of a drag event. - * - * @param aMessage the message parameter for a Gecko NS_DRAGDROP_EVENT (See nsGUIEvent.h for list). - * @param aMouseGlobalX x coordinate of mouse, in global coordinates - * @param aMouseGlobalY y coordinate of mouse, in global coordinates - * @param aKeyModifiers a native bitfield of which modifier keys are currently pressed - * - * @return PR_TRUE if event was handled - * PR_FALSE if not handled - */ - boolean dragEvent ( in unsigned long aMessage, in short aMouseGlobalX, in short aMouseGlobalY, - in unsigned short aKeyModifiers ) ; - - /** - * Tell gecko to scroll, usually in response to a mouse-wheel - * - * @param aVertical PR_TRUE if scrolling veritcally, PR_FALSE if horizontal - * @param aNumLines the number of lines to scroll, positive for down, negative for up - * @param aMouseLocalX the x coordinate of the mouse in window (local) coordinates - * @param aMouseLocalY the y coordinate of the mouse in window (local) coordinates - */ - boolean scroll ( in boolean aVertical, in short aNumLines, in short aMouseLocalX, - in short aMouseLocalY ) ; - - /** - * Perform any idle processing (handle timers, set the cursor, etc) - */ - void Idle ( ) ; - -}; \ No newline at end of file diff --git a/widget/src/cocoa/nsChildView.h b/widget/src/cocoa/nsChildView.h index 22ac35f522bc..583357f2aa40 100644 --- a/widget/src/cocoa/nsChildView.h +++ b/widget/src/cocoa/nsChildView.h @@ -49,7 +49,6 @@ #include "nsISupports.h" #include "nsBaseWidget.h" #include "nsIPluginWidget.h" -#include "nsIEventSink.h" #include "nsIScrollableView.h" #include "nsWeakPtr.h" @@ -178,8 +177,7 @@ private: class nsChildView : public nsBaseWidget, public nsIPluginWidget, - public nsIKBStateControl, - public nsIEventSink + public nsIKBStateControl { private: typedef nsBaseWidget Inherited; @@ -189,7 +187,6 @@ public: virtual ~nsChildView(); NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIEVENTSINK // nsIKBStateControl interface NS_IMETHOD ResetInputState(); diff --git a/widget/src/cocoa/nsChildView.mm b/widget/src/cocoa/nsChildView.mm index e4d98e7561f3..a501086515fb 100644 --- a/widget/src/cocoa/nsChildView.mm +++ b/widget/src/cocoa/nsChildView.mm @@ -57,7 +57,6 @@ #include "nsIDeviceContext.h" #include "nsIRegion.h" #include "nsIRollupListener.h" -#include "nsIEventSink.h" #include "nsIScrollableView.h" #include "nsIViewManager.h" #include "nsIInterfaceRequestor.h" @@ -121,7 +120,7 @@ nsIWidget * gRollupWidget = nsnull; @interface ChildView(Private) // sets up our view, attaching it to its owning gecko view -- (id)initWithFrame:(NSRect)inFrame geckoChild:(nsChildView*)inChild eventSink:(nsIEventSink*)inSink; +- (id)initWithFrame:(NSRect)inFrame geckoChild:(nsChildView*)inChild; // sends gecko an ime composition event - (nsRect) sendCompositionEvent:(PRInt32)aEventType; @@ -373,7 +372,7 @@ nsChildView::~nsChildView() } -NS_IMPL_ISUPPORTS_INHERITED3(nsChildView, nsBaseWidget, nsIPluginWidget, nsIKBStateControl, nsIEventSink) +NS_IMPL_ISUPPORTS_INHERITED2(nsChildView, nsBaseWidget, nsIPluginWidget, nsIKBStateControl) // Utility method for implementing both Create(nsIWidget ...) @@ -466,7 +465,7 @@ nsresult nsChildView::StandardCreate(nsIWidget *aParent, NSView* nsChildView::CreateCocoaView(NSRect inFrame) { - return [[[ChildView alloc] initWithFrame:inFrame geckoChild:this eventSink:nsnull] autorelease]; + return [[[ChildView alloc] initWithFrame:inFrame geckoChild:this] autorelease]; } @@ -1670,69 +1669,6 @@ NS_IMETHODIMP nsChildView::GetToggledKeyState(PRUint32 aKeyCode, #pragma mark - -// Handle an event coming into us and send it to gecko. -NS_IMETHODIMP -nsChildView::DispatchEvent(void* anEvent, PRBool *_retval) -{ - return NS_OK; -} - - -// The drag manager has let us know that something related to a drag has -// occurred in this window. It could be any number of things, ranging from -// a drop, to a drag enter/leave, or a drag over event. The actual event -// is passed in |aMessage| and is passed along to our event handler so Gecko -// knows about it. -NS_IMETHODIMP -nsChildView::DragEvent(PRUint32 aMessage, PRInt16 aMouseGlobalX, PRInt16 aMouseGlobalY, - PRUint16 aKeyModifiers, PRBool *_retval) -{ - // ensure that this is going to a ChildView (not something else like a - // scrollbar). I think it's safe to just bail at this point if it's not - // what we expect it to be - if (![mView isKindOfClass:[ChildView class]]) { - *_retval = PR_FALSE; - return NS_OK; - } - - // set up gecko event - nsMouseEvent geckoEvent(PR_TRUE, aMessage, nsnull, nsMouseEvent::eReal); - [(ChildView*)mView convertGenericCocoaEvent:nil toGeckoEvent:&geckoEvent]; - - // Use our own coordinates in the gecko event. - // Convert event from gecko global coords to gecko view coords. - NSPoint localPoint = NSMakePoint(aMouseGlobalX, aMouseGlobalY); - FlipCocoaScreenCoordinate(localPoint); - localPoint = [[mView window] convertScreenToBase:localPoint]; - localPoint = [mView convertPoint:localPoint fromView:nil]; - geckoEvent.refPoint.x = static_cast(localPoint.x); - geckoEvent.refPoint.y = static_cast(localPoint.y); - - DispatchWindowEvent(geckoEvent); - - // we handled the event - *_retval = PR_TRUE; - return NS_OK; -} - - -// The cocoa view calls DispatchWindowEvent() directly, so no need for this -NS_IMETHODIMP -nsChildView::Scroll(PRBool aVertical, PRInt16 aNumLines, PRInt16 aMouseLocalX, - PRInt16 aMouseLocalY, PRBool *_retval) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - - -NS_IMETHODIMP -nsChildView::Idle() -{ - // do some idle stuff? - return NS_ERROR_NOT_IMPLEMENTED; -} - - gfxASurface* nsChildView::GetThebesSurface() { @@ -1813,8 +1749,8 @@ NSView* gLastDragView = nil; NSEvent* gLastDragEvent = nil; -// initWithFrame:geckoChild:eventSink: -- (id)initWithFrame:(NSRect)inFrame geckoChild:(nsChildView*)inChild eventSink:(nsIEventSink*)inSink +// initWithFrame:geckoChild: +- (id)initWithFrame:(NSRect)inFrame geckoChild:(nsChildView*)inChild { if ((self = [super initWithFrame:inFrame])) { mWindow = nil; @@ -4202,14 +4138,17 @@ static PRBool IsSpecialGeckoKey(UInt32 macKeyCode) dragSession->SetDragAction(action); } - NSPoint dragLocation = [aSender draggingLocation]; - dragLocation = [[self window] convertBaseToScreen:dragLocation]; - FlipCocoaScreenCoordinate(dragLocation); + // set up gecko event + nsMouseEvent geckoEvent(PR_TRUE, aMessage, nsnull, nsMouseEvent::eReal); + [self convertGenericCocoaEvent:nil toGeckoEvent:&geckoEvent]; - // Pass into Gecko for handling. - PRBool handled = PR_FALSE; - mGeckoChild->DragEvent(aMessage, (PRInt16)dragLocation.x, - (PRInt16)dragLocation.y, 0, &handled); + // Use our own coordinates in the gecko event. + // Convert event from gecko global coords to gecko view coords. + NSPoint localPoint = [self convertPoint:[aSender draggingLocation] fromView:nil]; + geckoEvent.refPoint.x = static_cast(localPoint.x); + geckoEvent.refPoint.y = static_cast(localPoint.y); + + mGeckoChild->DispatchWindowEvent(geckoEvent); if (aMessage == NS_DRAGDROP_EXIT && dragSession) { nsCOMPtr sourceNode; @@ -4223,7 +4162,7 @@ static PRBool IsSpecialGeckoKey(UInt32 macKeyCode) } } - return handled ? YES : NO; + return YES; }