Bug 1225137 - Avoid crash on some platforms if scrollbar fading is enabled and the duration is set to zero. r=spohl
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 16 Nov 2015 10:44:45 -0500
changeset 272682 8fa1bffbfeafb3ab9c9a9693896cb638d19440fb
parent 272681 c71907f31ba8765474fa5aab076f71caaa4523f7
child 272683 cf1acdeb6d0f28a7e50cd6d32a0786c19dd0d049
push id68045
push userkgupta@mozilla.com
push dateMon, 16 Nov 2015 15:45:01 +0000
treeherdermozilla-inbound@8fa1bffbfeaf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl
bugs1225137
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1225137 - Avoid crash on some platforms if scrollbar fading is enabled and the duration is set to zero. r=spohl
layout/generic/ScrollbarActivity.cpp
--- a/layout/generic/ScrollbarActivity.cpp
+++ b/layout/generic/ScrollbarActivity.cpp
@@ -358,17 +358,21 @@ SetOpacityOnElement(nsIContent* aContent
       decl->SetProperty(NS_LITERAL_STRING("opacity"), str, EmptyString());
     }
   }
 }
 
 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.
   nsWeakFrame weakFrame((do_QueryFrame(mScrollableFrame)));
   SetOpacityOnElement(GetHorizontalScrollbar(), opacity);
   if (!weakFrame.IsAlive()) {
     return false;
   }