From dba0a9ec3671be395a2f1c17cdd6e3a84ccb80fe Mon Sep 17 00:00:00 2001 From: "Adam Dane [:hobophobe]" Date: Thu, 10 Oct 2013 15:27:15 -0500 Subject: [PATCH] Bug 897751 - Tab close button's DoubleClick protection handler leaks. r=mano --- browser/base/content/tabbrowser.xml | 102 ++++++++++++++++------------ 1 file changed, 57 insertions(+), 45 deletions(-) diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index a910067d09a2..401ce2216921 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -4115,6 +4115,61 @@ event.preventDefault(); ]]> + 1 && !target._ignoredCloseButtonClicks) { + target._ignoredCloseButtonClicks = true; + event.stopPropagation(); + return; + } else { + // Reset the "ignored click" flag + target._ignoredCloseButtonClicks = false; + } + } + + /* Protects from close-tab-button errant doubleclick: + * Since we're removing the event target, if the user + * double-clicks the 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, we're manually blocking the dblclick event + * (see tabbrowser-close-tab-button dblclick handler). + */ + if (this._blockDblClick) { + if (!("_clickedTabBarOnce" in this)) { + this._clickedTabBarOnce = true; + return; + } + delete this._clickedTabBarOnce; + this._blockDblClick = false; + } + ]]> + 1 && !this._ignoredClick) { - this._ignoredClick = true; - return; - } - - // Reset the "ignored click" flag - this._ignoredClick = false; - tabContainer.tabbrowser.removeTab(bindingParent, {animate: true, byMouse: true}); + // This enables double-click protection for the tab container + // (see tabbrowser-tabs 'click' handler). tabContainer._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, we're manually blocking the dblclick event - * (see dblclick handler). - */ - var clickedOnce = false; - function enableDblClick(event) { - var target = event.originalTarget; - if (target.className == 'tab-close-button') - target._ignoredClick = true; - if (!clickedOnce) { - clickedOnce = true; - return; - } - tabContainer._blockDblClick = false; - tabContainer.removeEventListener("click", enableDblClick, true); - } - tabContainer.addEventListener("click", enableDblClick, true); ]]>