Commit 429dbf04 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Add AnimationTimeDelta::operator/(T), as well as /=.

It already had *, and the underlying TimeDelta has long had /(T), so
this just makes the API a little less asymmetric.

This simplifies one callsite.

Bug: none
Change-Id: I49fe5f69a36c53c7857e623f17f7c5b4e66346f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2344815
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Kevin Ellis <kevers@chromium.org>
Reviewed-by: default avatarKevin Ellis <kevers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796369}
parent c39df9bf
......@@ -1936,16 +1936,15 @@ base::Optional<AnimationTimeDelta> Animation::TimeToEffectChange() {
playback_rate_);
}
double result =
AnimationTimeDelta result =
playback_rate_ > 0
? content_->TimeToForwardsEffectChange().InSecondsF() / playback_rate_
: content_->TimeToReverseEffectChange().InSecondsF() /
-playback_rate_;
? content_->TimeToForwardsEffectChange() / playback_rate_
: content_->TimeToReverseEffectChange() / -playback_rate_;
return !HasActiveAnimationsOnCompositor() &&
content_->GetPhase() == Timing::kPhaseActive
? AnimationTimeDelta()
: AnimationTimeDelta::FromSecondsD(result);
: result;
}
void Animation::cancel() {
......
......@@ -80,6 +80,14 @@ class CORE_EXPORT AnimationTimeDelta {
AnimationTimeDelta& operator*=(V a) {
return *this = (*this * a);
}
template <typename T>
AnimationTimeDelta operator/(T a) const {
return AnimationTimeDelta(delta_ / a);
}
template <typename T>
AnimationTimeDelta& operator/=(T a) {
return *this = (*this / a);
}
protected:
constexpr explicit AnimationTimeDelta(double delta) : delta_(delta) {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment