diff --git a/layout/xul/base/public/nsXULPopupManager.h b/layout/xul/base/public/nsXULPopupManager.h index 86e75d7b18b..7b077f051b7 100644 --- a/layout/xul/base/public/nsXULPopupManager.h +++ b/layout/xul/base/public/nsXULPopupManager.h @@ -323,9 +323,11 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSIROLLUPLISTENER - NS_DECL_NSIMENUROLLUP NS_DECL_NSITIMERCALLBACK + virtual void GetSubmenuWidgetChain(nsTArray *_retval); + virtual void AdjustPopupsOnWindowChange(void); + static nsXULPopupManager* sInstance; // initialize and shutdown methods called by nsLayoutStatics diff --git a/widget/public/Makefile.in b/widget/public/Makefile.in index 944681939ca..74e0c7c0b03 100644 --- a/widget/public/Makefile.in +++ b/widget/public/Makefile.in @@ -60,6 +60,7 @@ EXPORTS = \ nsIPluginWidget.h \ nsINativeKeyBindings.h \ nsIDeviceContextSpec.h \ + nsIMenuRollup.h \ $(NULL) ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa) @@ -100,7 +101,6 @@ XPIDLSRCS = \ nsIClipboardHelper.idl \ nsIClipboardOwner.idl \ nsIRollupListener.idl \ - nsIMenuRollup.idl \ nsIBaseWindow.idl \ nsIBidiKeyboard.idl \ nsIFullScreen.idl \ diff --git a/widget/public/nsIMenuRollup.idl b/widget/public/nsIMenuRollup.h similarity index 62% rename from widget/public/nsIMenuRollup.idl rename to widget/public/nsIMenuRollup.h index 15956872319..b20e6a1691a 100644 --- a/widget/public/nsIMenuRollup.idl +++ b/widget/public/nsIMenuRollup.h @@ -1,6 +1,5 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * ***** BEGIN LICENSE BLOCK ***** +/* -*- 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 @@ -13,19 +12,18 @@ * for the specific language governing rights and limitations under the * License. * - * The Original Code is the Mozilla browser. + * 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) 1999 + * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Mike Pinkerton * * 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"), + * either of 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 @@ -37,19 +35,31 @@ * * ***** END LICENSE BLOCK ***** */ -#include "nsISupports.idl" -#include "nsISupportsArray.idl" +#ifndef nsIMenuRollup_h___ +#define nsIMenuRollup_h___ -[uuid(10C69225-2C5A-4948-8690-0BC589D145B4)] -interface nsIMenuRollup : nsISupports -{ - // Walks up the menu parent chain of a submenu pulling out the widgets and - // places them into a list. Useful for determining if a click is in a - // parent menu. - nsISupportsArray GetSubmenuWidgetChain ( ) ; +#include "nsISupports.h" +#include "nsIWidget.h" +#include "nsTArray.h" + +#define NS_IMENUROLLUP_IID \ + {0x2b65d177, 0xc3e4, 0x4564, \ + { 0x8d, 0xed, 0x86, 0xd2, 0xfa, 0x2f, 0x65, 0x9a }} + +class nsIMenuRollup : public nsISupports { + public: + + NS_DECLARE_STATIC_IID_ACCESSOR(NS_IMENUROLLUP_IID) + + /* void GetSubmenuWidgetChain (nsTArray*); */ + virtual void GetSubmenuWidgetChain(nsTArray *_retval) = 0; + + /* void AdjustPopupsOnWindowChange (); */ + virtual void AdjustPopupsOnWindowChange(void) = 0; - // adjust the position of any open popups when the position or size of a - // window has been changed. - void AdjustPopupsOnWindowChange ( ); }; + + NS_DEFINE_STATIC_IID_ACCESSOR(nsIMenuRollup, NS_IMENUROLLUP_IID) + +#endif diff --git a/widget/src/beos/nsWindow.cpp b/widget/src/beos/nsWindow.cpp index 816095707da..e4d5936702e 100644 --- a/widget/src/beos/nsWindow.cpp +++ b/widget/src/beos/nsWindow.cpp @@ -885,28 +885,18 @@ nsWindow::DealWithPopups(uint32 methodID, nsPoint pos) nsCOMPtr menuRollup ( do_QueryInterface(gRollupListener) ); if ( menuRollup ) { - nsCOMPtr widgetChain; - menuRollup->GetSubmenuWidgetChain ( getter_AddRefs(widgetChain) ); - if ( widgetChain ) + nsAutoTArray widgetChain; + menuRollup->GetSubmenuWidgetChain(&widgetChain); + + for ( PRUint32 i = 0; i < widgetChain.Length(); ++i ) { - PRUint32 count = 0; - widgetChain->Count(&count); - for ( PRUint32 i = 0; i < count; ++i ) + nsIWidget* widget = widgetChain[i]; + if ( nsWindow::EventIsInsideWindow((nsWindow*)widget, pos) ) { - nsCOMPtr genericWidget; - widgetChain->GetElementAt ( i, getter_AddRefs(genericWidget) ); - nsCOMPtr widget ( do_QueryInterface(genericWidget) ); - if ( widget ) - { - nsIWidget* temp = widget.get(); - if ( nsWindow::EventIsInsideWindow((nsWindow*)temp, pos) ) - { - rollup = PR_FALSE; - break; - } - } - } // foreach parent menu widget - } // if widgetChain + rollup = PR_FALSE; + break; + } + } // foreach parent menu widget } // if rollup listener knows about menus } // if rollup diff --git a/widget/src/cocoa/nsChildView.mm b/widget/src/cocoa/nsChildView.mm index 99568372044..35d54a75917 100644 --- a/widget/src/cocoa/nsChildView.mm +++ b/widget/src/cocoa/nsChildView.mm @@ -2455,21 +2455,15 @@ NSEvent* gLastDragEvent = nil; nsCOMPtr menuRollup; menuRollup = (do_QueryInterface(gRollupListener)); if (menuRollup) { - nsCOMPtr widgetChain; - menuRollup->GetSubmenuWidgetChain(getter_AddRefs(widgetChain)); + nsAutoTArray widgetChain; + menuRollup->GetSubmenuWidgetChain(&widgetChain); if (widgetChain) { - PRUint32 count = 0; - widgetChain->Count(&count); - for (PRUint32 i = 0; i < count; i++) { - nsCOMPtr genericWidget; - widgetChain->GetElementAt(i, getter_AddRefs(genericWidget)); - nsCOMPtr widget(do_QueryInterface(genericWidget)); - if (widget) { - NSWindow* currWindow = (NSWindow*)widget->GetNativeData(NS_NATIVE_WINDOW); - if (nsCocoaUtils::IsEventOverWindow(theEvent, currWindow)) { - rollup = PR_FALSE; - break; - } + for (PRUint32 i = 0; i < widgetChain.Length(); i++) { + nsIWidget* widget = widgetChain[i]; + NSWindow* currWindow = (NSWindow*)widget->GetNativeData(NS_NATIVE_WINDOW); + if (nsCocoaUtils::IsEventOverWindow(theEvent, currWindow)) { + rollup = PR_FALSE; + break; } } // foreach parent menu widget } diff --git a/widget/src/gtk2/nsWindow.cpp b/widget/src/gtk2/nsWindow.cpp index 90c315638fc..35d9cee6ccc 100644 --- a/widget/src/gtk2/nsWindow.cpp +++ b/widget/src/gtk2/nsWindow.cpp @@ -4104,26 +4104,17 @@ check_for_rollup(GdkWindow *aWindow, gdouble aMouseX, gdouble aMouseY, nsCOMPtr menuRollup; menuRollup = (do_QueryInterface(gRollupListener)); if (menuRollup) { - nsCOMPtr widgetChain; - menuRollup->GetSubmenuWidgetChain(getter_AddRefs(widgetChain)); - if (widgetChain) { - PRUint32 count = 0; - widgetChain->Count(&count); - for (PRUint32 i=0; i genericWidget; - widgetChain->GetElementAt(i, - getter_AddRefs(genericWidget)); - nsCOMPtr widget(do_QueryInterface(genericWidget)); - if (widget) { - GdkWindow* currWindow = - (GdkWindow*) widget->GetNativeData(NS_NATIVE_WINDOW); - if (is_mouse_in_window(currWindow, aMouseX, aMouseY)) { - rollup = PR_FALSE; - break; - } - } - } // foreach parent menu widget - } + nsAutoTArray widgetChain; + menuRollup->GetSubmenuWidgetChain(&widgetChain); + for (PRUint32 i=0; iGetNativeData(NS_NATIVE_WINDOW); + if (is_mouse_in_window(currWindow, aMouseX, aMouseY)) { + rollup = PR_FALSE; + break; + } + } // foreach parent menu widget } // if rollup listener knows about menus // if we've determined that we should still rollup, do it. diff --git a/widget/src/os2/nsWindow.cpp b/widget/src/os2/nsWindow.cpp index b3280f94d44..ea16535852b 100644 --- a/widget/src/os2/nsWindow.cpp +++ b/widget/src/os2/nsWindow.cpp @@ -640,24 +640,15 @@ nsWindow :: DealWithPopups ( ULONG inMsg, MRESULT* outResult ) if (rollup) { nsCOMPtr menuRollup ( do_QueryInterface(gRollupListener) ); if ( menuRollup ) { - nsCOMPtr widgetChain; - menuRollup->GetSubmenuWidgetChain ( getter_AddRefs(widgetChain) ); - if ( widgetChain ) { - PRUint32 count = 0; - widgetChain->Count(&count); - for ( PRUint32 i = 0; i < count; ++i ) { - nsCOMPtr genericWidget; - widgetChain->GetElementAt ( i, getter_AddRefs(genericWidget) ); - nsCOMPtr widget ( do_QueryInterface(genericWidget) ); - if ( widget ) { - nsIWidget* temp = widget.get(); - if ( nsWindow::EventIsInsideWindow((nsWindow*)temp) ) { - rollup = PR_FALSE; - break; - } - } - } // foreach parent menu widget - } + nsAutoTArray widgetChain; + menuRollup->GetSubmenuWidgetChain ( &widgetChain ); + for ( PRUint32 i = 0; i < widgetChain.Length(); ++i ) { + nsIWidget* widget = widgetChain[i]; + if ( nsWindow::EventIsInsideWindow((nsWindow*)widget) ) { + rollup = PR_FALSE; + break; + } + } // foreach parent menu widget } // if rollup listener knows about menus } @@ -744,24 +735,15 @@ MRESULT EXPENTRY fnwpNSWindow( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) if (rollup) { nsCOMPtr menuRollup ( do_QueryInterface(gRollupListener) ); if ( menuRollup ) { - nsCOMPtr widgetChain; - menuRollup->GetSubmenuWidgetChain ( getter_AddRefs(widgetChain) ); - if ( widgetChain ) { - PRUint32 count = 0; - widgetChain->Count(&count); - for ( PRUint32 i = 0; i < count; ++i ) { - nsCOMPtr genericWidget; - widgetChain->GetElementAt ( i, getter_AddRefs(genericWidget) ); - nsCOMPtr widget ( do_QueryInterface(genericWidget) ); - if ( widget ) { - nsIWidget* temp = widget.get(); - if ( nsWindow::EventIsInsideWindow((nsWindow*)temp) ) { - rollup = PR_FALSE; - break; - } - } - } // foreach parent menu widget - } + nsAutoTArray widgetChain; + menuRollup->GetSubmenuWidgetChain ( &widgetChain ); + for ( PRUint32 i = 0; i < widgetChain.Length(); ++i ) { + nsIWidget* widget = widgetChain[i]; + if ( nsWindow::EventIsInsideWindow((nsWindow*)widget) ) { + rollup = PR_FALSE; + break; + } + } // foreach parent menu widget } // if rollup listener knows about menus } } diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 66f5b25e8a3..1b490b80e42 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -7724,24 +7724,15 @@ nsWindow :: DealWithPopups ( HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inL if (rollup) { nsCOMPtr menuRollup ( do_QueryInterface(gRollupListener) ); if ( menuRollup ) { - nsCOMPtr widgetChain; - menuRollup->GetSubmenuWidgetChain ( getter_AddRefs(widgetChain) ); - if ( widgetChain ) { - PRUint32 count = 0; - widgetChain->Count(&count); - for ( PRUint32 i = 0; i < count; ++i ) { - nsCOMPtr genericWidget; - widgetChain->GetElementAt ( i, getter_AddRefs(genericWidget) ); - nsCOMPtr widget ( do_QueryInterface(genericWidget) ); - if ( widget ) { - nsIWidget* temp = widget.get(); - if ( nsWindow::EventIsInsideWindow(inMsg, (nsWindow*)temp) ) { - rollup = PR_FALSE; - break; - } - } - } // foreach parent menu widget - } + nsAutoTArray widgetChain; + menuRollup->GetSubmenuWidgetChain ( &widgetChain ); + for ( PRUint32 i = 0; i < widgetChain.Length(); ++i ) { + nsIWidget* widget = widgetChain[i]; + if ( nsWindow::EventIsInsideWindow(inMsg, (nsWindow*)widget) ) { + rollup = PR_FALSE; + break; + } + } // foreach parent menu widget } // if rollup listener knows about menus }