Bug 343628 - Double-clicking a close button of a tab shouldn't open a new tab. r=robert.

This commit is contained in:
mozilla.mano%sent.com 2006-07-13 06:46:57 +00:00
Родитель e121423cb8
Коммит e36b155053
3 изменённых файлов: 59 добавлений и 18 удалений

Просмотреть файл

@ -25,6 +25,7 @@
- Mike Connor <mconnor@steelgryphon.com>
- Peter Parente <parente@cs.unc.edu>
- 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
- either the GNU General Public License Version 2 or later (the "GPL"), or
@ -194,6 +195,10 @@
null
</field>
<field name="_blockDblClick">
false
</field>
<method name="getBrowserAtIndex">
<parameter name="aIndex"/>
<body>
@ -1456,7 +1461,8 @@
<parameter name="aEvent"/>
<body>
<![CDATA[
if (aEvent.button == 0 &&
// See hack note in the tabbrowser-close-button binding
if (!this._blockDblClick && aEvent.button == 0 &&
aEvent.originalTarget.localName == "box") {
// xxx this needs to check that we're in the empty area of the tabstrip
var e = document.createEvent("Events");
@ -2392,9 +2398,7 @@
<children includes="tab"/>
</xul:arrowscrollbox>
<xul:hbox class="tabs-closebutton-box" align="center" pack="end" anonid="tabstrip-closebutton">
<xul:toolbarbutton ondblclick="event.stopPropagation();"
class="close-button tabs-closebutton"
oncommand="this.parentNode.parentNode.parentNode.parentNode.parentNode.removeCurrentTab()"/>
<xul:toolbarbutton class="close-button tabs-closebutton"/>
</xul:hbox>
</content>
<implementation>
@ -2580,6 +2584,51 @@
</handlers>
</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"
extends="chrome://global/content/bindings/tabbox.xml#tab">
<content chromedir="&locale.dir;"
@ -2607,13 +2656,6 @@
if (anonid == "close-button")
this.mOverCloseButton = false;
</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">
<![CDATA[
if (this.mOverCloseButton)

Просмотреть файл

@ -623,6 +623,11 @@ tab {
-moz-binding: url("chrome://global/content/bindings/tabbrowser.xml#tabbrowser-tab");
}
.tabbrowser-tabs > .tabbrowser-tab > .tab-close-button,
.tabs-closebutton-box > .tabs-closebutton {
-moz-binding: url("chrome://global/content/bindings/tabbrowser.xml#tabbrowser-close-tab-button");
}
.tab-close-button {
display: none;
}
@ -639,10 +644,6 @@ tab {
display: none;
}
.tabs-closebutton-box > .tab-close-button {
display: -moz-box;
}
.tabbrowser-tabs[disablebackgroundclose="true"] > .tabbrowser-tab:not([selected="true"]) > .tab-close-button {
display: none;
}

Просмотреть файл

@ -63,9 +63,7 @@
<children/>
</xul:arrowscrollbox>
<xul:hbox class="tabs-closebutton-box" align="center" pack="end" anonid="tabstrip-closebutton">
<xul:toolbarbutton ondblclick="event.stopPropagation();"
class="close-button tabs-closebutton"
oncommand="this.parentNode.parentNode.parentNode.parentNode.parentNode.removeCurrentTab()"/>
<xul:toolbarbutton class="close-button tabs-closebutton"/>
</xul:hbox>
</xul:hbox>
<xul:spacer class="tabs-bottom-spacer"/>