Bug 389573, context menus opening in wrong place, affects email address menu, r+sr=bz,a=dbaron
authorenndeakin@sympatico.ca
Fri, 03 Aug 2007 10:57:44 -0700
changeset 4243 1518341b8a0415c7e98f4344073e9e49da005e99
parent 4242 ae44dc46ca513c034583f3655e14eb656fecb475
child 4244 dcd22587ea8c09a8722aa34e18d33f903dc11e98
push idunknown
push userunknown
push dateunknown
reviewersdbaron
bugs389573
milestone1.9a8pre
Bug 389573, context menus opening in wrong place, affects email address menu, r+sr=bz,a=dbaron
content/xul/content/src/nsXULPopupListener.cpp
--- 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) {