Bug 389573, context menus opening in wrong place, affects email address menu, r+sr=bz,a=dbaron
Bug 389573, context menus opening in wrong place, affects email address menu, r+sr=bz,a=dbaron
--- a/content/xul/content/src/nsXULPopupListener.cpp
+++ b/content/xul/content/src/nsXULPopupListener.cpp
@@ -460,24 +460,27 @@ nsXULPopupListener::LaunchPopup(nsIDOMEv
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (!pm)
return NS_OK;
// XXXndeakin this is temporary. It is needed to grab the mouse location details
// used by the spellchecking popup. See bug 383930.
pm->SetMouseLocation(aEvent, popup);
- // if the popup has an anchoring attribute, anchor it to the element,
- // otherwise just open it at the screen position where the mouse was clicked.
+ // For left-clicks, if the popup has an position attribute, or both the
+ // popupanchor and popupalign attributes are used, anchor the popup to the
+ // element, otherwise just open it at the screen position where the mouse
+ // was clicked. Context menus always open at the mouse position.
mPopupContent = popup;
- if (mPopupContent->HasAttr(kNameSpaceID_None, nsGkAtoms::position) ||
- mPopupContent->HasAttr(kNameSpaceID_None, nsGkAtoms::popupanchor) ||
- mPopupContent->HasAttr(kNameSpaceID_None, nsGkAtoms::popupalign)) {
+ if (!mIsContext &&
+ (mPopupContent->HasAttr(kNameSpaceID_None, nsGkAtoms::position) ||
+ (mPopupContent->HasAttr(kNameSpaceID_None, nsGkAtoms::popupanchor) &&
+ mPopupContent->HasAttr(kNameSpaceID_None, nsGkAtoms::popupalign)))) {
pm->ShowPopup(mPopupContent, content, EmptyString(), 0, 0,
- mIsContext, PR_TRUE, PR_FALSE);
+ PR_FALSE, PR_TRUE, PR_FALSE);
}
else {
PRInt32 xPos = 0, yPos = 0;
nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aEvent);
mouseEvent->GetScreenX(&xPos);
mouseEvent->GetScreenY(&yPos);
if (mIsContext) {