From 7b3ef4bf7f6bdee24745426b0cc484040ad2afc2 Mon Sep 17 00:00:00 2001 From: "mozilla.mano%sent.com" Date: Thu, 7 Feb 2008 02:19:13 +0000 Subject: [PATCH] Backing out 406686 again --- content/base/public/nsContentUtils.h | 6 ------ content/base/src/nsContentUtils.cpp | 16 --------------- dom/src/base/nsGlobalWindow.cpp | 8 ++++++-- layout/base/nsDocumentViewer.cpp | 4 +++- layout/generic/nsFrameFrame.cpp | 15 +------------- layout/xul/base/public/nsXULPopupManager.h | 10 ++------- layout/xul/base/src/nsXULPopupManager.cpp | 24 +++------------------- 7 files changed, 15 insertions(+), 68 deletions(-) diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index ca69a77e16f..f607fcd5c2d 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -1152,12 +1152,6 @@ public: nsNativeKeyEvent* aNativeEvent, PRBool aGetCharCode); - /** - * Hide any XUL popups associated with aDocument, including any documents - * displayed in child frames. - */ - static void HidePopupsInDocument(nsIDocument* aDocument); - /** * Get the application manifest URI for this context. The manifest URI * is specified in the manifest= attribute of the root element of the diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index aa1f8a70de0..c151f3fb5d1 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -145,7 +145,6 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID); #include "nsIDOMNSUIEvent.h" #include "nsIDOMNSEvent.h" #include "nsIPrivateDOMEvent.h" -#include "nsXULPopupManager.h" #include "nsIPermissionManager.h" #ifdef IBMBIDI @@ -3925,21 +3924,6 @@ nsContentUtils::DOMEventToNativeKeyEvent(nsIDOMEvent* aDOMEvent, return PR_TRUE; } -/* static */ -void -nsContentUtils::HidePopupsInDocument(nsIDocument* aDocument) -{ - NS_PRECONDITION(aDocument, "Null document"); - - nsXULPopupManager* pm = nsXULPopupManager::GetInstance(); - if (pm) { - nsCOMPtr container = aDocument->GetContainer(); - nsCOMPtr docShellToHide = do_QueryInterface(container); - if (docShellToHide) - pm->HidePopupsInDocShell(docShellToHide); - } -} - /* static */ void nsAutoGCRoot::Shutdown() diff --git a/dom/src/base/nsGlobalWindow.cpp b/dom/src/base/nsGlobalWindow.cpp index 174ff30d5ba..e17612c3307 100644 --- a/dom/src/base/nsGlobalWindow.cpp +++ b/dom/src/base/nsGlobalWindow.cpp @@ -3297,8 +3297,10 @@ nsGlobalWindow::CheckSecurityWidthAndHeight(PRInt32* aWidth, PRInt32* aHeight) #ifdef MOZ_XUL if (!nsContentUtils::IsCallerTrustedForWrite()) { // if attempting to resize the window, hide any open popups + nsXULPopupManager* pm = nsXULPopupManager::GetInstance(); nsCOMPtr doc(do_QueryInterface(mDocument)); - nsContentUtils::HidePopupsInDocument(doc); + if (pm && doc) + pm->HidePopupsInDocument(doc); } #endif @@ -3330,8 +3332,10 @@ nsGlobalWindow::CheckSecurityLeftAndTop(PRInt32* aLeft, PRInt32* aTop) if (!nsContentUtils::IsCallerTrustedForWrite()) { #ifdef MOZ_XUL // if attempting to move the window, hide any open popups + nsXULPopupManager* pm = nsXULPopupManager::GetInstance(); nsCOMPtr doc(do_QueryInterface(mDocument)); - nsContentUtils::HidePopupsInDocument(doc); + if (pm && doc) + pm->HidePopupsInDocument(doc); #endif PRInt32 screenLeft, screenTop, screenWidth, screenHeight; diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 46c86193d3e..225741fdd33 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -1179,7 +1179,9 @@ DocumentViewerImpl::PageHide(PRBool aIsUnload) #ifdef MOZ_XUL // look for open menupopups and close them after the unload event, in case // the unload event listeners open any new popups - nsContentUtils::HidePopupsInDocument(mDocument); + nsXULPopupManager* pm = nsXULPopupManager::GetInstance(); + if (pm && mDocument) + pm->HidePopupsInDocument(mDocument); #endif return NS_OK; diff --git a/layout/generic/nsFrameFrame.cpp b/layout/generic/nsFrameFrame.cpp index 3b66578af62..3c010c19c7e 100644 --- a/layout/generic/nsFrameFrame.cpp +++ b/layout/generic/nsFrameFrame.cpp @@ -21,7 +21,7 @@ * * Contributor(s): * Travis Bogard - * HÂkan Waara + * Håkan Waara * * 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"), @@ -94,10 +94,6 @@ #include "nsIObjectLoadingContent.h" #include "nsLayoutUtils.h" -#ifdef MOZ_XUL -#include "nsXULPopupManager.h" -#endif - // For Accessibility #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" @@ -677,15 +673,6 @@ nsSubDocumentFrame::AttributeChanged(PRInt32 aNameSpaceID, PRBool is_primary = value.LowerCaseEqualsLiteral("content-primary"); -#ifdef MOZ_XUL - // when a content panel is no longer primary, hide any open popups it may have - if (!is_primary) { - nsXULPopupManager* pm = nsXULPopupManager::GetInstance(); - if (pm) - pm->HidePopupsInDocShell(docShellAsItem); - } -#endif - parentTreeOwner->ContentShellRemoved(docShellAsItem); if (value.LowerCaseEqualsLiteral("content") || diff --git a/layout/xul/base/public/nsXULPopupManager.h b/layout/xul/base/public/nsXULPopupManager.h index 1172e6bc3a6..7b077f051b7 100644 --- a/layout/xul/base/public/nsXULPopupManager.h +++ b/layout/xul/base/public/nsXULPopupManager.h @@ -75,7 +75,6 @@ class nsMenuPopupFrame; class nsMenuBarFrame; class nsIMenuParent; class nsIDOMKeyEvent; -class nsIDocShellTreeItem; enum nsPopupType { ePopupTypePanel, @@ -474,10 +473,10 @@ public: void HidePopupAfterDelay(nsMenuPopupFrame* aPopup); /** - * Hide all of the popups from a given docshell. This should be called when the + * Hide all of the popups from a given document. This should be called when the * document is hidden. */ - void HidePopupsInDocShell(nsIDocShellTreeItem* aDocShellToHide); + void HidePopupsInDocument(nsIDocument* aDocument); /** * Execute a menu command from the triggering event aEvent. @@ -713,11 +712,6 @@ protected: */ void UpdateKeyboardListeners(); - /* - * Returns true if the docshell for aDoc is aExpected or a child of aExpected. - */ - PRBool IsChildOfDocShell(nsIDocument* aDoc, nsIDocShellTreeItem* aExpected); - // the document the key event listener is attached to nsCOMPtr mKeyListener; diff --git a/layout/xul/base/src/nsXULPopupManager.cpp b/layout/xul/base/src/nsXULPopupManager.cpp index 6cc44cf6f2f..78eddd2339d 100644 --- a/layout/xul/base/src/nsXULPopupManager.cpp +++ b/layout/xul/base/src/nsXULPopupManager.cpp @@ -60,7 +60,6 @@ #include "nsPIDOMWindow.h" #include "nsIInterfaceRequestorUtils.h" #include "nsIBaseWindow.h" -#include "nsIDocShellTreeItem.h" // See matching definitions in nsXULPopupManager.h nsNavigationDirection DirectionFromKeyCode_lr_tb [6] = { @@ -766,25 +765,8 @@ nsXULPopupManager::HidePopupsInList(const nsTArray &aFrames, SetCaptureState(nsnull); } -PRBool -nsXULPopupManager::IsChildOfDocShell(nsIDocument* aDoc, nsIDocShellTreeItem* aExpected) -{ - nsCOMPtr doc = aDoc->GetContainer(); - nsCOMPtr docShellItem(do_QueryInterface(doc)); - while(docShellItem) { - if (docShellItem == aExpected) - return PR_TRUE; - - nsCOMPtr parent; - docShellItem->GetParent(getter_AddRefs(parent)); - docShellItem = parent; - } - - return PR_FALSE; -} - void -nsXULPopupManager::HidePopupsInDocShell(nsIDocShellTreeItem* aDocShellToHide) +nsXULPopupManager::HidePopupsInDocument(nsIDocument* aDocument) { nsTArray popupsToHide; @@ -793,7 +775,7 @@ nsXULPopupManager::HidePopupsInDocShell(nsIDocShellTreeItem* aDocShellToHide) while (item) { nsMenuChainItem* parent = item->GetParent(); if (item->Frame()->PopupState() != ePopupInvisible && - IsChildOfDocShell(item->Content()->GetOwnerDoc(), aDocShellToHide)) { + aDocument && item->Content()->GetOwnerDoc() == aDocument) { nsMenuPopupFrame* frame = item->Frame(); item->Detach(&mCurrentMenu); delete item; @@ -807,7 +789,7 @@ nsXULPopupManager::HidePopupsInDocShell(nsIDocShellTreeItem* aDocShellToHide) while (item) { nsMenuChainItem* parent = item->GetParent(); if (item->Frame()->PopupState() != ePopupInvisible && - IsChildOfDocShell(item->Content()->GetOwnerDoc(), aDocShellToHide)) { + aDocument && item->Content()->GetOwnerDoc() == aDocument) { nsMenuPopupFrame* frame = item->Frame(); item->Detach(&mPanels); delete item;