Bug 1356705 - Fixes to fold on to previous patch. r?dao
MozReview-Commit-ID: JGn3nuobVaB
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -5884,16 +5884,31 @@
if (this._tabMarginLeft === null || this._tabMarginRight === null) {
let tabMiddle = document.getAnonymousElementByAttribute(aTab, "class", "tab-background-middle");
let tabMiddleStyle = window.getComputedStyle(tabMiddle);
this._tabMarginLeft = parseFloat(tabMiddleStyle.marginLeft);
this._tabMarginRight = parseFloat(tabMiddleStyle.marginRight);
}
]]></body>
</method>
+ <method name="_adjustElementStartAndEnd">
+ <parameter name="aTab"/>
+ <parameter name="tabStart"/>
+ <parameter name="tabEnd"/>
+ <body><![CDATA[
+ this._calcTabMargins(aTab);
+ if (this._tabMarginLeft < 0) {
+ tabStart = tabStart + this._tabMarginLeft;
+ }
+ if (this._tabMarginRight < 0) {
+ tabEnd = tabEnd - this._tabMarginRight;
+ }
+ return [tabStart, tabEnd];
+ ]]></body>
+ </method>
</implementation>
<handlers>
<handler event="underflow" phase="capturing"><![CDATA[
if (event.originalTarget != this._scrollbox)
return;
// Ignore vertical events
--- a/toolkit/content/widgets/scrollbox.xml
+++ b/toolkit/content/widgets/scrollbox.xml
@@ -244,23 +244,53 @@
return;
let elements = this._getScrollableElements();
let index = elements.indexOf(element);
if (index == -1) {
return;
}
if (index == 0) {
- //XXX special case for Firefox tabs using negative margin, remove after bug 1349555
+ // XXX special case for Firefox tabs using negative margin, remove after bug 1349555
this.scrollPosition = 0;
} else if (index == elements.length - 1) {
- //XXX special case for Firefox tabs using negative margin, remove after bug 1349555
+ // XXX special case for Firefox tabs using negative margin, remove after bug 1349555
this.scrollPosition = this.scrollSize;
+ } else if (this._adjustElementStartAndEnd) {
+ // XXX special case for Firefox tabs using negative margin, remove after bug 1349555
+ let windowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindowUtils);
+ let bounds = windowUtils.getBoundsWithoutFlushing(element);
+ let thisRect = windowUtils.getBoundsWithoutFlushing(this._scrollbox);
+
+ let vertical = this.orient == "vertical";
+ let containerStart = vertical ? thisRect.top : thisRect.left;
+ let containerEnd = vertical ? thisRect.bottom : thisRect.right;
+ let elementStart = vertical ? bounds.top : bounds.left;
+ let elementEnd = vertical ? bounds.bottom : bounds.right;
+
+ [elementStart, elementEnd] =
+ this._adjustElementStartAndEnd(element, elementStart, elementEnd);
+
+ let amountToScroll = 0;
+ if (elementStart < containerStart) {
+ amountToScroll = elementStart - containerStart;
+ } else if (containerEnd < elementEnd) {
+ amountToScroll = elementEnd - containerEnd;
+ } else {
+ return;
+ }
+
+ let opts = { behavior: aSmoothScroll == false ? "instant" : "auto" };
+ let prop = vertical ? "top" : "left";
+ opts[prop] = amountToScroll;
+
+ this._scrollbox.scrollBy(opts);
} else {
- element.scrollIntoView({ behavior: aSmoothScroll == false ? "instant" : "auto" });
+ element.scrollIntoView({ behavior: aSmoothScroll == false ? "instant" : "auto" });
}
]]></body>
</method>
<method name="scrollByIndex">
<parameter name="index"/>
<parameter name="aSmoothScroll"/>
<body><![CDATA[
@@ -748,20 +778,16 @@
</body>
</method>
<method name="_stopScroll">
<body><![CDATA[
if (this._scrollTimer)
this._scrollTimer.cancel();
this._mousedown = false;
- if (!this._scrollIndex)
- return;
-
- this.scrollByIndex(this._scrollIndex);
this._scrollIndex = 0;
]]></body>
</method>
<method name="_pauseScroll">
<body><![CDATA[
if (this._mousedown) {
this._stopScroll();