[Pkg-mozext-commits] [tabmixplus] 23/48: Follow up bug 1387084 - Use instant scroll behavior when doing pixel scrolling
David Prévot
taffit at moszumanska.debian.org
Sun Aug 20 03:14:36 UTC 2017
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository tabmixplus.
commit c9d7d84c9a49b5307c565db7551aaadc521cb258
Author: onemen <tabmix.onemen at gmail.com>
Date: Tue Aug 8 23:18:02 2017 +0300
Follow up bug 1387084 - Use instant scroll behavior when doing pixel scrolling
---
chrome/content/minit/minit.js | 3 ++-
chrome/content/minit/tablib.js | 6 +++--
chrome/content/places/places.js | 9 ++++++--
chrome/content/tab/scrollbox.xml | 46 ++++++++++++++++++++++---------------
chrome/content/tab/tabbrowser_4.xml | 6 +++--
chrome/content/tabmix.js | 12 +++++++---
6 files changed, 54 insertions(+), 28 deletions(-)
diff --git a/chrome/content/minit/minit.js b/chrome/content/minit/minit.js
index ae06818..1aabd0d 100644
--- a/chrome/content/minit/minit.js
+++ b/chrome/content/minit/minit.js
@@ -389,7 +389,8 @@ var TMP_tabDNDObserver = {
if (_scroll) {
let scrollIncrement = TabmixTabbar.isMultiRow ?
Math.round(tabStrip._singleRowHeight / 6) : tabStrip.scrollIncrement;
- tabStrip.scrollByPixels((ltr ? _scroll : -_scroll) * scrollIncrement, true);
+ const instantScroll = !Tabmix.isVersion(570);
+ tabStrip.scrollByPixels((ltr ? _scroll : -_scroll) * scrollIncrement, instantScroll);
hideIndicator = true;
}
}
diff --git a/chrome/content/minit/tablib.js b/chrome/content/minit/tablib.js
index 4629d80..373b7ff 100644
--- a/chrome/content/minit/tablib.js
+++ b/chrome/content/minit/tablib.js
@@ -1773,8 +1773,10 @@ Tabmix.tablib = {
// Bug 752376 - Avoid calling scrollbox.ensureElementIsVisible()
// if the tab strip doesn't overflow to prevent layout flushes
gBrowser.ensureTabIsVisible = function tabmix_ensureTabIsVisible(aTab, aSmoothScroll) {
- if (Tabmix.tabsUtils.overflow)
- this.tabContainer.mTabstrip.ensureElementIsVisible(aTab, aSmoothScroll);
+ if (Tabmix.tabsUtils.overflow) {
+ const instantScroll = Tabmix.isVersion(570) ? !aSmoothScroll : aSmoothScroll;
+ this.tabContainer.mTabstrip.ensureElementIsVisible(aTab, instantScroll);
+ }
};
/** DEPRECATED **/
diff --git a/chrome/content/places/places.js b/chrome/content/places/places.js
index 388eeb5..881bd18 100644
--- a/chrome/content/places/places.js
+++ b/chrome/content/places/places.js
@@ -510,8 +510,13 @@ var TMP_Places = {
let tabstrip = gBrowser.tabContainer.mTabstrip;
if (!TabmixTabbar.isMultiRow) {
let scrollPosition = tabstrip.scrollPosition;
- if (scrollPosition < 100)
- tabstrip.scrollPosition = 0;
+ if (scrollPosition < 100) {
+ if (tabstrip.orient == "vertical") {
+ tabstrip._scrollbox.scrollTop = 0;
+ } else {
+ tabstrip._scrollbox.scrollLeft = 0;
+ }
+ }
}
gBrowser.ensureTabIsVisible(this.currentTab, false);
this.currentTab = null;
diff --git a/chrome/content/tab/scrollbox.xml b/chrome/content/tab/scrollbox.xml
index ac38588..bce51b6 100644
--- a/chrome/content/tab/scrollbox.xml
+++ b/chrome/content/tab/scrollbox.xml
@@ -177,7 +177,15 @@
this.offsetAmountToScroll = Tabmix.prefs.getBoolPref("offsetAmountToScroll");
this.offsetRatio = Tabmix.tabsUtils.closeButtonsEnabled ? 0.70 : 0.50;
this.minOffset = TabmixSvc.australis ? 25 : 50;
- if (!Tabmix.isVersion(570)) {
+ if (Tabmix.isVersion(570)) {
+ Object.defineProperty(this, 'scrollPosition', {
+ get: () => {
+ return this.orient == "vertical" ?
+ this._scrollbox.scrollTop :
+ this._scrollbox.scrollLeft;
+ },
+ });
+ } else {
Tabmix.changeCode(this, "scrollbox.ensureElementIsVisible")._replace(
'var amountToScroll',
'$&, offset = true'
@@ -213,6 +221,15 @@
'Math.abs(distance)',
'Math.abs(distance * (this.scrollbox.isMultiRow ? this.scrollbox._verticalAnimation : 1))'
).toCode();
+
+ // replace the original method
+ this.scrollByPixels = (px, aSmoothScroll) => {
+ if (this._isScrolling || aSmoothScroll) {
+ this.scrollPosition += px;
+ } else {
+ this.scrollPosition += this._distanceToRow(px);
+ }
+ };
}
Tabmix.changeCode(this, "scrollbox._distanceScroll")._replace(
@@ -330,19 +347,7 @@
});
]]></field>
- <!-- replace the original method -->
- <method name="scrollByPixels">
- <parameter name="px"/>
- <parameter name="aSmoothScroll"/>
- <body><![CDATA[
- if (this._isScrolling || aSmoothScroll) {
- this.scrollPosition += px;
- } else {
- this.scrollPosition += this._distanceToRow(px);
- }
- ]]></body>
- </method>
-
+ <!-- not in use in Firefox 57+ -->
<method name="getOffsetAmountToScroll">
<parameter name="element"/>
<parameter name="amountToScroll"/>
@@ -386,6 +391,7 @@
]]></getter>
</property>
+ <!-- not in use in Firefox 57+ -->
<property name="isScrolledToEnd" readonly="true">
<getter><![CDATA[
let scrollPosition = this.scrollClientSize + this.scrollPosition;
@@ -521,8 +527,10 @@
// if a smoothScroll is in progress call ensureElementIsVisible again
// the amountToScroll changed when we changed firstTabInRow
- if (this._scrollTarget)
- this.ensureElementIsVisible(this._scrollTarget, true);
+ if (this._scrollTarget) {
+ const instantScroll = !Tabmix.isVersion(570);
+ this.ensureElementIsVisible(this._scrollTarget, instantScroll);
+ }
]]></body>
</method>
@@ -561,8 +569,10 @@
if (!overflow) {
let childNodes = this._getScrollableElements();
- if (childNodes && childNodes.length)
- this.ensureElementIsVisible(childNodes[0], false);
+ if (childNodes && childNodes.length) {
+ const instantScroll = Tabmix.isVersion(570);
+ this.ensureElementIsVisible(childNodes[0], instantScroll);
+ }
}
} catch (e) {
Tabmix.setItem(this, "notoverflowing", overflow || null);
diff --git a/chrome/content/tab/tabbrowser_4.xml b/chrome/content/tab/tabbrowser_4.xml
index 989eed2..71fd549 100644
--- a/chrome/content/tab/tabbrowser_4.xml
+++ b/chrome/content/tab/tabbrowser_4.xml
@@ -450,8 +450,10 @@
<parameter name="aIndex"/>
<parameter name="aSmoothScroll"/>
<body><![CDATA[
- if (!this.isTabVisible(aIndex))
- this.mTabstrip.ensureElementIsVisible(this.childNodes.item(aIndex), aSmoothScroll);
+ if (!this.isTabVisible(aIndex)) {
+ const instantScroll = Tabmix.isVersion(570) ? !aSmoothScroll : aSmoothScroll;
+ this.mTabstrip.ensureElementIsVisible(this.childNodes.item(aIndex), instantScroll);
+ }
]]></body>
</method>
<property name="lastTabVisible" readonly="true">
diff --git a/chrome/content/tabmix.js b/chrome/content/tabmix.js
index 759f557..3717494 100644
--- a/chrome/content/tabmix.js
+++ b/chrome/content/tabmix.js
@@ -915,8 +915,10 @@ var TMP_eventListener = {
// workaround when we remove last visible tab
if (tabBar.firstChild.pinned && TabmixTabbar.isMultiRow && Tabmix.tabsUtils.overflow &&
- aTab._tPos >= Tabmix.visibleTabs.last._tPos)
- tabBar.mTabstrip.ensureElementIsVisible(gBrowser.selectedTab, false);
+ aTab._tPos >= Tabmix.visibleTabs.last._tPos) {
+ const instantScroll = Tabmix.isVersion(570);
+ tabBar.mTabstrip.ensureElementIsVisible(gBrowser.selectedTab, instantScroll);
+ }
if (Tabmix.tabsUtils.disAllowNewtabbutton)
Tabmix.tabsUtils.adjustNewtabButtonVisibility();
@@ -1054,14 +1056,16 @@ var TMP_eventListener = {
// this code is based on scrollbox.xml wheel/DOMMouseScroll event handler
let scrollByDelta = function(delta) {
let scrollByPixels = true;
+ let instant;
let scrollAmount = 0;
if (Tabmix.isVersion(480) &&
aEvent.deltaMode == aEvent.DOM_DELTA_PIXEL) {
scrollAmount = delta;
+ instant = true;
} else if (Tabmix.isVersion(490) &&
aEvent.deltaMode == aEvent.DOM_DELTA_PAGE) {
scrollAmount = delta * tabStrip.scrollClientSize;
- } else if (Tabmix.isVersion(530) && !TabmixTabbar.isMultiRow) {
+ } else if (Tabmix.isVersion(570) || Tabmix.isVersion(530) && !TabmixTabbar.isMultiRow) {
scrollAmount = delta * tabStrip.lineScrollAmount;
} else {
// scroll the tabbar by one tab
@@ -1077,6 +1081,8 @@ var TMP_eventListener = {
aEvent.deltaMode != aEvent.DOM_DELTA_PIXEL && tabStrip.smoothScroll;
if (useSmoothScroll) {
tabStrip._smoothScrollByPixels(scrollAmount);
+ } else if (Tabmix.isVersion(570)) {
+ tabStrip.scrollByPixels(scrollAmount, instant);
} else {
tabStrip.scrollByPixels(scrollAmount);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git
More information about the Pkg-mozext-commits
mailing list