Bug 696745, remove nsIMenuRollup and xul-popup-manager component, r=mats,sr=roc

This commit is contained in:
Neil Deakin
2011-11-08 14:59:07 -05:00
parent f5f42599ce
commit cc508ba376
29 changed files with 111 additions and 250 deletions

View File

@@ -115,10 +115,6 @@
#define NS_DOMSTORAGEMANAGER_CID \ #define NS_DOMSTORAGEMANAGER_CID \
{ 0xb88a4712, 0xeb52, 0x4c10, { 0x9b, 0x85, 0xbf, 0x58, 0x94, 0xb5, 0x10, 0xf0 } } { 0xb88a4712, 0xeb52, 0x4c10, { 0x9b, 0x85, 0xbf, 0x58, 0x94, 0xb5, 0x10, 0xf0 } }
// {14632191-AC21-4BDF-83E7-2363AD17E838}
#define NS_XULPOPUPMANAGER_CID \
{ 0x14632191, 0xac21, 0x4bdf, { 0x83, 0xe7, 0x23, 0x63, 0xad, 0x17, 0xe8, 0x38 } }
// {93ad72a6-02cd-4716-9626-d47d5ec275ec} // {93ad72a6-02cd-4716-9626-d47d5ec275ec}
#define NS_DOMJSON_CID \ #define NS_DOMJSON_CID \
{ 0x93ad72a6, 0x02cd, 0x4716, { 0x96, 0x26, 0xd4, 0x7d, 0x5e, 0xc2, 0x75, 0xec } } { 0x93ad72a6, 0x02cd, 0x4716, { 0x96, 0x26, 0xd4, 0x7d, 0x5e, 0xc2, 0x75, 0xec } }

View File

@@ -86,7 +86,6 @@
#include "nsIFrameTraversal.h" #include "nsIFrameTraversal.h"
#include "nsLayoutCID.h" #include "nsLayoutCID.h"
#include "nsStyleSheetService.h" #include "nsStyleSheetService.h"
#include "nsXULPopupManager.h"
#include "nsFocusManager.h" #include "nsFocusManager.h"
#include "ThirdPartyUtil.h" #include "ThirdPartyUtil.h"
#include "mozilla/Services.h" #include "mozilla/Services.h"
@@ -534,7 +533,6 @@ MAKE_CTOR(CreateXULSortService, nsIXULSortService, NS_NewXUL
// NS_NewXULTreeBuilder // NS_NewXULTreeBuilder
MAKE_CTOR(CreateXULDocument, nsIXULDocument, NS_NewXULDocument) MAKE_CTOR(CreateXULDocument, nsIXULDocument, NS_NewXULDocument)
// NS_NewXULControllers // NS_NewXULControllers
MAKE_CTOR(CreateXULPopupManager, nsISupports, NS_NewXULPopupManager)
#endif #endif
#ifdef MOZ_XTF #ifdef MOZ_XTF
MAKE_CTOR(CreateXTFService, nsIXTFService, NS_NewXTFService) MAKE_CTOR(CreateXTFService, nsIXTFService, NS_NewXTFService)
@@ -776,7 +774,6 @@ NS_DEFINE_NAMED_CID(NS_XULCONTROLLERS_CID);
NS_DEFINE_NAMED_CID(NS_XULSORTSERVICE_CID); NS_DEFINE_NAMED_CID(NS_XULSORTSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_XULTEMPLATEBUILDER_CID); NS_DEFINE_NAMED_CID(NS_XULTEMPLATEBUILDER_CID);
NS_DEFINE_NAMED_CID(NS_XULTREEBUILDER_CID); NS_DEFINE_NAMED_CID(NS_XULTREEBUILDER_CID);
NS_DEFINE_NAMED_CID(NS_XULPOPUPMANAGER_CID);
NS_DEFINE_NAMED_CID(NS_XULDOCUMENT_CID); NS_DEFINE_NAMED_CID(NS_XULDOCUMENT_CID);
#endif #endif
#ifdef MOZ_XTF #ifdef MOZ_XTF
@@ -909,7 +906,6 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
{ &kNS_XULSORTSERVICE_CID, false, NULL, CreateXULSortService }, { &kNS_XULSORTSERVICE_CID, false, NULL, CreateXULSortService },
{ &kNS_XULTEMPLATEBUILDER_CID, false, NULL, NS_NewXULContentBuilder }, { &kNS_XULTEMPLATEBUILDER_CID, false, NULL, NS_NewXULContentBuilder },
{ &kNS_XULTREEBUILDER_CID, false, NULL, NS_NewXULTreeBuilder }, { &kNS_XULTREEBUILDER_CID, false, NULL, NS_NewXULTreeBuilder },
{ &kNS_XULPOPUPMANAGER_CID, false, NULL, CreateXULPopupManager },
{ &kNS_XULDOCUMENT_CID, false, NULL, CreateXULDocument }, { &kNS_XULDOCUMENT_CID, false, NULL, CreateXULDocument },
#endif #endif
#ifdef MOZ_XTF #ifdef MOZ_XTF
@@ -1044,7 +1040,6 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = {
{ "@mozilla.org/xul/xul-sort-service;1", &kNS_XULSORTSERVICE_CID }, { "@mozilla.org/xul/xul-sort-service;1", &kNS_XULSORTSERVICE_CID },
{ "@mozilla.org/xul/xul-template-builder;1", &kNS_XULTEMPLATEBUILDER_CID }, { "@mozilla.org/xul/xul-template-builder;1", &kNS_XULTEMPLATEBUILDER_CID },
{ "@mozilla.org/xul/xul-tree-builder;1", &kNS_XULTREEBUILDER_CID }, { "@mozilla.org/xul/xul-tree-builder;1", &kNS_XULTREEBUILDER_CID },
{ "@mozilla.org/xul/xul-popup-manager;1", &kNS_XULPOPUPMANAGER_CID },
{ "@mozilla.org/xul/xul-document;1", &kNS_XULDOCUMENT_CID }, { "@mozilla.org/xul/xul-document;1", &kNS_XULDOCUMENT_CID },
#endif #endif
#ifdef MOZ_XTF #ifdef MOZ_XTF

View File

@@ -473,7 +473,7 @@ nsComboboxControlFrame::ShowList(bool aShowList)
if (view) { if (view) {
nsIWidget* widget = view->GetWidget(); nsIWidget* widget = view->GetWidget();
if (widget) { if (widget) {
widget->CaptureRollupEvents(this, nsnull, mDroppedDown, mDroppedDown); widget->CaptureRollupEvents(this, mDroppedDown, mDroppedDown);
if (!aShowList) { if (!aShowList) {
nsCOMPtr<nsIRunnable> widgetDestroyer = nsCOMPtr<nsIRunnable> widgetDestroyer =
@@ -1322,7 +1322,7 @@ nsComboboxControlFrame::DestroyFrom(nsIFrame* aDestructRoot)
if (view) { if (view) {
nsIWidget* widget = view->GetWidget(); nsIWidget* widget = view->GetWidget();
if (widget) if (widget)
widget->CaptureRollupEvents(this, nsnull, false, true); widget->CaptureRollupEvents(this, false, true);
} }
} }
} }
@@ -1375,24 +1375,21 @@ nsComboboxControlFrame::SetInitialChildList(ChildListID aListID,
//---------------------------------------------------------------------- //----------------------------------------------------------------------
//nsIRollupListener //nsIRollupListener
//---------------------------------------------------------------------- //----------------------------------------------------------------------
NS_IMETHODIMP nsIContent*
nsComboboxControlFrame::Rollup(PRUint32 aCount, nsComboboxControlFrame::Rollup(PRUint32 aCount, bool aGetLastRolledUp)
nsIContent** aLastRolledUp)
{ {
if (aLastRolledUp)
*aLastRolledUp = nsnull;
if (mDroppedDown) { if (mDroppedDown) {
nsWeakFrame weakFrame(this); nsWeakFrame weakFrame(this);
mListControlFrame->AboutToRollup(); // might destroy us mListControlFrame->AboutToRollup(); // might destroy us
if (!weakFrame.IsAlive()) if (!weakFrame.IsAlive())
return NS_OK; return nsnull;
ShowDropDown(false); // might destroy us ShowDropDown(false); // might destroy us
if (!weakFrame.IsAlive()) if (!weakFrame.IsAlive())
return NS_OK; return nsnull;
mListControlFrame->CaptureMouseEvents(false); mListControlFrame->CaptureMouseEvents(false);
} }
return NS_OK;
return nsnull;
} }
void void

View File

@@ -192,20 +192,24 @@ public:
* Hide the dropdown menu and stop capturing mouse events. * Hide the dropdown menu and stop capturing mouse events.
* @note This method might destroy |this|. * @note This method might destroy |this|.
*/ */
NS_IMETHOD Rollup(PRUint32 aCount, nsIContent** aLastRolledUp); virtual nsIContent* Rollup(PRUint32 aCount, bool aGetLastRolledUp = false);
/** /**
* A combobox should roll up if a mousewheel event happens outside of * A combobox should roll up if a mousewheel event happens outside of
* the popup area. * the popup area.
*/ */
NS_IMETHOD ShouldRollupOnMouseWheelEvent(bool *aShouldRollup) virtual bool ShouldRollupOnMouseWheelEvent()
{ *aShouldRollup = true; return NS_OK;} { return true; }
/** /**
* A combobox should not roll up if activated by a mouse activate message * A combobox should not roll up if activated by a mouse activate message
* (eg. X-mouse). * (eg. X-mouse).
*/ */
NS_IMETHOD ShouldRollupOnMouseActivate(bool *aShouldRollup) virtual bool ShouldRollupOnMouseActivate()
{ *aShouldRollup = false; return NS_OK;} { return false; }
virtual PRUint32 GetSubmenuWidgetChain(nsTArray<nsIWidget*> *aWidgetChain)
{ return 0; }
//nsIStatefulFrame //nsIStatefulFrame
NS_IMETHOD SaveState(SpecialStateID aStateID, nsPresState** aState); NS_IMETHOD SaveState(SpecialStateID aStateID, nsPresState** aState);

View File

@@ -45,7 +45,6 @@
#include "nsGUIEvent.h" #include "nsGUIEvent.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsIRollupListener.h" #include "nsIRollupListener.h"
#include "nsIMenuRollup.h"
#include "nsIDOMEventListener.h" #include "nsIDOMEventListener.h"
#include "nsPoint.h" #include "nsPoint.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
@@ -302,7 +301,6 @@ private:
}; };
class nsXULPopupManager : public nsIDOMEventListener, class nsXULPopupManager : public nsIDOMEventListener,
public nsIMenuRollup,
public nsIRollupListener, public nsIRollupListener,
public nsITimerCallback, public nsITimerCallback,
public nsIObserver public nsIObserver
@@ -319,12 +317,10 @@ public:
NS_DECL_NSIDOMEVENTLISTENER NS_DECL_NSIDOMEVENTLISTENER
// nsIRollupListener // nsIRollupListener
NS_IMETHOD Rollup(PRUint32 aCount, nsIContent **aContent); virtual nsIContent* Rollup(PRUint32 aCount, bool aGetLastRolledUp = false);
NS_IMETHOD ShouldRollupOnMouseWheelEvent(bool *aShould); virtual bool ShouldRollupOnMouseWheelEvent();
NS_IMETHOD ShouldRollupOnMouseActivate(bool *aShould); virtual bool ShouldRollupOnMouseActivate();
virtual PRUint32 GetSubmenuWidgetChain(nsTArray<nsIWidget*> *aWidgetChain); virtual PRUint32 GetSubmenuWidgetChain(nsTArray<nsIWidget*> *aWidgetChain);
virtual void AdjustPopupsOnWindowChange(nsPIDOMWindow* aWindow);
static nsXULPopupManager* sInstance; static nsXULPopupManager* sInstance;
@@ -336,6 +332,8 @@ public:
// if a popup manager could not be allocated // if a popup manager could not be allocated
static nsXULPopupManager* GetInstance(); static nsXULPopupManager* GetInstance();
void AdjustPopupsOnWindowChange(nsPIDOMWindow* aWindow);
// get the frame for a content node aContent if the frame's type // get the frame for a content node aContent if the frame's type
// matches aFrameType. Otherwise, return null. If aShouldFlush is true, // matches aFrameType. Otherwise, return null. If aShouldFlush is true,
// then the frames are flushed before retrieving the frame. // then the frames are flushed before retrieving the frame.
@@ -790,7 +788,4 @@ protected:
nsCOMPtr<nsIContent> mOpeningPopup; nsCOMPtr<nsIContent> mOpeningPopup;
}; };
nsresult
NS_NewXULPopupManager(nsISupports** aResult);
#endif #endif

View File

@@ -137,9 +137,8 @@ void nsMenuChainItem::Detach(nsMenuChainItem** aRoot)
} }
} }
NS_IMPL_ISUPPORTS4(nsXULPopupManager, NS_IMPL_ISUPPORTS3(nsXULPopupManager,
nsIDOMEventListener, nsIDOMEventListener,
nsIMenuRollup,
nsITimerCallback, nsITimerCallback,
nsIObserver) nsIObserver)
@@ -207,15 +206,14 @@ nsXULPopupManager::GetInstance()
return sInstance; return sInstance;
} }
NS_IMETHODIMP nsIContent*
nsXULPopupManager::Rollup(PRUint32 aCount, nsIContent** aLastRolledUp) nsXULPopupManager::Rollup(PRUint32 aCount, bool aGetLastRolledUp)
{ {
if (aLastRolledUp) nsIContent* lastRolledUpPopup = nsnull;
*aLastRolledUp = nsnull;
nsMenuChainItem* item = GetTopVisibleMenu(); nsMenuChainItem* item = GetTopVisibleMenu();
if (item) { if (item) {
if (aLastRolledUp) { if (aGetLastRolledUp) {
// we need to get the popup that will be closed last, so that // we need to get the popup that will be closed last, so that
// widget can keep track of it so it doesn't reopen if a mouse // widget can keep track of it so it doesn't reopen if a mouse
// down event is going to processed. // down event is going to processed.
@@ -227,7 +225,7 @@ nsXULPopupManager::Rollup(PRUint32 aCount, nsIContent** aLastRolledUp)
nsMenuChainItem* first = item; nsMenuChainItem* first = item;
while (first->GetParent()) while (first->GetParent())
first = first->GetParent(); first = first->GetParent();
NS_ADDREF(*aLastRolledUp = first->Content()); lastRolledUpPopup = first->Content();
} }
// if a number of popups to close has been specified, determine the last // if a number of popups to close has been specified, determine the last
@@ -245,35 +243,33 @@ nsXULPopupManager::Rollup(PRUint32 aCount, nsIContent** aLastRolledUp)
HidePopup(item->Content(), true, true, false, lastPopup); HidePopup(item->Content(), true, true, false, lastPopup);
} }
return NS_OK;
return lastRolledUpPopup;
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP nsXULPopupManager::ShouldRollupOnMouseWheelEvent(bool *aShouldRollup) bool nsXULPopupManager::ShouldRollupOnMouseWheelEvent()
{ {
// should rollup only for autocomplete widgets // should rollup only for autocomplete widgets
// XXXndeakin this should really be something the popup has more control over // XXXndeakin this should really be something the popup has more control over
*aShouldRollup = false;
nsMenuChainItem* item = GetTopVisibleMenu(); nsMenuChainItem* item = GetTopVisibleMenu();
if (!item) if (!item)
return NS_OK; return false;
nsIContent* content = item->Frame()->GetContent(); nsIContent* content = item->Frame()->GetContent();
if (content) { if (!content)
nsAutoString value; return false;
content->GetAttr(kNameSpaceID_None, nsGkAtoms::type, value);
*aShouldRollup = StringBeginsWith(value, NS_LITERAL_STRING("autocomplete"));
}
return NS_OK; nsAutoString value;
content->GetAttr(kNameSpaceID_None, nsGkAtoms::type, value);
return StringBeginsWith(value, NS_LITERAL_STRING("autocomplete"));
} }
// a menu should not roll up if activated by a mouse activate message (eg. X-mouse) // a menu should not roll up if activated by a mouse activate message (eg. X-mouse)
NS_IMETHODIMP nsXULPopupManager::ShouldRollupOnMouseActivate(bool *aShouldRollup) bool nsXULPopupManager::ShouldRollupOnMouseActivate()
{ {
*aShouldRollup = false; return false;
return NS_OK;
} }
PRUint32 PRUint32
@@ -1620,7 +1616,7 @@ nsXULPopupManager::SetCaptureState(nsIContent* aOldPopup)
return; return;
if (mWidget) { if (mWidget) {
mWidget->CaptureRollupEvents(this, this, false, false); mWidget->CaptureRollupEvents(this, false, false);
mWidget = nsnull; mWidget = nsnull;
} }
@@ -1629,8 +1625,7 @@ nsXULPopupManager::SetCaptureState(nsIContent* aOldPopup)
nsCOMPtr<nsIWidget> widget; nsCOMPtr<nsIWidget> widget;
popup->GetWidget(getter_AddRefs(widget)); popup->GetWidget(getter_AddRefs(widget));
if (widget) { if (widget) {
widget->CaptureRollupEvents(this, this, true, widget->CaptureRollupEvents(this, true, popup->ConsumeOutsideClicks());
popup->ConsumeOutsideClicks());
mWidget = widget; mWidget = widget;
popup->AttachedDismissalListener(); popup->AttachedDismissalListener();
} }
@@ -2182,7 +2177,7 @@ nsXULPopupManager::KeyDown(nsIDOMKeyEvent* aKeyEvent)
// The access key just went down and no other // The access key just went down and no other
// modifiers are already down. // modifiers are already down.
if (mPopups) if (mPopups)
Rollup(nsnull, nsnull); Rollup(0);
else if (mActiveMenuBar) else if (mActiveMenuBar)
mActiveMenuBar->MenuClosed(); mActiveMenuBar->MenuClosed();
} }
@@ -2261,7 +2256,7 @@ nsXULPopupManager::KeyPress(nsIDOMKeyEvent* aKeyEvent)
) { ) {
// close popups or deactivate menubar when Tab or F10 are pressed // close popups or deactivate menubar when Tab or F10 are pressed
if (item) if (item)
Rollup(nsnull, nsnull); Rollup(0);
else if (mActiveMenuBar) else if (mActiveMenuBar)
mActiveMenuBar->MenuClosed(); mActiveMenuBar->MenuClosed();
} }
@@ -2381,12 +2376,3 @@ nsXULMenuCommandEvent::Run()
return NS_OK; return NS_OK;
} }
nsresult
NS_NewXULPopupManager(nsISupports** aResult)
{
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
NS_IF_ADDREF(pm);
*aResult = static_cast<nsIMenuRollup *>(pm);
return NS_OK;
}

View File

@@ -74,7 +74,6 @@ EXPORTS = \
nsIPluginWidget.h \ nsIPluginWidget.h \
nsINativeKeyBindings.h \ nsINativeKeyBindings.h \
nsIDeviceContextSpec.h \ nsIDeviceContextSpec.h \
nsIMenuRollup.h \
nsIRollupListener.h \ nsIRollupListener.h \
$(NULL) $(NULL)

View File

@@ -1,76 +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 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
* 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 nsIMenuRollup_h___
#define nsIMenuRollup_h___
#include "nsISupports.h"
#include "nsTArray.h"
class nsIWidget;
class nsIContent;
class nsPIDOMWindow;
#define NS_IMENUROLLUP_IID \
{0xa707b588, 0xa564, 0x488d, \
{ 0x87, 0xb6, 0xdb, 0x71, 0x2d, 0x78, 0x9d, 0x4c }}
class nsIMenuRollup : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IMENUROLLUP_IID)
/*
* Retrieve the widgets for open menus are store them in the array
* aWidgetChain. The number of menus of the same type should be returned,
* for example, if a context menu is open, return only the number of menus
* that are part of the context menu chain. This allows closing up only
* those menus in different situations.
*/
virtual PRUint32 GetSubmenuWidgetChain(nsTArray<nsIWidget*> *aWidgetChain) = 0;
/**
* Adjust the position of open panels when a window is moved or resized.
*/
virtual void AdjustPopupsOnWindowChange(nsPIDOMWindow* aWindow) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIMenuRollup, NS_IMENUROLLUP_IID)
#endif

View File

@@ -42,7 +42,10 @@
#ifndef __nsIRollupListener_h__ #ifndef __nsIRollupListener_h__
#define __nsIRollupListener_h__ #define __nsIRollupListener_h__
#include "nsTArray.h"
class nsIContent; class nsIContent;
class nsIWidget;
class nsIRollupListener { class nsIRollupListener {
public: public:
@@ -53,19 +56,30 @@ class nsIRollupListener {
* *
* aCount is the number of popups in a chain to close. If this is * aCount is the number of popups in a chain to close. If this is
* PR_UINT32_MAX, then all popups are closed. * PR_UINT32_MAX, then all popups are closed.
* If aGetLastRolledUp is true, then return the last rolled up popup,
* if this is supported.
*/ */
NS_IMETHOD Rollup(PRUint32 aCount, nsIContent **aContent) = 0; virtual nsIContent* Rollup(PRUint32 aCount, bool aGetLastRolledUp = false) = 0;
/** /**
* Asks the RollupListener if it should rollup on mousevents * Asks the RollupListener if it should rollup on mousevents
*/ */
NS_IMETHOD ShouldRollupOnMouseWheelEvent(bool *aShould) = 0; virtual bool ShouldRollupOnMouseWheelEvent() = 0;
/** /**
* Asks the RollupListener if it should rollup on mouse activate, eg. X-Mouse * Asks the RollupListener if it should rollup on mouse activate, eg. X-Mouse
*/ */
NS_IMETHOD ShouldRollupOnMouseActivate(bool *aShould) = 0; virtual bool ShouldRollupOnMouseActivate() = 0;
/*
* Retrieve the widgets for open menus and store them in the array
* aWidgetChain. The number of menus of the same type should be returned,
* for example, if a context menu is open, return only the number of menus
* that are part of the context menu chain. This allows closing up only
* those menus in different situations. The returned value should be exactly
* the same number of widgets added to aWidgetChain.
*/
virtual PRUint32 GetSubmenuWidgetChain(nsTArray<nsIWidget*> *aWidgetChain) = 0;
}; };
#endif /* __nsIRollupListener_h__ */ #endif /* __nsIRollupListener_h__ */

View File

@@ -62,7 +62,6 @@ class nsRenderingContext;
class nsDeviceContext; class nsDeviceContext;
struct nsFont; struct nsFont;
class nsIRollupListener; class nsIRollupListener;
class nsIMenuRollup;
class nsGUIEvent; class nsGUIEvent;
class imgIContainer; class imgIContainer;
class gfxASurface; class gfxASurface;
@@ -119,8 +118,8 @@ typedef nsEventStatus (* EVENT_CALLBACK)(nsGUIEvent *event);
#endif #endif
#define NS_IWIDGET_IID \ #define NS_IWIDGET_IID \
{ 0x712b07a4, 0x4344, 0x4404, \ { 0x32966f95, 0x89e0, 0x447a, \
{ 0xaf, 0x85, 0x63, 0x3d, 0x68, 0x0b, 0x21, 0xb0 } } { 0x91, 0x8d, 0x58, 0x53, 0xd6, 0x99, 0x4a, 0x72 } }
/* /*
* Window shadow styles * Window shadow styles
@@ -1028,8 +1027,8 @@ class nsIWidget : public nsISupports {
* @param aConsumeRollupEvent true consumes the rollup event, false dispatches rollup event * @param aConsumeRollupEvent true consumes the rollup event, false dispatches rollup event
* *
*/ */
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, nsIMenuRollup * aMenuRollup, NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, bool aDoCapture,
bool aDoCapture, bool aConsumeRollupEvent) = 0; bool aConsumeRollupEvent) = 0;
/** /**
* Bring this window to the user's attention. This is intended to be a more * Bring this window to the user's attention. This is intended to be a more

View File

@@ -144,7 +144,6 @@ public:
NS_IMETHOD EnableDragDrop(bool aEnable) { return NS_OK; } NS_IMETHOD EnableDragDrop(bool aEnable) { return NS_OK; }
NS_IMETHOD CaptureMouse(bool aCapture) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD CaptureMouse(bool aCapture) { return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener, NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
nsIMenuRollup *aMenuRollup,
bool aDoCapture, bool aDoCapture,
bool aConsumeRollupEvent) { return NS_ERROR_NOT_IMPLEMENTED; } bool aConsumeRollupEvent) { return NS_ERROR_NOT_IMPLEMENTED; }

View File

@@ -979,7 +979,7 @@ nsAppShell::AfterProcessNextEvent(nsIThreadInternal *aThread,
NSString *sender = [aNotification object]; NSString *sender = [aNotification object];
if (!sender || ![sender isEqualToString:@"org.mozilla.gecko.PopupWindow"]) { if (!sender || ![sender isEqualToString:@"org.mozilla.gecko.PopupWindow"]) {
if (gRollupListener && gRollupWidget) if (gRollupListener && gRollupWidget)
gRollupListener->Rollup(nsnull, nsnull); gRollupListener->Rollup(0);
} }
NS_OBJC_END_TRY_ABORT_BLOCK; NS_OBJC_END_TRY_ABORT_BLOCK;

View File

@@ -435,8 +435,7 @@ public:
NS_IMETHOD SetCursor(nsCursor aCursor); NS_IMETHOD SetCursor(nsCursor aCursor);
NS_IMETHOD SetCursor(imgIContainer* aCursor, PRUint32 aHotspotX, PRUint32 aHotspotY); NS_IMETHOD SetCursor(imgIContainer* aCursor, PRUint32 aHotspotX, PRUint32 aHotspotY);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, nsIMenuRollup * aMenuRollup, NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, bool aDoCapture, bool aConsumeRollupEvent);
bool aDoCapture, bool aConsumeRollupEvent);
NS_IMETHOD SetTitle(const nsAString& title); NS_IMETHOD SetTitle(const nsAString& title);
NS_IMETHOD GetAttention(PRInt32 aCycleCount); NS_IMETHOD GetAttention(PRInt32 aCycleCount);

View File

@@ -66,7 +66,6 @@
#include "nsILocalFile.h" #include "nsILocalFile.h"
#include "nsILocalFileMac.h" #include "nsILocalFileMac.h"
#include "nsGfxCIID.h" #include "nsGfxCIID.h"
#include "nsIMenuRollup.h"
#include "nsIDOMSimpleGestureEvent.h" #include "nsIDOMSimpleGestureEvent.h"
#include "nsNPAPIPluginInstance.h" #include "nsNPAPIPluginInstance.h"
#include "nsThemeConstants.h" #include "nsThemeConstants.h"
@@ -139,7 +138,6 @@ static void blinkRgn(RgnHandle rgn);
#endif #endif
nsIRollupListener * gRollupListener = nsnull; nsIRollupListener * gRollupListener = nsnull;
nsIMenuRollup * gMenuRollup = nsnull;
nsIWidget * gRollupWidget = nsnull; nsIWidget * gRollupWidget = nsnull;
bool gUserCancelledDrag = false; bool gUserCancelledDrag = false;
@@ -1587,7 +1585,6 @@ nsIntPoint nsChildView::WidgetToScreenOffset()
} }
NS_IMETHODIMP nsChildView::CaptureRollupEvents(nsIRollupListener * aListener, NS_IMETHODIMP nsChildView::CaptureRollupEvents(nsIRollupListener * aListener,
nsIMenuRollup * aMenuRollup,
bool aDoCapture, bool aDoCapture,
bool aConsumeRollupEvent) bool aConsumeRollupEvent)
{ {
@@ -2759,7 +2756,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
// check to see if scroll events should roll up the popup // check to see if scroll events should roll up the popup
if ([theEvent type] == NSScrollWheel) { if ([theEvent type] == NSScrollWheel) {
gRollupListener->ShouldRollupOnMouseWheelEvent(&shouldRollup); shouldRollup = gRollupListener->ShouldRollupOnMouseWheelEvent();
// always consume scroll events that aren't over the popup // always consume scroll events that aren't over the popup
consumeEvent = YES; consumeEvent = YES;
} }
@@ -2768,10 +2765,10 @@ NSEvent* gLastDragMouseDownEvent = nil;
// we don't want to rollup if the click is in a parent menu of // we don't want to rollup if the click is in a parent menu of
// the current submenu // the current submenu
PRUint32 popupsToRollup = PR_UINT32_MAX; PRUint32 popupsToRollup = PR_UINT32_MAX;
if (gMenuRollup) { if (gRollupListener) {
nsAutoTArray<nsIWidget*, 5> widgetChain; nsAutoTArray<nsIWidget*, 5> widgetChain;
gMenuRollup->GetSubmenuWidgetChain(&widgetChain); gRollupListener->GetSubmenuWidgetChain(&widgetChain);
PRUint32 sameTypeCount = gMenuRollup->GetSubmenuWidgetChain(&widgetChain); PRUint32 sameTypeCount = gRollupListener->GetSubmenuWidgetChain(&widgetChain);
for (PRUint32 i = 0; i < widgetChain.Length(); i++) { for (PRUint32 i = 0; i < widgetChain.Length(); i++) {
nsIWidget* widget = widgetChain[i]; nsIWidget* widget = widgetChain[i];
NSWindow* currWindow = (NSWindow*)widget->GetNativeData(NS_NATIVE_WINDOW); NSWindow* currWindow = (NSWindow*)widget->GetNativeData(NS_NATIVE_WINDOW);
@@ -2792,7 +2789,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
} }
if (shouldRollup) { if (shouldRollup) {
gRollupListener->Rollup(popupsToRollup, nsnull); gRollupListener->Rollup(popupsToRollup);
consumeEvent = (BOOL)gConsumeRollupEvent; consumeEvent = (BOOL)gConsumeRollupEvent;
} }
} }

View File

@@ -260,8 +260,7 @@ public:
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT, LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
bool* aAllowRetaining = nsnull); bool* aAllowRetaining = nsnull);
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus) ; NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus) ;
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, nsIMenuRollup * aMenuRollup, NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, bool aDoCapture, bool aConsumeRollupEvent);
bool aDoCapture, bool aConsumeRollupEvent);
NS_IMETHOD GetAttention(PRInt32 aCycleCount); NS_IMETHOD GetAttention(PRInt32 aCycleCount);
virtual bool HasPendingInputEvent(); virtual bool HasPendingInputEvent();
virtual nsTransparencyMode GetTransparencyMode(); virtual nsTransparencyMode GetTransparencyMode();

View File

@@ -61,7 +61,6 @@
#include "nsStyleConsts.h" #include "nsStyleConsts.h"
#include "nsNativeThemeColors.h" #include "nsNativeThemeColors.h"
#include "nsChildView.h" #include "nsChildView.h"
#include "nsIMenuRollup.h"
#include "gfxPlatform.h" #include "gfxPlatform.h"
#include "qcms.h" #include "qcms.h"
@@ -95,7 +94,6 @@ extern NSMenu* sApplicationMenu; // Application menu shared by all menubars
// defined in nsChildView.mm // defined in nsChildView.mm
extern nsIRollupListener * gRollupListener; extern nsIRollupListener * gRollupListener;
extern nsIMenuRollup * gMenuRollup;
extern nsIWidget * gRollupWidget; extern nsIWidget * gRollupWidget;
extern BOOL gSomeMenuBarPainted; extern BOOL gSomeMenuBarPainted;
@@ -126,7 +124,7 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsCocoaWindow, Inherited, nsPIWidgetCocoa)
static void RollUpPopups() static void RollUpPopups()
{ {
if (gRollupListener && gRollupWidget) if (gRollupListener && gRollupWidget)
gRollupListener->Rollup(nsnull, nsnull); gRollupListener->Rollup(0);
} }
nsCocoaWindow::nsCocoaWindow() nsCocoaWindow::nsCocoaWindow()
@@ -1486,22 +1484,17 @@ nsMenuBarX* nsCocoaWindow::GetMenuBar()
return mMenuBar; return mMenuBar;
} }
NS_IMETHODIMP nsCocoaWindow::CaptureRollupEvents(nsIRollupListener * aListener, NS_IMETHODIMP nsCocoaWindow::CaptureRollupEvents(nsIRollupListener * aListener,
nsIMenuRollup * aMenuRollup, bool aDoCapture,
bool aDoCapture,
bool aConsumeRollupEvent) bool aConsumeRollupEvent)
{ {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
gRollupListener = nsnull; gRollupListener = nsnull;
NS_IF_RELEASE(gMenuRollup);
NS_IF_RELEASE(gRollupWidget); NS_IF_RELEASE(gRollupWidget);
if (aDoCapture) { if (aDoCapture) {
gRollupListener = aListener; gRollupListener = aListener;
NS_IF_RELEASE(gMenuRollup);
gMenuRollup = aMenuRollup;
NS_IF_ADDREF(aMenuRollup);
gRollupWidget = this; gRollupWidget = this;
NS_ADDREF(this); NS_ADDREF(this);

View File

@@ -913,7 +913,7 @@ nsresult nsMenuX::SetupIcon()
return; return;
if (gRollupListener && gRollupWidget) { if (gRollupListener && gRollupWidget) {
gRollupListener->Rollup(nsnull, nsnull); gRollupListener->Rollup(0);
[menu cancelTracking]; [menu cancelTracking];
return; return;
} }

View File

@@ -218,7 +218,7 @@ static CGEventRef EventTapCallback(CGEventTapProxy proxy, CGEventType type, CGEv
// so would break the corresponding context menu). // so would break the corresponding context menu).
if (NSPointInRect(screenLocation, [ctxMenuWindow frame])) if (NSPointInRect(screenLocation, [ctxMenuWindow frame]))
return event; return event;
gRollupListener->Rollup(nsnull, nsnull); gRollupListener->Rollup(0);
return event; return event;
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NULL); NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NULL);

View File

@@ -51,7 +51,6 @@
#include "nsWindow.h" #include "nsWindow.h"
#include "nsGTKToolkit.h" #include "nsGTKToolkit.h"
#include "nsIRollupListener.h" #include "nsIRollupListener.h"
#include "nsIMenuRollup.h"
#include "nsIDOMNode.h" #include "nsIDOMNode.h"
#include "nsWidgetsCID.h" #include "nsWidgetsCID.h"
@@ -332,7 +331,6 @@ static bool gRaiseWindows = true;
static nsWindow *gPluginFocusWindow = NULL; static nsWindow *gPluginFocusWindow = NULL;
static nsIRollupListener* gRollupListener; static nsIRollupListener* gRollupListener;
static nsIMenuRollup* gMenuRollup;
static nsWeakPtr gRollupWindow; static nsWeakPtr gRollupWindow;
static bool gConsumeRollupEvent; static bool gConsumeRollupEvent;
@@ -772,8 +770,7 @@ nsWindow::Destroy(void)
nsCOMPtr<nsIWidget> rollupWidget = do_QueryReferent(gRollupWindow); nsCOMPtr<nsIWidget> rollupWidget = do_QueryReferent(gRollupWindow);
if (static_cast<nsIWidget *>(this) == rollupWidget.get()) { if (static_cast<nsIWidget *>(this) == rollupWidget.get()) {
if (gRollupListener) if (gRollupListener)
gRollupListener->Rollup(nsnull, nsnull); gRollupListener->Rollup(0);
NS_IF_RELEASE(gMenuRollup);
gRollupWindow = nsnull; gRollupWindow = nsnull;
gRollupListener = nsnull; gRollupListener = nsnull;
} }
@@ -1867,7 +1864,6 @@ nsWindow::CaptureMouse(bool aCapture)
NS_IMETHODIMP NS_IMETHODIMP
nsWindow::CaptureRollupEvents(nsIRollupListener *aListener, nsWindow::CaptureRollupEvents(nsIRollupListener *aListener,
nsIMenuRollup *aMenuRollup,
bool aDoCapture, bool aDoCapture,
bool aConsumeRollupEvent) bool aConsumeRollupEvent)
{ {
@@ -1883,9 +1879,6 @@ nsWindow::CaptureRollupEvents(nsIRollupListener *aListener,
if (aDoCapture) { if (aDoCapture) {
gConsumeRollupEvent = aConsumeRollupEvent; gConsumeRollupEvent = aConsumeRollupEvent;
gRollupListener = aListener; gRollupListener = aListener;
NS_IF_RELEASE(gMenuRollup);
gMenuRollup = aMenuRollup;
NS_IF_ADDREF(aMenuRollup);
gRollupWindow = do_GetWeakReference(static_cast<nsIWidget*> gRollupWindow = do_GetWeakReference(static_cast<nsIWidget*>
(this)); (this));
// real grab is only done when there is no dragging // real grab is only done when there is no dragging
@@ -1903,7 +1896,6 @@ nsWindow::CaptureRollupEvents(nsIRollupListener *aListener,
// was not added to this widget. // was not added to this widget.
gtk_grab_remove(widget); gtk_grab_remove(widget);
gRollupListener = nsnull; gRollupListener = nsnull;
NS_IF_RELEASE(gMenuRollup);
gRollupWindow = nsnull; gRollupWindow = nsnull;
} }
@@ -5357,16 +5349,16 @@ check_for_rollup(GdkWindow *aWindow, gdouble aMouseX, gdouble aMouseY,
if (aAlwaysRollup || !is_mouse_in_window(currentPopup, aMouseX, aMouseY)) { if (aAlwaysRollup || !is_mouse_in_window(currentPopup, aMouseX, aMouseY)) {
bool rollup = true; bool rollup = true;
if (aIsWheel) { if (aIsWheel) {
gRollupListener->ShouldRollupOnMouseWheelEvent(&rollup); rollup = gRollupListener->ShouldRollupOnMouseWheelEvent();
retVal = true; retVal = true;
} }
// if we're dealing with menus, we probably have submenus and // if we're dealing with menus, we probably have submenus and
// we don't want to rollup if the click is in a parent menu of // we don't want to rollup if the click is in a parent menu of
// the current submenu // the current submenu
PRUint32 popupsToRollup = PR_UINT32_MAX; PRUint32 popupsToRollup = PR_UINT32_MAX;
if (gMenuRollup && !aAlwaysRollup) { if (!aAlwaysRollup) {
nsAutoTArray<nsIWidget*, 5> widgetChain; nsAutoTArray<nsIWidget*, 5> widgetChain;
PRUint32 sameTypeCount = gMenuRollup->GetSubmenuWidgetChain(&widgetChain); PRUint32 sameTypeCount = gRollupListener->GetSubmenuWidgetChain(&widgetChain);
for (PRUint32 i=0; i<widgetChain.Length(); ++i) { for (PRUint32 i=0; i<widgetChain.Length(); ++i) {
nsIWidget* widget = widgetChain[i]; nsIWidget* widget = widgetChain[i];
GdkWindow* currWindow = GdkWindow* currWindow =
@@ -5390,7 +5382,7 @@ check_for_rollup(GdkWindow *aWindow, gdouble aMouseX, gdouble aMouseY,
// if we've determined that we should still rollup, do it. // if we've determined that we should still rollup, do it.
if (rollup) { if (rollup) {
gRollupListener->Rollup(popupsToRollup, nsnull); gRollupListener->Rollup(popupsToRollup);
if (popupsToRollup == PR_UINT32_MAX) { if (popupsToRollup == PR_UINT32_MAX) {
retVal = true; retVal = true;
} }
@@ -5399,7 +5391,6 @@ check_for_rollup(GdkWindow *aWindow, gdouble aMouseX, gdouble aMouseY,
} else { } else {
gRollupWindow = nsnull; gRollupWindow = nsnull;
gRollupListener = nsnull; gRollupListener = nsnull;
NS_IF_RELEASE(gMenuRollup);
} }
return retVal; return retVal;

View File

@@ -186,7 +186,6 @@ public:
NS_IMETHOD EnableDragDrop(bool aEnable); NS_IMETHOD EnableDragDrop(bool aEnable);
NS_IMETHOD CaptureMouse(bool aCapture); NS_IMETHOD CaptureMouse(bool aCapture);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener, NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
nsIMenuRollup *aMenuRollup,
bool aDoCapture, bool aDoCapture,
bool aConsumeRollupEvent); bool aConsumeRollupEvent);
NS_IMETHOD GetAttention(PRInt32 aCycleCount); NS_IMETHOD GetAttention(PRInt32 aCycleCount);

View File

@@ -74,7 +74,6 @@
#include "nsDragService.h" #include "nsDragService.h"
#include "nsGfxCIID.h" #include "nsGfxCIID.h"
#include "nsHashKeys.h" #include "nsHashKeys.h"
#include "nsIMenuRollup.h"
#include "nsIRollupListener.h" #include "nsIRollupListener.h"
#include "nsIScreenManager.h" #include "nsIScreenManager.h"
#include "nsOS2Uni.h" #include "nsOS2Uni.h"
@@ -184,7 +183,6 @@ using namespace mozilla;
// Rollup Listener - used by nsWindow & os2FrameWindow // Rollup Listener - used by nsWindow & os2FrameWindow
nsIRollupListener* gRollupListener = 0; nsIRollupListener* gRollupListener = 0;
nsIMenuRollup* gMenuRollup = 0;
nsIWidget* gRollupWidget = 0; nsIWidget* gRollupWidget = 0;
bool gRollupConsumeRollupEvent = false; bool gRollupConsumeRollupEvent = false;
@@ -486,9 +484,9 @@ NS_METHOD nsWindow::Destroy()
// the rollup widget, rollup and turn off capture. // the rollup widget, rollup and turn off capture.
if (this == gRollupWidget) { if (this == gRollupWidget) {
if (gRollupListener) { if (gRollupListener) {
gRollupListener->Rollup(PR_UINT32_MAX, nsnull); gRollupListener->Rollup(PR_UINT32_MAX);
} }
CaptureRollupEvents(nsnull, nsnull, false, true); CaptureRollupEvents(nsnull, false, true);
} }
HWND hMain = GetMainWindow(); HWND hMain = GetMainWindow();
@@ -1536,7 +1534,6 @@ HBITMAP nsWindow::CreateTransparencyMask(gfxASurface::gfxImageFormat format,
//============================================================================= //=============================================================================
NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener* aListener, NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener* aListener,
nsIMenuRollup* aMenuRollup,
bool aDoCapture, bool aDoCapture,
bool aConsumeRollupEvent) bool aConsumeRollupEvent)
{ {
@@ -1548,14 +1545,10 @@ NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener* aListener,
gRollupConsumeRollupEvent = aConsumeRollupEvent; gRollupConsumeRollupEvent = aConsumeRollupEvent;
NS_IF_RELEASE(gRollupWidget); NS_IF_RELEASE(gRollupWidget);
gRollupListener = aListener; gRollupListener = aListener;
NS_IF_RELEASE(gMenuRollup);
gMenuRollup = aMenuRollup;
NS_IF_ADDREF(aMenuRollup);
gRollupWidget = this; gRollupWidget = this;
NS_ADDREF(this); NS_ADDREF(this);
} else { } else {
gRollupListener = nsnull; gRollupListener = nsnull;
NS_IF_RELEASE(gMenuRollup);
NS_IF_RELEASE(gRollupWidget); NS_IF_RELEASE(gRollupWidget);
} }
@@ -1599,9 +1592,9 @@ bool nsWindow::RollupOnButtonDown(ULONG aMsg)
// event was inside a parent of the current submenu. // event was inside a parent of the current submenu.
PRUint32 popupsToRollup = PR_UINT32_MAX; PRUint32 popupsToRollup = PR_UINT32_MAX;
if (gMenuRollup) { if (gRollupListener) {
nsAutoTArray<nsIWidget*, 5> widgetChain; nsAutoTArray<nsIWidget*, 5> widgetChain;
PRUint32 sameTypeCount = gMenuRollup->GetSubmenuWidgetChain(&widgetChain); PRUint32 sameTypeCount = gRollupListener->GetSubmenuWidgetChain(&widgetChain);
for (PRUint32 i = 0; i < widgetChain.Length(); ++i) { for (PRUint32 i = 0; i < widgetChain.Length(); ++i) {
nsIWidget* widget = widgetChain[i]; nsIWidget* widget = widgetChain[i];
if (EventIsInsideWindow((nsWindow*)widget)) { if (EventIsInsideWindow((nsWindow*)widget)) {
@@ -1615,8 +1608,9 @@ bool nsWindow::RollupOnButtonDown(ULONG aMsg)
} // if rollup listener knows about menus } // if rollup listener knows about menus
// We only need to deal with the last rollup for left mouse down events. // We only need to deal with the last rollup for left mouse down events.
gRollupListener->Rollup(popupsToRollup, NS_ASSERTION(!mLastRollup, "mLastRollup is null");
aMsg == WM_BUTTON1DOWN ? &mLastRollup : nsnull); mLastRollup = gRollupListener->Rollup(popupsToRollup, aMsg == WM_BUTTON1DOWN);
NS_IF_ADDREF(mLastRollup);
// If true, the buttondown event won't be passed on to the wndproc. // If true, the buttondown event won't be passed on to the wndproc.
return gRollupConsumeRollupEvent; return gRollupConsumeRollupEvent;
@@ -1635,9 +1629,9 @@ void nsWindow::RollupOnFocusLost(HWND aFocus)
} }
// Exit if focus was lost to a parent of the current submenu. // Exit if focus was lost to a parent of the current submenu.
if (gMenuRollup) { if (gRollupListener) {
nsAutoTArray<nsIWidget*, 5> widgetChain; nsAutoTArray<nsIWidget*, 5> widgetChain;
gMenuRollup->GetSubmenuWidgetChain(&widgetChain); gRollupListener->GetSubmenuWidgetChain(&widgetChain);
for (PRUint32 i = 0; i < widgetChain.Length(); ++i) { for (PRUint32 i = 0; i < widgetChain.Length(); ++i) {
if (((nsWindow*)widgetChain[i])->mWnd == aFocus) { if (((nsWindow*)widgetChain[i])->mWnd == aFocus) {
return; return;
@@ -1646,7 +1640,7 @@ void nsWindow::RollupOnFocusLost(HWND aFocus)
} }
// Rollup all popups. // Rollup all popups.
gRollupListener->Rollup(PR_UINT32_MAX, nsnull); gRollupListener->Rollup(PR_UINT32_MAX);
return; return;
} }

View File

@@ -206,7 +206,6 @@ public:
NS_IMETHOD SetCursor(imgIContainer* aCursor, NS_IMETHOD SetCursor(imgIContainer* aCursor,
PRUint32 aHotspotX, PRUint32 aHotspotY); PRUint32 aHotspotX, PRUint32 aHotspotY);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener* aListener, NS_IMETHOD CaptureRollupEvents(nsIRollupListener* aListener,
nsIMenuRollup* aMenuRollup,
bool aDoCapture, bool aConsumeRollupEvent); bool aDoCapture, bool aConsumeRollupEvent);
NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode, NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode,
bool* aLEDState); bool* aLEDState);

View File

@@ -630,7 +630,7 @@ MRESULT EXPENTRY fnwpFrame(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
msg == WM_BUTTON3DOWN) { msg == WM_BUTTON3DOWN) {
// Rollup if the event is outside the popup // Rollup if the event is outside the popup
if (!nsWindow::EventIsInsideWindow((nsWindow*)gRollupWidget)) { if (!nsWindow::EventIsInsideWindow((nsWindow*)gRollupWidget)) {
gRollupListener->Rollup(PR_UINT32_MAX, nsnull); gRollupListener->Rollup(PR_UINT32_MAX);
} }
} }
} }

View File

@@ -98,7 +98,6 @@ using namespace QtMobility;
#include "nsIdleService.h" #include "nsIdleService.h"
#include "nsRenderingContext.h" #include "nsRenderingContext.h"
#include "nsIRollupListener.h" #include "nsIRollupListener.h"
#include "nsIMenuRollup.h"
#include "nsWidgetsCID.h" #include "nsWidgetsCID.h"
#include "nsQtKeyUtils.h" #include "nsQtKeyUtils.h"
#include "mozilla/Services.h" #include "mozilla/Services.h"
@@ -183,7 +182,6 @@ static const int WHEEL_DELTA = 120;
static bool gGlobalsInitialized = false; static bool gGlobalsInitialized = false;
static nsIRollupListener* gRollupListener; static nsIRollupListener* gRollupListener;
static nsIMenuRollup* gMenuRollup;
static nsWeakPtr gRollupWindow; static nsWeakPtr gRollupWindow;
static bool gConsumeRollupEvent; static bool gConsumeRollupEvent;
@@ -423,10 +421,9 @@ nsWindow::Destroy(void)
nsCOMPtr<nsIWidget> rollupWidget = do_QueryReferent(gRollupWindow); nsCOMPtr<nsIWidget> rollupWidget = do_QueryReferent(gRollupWindow);
if (static_cast<nsIWidget *>(this) == rollupWidget.get()) { if (static_cast<nsIWidget *>(this) == rollupWidget.get()) {
if (gRollupListener) if (gRollupListener)
gRollupListener->Rollup(nsnull, nsnull); gRollupListener->Rollup(0);
gRollupWindow = nsnull; gRollupWindow = nsnull;
gRollupListener = nsnull; gRollupListener = nsnull;
NS_IF_RELEASE(gMenuRollup);
} }
if (mLayerManager) { if (mLayerManager) {
@@ -939,7 +936,6 @@ nsWindow::CaptureMouse(bool aCapture)
NS_IMETHODIMP NS_IMETHODIMP
nsWindow::CaptureRollupEvents(nsIRollupListener *aListener, nsWindow::CaptureRollupEvents(nsIRollupListener *aListener,
nsIMenuRollup *aMenuRollup,
bool aDoCapture, bool aDoCapture,
bool aConsumeRollupEvent) bool aConsumeRollupEvent)
{ {
@@ -951,14 +947,10 @@ nsWindow::CaptureRollupEvents(nsIRollupListener *aListener,
if (aDoCapture) { if (aDoCapture) {
gConsumeRollupEvent = aConsumeRollupEvent; gConsumeRollupEvent = aConsumeRollupEvent;
gRollupListener = aListener; gRollupListener = aListener;
NS_IF_RELEASE(gMenuRollup);
gMenuRollup = aMenuRollup;
NS_IF_ADDREF(aMenuRollup);
gRollupWindow = do_GetWeakReference(static_cast<nsIWidget*>(this)); gRollupWindow = do_GetWeakReference(static_cast<nsIWidget*>(this));
} }
else { else {
gRollupListener = nsnull; gRollupListener = nsnull;
NS_IF_RELEASE(gMenuRollup);
gRollupWindow = nsnull; gRollupWindow = nsnull;
} }
@@ -979,16 +971,16 @@ check_for_rollup(double aMouseX, double aMouseY,
if (!is_mouse_in_window(currentPopup, aMouseX, aMouseY)) { if (!is_mouse_in_window(currentPopup, aMouseX, aMouseY)) {
bool rollup = true; bool rollup = true;
if (aIsWheel) { if (aIsWheel) {
gRollupListener->ShouldRollupOnMouseWheelEvent(&rollup); rollup = gRollupListener->ShouldRollupOnMouseWheelEvent();
retVal = true; retVal = true;
} }
// if we're dealing with menus, we probably have submenus and // if we're dealing with menus, we probably have submenus and
// we don't want to rollup if the clickis in a parent menu of // we don't want to rollup if the clickis in a parent menu of
// the current submenu // the current submenu
PRUint32 popupsToRollup = PR_UINT32_MAX; PRUint32 popupsToRollup = PR_UINT32_MAX;
if (gMenuRollup) { if (gRollupListener) {
nsAutoTArray<nsIWidget*, 5> widgetChain; nsAutoTArray<nsIWidget*, 5> widgetChain;
PRUint32 sameTypeCount = gMenuRollup->GetSubmenuWidgetChain(&widgetChain); PRUint32 sameTypeCount = gRollupListener->GetSubmenuWidgetChain(&widgetChain);
for (PRUint32 i=0; i<widgetChain.Length(); ++i) { for (PRUint32 i=0; i<widgetChain.Length(); ++i) {
nsIWidget* widget = widgetChain[i]; nsIWidget* widget = widgetChain[i];
MozQWidget* currWindow = MozQWidget* currWindow =
@@ -1007,14 +999,13 @@ check_for_rollup(double aMouseX, double aMouseY,
// if we've determined that we should still rollup, do it. // if we've determined that we should still rollup, do it.
if (rollup) { if (rollup) {
gRollupListener->Rollup(popupsToRollup, nsnull); gRollupListener->Rollup(popupsToRollup);
retVal = true; retVal = true;
} }
} }
} else { } else {
gRollupWindow = nsnull; gRollupWindow = nsnull;
gRollupListener = nsnull; gRollupListener = nsnull;
NS_IF_RELEASE(gMenuRollup);
} }
return retVal; return retVal;

View File

@@ -186,7 +186,6 @@ public:
NS_IMETHOD EnableDragDrop(bool aEnable); NS_IMETHOD EnableDragDrop(bool aEnable);
NS_IMETHOD CaptureMouse(bool aCapture); NS_IMETHOD CaptureMouse(bool aCapture);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener, NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
nsIMenuRollup *aMenuRollup,
bool aDoCapture, bool aDoCapture,
bool aConsumeRollupEvent); bool aConsumeRollupEvent);

View File

@@ -129,7 +129,6 @@
#include "imgIContainer.h" #include "imgIContainer.h"
#include "nsIFile.h" #include "nsIFile.h"
#include "nsIRollupListener.h" #include "nsIRollupListener.h"
#include "nsIMenuRollup.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsIClipboard.h" #include "nsIClipboard.h"
#include "nsIMM32Handler.h" #include "nsIMM32Handler.h"
@@ -253,7 +252,6 @@ UINT nsWindow::sHookTimerId = 0;
// Rollup Listener // Rollup Listener
nsIRollupListener* nsWindow::sRollupListener = nsnull; nsIRollupListener* nsWindow::sRollupListener = nsnull;
nsIMenuRollup* nsWindow::sMenuRollup = nsnull;
nsIWidget* nsWindow::sRollupWidget = nsnull; nsIWidget* nsWindow::sRollupWidget = nsnull;
bool nsWindow::sRollupConsumeEvent = false; bool nsWindow::sRollupConsumeEvent = false;
@@ -3077,7 +3075,6 @@ NS_METHOD nsWindow::CaptureMouse(bool aCapture)
**************************************************************/ **************************************************************/
NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener, NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener,
nsIMenuRollup * aMenuRollup,
bool aDoCapture, bool aDoCapture,
bool aConsumeRollupEvent) bool aConsumeRollupEvent)
{ {
@@ -3088,10 +3085,7 @@ NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener,
NS_ASSERTION(!sRollupWidget, "rollup widget reassigned before release"); NS_ASSERTION(!sRollupWidget, "rollup widget reassigned before release");
sRollupConsumeEvent = aConsumeRollupEvent; sRollupConsumeEvent = aConsumeRollupEvent;
NS_IF_RELEASE(sRollupWidget); NS_IF_RELEASE(sRollupWidget);
NS_IF_RELEASE(sMenuRollup);
sRollupListener = aListener; sRollupListener = aListener;
sMenuRollup = aMenuRollup;
NS_IF_ADDREF(aMenuRollup);
sRollupWidget = this; sRollupWidget = this;
NS_ADDREF(this); NS_ADDREF(this);
if (!sMsgFilterHook && !sCallProcHook && !sCallMouseHook) { if (!sMsgFilterHook && !sCallProcHook && !sCallMouseHook) {
@@ -3100,7 +3094,6 @@ NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener,
sProcessHook = true; sProcessHook = true;
} else { } else {
sRollupListener = nsnull; sRollupListener = nsnull;
NS_IF_RELEASE(sMenuRollup);
NS_IF_RELEASE(sRollupWidget); NS_IF_RELEASE(sRollupWidget);
sProcessHook = false; sProcessHook = false;
UnregisterSpecialDropdownHooks(); UnregisterSpecialDropdownHooks();
@@ -7413,8 +7406,8 @@ void nsWindow::OnDestroy()
// turn off capture. // turn off capture.
if ( this == sRollupWidget ) { if ( this == sRollupWidget ) {
if ( sRollupListener ) if ( sRollupListener )
sRollupListener->Rollup(nsnull, nsnull); sRollupListener->Rollup(0);
CaptureRollupEvents(nsnull, nsnull, false, true); CaptureRollupEvents(nsnull, false, true);
} }
// Restore the IM context. // Restore the IM context.
@@ -8717,7 +8710,7 @@ nsWindow::DealWithPopups(HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inLPara
if (rollup && (inMsg == WM_MOUSEWHEEL || inMsg == WM_MOUSEHWHEEL)) if (rollup && (inMsg == WM_MOUSEWHEEL || inMsg == WM_MOUSEHWHEEL))
{ {
sRollupListener->ShouldRollupOnMouseWheelEvent(&rollup); rollup = sRollupListener->ShouldRollupOnMouseWheelEvent();
*outResult = true; *outResult = true;
} }
@@ -8725,9 +8718,9 @@ nsWindow::DealWithPopups(HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inLPara
// want to rollup if the click is in a parent menu of the current submenu. // want to rollup if the click is in a parent menu of the current submenu.
PRUint32 popupsToRollup = PR_UINT32_MAX; PRUint32 popupsToRollup = PR_UINT32_MAX;
if (rollup) { if (rollup) {
if ( sMenuRollup ) { if ( sRollupListener ) {
nsAutoTArray<nsIWidget*, 5> widgetChain; nsAutoTArray<nsIWidget*, 5> widgetChain;
PRUint32 sameTypeCount = sMenuRollup->GetSubmenuWidgetChain(&widgetChain); PRUint32 sameTypeCount = sRollupListener->GetSubmenuWidgetChain(&widgetChain);
for ( PRUint32 i = 0; i < widgetChain.Length(); ++i ) { for ( PRUint32 i = 0; i < widgetChain.Length(); ++i ) {
nsIWidget* widget = widgetChain[i]; nsIWidget* widget = widgetChain[i];
if ( nsWindow::EventIsInsideWindow(inMsg, (nsWindow*)widget) ) { if ( nsWindow::EventIsInsideWindow(inMsg, (nsWindow*)widget) ) {
@@ -8763,7 +8756,7 @@ nsWindow::DealWithPopups(HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inLPara
{ {
// WM_MOUSEACTIVATE cause by moving the mouse - X-mouse (eg. TweakUI) // WM_MOUSEACTIVATE cause by moving the mouse - X-mouse (eg. TweakUI)
// must be enabled in Windows. // must be enabled in Windows.
sRollupListener->ShouldRollupOnMouseActivate(&rollup); rollup = sRollupListener->ShouldRollupOnMouseActivate();
if (!rollup) if (!rollup)
{ {
*outResult = MA_NOACTIVATE; *outResult = MA_NOACTIVATE;
@@ -8778,7 +8771,9 @@ nsWindow::DealWithPopups(HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inLPara
// nsIRollupListener::Rollup. // nsIRollupListener::Rollup.
bool consumeRollupEvent = sRollupConsumeEvent; bool consumeRollupEvent = sRollupConsumeEvent;
// only need to deal with the last rollup for left mouse down events. // only need to deal with the last rollup for left mouse down events.
sRollupListener->Rollup(popupsToRollup, inMsg == WM_LBUTTONDOWN ? &mLastRollup : nsnull); NS_ASSERTION(!mLastRollup, "mLastRollup is null");
mLastRollup = sRollupListener->Rollup(popupsToRollup, inMsg == WM_LBUTTONDOWN);
NS_IF_ADDREF(mLastRollup);
// Tell hook to stop processing messages // Tell hook to stop processing messages
sProcessHook = false; sProcessHook = false;

View File

@@ -158,7 +158,7 @@ public:
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus); NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
NS_IMETHOD EnableDragDrop(bool aEnable); NS_IMETHOD EnableDragDrop(bool aEnable);
NS_IMETHOD CaptureMouse(bool aCapture); NS_IMETHOD CaptureMouse(bool aCapture);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, nsIMenuRollup * aMenuRollup, NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener,
bool aDoCapture, bool aConsumeRollupEvent); bool aDoCapture, bool aConsumeRollupEvent);
NS_IMETHOD GetAttention(PRInt32 aCycleCount); NS_IMETHOD GetAttention(PRInt32 aCycleCount);
virtual bool HasPendingInputEvent(); virtual bool HasPendingInputEvent();
@@ -594,7 +594,6 @@ protected:
static nsIWidget* sRollupWidget; static nsIWidget* sRollupWidget;
static bool sRollupConsumeEvent; static bool sRollupConsumeEvent;
static nsIRollupListener* sRollupListener; static nsIRollupListener* sRollupListener;
static nsIMenuRollup* sMenuRollup;
// Mouse Clicks - static variable definitions for figuring // Mouse Clicks - static variable definitions for figuring
// out 1 - 3 Clicks. // out 1 - 3 Clicks.

View File

@@ -150,7 +150,7 @@ public:
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus& aStatus); NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus& aStatus);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener* aListener, nsIMenuRollup* aMenuRollup, NS_IMETHOD CaptureRollupEvents(nsIRollupListener* aListener,
bool aDoCapture, bool aConsumeRollupEvent) bool aDoCapture, bool aConsumeRollupEvent)
{ return NS_ERROR_UNEXPECTED; } { return NS_ERROR_UNEXPECTED; }

View File

@@ -320,8 +320,7 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
case NS_MOVE: { case NS_MOVE: {
// Adjust any child popups so that their widget offsets and coordinates // Adjust any child popups so that their widget offsets and coordinates
// are correct with respect to the new position of the window // are correct with respect to the new position of the window
nsCOMPtr<nsIMenuRollup> pm = nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
do_GetService("@mozilla.org/xul/xul-popup-manager;1");
if (pm) { if (pm) {
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(docShell); nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(docShell);
pm->AdjustPopupsOnWindowChange(window); pm->AdjustPopupsOnWindowChange(window);
@@ -333,8 +332,7 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
break; break;
} }
case NS_SIZE: { case NS_SIZE: {
nsCOMPtr<nsIMenuRollup> pm = nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
do_GetService("@mozilla.org/xul/xul-popup-manager;1");
if (pm) { if (pm) {
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(docShell); nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(docShell);
pm->AdjustPopupsOnWindowChange(window); pm->AdjustPopupsOnWindowChange(window);