From cfaa6b44e6bc8a945ffab4e7cf37b480a2a34102 Mon Sep 17 00:00:00 2001 From: "Olli.Pettay%helsinki.fi" Date: Mon, 21 Aug 2006 06:53:40 +0000 Subject: [PATCH] Bug 349201, r=enndeakin, sr=bz --- .../xul/content/src/nsXULPopupListener.cpp | 49 +++++-------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/content/xul/content/src/nsXULPopupListener.cpp b/content/xul/content/src/nsXULPopupListener.cpp index 920b0a8a8b5d..e805d639b0fe 100644 --- a/content/xul/content/src/nsXULPopupListener.cpp +++ b/content/xul/content/src/nsXULPopupListener.cpp @@ -128,7 +128,6 @@ protected: virtual nsresult LaunchPopup(nsIDOMEvent* anEvent); virtual nsresult LaunchPopup(PRInt32 aClientX, PRInt32 aClientY) ; - virtual void ClosePopup(); private: @@ -139,7 +138,7 @@ private: nsIDOMElement* mElement; // Weak ref. The element will go away first. // The popup that is getting shown on top of mElement. - nsIDOMElement* mPopupContent; + nsCOMPtr mPopup; // The type of the popup XULPopupType popupType; @@ -149,13 +148,15 @@ private: //////////////////////////////////////////////////////////////////////// XULPopupListenerImpl::XULPopupListenerImpl(void) - : mElement(nsnull), mPopupContent(nsnull) + : mElement(nsnull) { } XULPopupListenerImpl::~XULPopupListenerImpl(void) { - ClosePopup(); + if (mPopup) { + mPopup->HidePopup(); + } #ifdef DEBUG_REFS --gInstanceCount; @@ -388,30 +389,6 @@ XULPopupListenerImpl::FireFocusOnTargetContent(nsIDOMNode* aTargetNode) return rv; } -// -// ClosePopup -// -// Do everything needed to shut down the popup. -// -// NOTE: This routine is safe to call even if the popup is already closed. -// -void -XULPopupListenerImpl :: ClosePopup ( ) -{ - if ( mPopupContent ) { - nsCOMPtr popupElement(do_QueryInterface(mPopupContent)); - nsCOMPtr boxObject; - if (popupElement) - popupElement->GetBoxObject(getter_AddRefs(boxObject)); - nsCOMPtr popupObject(do_QueryInterface(boxObject)); - if (popupObject) - popupObject->HidePopup(); - - mPopupContent = nsnull; // release the popup - } - -} // ClosePopup - // // LaunchPopup // @@ -607,28 +584,28 @@ XULPopupListenerImpl::LaunchPopup(PRInt32 aClientX, PRInt32 aClientY) if (domWindow) { // Find out if we're anchored. - mPopupContent = popupContent.get(); - nsAutoString anchorAlignment; - mPopupContent->GetAttribute(NS_LITERAL_STRING("popupanchor"), anchorAlignment); + popupContent->GetAttribute(NS_LITERAL_STRING("popupanchor"), anchorAlignment); nsAutoString popupAlignment; - mPopupContent->GetAttribute(NS_LITERAL_STRING("popupalign"), popupAlignment); + popupContent->GetAttribute(NS_LITERAL_STRING("popupalign"), popupAlignment); PRInt32 xPos = aClientX, yPos = aClientY; - ConvertPosition(mPopupContent, anchorAlignment, popupAlignment, yPos); + ConvertPosition(popupContent, anchorAlignment, popupAlignment, yPos); if (!anchorAlignment.IsEmpty() && !popupAlignment.IsEmpty()) xPos = yPos = -1; nsCOMPtr popupBox; - nsCOMPtr xulPopupElt(do_QueryInterface(mPopupContent)); + nsCOMPtr xulPopupElt(do_QueryInterface(popupContent)); xulPopupElt->GetBoxObject(getter_AddRefs(popupBox)); nsCOMPtr popupBoxObject(do_QueryInterface(popupBox)); - if (popupBoxObject) - popupBoxObject->ShowPopup(mElement, mPopupContent, xPos, yPos, + if (popupBoxObject) { + mPopup = popupBoxObject; + popupBoxObject->ShowPopup(mElement, popupContent, xPos, yPos, type.get(), anchorAlignment.get(), popupAlignment.get()); + } } return NS_OK;