when the browser is too slow, manual scrollings on the tab bar can be canceled by smooth scroll animations of TST

This commit is contained in:
SHIMODA Hiroshi 2012-01-06 19:38:38 +09:00
parent d512dbbfa4
commit d45ec4a947
2 changed files with 24 additions and 1 deletions

View File

@ -1354,6 +1354,7 @@ TreeStyleTabBrowser.prototype = {
strip.addEventListener('MozMouseHittest', this, true); // to block default behaviors of the tab bar strip.addEventListener('MozMouseHittest', this, true); // to block default behaviors of the tab bar
strip.addEventListener('mousedown', this, true); strip.addEventListener('mousedown', this, true);
strip.addEventListener('click', this, true); strip.addEventListener('click', this, true);
strip.addEventListener('DOMMouseScroll', this, true);
this.scrollBox.addEventListener('overflow', this, true); this.scrollBox.addEventListener('overflow', this, true);
this.scrollBox.addEventListener('underflow', this, true); this.scrollBox.addEventListener('underflow', this, true);
@ -1920,6 +1921,7 @@ TreeStyleTabBrowser.prototype = {
strip.removeEventListener('MozMouseHittest', this, true); strip.removeEventListener('MozMouseHittest', this, true);
strip.removeEventListener('mousedown', this, true); strip.removeEventListener('mousedown', this, true);
strip.removeEventListener('click', this, true); strip.removeEventListener('click', this, true);
strip.removeEventListener('DOMMouseScroll', this, true);
this.scrollBox.removeEventListener('overflow', this, true); this.scrollBox.removeEventListener('overflow', this, true);
this.scrollBox.removeEventListener('underflow', this, true); this.scrollBox.removeEventListener('underflow', this, true);
@ -2396,6 +2398,9 @@ TreeStyleTabBrowser.prototype = {
case 'mousedown': case 'mousedown':
return this.onMouseDown(aEvent); return this.onMouseDown(aEvent);
case 'DOMMouseScroll':
return this.onDOMMouseScroll(aEvent);
case 'scroll': case 'scroll':
return this.onScroll(aEvent); return this.onScroll(aEvent);
@ -4090,6 +4095,9 @@ TreeStyleTabBrowser.prototype = {
onMouseDown : function TSTBrowser_onMouseDown(aEvent) onMouseDown : function TSTBrowser_onMouseDown(aEvent)
{ {
if (this.smoothScrollTask && this.isEventFiredOnScrollbar(aEvent))
this.animationManager.removeTask(this.smoothScrollTask);
if ( if (
aEvent.button == 0 && aEvent.button == 0 &&
this.isEventFiredOnTwisty(aEvent) 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) onScroll : function TSTBrowser_onScroll(aEvent)
{ {
// restore scroll position when a tab is closed. // restore scroll position when a tab is closed.

View File

@ -842,7 +842,16 @@ var TreeStyleTabUtils = {
isEventFiredOnClickable : function TSTUtils_isEventFiredOnClickable(aEvent) isEventFiredOnClickable : function TSTUtils_isEventFiredOnClickable(aEvent)
{ {
return this.evaluateXPath( 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, aEvent.originalTarget,
Ci.nsIDOMXPathResult.BOOLEAN_TYPE Ci.nsIDOMXPathResult.BOOLEAN_TYPE
).booleanValue; ).booleanValue;