Bug 1273240 - Add logic for processing middle mouse clicks on text links. r=Ratty a=Ratty
authorFrank-Rainer Grahl <frgrahl@gmx.net>
Sun, 29 May 2016 10:56:11 +0200
changeset 19390 5adad11ce60baa398b1ab12f439e45178a7229e5
parent 19389 23d2205feabf6bbdc71773bdfcd4a4bc3e3efe7d
child 19391 85e97d05f9a53930b20ee854fb700ba26b283b0f
push id11930
push userfrgrahl@gmx.net
push dateSun, 29 May 2016 08:56:33 +0000
treeherdercomm-central@5adad11ce60b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersRatty, Ratty
bugs1273240, 263433, 1268943, 1274533
Bug 1273240 - Add logic for processing middle mouse clicks on text links. r=Ratty a=Ratty Port Bug 263433, 1268943 and 1274533.
suite/common/src/nsSuiteGlue.js
--- a/suite/common/src/nsSuiteGlue.js
+++ b/suite/common/src/nsSuiteGlue.js
@@ -262,16 +262,33 @@ SuiteGlue.prototype = {
         break;
       case "timer-callback":
         // Load the Login Manager data from disk off the main thread, some time
         // after startup.  If the data is required before the timeout, for example
         // because a restored page contains a password field, it will be loaded on
         // the main thread, and this initialization request will be ignored.
         Services.logins;
         break;
+      case "handle-xul-text-link":
+        let linkHandled = subject.QueryInterface(Components.interfaces.nsISupportsPRBool);
+        if (!linkHandled.data) {
+          let mostRecentBrowserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+          if (mostRecentBrowserWindow) {
+            let dataObj = JSON.parse(data);
+            let where = mostRecentBrowserWindow.whereToOpenLink(dataObj, false, true, true);
+            // Preserve legacy behavior of non-modifier left-clicks
+            // opening in a new selected tab.
+            if (where == "current") {
+              where = "tabfocused";
+            }
+            mostRecentBrowserWindow.openUILinkIn(dataObj.href, where);
+            linkHandled.data = true;
+          }
+        }
+        break;
     }
   },
 
   // nsIWebProgressListener partial implementation
   onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags)
   {
     if (aWebProgress.isTopLevel &&
         aWebProgress instanceof Components.interfaces.nsIDocShell &&
@@ -322,16 +339,17 @@ SuiteGlue.prototype = {
     Services.obs.addObserver(this, "session-save", true);
     Services.obs.addObserver(this, "dl-done", true);
     Services.obs.addObserver(this, "places-init-complete", true);
     Services.obs.addObserver(this, "places-database-locked", true);
     Services.obs.addObserver(this, "places-shutdown", true);
     Services.obs.addObserver(this, "browser-search-engine-modified", true);
     Services.obs.addObserver(this, "notifications-open-settings", true);
     Services.prefs.addObserver("devtools.debugger.", this, true);
+    Services.obs.addObserver(this, "handle-xul-text-link", true);
     Components.classes['@mozilla.org/docloaderservice;1']
               .getService(Components.interfaces.nsIWebProgress)
               .addProgressListener(this, Components.interfaces.nsIWebProgress.NOTIFY_LOCATION);
   },
 
   // profile is available
   _onProfileAfterChange: function()
   {