Bug 860779 - Enable two-finger horizontal swipes when swipe animations are disabled. r=smichaud

This commit is contained in:
Stephen Pohl 2013-04-11 17:45:04 -04:00
Родитель 090055e5e3
Коммит 7ef7d69d64
1 изменённых файлов: 19 добавлений и 12 удалений

Просмотреть файл

@ -177,7 +177,7 @@ let gGestureSupport = {
* The swipe gesture start event.
*/
_setupSwipeGesture: function GS__setupSwipeGesture(aEvent) {
if (!this._swipeNavigatesHistory(aEvent) || !gHistorySwipeAnimation.active)
if (!this._swipeNavigatesHistory(aEvent))
return;
let canGoBack = gHistorySwipeAnimation.canGoBack();
@ -534,15 +534,10 @@ let gHistorySwipeAnimation = {
* by the platform/configuration.
*/
init: function HSA_init() {
if (!this._isSupported() || this._getMaxSnapshots() < 1)
if (!this._isSupported())
return;
gBrowser.addEventListener("pagehide", this, false);
gBrowser.addEventListener("pageshow", this, false);
gBrowser.addEventListener("popstate", this, false);
gBrowser.tabContainer.addEventListener("TabClose", this, false);
this.active = true;
this.active = false;
this.isLTR = document.documentElement.mozMatchesSelector(
":-moz-locale-dir(ltr)");
this._trackedSnapshots = [];
@ -550,6 +545,16 @@ let gHistorySwipeAnimation = {
this._boxWidth = -1;
this._maxSnapshots = this._getMaxSnapshots();
this._lastSwipeDir = "";
// We only want to activate history swipe animations if we store snapshots.
// If we don't store any, we handle horizontal swipes without animations.
if (this._maxSnapshots > 0) {
this.active = true;
gBrowser.addEventListener("pagehide", this, false);
gBrowser.addEventListener("pageshow", this, false);
gBrowser.addEventListener("popstate", this, false);
gBrowser.tabContainer.addEventListener("TabClose", this, false);
}
},
/**
@ -581,10 +586,12 @@ let gHistorySwipeAnimation = {
this._historyIndex = gBrowser.webNavigation.sessionHistory.index;
this._canGoBack = this.canGoBack();
this._canGoForward = this.canGoForward();
this._takeSnapshot();
this._installPrevAndNextSnapshots();
this._addBoxes();
this._lastSwipeDir = "";
if (this.active) {
this._takeSnapshot();
this._installPrevAndNextSnapshots();
this._addBoxes();
this._lastSwipeDir = "";
}
}
this.updateAnimation(0);
},