Bug 1219215 - final part: ignore middle clicks to open tabs in the middle of closing tabs unless past the end of the last visible tab, r?dao draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 12 Jan 2016 22:17:50 +0000
changeset 327533 c25fb96efa590e0c36985b82d6a69d0d76f15744
parent 327532 eebe1132e3eb08745e1cbd1100ccec0bf99f201b
child 513713 0b401bd1edab70a49127a1e2b610b83ad43042f9
push id10252
push usergijskruitbosch@gmail.com
push dateMon, 01 Feb 2016 11:55:08 +0000
reviewersdao
bugs1219215
milestone47.0a1
Bug 1219215 - final part: ignore middle clicks to open tabs in the middle of closing tabs unless past the end of the last visible tab, r?dao
browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -5498,17 +5498,35 @@
 
       <handler event="click"><![CDATA[
         if (event.button != 1)
           return;
 
         if (event.target.localName == "tab") {
           this.tabbrowser.removeTab(event.target, {animate: true, byMouse: true});
         } else if (event.originalTarget.localName == "box") {
-          BrowserOpenTab();
+          // The user middleclicked an open space on the tabstrip. This could
+          // be because they intend to open a new tab, but it could also be
+          // because they just removed a tab and they now middleclicked on the
+          // resulting space while that tab is closing. In that case, we don't
+          // want to open a tab. So if we're removing one or more tabs, and
+          // the tab click is before the end of the last visible tab, we do
+          // nothing.
+          if (this.tabbrowser._removingTabs.length) {
+            let visibleTabs = this.tabbrowser.visibleTabs;
+            let ltr = (window.getComputedStyle(this, null).direction == "ltr");
+            let lastTab = visibleTabs[visibleTabs.length - 1];
+            let endOfTab = lastTab.getBoundingClientRect()[ltr ? "right" : "left"];
+            if ((ltr && event.clientX > endOfTab) ||
+                (!ltr && event.clientX < endOfTab)) {
+              BrowserOpenTab();
+            }
+          } else {
+            BrowserOpenTab();
+          }
         } else {
           return;
         }
 
         event.stopPropagation();
       ]]></handler>
 
       <handler event="keydown" group="system"><![CDATA[