Bug 1435142 - Part 1: pref to enable close selected tab by dblclicking it. r=dao

MozReview-Commit-ID: ErulnUeVK0F

--HG--
extra : rebase_source : f9aaaa4ee6bf005e40b6f9f88255c589d2695e74
This commit is contained in:
Hector Zhao 2018-02-02 11:37:58 +08:00
Родитель 15414c4ffe
Коммит dd3e7ab8f5
2 изменённых файлов: 23 добавлений и 0 удалений

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

@ -463,6 +463,7 @@ pref("browser.link.open_newwindow.disabled_in_fullscreen", false);
#endif #endif
// Tabbed browser // Tabbed browser
pref("browser.tabs.closeTabByDblclick", false);
pref("browser.tabs.closeWindowWithLastTab", true); pref("browser.tabs.closeWindowWithLastTab", true);
pref("browser.tabs.insertRelatedAfterCurrent", true); pref("browser.tabs.insertRelatedAfterCurrent", true);
pref("browser.tabs.warnOnClose", true); pref("browser.tabs.warnOnClose", true);

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

@ -143,6 +143,9 @@
CustomizableUI.addListener(this); CustomizableUI.addListener(this);
this._updateNewTabVisibility(); this._updateNewTabVisibility();
XPCOMUtils.defineLazyPreferenceGetter(this, "_closeTabByDblclick",
"browser.tabs.closeTabByDblclick", false);
]]> ]]>
</constructor> </constructor>
@ -1689,6 +1692,7 @@
]]> ]]>
</setter> </setter>
</property> </property>
<field name="_selectedOnFirstMouseDown">false</field>
<property name="pinned" readonly="true"> <property name="pinned" readonly="true">
<getter> <getter>
@ -1992,6 +1996,13 @@
<handler event="mousedown" phase="capturing"> <handler event="mousedown" phase="capturing">
<![CDATA[ <![CDATA[
let tabContainer = this.parentNode;
if (tabContainer._closeTabByDblclick &&
event.button == 0 &&
event.detail == 1) {
this._selectedOnFirstMouseDown = this.selected;
}
if (this.selected) { if (this.selected) {
this.style.MozUserFocus = "ignore"; this.style.MozUserFocus = "ignore";
} else if (this.mOverCloseButton || } else if (this.mOverCloseButton ||
@ -2027,6 +2038,17 @@
if (event.originalTarget.getAttribute("anonid") == "close-button") { if (event.originalTarget.getAttribute("anonid") == "close-button") {
event.stopPropagation(); event.stopPropagation();
} }
let tabContainer = this.parentNode;
if (tabContainer._closeTabByDblclick &&
this._selectedOnFirstMouseDown &&
this.selected &&
!this._overPlayingIcon) {
gBrowser.removeTab(this, {
animate: true,
byMouse: event.mozInputSource == MouseEvent.MOZ_SOURCE_MOUSE,
});
}
]]></handler> ]]></handler>
<handler event="animationend"> <handler event="animationend">