From d45ec4a94788115ad6066eeb414dd561d09ffc3f Mon Sep 17 00:00:00 2001 From: SHIMODA Hiroshi Date: Fri, 6 Jan 2012 19:38:38 +0900 Subject: [PATCH] when the browser is too slow, manual scrollings on the tab bar can be canceled by smooth scroll animations of TST --- modules/browser.js | 14 ++++++++++++++ modules/utils.js | 11 ++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/modules/browser.js b/modules/browser.js index a6b7930f..c68d8235 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -1354,6 +1354,7 @@ TreeStyleTabBrowser.prototype = { strip.addEventListener('MozMouseHittest', this, true); // to block default behaviors of the tab bar strip.addEventListener('mousedown', this, true); strip.addEventListener('click', this, true); + strip.addEventListener('DOMMouseScroll', this, true); this.scrollBox.addEventListener('overflow', this, true); this.scrollBox.addEventListener('underflow', this, true); @@ -1920,6 +1921,7 @@ TreeStyleTabBrowser.prototype = { strip.removeEventListener('MozMouseHittest', this, true); strip.removeEventListener('mousedown', this, true); strip.removeEventListener('click', this, true); + strip.removeEventListener('DOMMouseScroll', this, true); this.scrollBox.removeEventListener('overflow', this, true); this.scrollBox.removeEventListener('underflow', this, true); @@ -2396,6 +2398,9 @@ TreeStyleTabBrowser.prototype = { case 'mousedown': return this.onMouseDown(aEvent); + case 'DOMMouseScroll': + return this.onDOMMouseScroll(aEvent); + case 'scroll': return this.onScroll(aEvent); @@ -4090,6 +4095,9 @@ TreeStyleTabBrowser.prototype = { onMouseDown : function TSTBrowser_onMouseDown(aEvent) { + if (this.smoothScrollTask && this.isEventFiredOnScrollbar(aEvent)) + this.animationManager.removeTask(this.smoothScrollTask); + if ( aEvent.button == 0 && this.isEventFiredOnTwisty(aEvent) @@ -4104,6 +4112,12 @@ TreeStyleTabBrowser.prototype = { } }, + onDOMMouseScroll : function TSTBrowser_onDOMMouseScroll(aEvent) + { + if (this.smoothScrollTask) + this.animationManager.removeTask(this.smoothScrollTask); + }, + onScroll : function TSTBrowser_onScroll(aEvent) { // restore scroll position when a tab is closed. diff --git a/modules/utils.js b/modules/utils.js index 3ce36633..65130013 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -842,7 +842,16 @@ var TreeStyleTabUtils = { isEventFiredOnClickable : function TSTUtils_isEventFiredOnClickable(aEvent) { return this.evaluateXPath( - 'ancestor-or-self::*[contains(" button toolbarbutton scrollbar popup menupopup panel tooltip splitter textbox ", concat(" ", local-name(), " "))]', + 'ancestor-or-self::*[contains(" button toolbarbutton scrollbar nativescrollbar popup menupopup panel tooltip splitter textbox ", concat(" ", local-name(), " "))]', + aEvent.originalTarget, + Ci.nsIDOMXPathResult.BOOLEAN_TYPE + ).booleanValue; + }, + + isEventFiredOnScrollbar : function TSTUtils_isEventFiredOnScrollbar(aEvent) + { + return this.evaluateXPath( + 'ancestor-or-self::*[local-name()="scrollbar" or local-name()="nativescrollbar"]', aEvent.originalTarget, Ci.nsIDOMXPathResult.BOOLEAN_TYPE ).booleanValue;