Bug 1380294: Anchor non-tab tooltips to the correct remote browser. r?aswan draft
authorKris Maglione <maglione.k@gmail.com>
Tue, 01 Aug 2017 15:01:06 -0700
changeset 619370 3a0d185f78c6de9a77e0b228cc46eb088c3d8efb
parent 619248 f23f75bc9d39980d863e4d3d845dbd97d9de8f5c
child 619375 73e5ca7d8bf08eff5e1ba57df3e8da18123cebd9
push id71649
push usermaglione.k@gmail.com
push dateTue, 01 Aug 2017 22:01:28 +0000
reviewersaswan
bugs1380294
milestone56.0a1
Bug 1380294: Anchor non-tab tooltips to the correct remote browser. r?aswan MozReview-Commit-ID: EsJEseyfGYi
browser/base/content/browser.js
dom/ipc/TabParent.cpp
xpfe/appshell/nsIXULBrowserWindow.idl
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -4492,30 +4492,29 @@ var XULBrowserWindow = {
 
     if (gURLBar && gURLBar._mayTrimURLs /* corresponds to browser.urlbar.trimURLs */)
       url = trimURL(url);
 
     this.overLink = url;
     LinkTargetDisplay.update();
   },
 
-  showTooltip(x, y, tooltip, direction) {
+  showTooltip(x, y, tooltip, direction, browser) {
     if (Cc["@mozilla.org/widget/dragservice;1"].getService(Ci.nsIDragService).
         getCurrentSession()) {
       return;
     }
 
     // The x,y coordinates are relative to the <browser> element using
     // the chrome zoom level.
     let elt = document.getElementById("remoteBrowserTooltip");
     elt.label = tooltip;
     elt.style.direction = direction;
 
-    let anchor = gBrowser.selectedBrowser;
-    elt.openPopupAtScreen(anchor.boxObject.screenX + x, anchor.boxObject.screenY + y, false, null);
+    elt.openPopupAtScreen(browser.boxObject.screenX + x, browser.boxObject.screenY + y, false, null);
   },
 
   hideTooltip() {
     let elt = document.getElementById("remoteBrowserTooltip");
     elt.hidePopup();
   },
 
   getTabCount() {
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -1713,17 +1713,21 @@ mozilla::ipc::IPCResult
 TabParent::RecvShowTooltip(const uint32_t& aX, const uint32_t& aY, const nsString& aTooltip,
                            const nsString& aDirection)
 {
   nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow = GetXULBrowserWindow();
   if (!xulBrowserWindow) {
     return IPC_OK();
   }
 
-  xulBrowserWindow->ShowTooltip(aX, aY, aTooltip, aDirection);
+  nsCOMPtr<nsIFrameLoaderOwner> frame = do_QueryInterface(mFrameElement);
+  if (!frame)
+    return IPC_OK();
+
+  xulBrowserWindow->ShowTooltip(aX, aY, aTooltip, aDirection, frame);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 TabParent::RecvHideTooltip()
 {
   nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow = GetXULBrowserWindow();
   if (!xulBrowserWindow) {
--- a/xpfe/appshell/nsIXULBrowserWindow.idl
+++ b/xpfe/appshell/nsIXULBrowserWindow.idl
@@ -8,16 +8,17 @@
 #include "nsIURI.idl"
 #include "nsIDOMNode.idl"
 
 interface nsIBrowser;
 interface nsIRequest;
 interface nsIDOMElement;
 interface nsIInputStream;
 interface nsIDocShell;
+interface nsIFrameLoaderOwner;
 interface nsITabParent;
 interface nsIPrincipal;
 interface mozIDOMWindowProxy;
 
 /**
  * The nsIXULBrowserWindow supplies the methods that may be called from the
  * internals of the browser area to tell the containing xul window to update
  * its ui. 
@@ -71,17 +72,18 @@ interface nsIXULBrowserWindow : nsISuppo
   bool shouldLoadURI(in nsIDocShell    aDocShell,
                      in nsIURI         aURI,
                      in nsIURI         aReferrer,
                      in boolean        aHasPostData,
                      in nsIPrincipal   aTriggeringPrincipal);
   /**
    * Show/hide a tooltip (when the user mouses over a link, say).
    */
-  void showTooltip(in long x, in long y, in AString tooltip, in AString direction);
+  void showTooltip(in long x, in long y, in AString tooltip, in AString direction,
+                   in nsIFrameLoaderOwner browser);
   void hideTooltip();
 
   /**
    * Return the number of tabs in this window.
    */
   uint32_t getTabCount();
 
   /**