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
--- 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[