Bug 1384180 - Don't animate the stop->reload if the page loads within 150ms (too distracting). r=dao

MozReview-Commit-ID: 9KvMCRZo5LZ

--HG--
extra : rebase_source : b1392cf72d1cdc17fd3172b0fb48ddf7004a4bce
This commit is contained in:
Jared Wein 2017-07-26 07:08:00 -04:00
Родитель 17cc85402f
Коммит 776efb00ca
1 изменённых файлов: 30 добавлений и 2 удалений

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

@ -4865,6 +4865,9 @@ var XULBrowserWindow = {
onUpdateCurrentBrowser: function XWB_onUpdateCurrentBrowser(aStateFlags, aStatus, aMessage, aTotalProgress) {
if (FullZoom.updateBackgroundTabs)
FullZoom.onLocationChange(gBrowser.currentURI, true);
CombinedStopReload.onTabSwitch();
var nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
var loadingDone = aStateFlags & nsIWebProgressListener.STATE_STOP;
// use a pseudo-object instead of a (potentially nonexistent) channel for getting
@ -4969,6 +4972,7 @@ var CombinedStopReload = {
this.reload = reload;
this.stop = stop;
this.stopReloadContainer = this.reload.parentNode;
this.timeWhenSwitchedToStop = 0;
// Disable animations until the browser has fully loaded.
this.animate = false;
@ -5036,13 +5040,26 @@ var CombinedStopReload = {
});
},
onTabSwitch() {
// Reset the time in the event of a tabswitch since the stored time
// would have been associated with the previous tab.
this.timeWhenSwitchedToStop = 0;
},
switchToStop(aRequest, aWebProgress) {
if (!this._initialized || !this._shouldSwitch(aRequest, aWebProgress)) {
return;
}
// Store the time that we switched to the stop button only if a request
// is active. Requests are null if the switch is related to a tabswitch.
// This is used to determine if we should show the stop->reload animation.
if (aRequest) {
this.timeWhenSwitchedToStop = window.performance.now();
}
let shouldAnimate = AppConstants.MOZ_PHOTON_ANIMATIONS &&
aRequest instanceof Ci.nsIRequest &&
aRequest &&
aWebProgress.isTopLevel &&
aWebProgress.isLoadingDocument &&
!gBrowser.tabAnimationsInProgress &&
@ -5065,10 +5082,11 @@ var CombinedStopReload = {
}
let shouldAnimate = AppConstants.MOZ_PHOTON_ANIMATIONS &&
aRequest instanceof Ci.nsIRequest &&
aRequest &&
aWebProgress.isTopLevel &&
!aWebProgress.isLoadingDocument &&
!gBrowser.tabAnimationsInProgress &&
this._loadTimeExceedsMinimumForAnimation() &&
this.animate;
if (shouldAnimate) {
@ -5101,6 +5119,16 @@ var CombinedStopReload = {
}, 650, this);
},
_loadTimeExceedsMinimumForAnimation() {
// If the time between switching to the stop button then switching to
// the reload button exceeds 150ms, then we will show the animation.
// If we don't know when we switched to stop (a tabswitch occured while
// the page was loading), then we will not prevent the animation from
// occuring.
return !this.timeWhenSwitchedToStop ||
window.performance.now() - this.timeWhenSwitchedToStop > 150;
},
_shouldSwitch(aRequest, aWebProgress) {
if (aRequest &&
aRequest.originalURI &&