From 9c39f97e15c415d49a421accc663b48657711150 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Tue, 27 Oct 2015 13:38:02 +0900 Subject: [PATCH] Bug 962249 part 1 - Add Element.scroll{Top,Left}Min (chrome-only) and convert most of scrollLeftMax uses and part of scrollTopMax uses to combinations with the new properties. r=roc,bz --HG-- extra : source : 06ea81fe3f64c072d100e42b76678eaa9fb7448c --- browser/components/customizableui/CustomizableUI.jsm | 4 ++-- .../components/places/content/browserPlacesViews.js | 2 +- dom/base/Element.h | 12 ++++++++++++ .../BrowserElementPanningAPZDisabled.js | 6 ++++-- dom/webidl/Element.webidl | 8 +++++--- mobile/android/chrome/content/browser.js | 3 ++- toolkit/content/browser-content.js | 2 +- 7 files changed, 27 insertions(+), 10 deletions(-) diff --git a/browser/components/customizableui/CustomizableUI.jsm b/browser/components/customizableui/CustomizableUI.jsm index e74815230ddc..dfc6ead7ebe0 100644 --- a/browser/components/customizableui/CustomizableUI.jsm +++ b/browser/components/customizableui/CustomizableUI.jsm @@ -4086,7 +4086,7 @@ OverflowableToolbar.prototype = { let child = this._target.lastChild; - while (child && this._target.scrollLeftMax > 0) { + while (child && this._target.scrollLeftMin != this._target.scrollLeftMax) { let prevChild = child.previousSibling; if (child.getAttribute("overflows") != "false") { @@ -4166,7 +4166,7 @@ OverflowableToolbar.prototype = { if (!this._enabled) return; - if (this._target.scrollLeftMax > 0) { + if (this._target.scrollLeftMin != this._target.scrollLeftMax) { this.onOverflow(); } else { this._moveItemsBackToTheirOrigin(); diff --git a/browser/components/places/content/browserPlacesViews.js b/browser/components/places/content/browserPlacesViews.js index d444e4b3adde..149e64a26f1f 100644 --- a/browser/components/places/content/browserPlacesViews.js +++ b/browser/components/places/content/browserPlacesViews.js @@ -1181,7 +1181,7 @@ PlacesToolbar.prototype = { }, updateOverflowStatus: function() { - if (this._rootElt.scrollLeftMax > 0) { + if (this._rootElt.scrollLeftMin != this._rootElt.scrollLeftMax) { this._onOverflow(); } else { this._onUnderflow(); diff --git a/dom/base/Element.h b/dom/base/Element.h index 6d8f7db42d8f..3872c63679cf 100644 --- a/dom/base/Element.h +++ b/dom/base/Element.h @@ -777,6 +777,12 @@ public: { return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().height); } + int32_t ScrollTopMin() + { + nsIScrollableFrame* sf = GetScrollFrame(); + return sf ? + nsPresContext::AppUnitsToIntCSSPixels(sf->GetScrollRange().y) : 0; + } int32_t ScrollTopMax() { nsIScrollableFrame* sf = GetScrollFrame(); @@ -784,6 +790,12 @@ public: nsPresContext::AppUnitsToIntCSSPixels(sf->GetScrollRange().YMost()) : 0; } + int32_t ScrollLeftMin() + { + nsIScrollableFrame* sf = GetScrollFrame(); + return sf ? + nsPresContext::AppUnitsToIntCSSPixels(sf->GetScrollRange().x) : 0; + } int32_t ScrollLeftMax() { nsIScrollableFrame* sf = GetScrollFrame(); diff --git a/dom/browser-element/BrowserElementPanningAPZDisabled.js b/dom/browser-element/BrowserElementPanningAPZDisabled.js index 662ee98962a2..8dc0d384cc71 100644 --- a/dom/browser-element/BrowserElementPanningAPZDisabled.js +++ b/dom/browser-element/BrowserElementPanningAPZDisabled.js @@ -348,8 +348,10 @@ const ContentPanningAPZDisabled = { let isScrollableTextarea = (node.tagName == 'TEXTAREA' && (node.scrollHeight > node.clientHeight || node.scrollWidth > node.clientWidth || - ('scrollLeftMax' in node && node.scrollLeftMax > 0) || - ('scrollTopMax' in node && node.scrollTopMax > 0))); + ('scrollLeftMin' in node && 'scrollLeftMax' in node && + node.scrollLeftMin != node.scrollLeftMax) || + ('scrollTopMin' in node && 'scrollTopMax' in node && + node.scrollTopMin != node.scrollTopMax))); if (isScroll || isAuto || isScrollableTextarea) { return node; } diff --git a/dom/webidl/Element.webidl b/dom/webidl/Element.webidl index 978cf9b6e59b..0e572cd875cb 100644 --- a/dom/webidl/Element.webidl +++ b/dom/webidl/Element.webidl @@ -199,11 +199,13 @@ partial interface Element { readonly attribute long clientHeight; // Mozilla specific stuff - /* The maximum offset that the element can be scrolled to + /* The minimum/maximum offset that the element can be scrolled to (i.e., the value that scrollLeft/scrollTop would be clamped to if they were set to arbitrarily large values. */ - readonly attribute long scrollTopMax; - readonly attribute long scrollLeftMax; + [ChromeOnly] readonly attribute long scrollTopMin; + readonly attribute long scrollTopMax; + [ChromeOnly] readonly attribute long scrollLeftMin; + readonly attribute long scrollLeftMax; }; // http://dvcs.w3.org/hg/undomanager/raw-file/tip/undomanager.html diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index 790587b46998..dccd16290be3 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -5090,7 +5090,8 @@ var BrowserEventHandler = { * - It's a select element showing multiple rows */ if (checkElem) { - if ((elem.scrollTopMax > 0 || elem.scrollLeftMax > 0) && + if ((elem.scrollTopMin != elem.scrollTopMin || + elem.scrollLeftMin != elem.scrollLeftMax) && (this._hasScrollableOverflow(elem) || elem.matches("textarea")) || (elem instanceof HTMLInputElement && elem.mozIsTextField(false)) || diff --git a/toolkit/content/browser-content.js b/toolkit/content/browser-content.js index c1a689ebcf5e..d7be8e8fdf15 100644 --- a/toolkit/content/browser-content.js +++ b/toolkit/content/browser-content.js @@ -93,7 +93,7 @@ var ClickEventHandler = { // do not allow horizontal scrolling for select elements, it leads // to visual artifacts and is not the expected behavior anyway if (!(this._scrollable instanceof content.HTMLSelectElement) && - this._scrollable.scrollLeftMax && + this._scrollable.scrollLeftMin != this._scrollable.scrollLeftMax && scrollingAllowed.indexOf(overflowx) >= 0) { this._scrolldir = scrollVert ? "NSEW" : "EW"; break;