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 \
{ 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}
#define NS_DOMJSON_CID \
{ 0x93ad72a6, 0x02cd, 0x4716, { 0x96, 0x26, 0xd4, 0x7d, 0x5e, 0xc2, 0x75, 0xec } }

View File

@@ -86,7 +86,6 @@
#include "nsIFrameTraversal.h"
#include "nsLayoutCID.h"
#include "nsStyleSheetService.h"
#include "nsXULPopupManager.h"
#include "nsFocusManager.h"
#include "ThirdPartyUtil.h"
#include "mozilla/Services.h"
@@ -534,7 +533,6 @@ MAKE_CTOR(CreateXULSortService, nsIXULSortService, NS_NewXUL
// NS_NewXULTreeBuilder
MAKE_CTOR(CreateXULDocument, nsIXULDocument, NS_NewXULDocument)
// NS_NewXULControllers
MAKE_CTOR(CreateXULPopupManager, nsISupports, NS_NewXULPopupManager)
#endif
#ifdef MOZ_XTF
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_XULTEMPLATEBUILDER_CID);
NS_DEFINE_NAMED_CID(NS_XULTREEBUILDER_CID);
NS_DEFINE_NAMED_CID(NS_XULPOPUPMANAGER_CID);
NS_DEFINE_NAMED_CID(NS_XULDOCUMENT_CID);
#endif
#ifdef MOZ_XTF
@@ -909,7 +906,6 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
{ &kNS_XULSORTSERVICE_CID, false, NULL, CreateXULSortService },
{ &kNS_XULTEMPLATEBUILDER_CID, false, NULL, NS_NewXULContentBuilder },
{ &kNS_XULTREEBUILDER_CID, false, NULL, NS_NewXULTreeBuilder },
{ &kNS_XULPOPUPMANAGER_CID, false, NULL, CreateXULPopupManager },
{ &kNS_XULDOCUMENT_CID, false, NULL, CreateXULDocument },
#endif
#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-template-builder;1", &kNS_XULTEMPLATEBUILDER_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 },
#endif
#ifdef MOZ_XTF

View File

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

View File

@@ -192,20 +192,24 @@ public:
* Hide the dropdown menu and stop capturing mouse events.
* @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
* the popup area.
*/
NS_IMETHOD ShouldRollupOnMouseWheelEvent(bool *aShouldRollup)
{ *aShouldRollup = true; return NS_OK;}
virtual bool ShouldRollupOnMouseWheelEvent()
{ return true; }
/**
* A combobox should not roll up if activated by a mouse activate message
* (eg. X-mouse).
*/
NS_IMETHOD ShouldRollupOnMouseActivate(bool *aShouldRollup)
{ *aShouldRollup = false; return NS_OK;}
virtual bool ShouldRollupOnMouseActivate()
{ return false; }
virtual PRUint32 GetSubmenuWidgetChain(nsTArray<nsIWidget*> *aWidgetChain)
{ return 0; }
//nsIStatefulFrame
NS_IMETHOD SaveState(SpecialStateID aStateID, nsPresState** aState);

View File

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

View File

@@ -137,9 +137,8 @@ void nsMenuChainItem::Detach(nsMenuChainItem** aRoot)
}
}
NS_IMPL_ISUPPORTS4(nsXULPopupManager,
NS_IMPL_ISUPPORTS3(nsXULPopupManager,
nsIDOMEventListener,
nsIMenuRollup,
nsITimerCallback,
nsIObserver)
@@ -207,15 +206,14 @@ nsXULPopupManager::GetInstance()
return sInstance;
}
NS_IMETHODIMP
nsXULPopupManager::Rollup(PRUint32 aCount, nsIContent** aLastRolledUp)
nsIContent*
nsXULPopupManager::Rollup(PRUint32 aCount, bool aGetLastRolledUp)
{
if (aLastRolledUp)
*aLastRolledUp = nsnull;
nsIContent* lastRolledUpPopup = nsnull;
nsMenuChainItem* item = GetTopVisibleMenu();
if (item) {
if (aLastRolledUp) {
if (aGetLastRolledUp) {
// 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
// down event is going to processed.
@@ -227,7 +225,7 @@ nsXULPopupManager::Rollup(PRUint32 aCount, nsIContent** aLastRolledUp)
nsMenuChainItem* first = item;
while (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
@@ -245,35 +243,33 @@ nsXULPopupManager::Rollup(PRUint32 aCount, nsIContent** aLastRolledUp)
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
// XXXndeakin this should really be something the popup has more control over
*aShouldRollup = false;
nsMenuChainItem* item = GetTopVisibleMenu();
if (!item)
return NS_OK;
return false;
nsIContent* content = item->Frame()->GetContent();
if (content) {
nsAutoString value;
content->GetAttr(kNameSpaceID_None, nsGkAtoms::type, value);
*aShouldRollup = StringBeginsWith(value, NS_LITERAL_STRING("autocomplete"));
}
if (!content)
return false;
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)
NS_IMETHODIMP nsXULPopupManager::ShouldRollupOnMouseActivate(bool *aShouldRollup)
bool nsXULPopupManager::ShouldRollupOnMouseActivate()
{
*aShouldRollup = false;
return NS_OK;
return false;
}
PRUint32
@@ -1620,7 +1616,7 @@ nsXULPopupManager::SetCaptureState(nsIContent* aOldPopup)
return;
if (mWidget) {
mWidget->CaptureRollupEvents(this, this, false, false);
mWidget->CaptureRollupEvents(this, false, false);
mWidget = nsnull;
}
@@ -1629,8 +1625,7 @@ nsXULPopupManager::SetCaptureState(nsIContent* aOldPopup)
nsCOMPtr<nsIWidget> widget;
popup->GetWidget(getter_AddRefs(widget));
if (widget) {
widget->CaptureRollupEvents(this, this, true,
popup->ConsumeOutsideClicks());
widget->CaptureRollupEvents(this, true, popup->ConsumeOutsideClicks());
mWidget = widget;
popup->AttachedDismissalListener();
}
@@ -2182,7 +2177,7 @@ nsXULPopupManager::KeyDown(nsIDOMKeyEvent* aKeyEvent)
// The access key just went down and no other
// modifiers are already down.
if (mPopups)
Rollup(nsnull, nsnull);
Rollup(0);
else if (mActiveMenuBar)
mActiveMenuBar->MenuClosed();
}
@@ -2261,7 +2256,7 @@ nsXULPopupManager::KeyPress(nsIDOMKeyEvent* aKeyEvent)
) {
// close popups or deactivate menubar when Tab or F10 are pressed
if (item)
Rollup(nsnull, nsnull);
Rollup(0);
else if (mActiveMenuBar)
mActiveMenuBar->MenuClosed();
}
@@ -2381,12 +2376,3 @@ nsXULMenuCommandEvent::Run()
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 \
nsINativeKeyBindings.h \
nsIDeviceContextSpec.h \
nsIMenuRollup.h \
nsIRollupListener.h \
$(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__
#define __nsIRollupListener_h__
#include "nsTArray.h"
class nsIContent;
class nsIWidget;
class nsIRollupListener {
public:
@@ -53,19 +56,30 @@ class nsIRollupListener {
*
* aCount is the number of popups in a chain to close. If this is
* 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
*/
NS_IMETHOD ShouldRollupOnMouseWheelEvent(bool *aShould) = 0;
virtual bool ShouldRollupOnMouseWheelEvent() = 0;
/**
* 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__ */

View File

@@ -62,7 +62,6 @@ class nsRenderingContext;
class nsDeviceContext;
struct nsFont;
class nsIRollupListener;
class nsIMenuRollup;
class nsGUIEvent;
class imgIContainer;
class gfxASurface;
@@ -119,8 +118,8 @@ typedef nsEventStatus (* EVENT_CALLBACK)(nsGUIEvent *event);
#endif
#define NS_IWIDGET_IID \
{ 0x712b07a4, 0x4344, 0x4404, \
{ 0xaf, 0x85, 0x63, 0x3d, 0x68, 0x0b, 0x21, 0xb0 } }
{ 0x32966f95, 0x89e0, 0x447a, \
{ 0x91, 0x8d, 0x58, 0x53, 0xd6, 0x99, 0x4a, 0x72 } }
/*
* Window shadow styles
@@ -1028,8 +1027,8 @@ class nsIWidget : public nsISupports {
* @param aConsumeRollupEvent true consumes the rollup event, false dispatches rollup event
*
*/
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, nsIMenuRollup * aMenuRollup,
bool aDoCapture, bool aConsumeRollupEvent) = 0;
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, bool aDoCapture,
bool aConsumeRollupEvent) = 0;
/**
* 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 CaptureMouse(bool aCapture) { return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
nsIMenuRollup *aMenuRollup,
bool aDoCapture,
bool aConsumeRollupEvent) { return NS_ERROR_NOT_IMPLEMENTED; }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -630,7 +630,7 @@ MRESULT EXPENTRY fnwpFrame(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
msg == WM_BUTTON3DOWN) {
// Rollup if the event is outside the popup
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 "nsRenderingContext.h"
#include "nsIRollupListener.h"
#include "nsIMenuRollup.h"
#include "nsWidgetsCID.h"
#include "nsQtKeyUtils.h"
#include "mozilla/Services.h"
@@ -183,7 +182,6 @@ static const int WHEEL_DELTA = 120;
static bool gGlobalsInitialized = false;
static nsIRollupListener* gRollupListener;
static nsIMenuRollup* gMenuRollup;
static nsWeakPtr gRollupWindow;
static bool gConsumeRollupEvent;
@@ -423,10 +421,9 @@ nsWindow::Destroy(void)
nsCOMPtr<nsIWidget> rollupWidget = do_QueryReferent(gRollupWindow);
if (static_cast<nsIWidget *>(this) == rollupWidget.get()) {
if (gRollupListener)
gRollupListener->Rollup(nsnull, nsnull);
gRollupListener->Rollup(0);
gRollupWindow = nsnull;
gRollupListener = nsnull;
NS_IF_RELEASE(gMenuRollup);
}
if (mLayerManager) {
@@ -939,7 +936,6 @@ nsWindow::CaptureMouse(bool aCapture)
NS_IMETHODIMP
nsWindow::CaptureRollupEvents(nsIRollupListener *aListener,
nsIMenuRollup *aMenuRollup,
bool aDoCapture,
bool aConsumeRollupEvent)
{
@@ -951,14 +947,10 @@ nsWindow::CaptureRollupEvents(nsIRollupListener *aListener,
if (aDoCapture) {
gConsumeRollupEvent = aConsumeRollupEvent;
gRollupListener = aListener;
NS_IF_RELEASE(gMenuRollup);
gMenuRollup = aMenuRollup;
NS_IF_ADDREF(aMenuRollup);
gRollupWindow = do_GetWeakReference(static_cast<nsIWidget*>(this));
}
else {
gRollupListener = nsnull;
NS_IF_RELEASE(gMenuRollup);
gRollupWindow = nsnull;
}
@@ -979,16 +971,16 @@ check_for_rollup(double aMouseX, double aMouseY,
if (!is_mouse_in_window(currentPopup, aMouseX, aMouseY)) {
bool rollup = true;
if (aIsWheel) {
gRollupListener->ShouldRollupOnMouseWheelEvent(&rollup);
rollup = gRollupListener->ShouldRollupOnMouseWheelEvent();
retVal = true;
}
// 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
// the current submenu
PRUint32 popupsToRollup = PR_UINT32_MAX;
if (gMenuRollup) {
if (gRollupListener) {
nsAutoTArray<nsIWidget*, 5> widgetChain;
PRUint32 sameTypeCount = gMenuRollup->GetSubmenuWidgetChain(&widgetChain);
PRUint32 sameTypeCount = gRollupListener->GetSubmenuWidgetChain(&widgetChain);
for (PRUint32 i=0; i<widgetChain.Length(); ++i) {
nsIWidget* widget = widgetChain[i];
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 (rollup) {
gRollupListener->Rollup(popupsToRollup, nsnull);
gRollupListener->Rollup(popupsToRollup);
retVal = true;
}
}
} else {
gRollupWindow = nsnull;
gRollupListener = nsnull;
NS_IF_RELEASE(gMenuRollup);
}
return retVal;

View File

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

View File

@@ -129,7 +129,6 @@
#include "imgIContainer.h"
#include "nsIFile.h"
#include "nsIRollupListener.h"
#include "nsIMenuRollup.h"
#include "nsIServiceManager.h"
#include "nsIClipboard.h"
#include "nsIMM32Handler.h"
@@ -253,7 +252,6 @@ UINT nsWindow::sHookTimerId = 0;
// Rollup Listener
nsIRollupListener* nsWindow::sRollupListener = nsnull;
nsIMenuRollup* nsWindow::sMenuRollup = nsnull;
nsIWidget* nsWindow::sRollupWidget = nsnull;
bool nsWindow::sRollupConsumeEvent = false;
@@ -3077,7 +3075,6 @@ NS_METHOD nsWindow::CaptureMouse(bool aCapture)
**************************************************************/
NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener,
nsIMenuRollup * aMenuRollup,
bool aDoCapture,
bool aConsumeRollupEvent)
{
@@ -3088,10 +3085,7 @@ NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener,
NS_ASSERTION(!sRollupWidget, "rollup widget reassigned before release");
sRollupConsumeEvent = aConsumeRollupEvent;
NS_IF_RELEASE(sRollupWidget);
NS_IF_RELEASE(sMenuRollup);
sRollupListener = aListener;
sMenuRollup = aMenuRollup;
NS_IF_ADDREF(aMenuRollup);
sRollupWidget = this;
NS_ADDREF(this);
if (!sMsgFilterHook && !sCallProcHook && !sCallMouseHook) {
@@ -3100,7 +3094,6 @@ NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener,
sProcessHook = true;
} else {
sRollupListener = nsnull;
NS_IF_RELEASE(sMenuRollup);
NS_IF_RELEASE(sRollupWidget);
sProcessHook = false;
UnregisterSpecialDropdownHooks();
@@ -7413,8 +7406,8 @@ void nsWindow::OnDestroy()
// turn off capture.
if ( this == sRollupWidget ) {
if ( sRollupListener )
sRollupListener->Rollup(nsnull, nsnull);
CaptureRollupEvents(nsnull, nsnull, false, true);
sRollupListener->Rollup(0);
CaptureRollupEvents(nsnull, false, true);
}
// 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))
{
sRollupListener->ShouldRollupOnMouseWheelEvent(&rollup);
rollup = sRollupListener->ShouldRollupOnMouseWheelEvent();
*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.
PRUint32 popupsToRollup = PR_UINT32_MAX;
if (rollup) {
if ( sMenuRollup ) {
if ( sRollupListener ) {
nsAutoTArray<nsIWidget*, 5> widgetChain;
PRUint32 sameTypeCount = sMenuRollup->GetSubmenuWidgetChain(&widgetChain);
PRUint32 sameTypeCount = sRollupListener->GetSubmenuWidgetChain(&widgetChain);
for ( PRUint32 i = 0; i < widgetChain.Length(); ++i ) {
nsIWidget* widget = widgetChain[i];
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)
// must be enabled in Windows.
sRollupListener->ShouldRollupOnMouseActivate(&rollup);
rollup = sRollupListener->ShouldRollupOnMouseActivate();
if (!rollup)
{
*outResult = MA_NOACTIVATE;
@@ -8778,7 +8771,9 @@ nsWindow::DealWithPopups(HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inLPara
// nsIRollupListener::Rollup.
bool consumeRollupEvent = sRollupConsumeEvent;
// 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
sProcessHook = false;

View File

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

View File

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

View File

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