Commit b1e08ce5 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Use TimeDelta::operator/() more, ash/ edition.

Bug: 1104532
Change-Id: Iea05cc80dbcee0f2aa84c777cded4e07e7cb1311
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2354989
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797941}
parent 8ec3090d
......@@ -115,7 +115,7 @@ void AccessibilityFocusRingGroup::AnimateFocusRings(base::TimeTicks timestamp) {
return;
}
double fraction = delta.InSecondsF() / transition_time.InSecondsF();
double fraction = delta / transition_time;
// Ease-in effect.
fraction = pow(fraction, 0.3);
......
......@@ -27,12 +27,10 @@ void ComputeOpacity(LayerAnimationInfo* animation_info,
}
float opacity;
if (start_delta < fade_in_time) {
opacity = start_delta.InSecondsF() / fade_in_time.InSecondsF();
} else {
opacity = 1.0 - (change_delta.InSecondsF() /
(fade_in_time + fade_out_time).InSecondsF());
}
if (start_delta < fade_in_time)
opacity = start_delta / fade_in_time;
else
opacity = 1.0 - (change_delta / (fade_in_time + fade_out_time));
// Layer::SetOpacity will throw an error if we're not within 0...1.
opacity = base::ClampToRange(opacity, 0.0f, 1.0f);
......
......@@ -335,11 +335,10 @@ void ExpandArrowView::AnimationProgressed(const gfx::Animation* animation) {
}
// Update pulse radius.
pulse_radius_ = base::ClampRound(
(kPulseMaxRadius - kPulseMinRadius) *
gfx::Tween::CalculateValue(
gfx::Tween::EASE_IN_OUT,
time.InMillisecondsF() / kCycleDuration.InMillisecondsF()));
pulse_radius_ =
base::ClampRound((kPulseMaxRadius - kPulseMinRadius) *
gfx::Tween::CalculateValue(gfx::Tween::EASE_IN_OUT,
time / kCycleDuration));
// Update y position offset of the arrow.
constexpr auto kArrowMoveOutBeginTime =
......@@ -348,16 +347,14 @@ void ExpandArrowView::AnimationProgressed(const gfx::Animation* animation) {
constexpr auto kArrowMoveInBeginTime = base::TimeDelta::FromMilliseconds(500);
constexpr auto kArrowMoveInEndTime = base::TimeDelta::FromMilliseconds(900);
if (time > kArrowMoveOutBeginTime && time <= kArrowMoveOutEndTime) {
const double progress =
(time - kArrowMoveOutBeginTime).InMillisecondsF() /
(kArrowMoveOutEndTime - kArrowMoveOutBeginTime).InMillisecondsF();
const double progress = (time - kArrowMoveOutBeginTime) /
(kArrowMoveOutEndTime - kArrowMoveOutBeginTime);
arrow_y_offset_ = base::ClampRound(
-kTotalArrowYOffset *
gfx::Tween::CalculateValue(gfx::Tween::EASE_IN, progress));
} else if (time > kArrowMoveInBeginTime && time <= kArrowMoveInEndTime) {
const double progress =
(time - kArrowMoveInBeginTime).InMillisecondsF() /
(kArrowMoveInEndTime - kArrowMoveInBeginTime).InMillisecondsF();
const double progress = (time - kArrowMoveInBeginTime) /
(kArrowMoveInEndTime - kArrowMoveInBeginTime);
arrow_y_offset_ = base::ClampRound(
kTotalArrowYOffset *
(1 - gfx::Tween::CalculateValue(gfx::Tween::EASE_OUT, progress)));
......
......@@ -97,8 +97,7 @@ float FastInkPoints::GetFadeoutFactor(int index) const {
DCHECK(!life_duration_.is_zero());
DCHECK(0 <= index && index < GetNumberOfPoints());
base::TimeDelta age = collection_latest_time_ - points_[index].time;
return std::min(age.InMillisecondsF() / life_duration_.InMillisecondsF(),
1.0);
return std::min(age / life_duration_, 1.0);
}
void FastInkPoints::Predict(const FastInkPoints& real_points,
......
......@@ -72,29 +72,25 @@ constexpr auto kShowAnimationDuration = kPositionAnimationDuration;
// Value of |tablet_mode_animation_| showing to begin animating alpha of
// |size_button_|.
float SizeButtonShowStartValue() {
return kShowAnimationAlphaDelay.InMillisecondsF() /
kShowAnimationDuration.InMillisecondsF();
return kShowAnimationAlphaDelay / kShowAnimationDuration;
}
// Amount of |tablet_mode_animation_| showing to animate the alpha of
// |size_button_|.
float SizeButtonShowDuration() {
return kAlphaAnimationDuration.InMillisecondsF() /
kShowAnimationDuration.InMillisecondsF();
return kAlphaAnimationDuration / kShowAnimationDuration;
}
// Amount of |tablet_mode_animation_| hiding to animate the alpha of
// |size_button_|.
float SizeButtonHideDuration() {
return kAlphaAnimationDuration.InMillisecondsF() /
kHideAnimationDuration.InMillisecondsF();
return kAlphaAnimationDuration / kHideAnimationDuration;
}
// Value of |tablet_mode_animation_| hiding to begin animating the position of
// buttons to the left of |size_button_|.
float HidePositionStartValue() {
return 1.0f - kHidePositionDelay.InMillisecondsF() /
kHideAnimationDuration.InMillisecondsF();
return 1.0f - kHidePositionDelay / kHideAnimationDuration;
}
// Bounds animation values to the range 0.0 - 1.0. Allows for mapping of offset
......
......@@ -769,8 +769,7 @@ void SplitViewController::SnapWindow(aura::Window* window,
// Apply the transform that |window| will undergo when the divider spawns.
static const double value = gfx::Tween::CalculateValue(
gfx::Tween::FAST_OUT_SLOW_IN,
kSplitviewDividerSpawnDelay.InMillisecondsF() /
kSplitviewWindowTransformDuration.InMillisecondsF());
kSplitviewDividerSpawnDelay / kSplitviewWindowTransformDuration);
gfx::TransformAboutPivot(bounds.origin(),
gfx::Tween::TransformValueBetween(
value, window->transform(), gfx::Transform()))
......
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