Bug 595570 Fix mouse coordinates for tooltip popupshowing events r=Enn a=roc
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Thu, 07 Oct 2010 21:38:13 +0100
changeset 55146 b5744e9dd0f09b2ba3ca92d9fcc02c52ea0c7c2d
parent 55145 416db086984109c66012d94c75129a0b350fee08
child 55147 dc689419476d1240dc08bbdaf933f6d98e822e69
push idunknown
push userunknown
push dateunknown
reviewersEnn, roc
bugs595570
milestone2.0b8pre
Bug 595570 Fix mouse coordinates for tooltip popupshowing events r=Enn a=roc
layout/xul/base/src/nsXULPopupManager.cpp
--- a/layout/xul/base/src/nsXULPopupManager.cpp
+++ b/layout/xul/base/src/nsXULPopupManager.cpp
@@ -602,16 +602,27 @@ nsXULPopupManager::ShowTooltipAtScreen(n
                                        PRInt32 aXPos, PRInt32 aYPos)
 {
   nsMenuPopupFrame* popupFrame = GetPopupFrameForContent(aPopup, PR_TRUE);
   if (!popupFrame || !MayShowPopup(popupFrame))
     return;
 
   InitTriggerEvent(nsnull, nsnull, nsnull);
 
+  mCachedMousePoint = nsIntPoint(aXPos, aYPos);
+  // coordinates are relative to the root widget
+  nsPresContext* rootPresContext =
+    popupFrame->PresContext()->GetRootPresContext();
+  if (rootPresContext) {
+    nsCOMPtr<nsIWidget> widget;
+    rootPresContext->PresShell()->GetViewManager()->
+      GetRootWidget(getter_AddRefs(widget));
+    mCachedMousePoint -= widget->WidgetToScreenOffset();
+  }
+
   popupFrame->InitializePopupAtScreen(aTriggerContent, aXPos, aYPos, PR_FALSE);
 
   FirePopupShowingEvent(aPopup, PR_FALSE, PR_FALSE);
 }
 
 void
 nsXULPopupManager::ShowPopupWithAnchorAlign(nsIContent* aPopup,
                                             nsIContent* aAnchorContent,