diff --git a/toolkit/content/widgets/scrollbox.xml b/toolkit/content/widgets/scrollbox.xml index df92aa238881..ff1bc0040c11 100644 --- a/toolkit/content/widgets/scrollbox.xml +++ b/toolkit/content/widgets/scrollbox.xml @@ -185,18 +185,14 @@ return innerRect; ]]> - - + + + - + + + null - - - - - @@ -642,73 +611,40 @@ ]]> - false + { - this._scrollButtonUpdatePending = false; - - this.setAttribute("scrolledtoend", "true"); - this.setAttribute("scrolledtostart", "true"); - }); - return; + scrolledToStart = true; + scrolledToEnd = true; + } else if (aScrolling) { + scrolledToStart = false; + scrolledToEnd = false; + } else if (this.scrollPosition == 0) { + // In the RTL case, this means the _last_ element in the + // scrollbox is visible + scrolledToEnd = this._isRTLScrollbox; + scrolledToStart = !this._isRTLScrollbox; + } else if (this.scrollClientSize + this.scrollPosition == this.scrollSize) { + // In the RTL case, this means the _first_ element in the + // scrollbox is visible + scrolledToStart = this._isRTLScrollbox; + scrolledToEnd = !this._isRTLScrollbox; } - // Wait until after the next paint to get current layout data from - // getBoundsWithoutFlushing. - window.requestAnimationFrame(() => { - window.requestAnimationFrame(() => { - this._scrollButtonUpdatePending = false; + if (scrolledToEnd) + this.setAttribute("scrolledtoend", "true"); + else + this.removeAttribute("scrolledtoend"); - let scrolledToStart = false; - let scrolledToEnd = false; - - if (this.hasAttribute("notoverflowing")) { - scrolledToStart = true; - scrolledToEnd = true; - } else { - let scrollboxPaddingStart = Math.round(this.scrollboxPaddingStart); - let scrollboxPaddingEnd = Math.round(this.scrollboxPaddingEnd); - let [start, end] = this._startEndProps; - if (this._isRTLScrollbox) { - [start, end] = [end, start]; - scrollboxPaddingStart = -scrollboxPaddingStart; - scrollboxPaddingEnd = -scrollboxPaddingEnd; - } - - let scrollboxRect = this._boundsWithoutFlushing(this._scrollbox); - let elements = this._getScrollableElements(); - let [firstElement, lastElement] = [elements[0], elements[elements.length - 1]]; - - if (firstElement && - this._boundsWithoutFlushing(firstElement)[start] - scrollboxPaddingStart == scrollboxRect[start]) { - scrolledToStart = true; - } else if (lastElement && - this._boundsWithoutFlushing(lastElement)[end] + scrollboxPaddingEnd == scrollboxRect[end]) { - scrolledToEnd = true; - } - } - - if (scrolledToEnd) { - this.setAttribute("scrolledtoend", "true"); - } else { - this.removeAttribute("scrolledtoend"); - } - - if (scrolledToStart) { - this.setAttribute("scrolledtostart", "true"); - } else { - this.removeAttribute("scrolledtostart"); - } - }); - }); + if (scrolledToStart) + this.setAttribute("scrolledtostart", "true"); + else + this.removeAttribute("scrolledtostart"); ]]> @@ -861,7 +797,27 @@ ]]> { + // Scrolling animation has finished. + this._delayedUpdateScrollButtonsTimer = 0; + this._updateScrollButtonsDisabledState(); + }, 200); ]]>