зеркало из https://github.com/mozilla/pjs.git
Bug 343628 - Double-clicking a close button of a tab shouldn't open a new tab. r=robert.
This commit is contained in:
Родитель
1dfa59ccab
Коммит
1009d0efbb
|
@ -25,6 +25,7 @@
|
||||||
- Mike Connor <mconnor@steelgryphon.com>
|
- Mike Connor <mconnor@steelgryphon.com>
|
||||||
- Peter Parente <parente@cs.unc.edu>
|
- Peter Parente <parente@cs.unc.edu>
|
||||||
- Giorgio Maone <g.maone@informaction.com>
|
- Giorgio Maone <g.maone@informaction.com>
|
||||||
|
- Asaf Romano <mozilla.mano@sent.com>
|
||||||
-
|
-
|
||||||
- Alternatively, the contents of this file may be used under the terms of
|
- Alternatively, the contents of this file may be used under the terms of
|
||||||
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
@ -194,6 +195,10 @@
|
||||||
null
|
null
|
||||||
</field>
|
</field>
|
||||||
|
|
||||||
|
<field name="_blockDblClick">
|
||||||
|
false
|
||||||
|
</field>
|
||||||
|
|
||||||
<method name="getBrowserAtIndex">
|
<method name="getBrowserAtIndex">
|
||||||
<parameter name="aIndex"/>
|
<parameter name="aIndex"/>
|
||||||
<body>
|
<body>
|
||||||
|
@ -1456,7 +1461,8 @@
|
||||||
<parameter name="aEvent"/>
|
<parameter name="aEvent"/>
|
||||||
<body>
|
<body>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (aEvent.button == 0 &&
|
// See hack note in the tabbrowser-close-button binding
|
||||||
|
if (!this._blockDblClick && aEvent.button == 0 &&
|
||||||
aEvent.originalTarget.localName == "box") {
|
aEvent.originalTarget.localName == "box") {
|
||||||
// xxx this needs to check that we're in the empty area of the tabstrip
|
// xxx this needs to check that we're in the empty area of the tabstrip
|
||||||
var e = document.createEvent("Events");
|
var e = document.createEvent("Events");
|
||||||
|
@ -2392,9 +2398,7 @@
|
||||||
<children includes="tab"/>
|
<children includes="tab"/>
|
||||||
</xul:arrowscrollbox>
|
</xul:arrowscrollbox>
|
||||||
<xul:hbox class="tabs-closebutton-box" align="center" pack="end" anonid="tabstrip-closebutton">
|
<xul:hbox class="tabs-closebutton-box" align="center" pack="end" anonid="tabstrip-closebutton">
|
||||||
<xul:toolbarbutton ondblclick="event.stopPropagation();"
|
<xul:toolbarbutton class="close-button tabs-closebutton"/>
|
||||||
class="close-button tabs-closebutton"
|
|
||||||
oncommand="this.parentNode.parentNode.parentNode.parentNode.parentNode.removeCurrentTab()"/>
|
|
||||||
</xul:hbox>
|
</xul:hbox>
|
||||||
</content>
|
</content>
|
||||||
<implementation>
|
<implementation>
|
||||||
|
@ -2580,6 +2584,51 @@
|
||||||
</handlers>
|
</handlers>
|
||||||
</binding>
|
</binding>
|
||||||
|
|
||||||
|
<!-- close-tab-button binding
|
||||||
|
This binding relies on the structure of the tabbrowser binding.
|
||||||
|
Therefor it should only be used as a child of the tab or the tabs
|
||||||
|
element (in both cases, when they are anonymous nodes of <tabbrowser>).
|
||||||
|
This binding is exposed as a pseudo-public-API so themes can customize
|
||||||
|
the tabbar appearance without having to be scriptable
|
||||||
|
(see globalBindings.xml in Pinstripe for example).
|
||||||
|
-->
|
||||||
|
<binding id="tabbrowser-close-tab-button"
|
||||||
|
extends="chrome://global/content/bindings/toolbarbutton.xml#toolbarbutton">
|
||||||
|
<handlers>
|
||||||
|
<handler event="command"><![CDATA[
|
||||||
|
var bindingParent = document.getBindingParent(this);
|
||||||
|
if (bindingParent) {
|
||||||
|
var tabbedBrowser = document.getBindingParent(bindingParent);
|
||||||
|
if (bindingParent.localName == "tab") {
|
||||||
|
tabbedBrowser.removeTab(bindingParent);
|
||||||
|
tabbedBrowser._blockDblClick = true;
|
||||||
|
|
||||||
|
/* XXXmano hack (see bug 343628):
|
||||||
|
* Since we're removing the event target, if the user
|
||||||
|
* double-clicks this button, the dblclick event will be dispatched
|
||||||
|
* with the tabbar as its event target (and explicit/originalTarget),
|
||||||
|
* which treats that as a mouse gesture for opening a new tab.
|
||||||
|
* In this context, there is no way to prevent the dispatching
|
||||||
|
* of the dblclick event, so we're manually blocking it (see
|
||||||
|
* onTabBarDblClick) until the mouse is moved.
|
||||||
|
*/
|
||||||
|
function mouseMoveHandler() {
|
||||||
|
tabbedBrowser._blockDblClick = false;
|
||||||
|
tabbedBrowser.removeEventListener("mousemove", mouseMoveHandler, false);
|
||||||
|
}
|
||||||
|
tabbedBrowser.addEventListener("mousemove", mouseMoveHandler, false);
|
||||||
|
}
|
||||||
|
else // "tabs"
|
||||||
|
tabbedBrowser.removeCurrentTab();
|
||||||
|
}
|
||||||
|
]]></handler>
|
||||||
|
<handler event="dblclick" phase="capturing">
|
||||||
|
// for the one-close-button case
|
||||||
|
event.stopPropagation();
|
||||||
|
</handler>
|
||||||
|
</handlers>
|
||||||
|
</binding>
|
||||||
|
|
||||||
<binding id="tabbrowser-tab" display="xul:box"
|
<binding id="tabbrowser-tab" display="xul:box"
|
||||||
extends="chrome://global/content/bindings/tabbox.xml#tab">
|
extends="chrome://global/content/bindings/tabbox.xml#tab">
|
||||||
<content chromedir="&locale.dir;"
|
<content chromedir="&locale.dir;"
|
||||||
|
@ -2607,13 +2656,6 @@
|
||||||
if (anonid == "close-button")
|
if (anonid == "close-button")
|
||||||
this.mOverCloseButton = false;
|
this.mOverCloseButton = false;
|
||||||
</handler>
|
</handler>
|
||||||
<handler event="command">
|
|
||||||
<![CDATA[
|
|
||||||
var anonid = event.originalTarget.getAttribute("anonid");
|
|
||||||
if (anonid == "close-button")
|
|
||||||
this.parentNode.parentNode.parentNode.parentNode.removeTab(this);
|
|
||||||
]]>
|
|
||||||
</handler>
|
|
||||||
<handler event="mousedown" button="0" phase="capturing">
|
<handler event="mousedown" button="0" phase="capturing">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (this.mOverCloseButton)
|
if (this.mOverCloseButton)
|
||||||
|
|
|
@ -63,9 +63,7 @@
|
||||||
<children/>
|
<children/>
|
||||||
</xul:arrowscrollbox>
|
</xul:arrowscrollbox>
|
||||||
<xul:hbox class="tabs-closebutton-box" align="center" pack="end" anonid="tabstrip-closebutton">
|
<xul:hbox class="tabs-closebutton-box" align="center" pack="end" anonid="tabstrip-closebutton">
|
||||||
<xul:toolbarbutton ondblclick="event.stopPropagation();"
|
<xul:toolbarbutton class="close-button tabs-closebutton"/>
|
||||||
class="close-button tabs-closebutton"
|
|
||||||
oncommand="this.parentNode.parentNode.parentNode.parentNode.parentNode.removeCurrentTab()"/>
|
|
||||||
</xul:hbox>
|
</xul:hbox>
|
||||||
</xul:hbox>
|
</xul:hbox>
|
||||||
<xul:spacer class="tabs-bottom-spacer"/>
|
<xul:spacer class="tabs-bottom-spacer"/>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче