mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 18:26:15 +00:00
Bug 288763, problems with context menupopup cause a crash on window close, r=enndeakin, sr=bz
This commit is contained in:
parent
492ad73ac7
commit
4d9109ceaa
@ -81,6 +81,7 @@
|
|||||||
#include "nsPIDOMWindow.h"
|
#include "nsPIDOMWindow.h"
|
||||||
|
|
||||||
#include "nsIFrame.h"
|
#include "nsIFrame.h"
|
||||||
|
#include "nsIMenuFrame.h"
|
||||||
|
|
||||||
// on win32 and os/2, context menus come up on mouse up. On other platforms,
|
// on win32 and os/2, context menus come up on mouse up. On other platforms,
|
||||||
// they appear on mouse down. Certain bits of code care about this difference.
|
// they appear on mouse down. Certain bits of code care about this difference.
|
||||||
@ -586,6 +587,21 @@ XULPopupListenerImpl::LaunchPopup(PRInt32 aClientX, PRInt32 aClientY)
|
|||||||
if ( !popupContent )
|
if ( !popupContent )
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
|
// Submenus can't be used as context menus or popups, bug 288763.
|
||||||
|
// Similar code also in nsXULTooltipListener::GetTooltipFor.
|
||||||
|
nsCOMPtr<nsIContent> popup = do_QueryInterface(popupContent);
|
||||||
|
nsIContent* parent = popup->GetParent();
|
||||||
|
if (parent) {
|
||||||
|
nsIDocument* doc = parent->GetCurrentDoc();
|
||||||
|
nsIPresShell* presShell = doc ? doc->GetShellAt(0) : nsnull;
|
||||||
|
nsIFrame* frame = presShell ? presShell->GetPrimaryFrameFor(parent) : nsnull;
|
||||||
|
if (frame) {
|
||||||
|
nsIMenuFrame* menu = nsnull;
|
||||||
|
CallQueryInterface(frame, &menu);
|
||||||
|
NS_ENSURE_FALSE(menu, NS_OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We have some popup content. Obtain our window.
|
// We have some popup content. Obtain our window.
|
||||||
nsPIDOMWindow *domWindow = document->GetWindow();
|
nsPIDOMWindow *domWindow = document->GetWindow();
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "nsXULAtoms.h"
|
#include "nsXULAtoms.h"
|
||||||
#include "nsIPresShell.h"
|
#include "nsIPresShell.h"
|
||||||
#include "nsIFrame.h"
|
#include "nsIFrame.h"
|
||||||
|
#include "nsIMenuFrame.h"
|
||||||
#include "nsIPopupBoxObject.h"
|
#include "nsIPopupBoxObject.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#ifdef MOZ_XUL
|
#ifdef MOZ_XUL
|
||||||
@ -557,7 +558,7 @@ GetImmediateChild(nsIContent* aContent, nsIAtom *aTag, nsIContent** aResult)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsXULTooltipListener::GetTooltipFor(nsIContent* aTarget, nsIContent** aTooltip)
|
nsXULTooltipListener::FindTooltip(nsIContent* aTarget, nsIContent** aTooltip)
|
||||||
{
|
{
|
||||||
if (!aTarget)
|
if (!aTarget)
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
@ -631,6 +632,34 @@ nsXULTooltipListener::GetTooltipFor(nsIContent* aTarget, nsIContent** aTooltip)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsXULTooltipListener::GetTooltipFor(nsIContent* aTarget, nsIContent** aTooltip)
|
||||||
|
{
|
||||||
|
*aTooltip = nsnull;
|
||||||
|
nsCOMPtr<nsIContent> tooltip;
|
||||||
|
nsresult rv = FindTooltip(aTarget, getter_AddRefs(tooltip));
|
||||||
|
if (NS_FAILED(rv) || !tooltip) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Submenus can't be used as tooltips, see bug 288763.
|
||||||
|
nsIContent* parent = tooltip->GetParent();
|
||||||
|
if (parent) {
|
||||||
|
nsIDocument* doc = parent->GetCurrentDoc();
|
||||||
|
nsIPresShell* presShell = doc ? doc->GetShellAt(0) : nsnull;
|
||||||
|
nsIFrame* frame = presShell ? presShell->GetPrimaryFrameFor(parent) : nsnull;
|
||||||
|
if (frame) {
|
||||||
|
nsIMenuFrame* menu = nsnull;
|
||||||
|
CallQueryInterface(frame, &menu);
|
||||||
|
NS_ENSURE_FALSE(menu, NS_ERROR_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tooltip.swap(*aTooltip);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsXULTooltipListener::DestroyTooltip()
|
nsXULTooltipListener::DestroyTooltip()
|
||||||
{
|
{
|
||||||
|
@ -119,6 +119,10 @@ protected:
|
|||||||
nsresult LaunchTooltip(nsIContent* aTarget, PRInt32 aX, PRInt32 aY);
|
nsresult LaunchTooltip(nsIContent* aTarget, PRInt32 aX, PRInt32 aY);
|
||||||
nsresult HideTooltip();
|
nsresult HideTooltip();
|
||||||
nsresult DestroyTooltip();
|
nsresult DestroyTooltip();
|
||||||
|
// This method tries to find a tooltip for aTarget.
|
||||||
|
nsresult FindTooltip(nsIContent* aTarget, nsIContent** aTooltip);
|
||||||
|
// This method calls FindTooltip and checks that the tooltip
|
||||||
|
// can be really used (i.e. tooltip is not a menu).
|
||||||
nsresult GetTooltipFor(nsIContent* aTarget, nsIContent** aTooltip);
|
nsresult GetTooltipFor(nsIContent* aTarget, nsIContent** aTooltip);
|
||||||
|
|
||||||
static int ToolbarTipsPrefChanged(const char *aPref, void *aClosure);
|
static int ToolbarTipsPrefChanged(const char *aPref, void *aClosure);
|
||||||
|
Loading…
Reference in New Issue
Block a user