Commit 38e1371b authored by Sergio Villar Senin's avatar Sergio Villar Senin Committed by Commit Bot

Remove NullValue() from CalculateTransformedProgress

NullValue() is represented as a NaN in a double. We could better return
a base::Optional<double> and use the undefined base::Optional as null
value. Also there is no need for the IsNull() call as we could just use
the returned value as a boolean.

Bug: 994811
Change-Id: Ibb4a6b89102dd49450d68aae35b03e9eba46332f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1760963Reviewed-by: default avatarKevin Ellis <kevers@chromium.org>
Reviewed-by: default avatarStephen McGruer <smcgruer@chromium.org>
Commit-Queue: Sergio Villar <svillar@igalia.com>
Cr-Commit-Position: refs/heads/master@{#689101}
parent 019ae61f
...@@ -181,9 +181,6 @@ Timing::CalculatedTiming Timing::CalculateTimings( ...@@ -181,9 +181,6 @@ Timing::CalculatedTiming Timing::CalculateTimings(
progress = CalculateTransformedProgress( progress = CalculateTransformedProgress(
current_phase, directed_progress, iteration_duration, current_phase, directed_progress, iteration_duration,
current_direction_is_forwards, timing_function); current_direction_is_forwards, timing_function);
if (IsNull(progress.value())) {
progress.reset();
}
double time_to_next_iteration = std::numeric_limits<double>::infinity(); double time_to_next_iteration = std::numeric_limits<double>::infinity();
// Conditionally compute the time to next iteration, which is only // Conditionally compute the time to next iteration, which is only
......
...@@ -261,14 +261,14 @@ static inline double CalculateDirectedProgress( ...@@ -261,14 +261,14 @@ static inline double CalculateDirectedProgress(
} }
// https://drafts.csswg.org/web-animations/#calculating-the-transformed-progress // https://drafts.csswg.org/web-animations/#calculating-the-transformed-progress
static inline double CalculateTransformedProgress( static inline base::Optional<double> CalculateTransformedProgress(
Timing::Phase phase, Timing::Phase phase,
double directed_progress, double directed_progress,
double iteration_duration, double iteration_duration,
bool is_current_direction_forward, bool is_current_direction_forward,
scoped_refptr<TimingFunction> timing_function) { scoped_refptr<TimingFunction> timing_function) {
if (IsNull(directed_progress)) if (IsNull(directed_progress))
return NullValue(); return base::nullopt;
// Set the before flag to indicate if at the leading edge of an iteration. // Set the before flag to indicate if at the leading edge of an iteration.
// This is used to determine if the left or right limit should be used if at a // This is used to determine if the left or right limit should be used if at a
......
...@@ -324,8 +324,8 @@ TEST(AnimationTimingCalculationsTest, TransformedProgress) { ...@@ -324,8 +324,8 @@ TEST(AnimationTimingCalculationsTest, TransformedProgress) {
StepsTimingFunction::Create(4, StepsTimingFunction::StepPosition::END); StepsTimingFunction::Create(4, StepsTimingFunction::StepPosition::END);
// directed_progress is null. // directed_progress is null.
EXPECT_TRUE(IsNull(CalculateTransformedProgress( EXPECT_FALSE(CalculateTransformedProgress(Timing::kPhaseActive, NullValue(),
Timing::kPhaseActive, NullValue(), 1, true, timing_function))); 1, true, timing_function));
// At step boundaries. // At step boundaries.
// Forward direction. // Forward direction.
......
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