mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-23 19:09:49 +00:00
Bug 406686, close popups on blur, r=roc,sr=dveditz
This commit is contained in:
parent
c03bd4e43f
commit
597b67b80a
@ -1152,6 +1152,12 @@ public:
|
|||||||
nsNativeKeyEvent* aNativeEvent,
|
nsNativeKeyEvent* aNativeEvent,
|
||||||
PRBool aGetCharCode);
|
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
|
* Get the application manifest URI for this context. The manifest URI
|
||||||
* is specified in the manifest= attribute of the root element of the
|
* is specified in the manifest= attribute of the root element of the
|
||||||
|
@ -145,6 +145,7 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
|
|||||||
#include "nsIDOMNSUIEvent.h"
|
#include "nsIDOMNSUIEvent.h"
|
||||||
#include "nsIDOMNSEvent.h"
|
#include "nsIDOMNSEvent.h"
|
||||||
#include "nsIPrivateDOMEvent.h"
|
#include "nsIPrivateDOMEvent.h"
|
||||||
|
#include "nsXULPopupManager.h"
|
||||||
#include "nsIPermissionManager.h"
|
#include "nsIPermissionManager.h"
|
||||||
|
|
||||||
#ifdef IBMBIDI
|
#ifdef IBMBIDI
|
||||||
@ -3924,6 +3925,21 @@ nsContentUtils::DOMEventToNativeKeyEvent(nsIDOMEvent* aDOMEvent,
|
|||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
void
|
||||||
|
nsContentUtils::HidePopupsInDocument(nsIDocument* aDocument)
|
||||||
|
{
|
||||||
|
NS_PRECONDITION(aDocument, "Null document");
|
||||||
|
|
||||||
|
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
||||||
|
if (pm) {
|
||||||
|
nsCOMPtr<nsISupports> container = aDocument->GetContainer();
|
||||||
|
nsCOMPtr<nsIDocShellTreeItem> docShellToHide = do_QueryInterface(container);
|
||||||
|
if (docShellToHide)
|
||||||
|
pm->HidePopupsInDocShell(docShellToHide);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
void
|
void
|
||||||
nsAutoGCRoot::Shutdown()
|
nsAutoGCRoot::Shutdown()
|
||||||
|
@ -3297,10 +3297,8 @@ nsGlobalWindow::CheckSecurityWidthAndHeight(PRInt32* aWidth, PRInt32* aHeight)
|
|||||||
#ifdef MOZ_XUL
|
#ifdef MOZ_XUL
|
||||||
if (!nsContentUtils::IsCallerTrustedForWrite()) {
|
if (!nsContentUtils::IsCallerTrustedForWrite()) {
|
||||||
// if attempting to resize the window, hide any open popups
|
// if attempting to resize the window, hide any open popups
|
||||||
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
|
||||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
||||||
if (pm && doc)
|
nsContentUtils::HidePopupsInDocument(doc);
|
||||||
pm->HidePopupsInDocument(doc);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -3332,10 +3330,8 @@ nsGlobalWindow::CheckSecurityLeftAndTop(PRInt32* aLeft, PRInt32* aTop)
|
|||||||
if (!nsContentUtils::IsCallerTrustedForWrite()) {
|
if (!nsContentUtils::IsCallerTrustedForWrite()) {
|
||||||
#ifdef MOZ_XUL
|
#ifdef MOZ_XUL
|
||||||
// if attempting to move the window, hide any open popups
|
// if attempting to move the window, hide any open popups
|
||||||
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
|
||||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
||||||
if (pm && doc)
|
nsContentUtils::HidePopupsInDocument(doc);
|
||||||
pm->HidePopupsInDocument(doc);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PRInt32 screenLeft, screenTop, screenWidth, screenHeight;
|
PRInt32 screenLeft, screenTop, screenWidth, screenHeight;
|
||||||
|
@ -1179,9 +1179,7 @@ DocumentViewerImpl::PageHide(PRBool aIsUnload)
|
|||||||
#ifdef MOZ_XUL
|
#ifdef MOZ_XUL
|
||||||
// look for open menupopups and close them after the unload event, in case
|
// look for open menupopups and close them after the unload event, in case
|
||||||
// the unload event listeners open any new popups
|
// the unload event listeners open any new popups
|
||||||
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
nsContentUtils::HidePopupsInDocument(mDocument);
|
||||||
if (pm && mDocument)
|
|
||||||
pm->HidePopupsInDocument(mDocument);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Travis Bogard <travis@netscape.com>
|
* Travis Bogard <travis@netscape.com>
|
||||||
* Håkan Waara <hwaara@chello.se>
|
* HÂkan Waara <hwaara@chello.se>
|
||||||
*
|
*
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
* 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"),
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||||
@ -94,6 +94,10 @@
|
|||||||
#include "nsIObjectLoadingContent.h"
|
#include "nsIObjectLoadingContent.h"
|
||||||
#include "nsLayoutUtils.h"
|
#include "nsLayoutUtils.h"
|
||||||
|
|
||||||
|
#ifdef MOZ_XUL
|
||||||
|
#include "nsXULPopupManager.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// For Accessibility
|
// For Accessibility
|
||||||
#ifdef ACCESSIBILITY
|
#ifdef ACCESSIBILITY
|
||||||
#include "nsIAccessibilityService.h"
|
#include "nsIAccessibilityService.h"
|
||||||
@ -673,6 +677,15 @@ nsSubDocumentFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
|||||||
|
|
||||||
PRBool is_primary = value.LowerCaseEqualsLiteral("content-primary");
|
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);
|
parentTreeOwner->ContentShellRemoved(docShellAsItem);
|
||||||
|
|
||||||
if (value.LowerCaseEqualsLiteral("content") ||
|
if (value.LowerCaseEqualsLiteral("content") ||
|
||||||
|
@ -75,6 +75,7 @@ class nsMenuPopupFrame;
|
|||||||
class nsMenuBarFrame;
|
class nsMenuBarFrame;
|
||||||
class nsIMenuParent;
|
class nsIMenuParent;
|
||||||
class nsIDOMKeyEvent;
|
class nsIDOMKeyEvent;
|
||||||
|
class nsIDocShellTreeItem;
|
||||||
|
|
||||||
enum nsPopupType {
|
enum nsPopupType {
|
||||||
ePopupTypePanel,
|
ePopupTypePanel,
|
||||||
@ -473,10 +474,10 @@ public:
|
|||||||
void HidePopupAfterDelay(nsMenuPopupFrame* aPopup);
|
void HidePopupAfterDelay(nsMenuPopupFrame* aPopup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide all of the popups from a given document. This should be called when the
|
* Hide all of the popups from a given docshell. This should be called when the
|
||||||
* document is hidden.
|
* document is hidden.
|
||||||
*/
|
*/
|
||||||
void HidePopupsInDocument(nsIDocument* aDocument);
|
void HidePopupsInDocShell(nsIDocShellTreeItem* aDocShellToHide);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a menu command from the triggering event aEvent.
|
* Execute a menu command from the triggering event aEvent.
|
||||||
@ -712,6 +713,11 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void UpdateKeyboardListeners();
|
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
|
// the document the key event listener is attached to
|
||||||
nsCOMPtr<nsIDOMEventTarget> mKeyListener;
|
nsCOMPtr<nsIDOMEventTarget> mKeyListener;
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@
|
|||||||
#include "nsPIDOMWindow.h"
|
#include "nsPIDOMWindow.h"
|
||||||
#include "nsIInterfaceRequestorUtils.h"
|
#include "nsIInterfaceRequestorUtils.h"
|
||||||
#include "nsIBaseWindow.h"
|
#include "nsIBaseWindow.h"
|
||||||
|
#include "nsIDocShellTreeItem.h"
|
||||||
|
|
||||||
// See matching definitions in nsXULPopupManager.h
|
// See matching definitions in nsXULPopupManager.h
|
||||||
nsNavigationDirection DirectionFromKeyCode_lr_tb [6] = {
|
nsNavigationDirection DirectionFromKeyCode_lr_tb [6] = {
|
||||||
@ -765,8 +766,25 @@ nsXULPopupManager::HidePopupsInList(const nsTArray<nsMenuPopupFrame *> &aFrames,
|
|||||||
SetCaptureState(nsnull);
|
SetCaptureState(nsnull);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRBool
|
||||||
|
nsXULPopupManager::IsChildOfDocShell(nsIDocument* aDoc, nsIDocShellTreeItem* aExpected)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsISupports> doc = aDoc->GetContainer();
|
||||||
|
nsCOMPtr<nsIDocShellTreeItem> docShellItem(do_QueryInterface(doc));
|
||||||
|
while(docShellItem) {
|
||||||
|
if (docShellItem == aExpected)
|
||||||
|
return PR_TRUE;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDocShellTreeItem> parent;
|
||||||
|
docShellItem->GetParent(getter_AddRefs(parent));
|
||||||
|
docShellItem = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PR_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsXULPopupManager::HidePopupsInDocument(nsIDocument* aDocument)
|
nsXULPopupManager::HidePopupsInDocShell(nsIDocShellTreeItem* aDocShellToHide)
|
||||||
{
|
{
|
||||||
nsTArray<nsMenuPopupFrame *> popupsToHide;
|
nsTArray<nsMenuPopupFrame *> popupsToHide;
|
||||||
|
|
||||||
@ -775,7 +793,7 @@ nsXULPopupManager::HidePopupsInDocument(nsIDocument* aDocument)
|
|||||||
while (item) {
|
while (item) {
|
||||||
nsMenuChainItem* parent = item->GetParent();
|
nsMenuChainItem* parent = item->GetParent();
|
||||||
if (item->Frame()->PopupState() != ePopupInvisible &&
|
if (item->Frame()->PopupState() != ePopupInvisible &&
|
||||||
aDocument && item->Content()->GetOwnerDoc() == aDocument) {
|
IsChildOfDocShell(item->Content()->GetOwnerDoc(), aDocShellToHide)) {
|
||||||
nsMenuPopupFrame* frame = item->Frame();
|
nsMenuPopupFrame* frame = item->Frame();
|
||||||
item->Detach(&mCurrentMenu);
|
item->Detach(&mCurrentMenu);
|
||||||
delete item;
|
delete item;
|
||||||
@ -789,7 +807,7 @@ nsXULPopupManager::HidePopupsInDocument(nsIDocument* aDocument)
|
|||||||
while (item) {
|
while (item) {
|
||||||
nsMenuChainItem* parent = item->GetParent();
|
nsMenuChainItem* parent = item->GetParent();
|
||||||
if (item->Frame()->PopupState() != ePopupInvisible &&
|
if (item->Frame()->PopupState() != ePopupInvisible &&
|
||||||
aDocument && item->Content()->GetOwnerDoc() == aDocument) {
|
IsChildOfDocShell(item->Content()->GetOwnerDoc(), aDocShellToHide)) {
|
||||||
nsMenuPopupFrame* frame = item->Frame();
|
nsMenuPopupFrame* frame = item->Frame();
|
||||||
item->Detach(&mPanels);
|
item->Detach(&mPanels);
|
||||||
delete item;
|
delete item;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user