Bug 1225137 - Avoid crash on some platforms if scrollbar fading is enabled and the duration is set to zero. r=spohl

This commit is contained in:
Kartikaya Gupta 2015-11-16 10:44:45 -05:00
parent 145a6397e3
commit aa47c05732

View File

@ -363,7 +363,11 @@ SetOpacityOnElement(nsIContent* aContent, double aOpacity)
bool
ScrollbarActivity::UpdateOpacity(TimeStamp aTime)
{
double progress = (aTime - mFadeBeginTime) / FadeDuration();
// Avoid division by zero if mScrollbarFadeDuration is zero, just jump
// to the end of the fade animation
double progress = mScrollbarFadeDuration
? ((aTime - mFadeBeginTime) / FadeDuration())
: 1.0;
double opacity = 1.0 - std::max(0.0, std::min(1.0, progress));
// 'this' may be getting destroyed during SetOpacityOnElement calls.