diff --git a/dom/animation/AnimationPlayer.cpp b/dom/animation/AnimationPlayer.cpp index 7db0412e8d..98ebf225c7 100644 --- a/dom/animation/AnimationPlayer.cpp +++ b/dom/animation/AnimationPlayer.cpp @@ -107,7 +107,7 @@ AnimationPlayer::SilentlySetCurrentTime(const TimeDuration& aSeekTime) } } else { mStartTime.SetValue(mTimeline->GetCurrentTime().Value() - - (aSeekTime / mPlaybackRate)); + (aSeekTime.MultDouble(1 / mPlaybackRate))); } mPreviousCurrentTime.SetNull(); @@ -604,7 +604,8 @@ AnimationPlayer::ResumeAt(const TimeDuration& aReadyTime) // we should use. In all other cases, we resolve it from the ready time. if (mStartTime.IsNull()) { if (mPlaybackRate != 0) { - mStartTime.SetValue(aReadyTime - (mHoldTime.Value() / mPlaybackRate)); + mStartTime.SetValue(aReadyTime - + (mHoldTime.Value().MultDouble(1 / mPlaybackRate))); mHoldTime.SetNull(); } else { mStartTime.SetValue(aReadyTime); @@ -679,7 +680,7 @@ AnimationPlayer::UpdateFinishedState(bool aSeekFlag) !currentTime.IsNull()) { if (aSeekFlag && !mHoldTime.IsNull()) { mStartTime.SetValue(mTimeline->GetCurrentTime().Value() - - (mHoldTime.Value() / mPlaybackRate)); + (mHoldTime.Value().MultDouble(1 / mPlaybackRate))); } mHoldTime.SetNull(); } diff --git a/mfbt/RollingMean.h b/mfbt/RollingMean.h index 5add14c879..8cc3148e96 100644 --- a/mfbt/RollingMean.h +++ b/mfbt/RollingMean.h @@ -86,7 +86,7 @@ public: T mean() { MOZ_ASSERT(!empty()); - return T(mTotal / mValues.length()); + return T(mTotal / int64_t(mValues.length())); } bool empty() diff --git a/widget/gonk/GeckoTouchDispatcher.cpp b/widget/gonk/GeckoTouchDispatcher.cpp index 146cfc4aaf..a9ea21bb56 100644 --- a/widget/gonk/GeckoTouchDispatcher.cpp +++ b/widget/gonk/GeckoTouchDispatcher.cpp @@ -271,7 +271,7 @@ GoannaTouchDispatcher::ResampleTouchMoves(MultiTouchInput& aOutTouch, TimeStamp TimeDuration touchDiff = currentTouch.mTimeStamp - baseTouch.mTimeStamp; if (currentTouch.mTimeStamp < sampleTime) { - TimeDuration maxResampleTime = std::min(touchDiff / 2, mMaxPredict); + TimeDuration maxResampleTime = std::min(touchDiff / int64_t(2), mMaxPredict); TimeStamp maxTimestamp = currentTouch.mTimeStamp + maxResampleTime; if (sampleTime > maxTimestamp) { sampleTime = maxTimestamp; diff --git a/xpcom/ds/TimeStamp.h b/xpcom/ds/TimeStamp.h index fdb87559d6..036ef578c3 100644 --- a/xpcom/ds/TimeStamp.h +++ b/xpcom/ds/TimeStamp.h @@ -181,6 +181,11 @@ private: // If required, use MultDouble explicitly and with care. BaseTimeDuration operator*(const double aMultiplier) const = delete; + // Block double divisor (for the same reason, and because dividing by + // fractional values would otherwise invoke the int64_t variant, and rounding + // the passed argument can then cause divide-by-zero) - Bug 1147491. + BaseTimeDuration operator/(const double aDivisor) const = delete; + public: BaseTimeDuration MultDouble(double aMultiplier) const {