diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index ff97c36dd0eb..8e6e31427371 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -183,6 +183,7 @@ pref("browser.tabs.maxOpenBeforeWarn", 15); // 0 = append, 1 = replace pref("browser.tabs.loadGroup", 1); +pref("toolkit.scrollbox.smoothScroll", true); pref("toolkit.scrollbox.scrollIncrement", 20); pref("toolkit.scrollbox.clickToScroll.scrollDelay", 150); diff --git a/toolkit/content/widgets/scrollbox.xml b/toolkit/content/widgets/scrollbox.xml index fe777e33cc88..d18a16ec2cb6 100644 --- a/toolkit/content/widgets/scrollbox.xml +++ b/toolkit/content/widgets/scrollbox.xml @@ -40,7 +40,7 @@ xbl:inherits="orient" oncommand="scrollByPixels(this.parentNode.scrollIncrement); event.stopPropagation();"/> - + document.getAnonymousElementByAttribute(this, "anonid", "scrollbox"); @@ -52,23 +52,58 @@ document.getAnonymousElementByAttribute(this, "anonid", "scrollbutton-down"); - 20 + null + + + + + null + + null + + + + + null - window.getComputedStyle(this._scrollbox, "").direction == "ltr"; + document.defaultView.getComputedStyle(this._scrollbox, "").direction == "ltr"; + false - + 2 || amountToScroll < -2) { + scrollAmount = round(amountToScroll * 0.2); + scrollAmounts.push (scrollAmount, scrollAmount, scrollAmount); + amountToScroll -= 3 * scrollAmount; + } + while (this._isScrolling < 0 && amountToScroll < 0 || + this._isScrolling > 0 && amountToScroll > 0) { + amountToScroll -= (scrollAmount = round(amountToScroll * 0.5)); + scrollAmounts.push(scrollAmount); + } + this._smoothScrollTimer = setInterval(processFrame, 60, this); + processFrame(this); ]]> - + = edge) + break; + } + } else { + edge += scrollBox.width; + for (var i = 0; nextElement = elements[i]; i++) { + var x = nextElement.boxObject.screenX; + if (x <= edge && + x + nextElement.boxObject.width > edge) + break; + } + } + if (!nextElement) + return; + + var targetElement; + + while (index < 0 && nextElement) { + targetElement = nextElement; + nextElement = nextElement.previousSibling; + index++; + } + while (index > 0 && nextElement) { + targetElement = nextElement; + nextElement = nextElement.nextSibling; + index--; + } + + this.ensureElementIsVisible(targetElement); ]]> @@ -112,15 +260,28 @@ ]]> + + 0 + 0 + + + + + - + @@ -190,10 +351,8 @@ // See bug 341047 and comments in overflow handler as to why // try..catch is needed here var childNodes = document.getAnonymousNodes(this._scrollbox); - if (childNodes && childNodes.length) { - if (childNodes.length > 0) - this.ensureElementIsVisible(childNodes[0]); - } + if (childNodes && childNodes.length) + this.scrollBoxObject.ensureElementIsVisible(childNodes[0]); } catch(e) { this._scrollButtonUp.collapsed = false; @@ -271,11 +430,9 @@ null - 0 + 0 150 @@ -299,44 +456,42 @@ - - - - - - + - + if (this.smoothScroll) + this._autorepeatSmoothScroll = true; + else { + this._scrollIndex = index; + if (!this._scrollTimer) + this._scrollTimer = + Components.classes["@mozilla.org/timer;1"] + .createInstance(Components.interfaces.nsITimer); + else + this._scrollTimer.cancel(); + + this._scrollTimer.initWithCallback(this, + this._scrollDelay, + Components.interfaces.nsITimer.TYPE_REPEATING_SLACK); + } + this.scrollByIndex(index); + ]]> + + - + diff --git a/toolkit/content/widgets/tabbrowser.xml b/toolkit/content/widgets/tabbrowser.xml index f99e1265b211..706bf35ded9e 100644 --- a/toolkit/content/widgets/tabbrowser.xml +++ b/toolkit/content/widgets/tabbrowser.xml @@ -2581,7 +2581,8 @@ - + @@ -2631,18 +2632,7 @@ pb2.addObserver("browser.tabs.closeButtons", this._prefObserver, false); - var self = this; - function onResize() { - var width = self.mTabstrip.boxObject.width; - if (width != self.mTabstripWidth) { - self.adjustTabstrip(); - self.mTabstrip.scrollByIndex(1); - self.mTabstrip.scrollBoxObject - .ensureElementIsVisible(self.selectedItem); - self.mTabstripWidth = width; - } - } - window.addEventListener("resize", onResize, false); + window.addEventListener("resize", this, false); // Listen to overflow/underflow events on the tabstrip, // we cannot put these as xbl handlers on the entire binding because @@ -2757,8 +2747,7 @@ @@ -2774,6 +2763,16 @@ case "underflow": this.removeAttribute("overflow"); break; + case "resize": + var width = this.mTabstrip.boxObject.width; + if (width != this.mTabstripWidth) { + this.adjustTabstrip(); + // XXX without this line the tab bar won't budge + this.mTabstrip.scrollByPixels(1); + this._handleTabSelect(); + this.mTabstripWidth = width; + } + break; } ]]>