Commit e4496d40 authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Convert SMILTimeContainer interfaces to SMILTime (from double)

Add InSecondsF() to SMILTime. Otherwise search-and-replace.

Bug: 1003338
Change-Id: I552706dc2349fc11e55a9d1f6d504ae35e598ce1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1800870
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#696470}
parent 5c19134c
......@@ -38,7 +38,7 @@ SMILTime operator*(const SMILTime& a, const SMILTime& b) {
}
std::ostream& operator<<(std::ostream& os, SMILTime time) {
return os << time.Value() << " s";
return os << time.InSecondsF() << " s";
}
} // namespace blink
......@@ -53,6 +53,7 @@ class SMILTime {
}
double Value() const { return time_; }
double InSecondsF() const { return time_; }
bool IsFinite() const { return std::isfinite(time_); }
bool IsIndefinite() const { return std::isinf(time_); }
......
......@@ -95,7 +95,7 @@ void SMILTimeContainer::Schedule(SVGSMILElement* animation,
sandwich->Schedule(animation);
double latest_update = CurrentDocumentTime();
SMILTime latest_update = CurrentDocumentTime();
if (animation->IntervalBegin() <= latest_update ||
animation->NextProgressTime(latest_update).IsFinite())
NotifyIntervalsChanged();
......@@ -148,7 +148,7 @@ void SMILTimeContainer::NotifyIntervalsChanged() {
ScheduleWakeUp(base::TimeDelta(), kSynchronizeAnimations);
}
double SMILTimeContainer::Elapsed() const {
SMILTime SMILTimeContainer::Elapsed() const {
if (!IsStarted())
return 0;
......@@ -160,7 +160,7 @@ double SMILTimeContainer::Elapsed() const {
base::TimeDelta()) -
reference_time_;
DCHECK_GE(time_offset, base::TimeDelta());
double elapsed = presentation_time_ + time_offset.InSecondsF();
SMILTime elapsed = presentation_time_ + time_offset.InSecondsF();
DCHECK_GE(elapsed, 0.0);
return elapsed;
}
......@@ -179,7 +179,7 @@ void SMILTimeContainer::ResetDocumentTime() {
SynchronizeToDocumentTimeline();
}
double SMILTimeContainer::CurrentDocumentTime() const {
SMILTime SMILTimeContainer::CurrentDocumentTime() const {
return latest_update_time_;
}
......@@ -245,7 +245,7 @@ void SMILTimeContainer::Unpause() {
ScheduleWakeUp(base::TimeDelta(), kSynchronizeAnimations);
}
void SMILTimeContainer::SetElapsed(double elapsed) {
void SMILTimeContainer::SetElapsed(SMILTime elapsed) {
presentation_time_ = elapsed;
// If the document hasn't finished loading, |m_presentationTime| will be
......@@ -411,7 +411,7 @@ bool SMILTimeContainer::CanScheduleFrame(SMILTime earliest_fire_time) const {
}
void SMILTimeContainer::UpdateAnimationsAndScheduleFrameIfNeeded(
double elapsed) {
SMILTime elapsed) {
if (!GetDocument().IsActive())
return;
......@@ -428,14 +428,14 @@ void SMILTimeContainer::UpdateAnimationsAndScheduleFrameIfNeeded(
if (!CanScheduleFrame(next_progress_time))
return;
double delay_time = next_progress_time.Value() - elapsed;
double delay_time = (next_progress_time - elapsed).Value();
DCHECK(std::isfinite(delay_time));
ScheduleAnimationFrame(base::TimeDelta::FromSecondsD(delay_time));
}
// A helper function to fetch the next interesting time after document_time
SMILTime SMILTimeContainer::NextInterestingTime(
double presentation_time) const {
SMILTime presentation_time) const {
DCHECK_GE(presentation_time, 0);
SMILTime next_interesting_time = SMILTime::Indefinite();
for (const auto& sandwich : scheduled_animations_) {
......@@ -472,7 +472,7 @@ void SMILTimeContainer::UpdateIntervals(SMILTime document_time) {
} while (intervals_dirty_);
}
void SMILTimeContainer::UpdateAnimationTimings(double presentation_time) {
void SMILTimeContainer::UpdateAnimationTimings(SMILTime presentation_time) {
DCHECK(GetDocument().IsActive());
#if DCHECK_IS_ON()
......@@ -501,7 +501,7 @@ void SMILTimeContainer::UpdateAnimationTimings(double presentation_time) {
}
}
void SMILTimeContainer::ApplyAnimationValues(double elapsed) {
void SMILTimeContainer::ApplyAnimationValues(SMILTime elapsed) {
#if DCHECK_IS_ON()
prevent_scheduled_animations_changes_ = true;
#endif
......@@ -549,8 +549,8 @@ void SMILTimeContainer::ApplyAnimationValues(double elapsed) {
}
void SMILTimeContainer::AdvanceFrameForTesting() {
const double kInitialFrameDelay = 0.025;
SetElapsed(Elapsed() + kInitialFrameDelay);
const SMILTime kFrameDuration = 0.025;
SetElapsed(Elapsed() + kFrameDuration);
}
void SMILTimeContainer::Trace(blink::Visitor* visitor) {
......
......@@ -59,9 +59,9 @@ class SMILTimeContainer final
void NotifyIntervalsChanged();
// Returns the time we are currently updating.
double Elapsed() const;
SMILTime Elapsed() const;
// Returns the current time in the document.
double CurrentDocumentTime() const;
SMILTime CurrentDocumentTime() const;
bool IsPaused() const;
bool IsStarted() const;
......@@ -69,7 +69,7 @@ class SMILTimeContainer final
void Start();
void Pause();
void Unpause();
void SetElapsed(double);
void SetElapsed(SMILTime);
void ServiceAnimations();
bool HasAnimations() const;
......@@ -114,12 +114,12 @@ class SMILTimeContainer final
ImageAnimationPolicy AnimationPolicy() const;
bool HandleAnimationPolicy(AnimationPolicyOnceAction);
bool CanScheduleFrame(SMILTime earliest_fire_time) const;
void UpdateAnimationsAndScheduleFrameIfNeeded(double elapsed);
void UpdateAnimationsAndScheduleFrameIfNeeded(SMILTime elapsed);
void RemoveUnusedKeys();
void UpdateIntervals(SMILTime);
SMILTime NextInterestingTime(double elapsed) const;
void UpdateAnimationTimings(double elapsed);
void ApplyAnimationValues(double elapsed);
SMILTime NextInterestingTime(SMILTime elapsed) const;
void UpdateAnimationTimings(SMILTime elapsed);
void ApplyAnimationValues(SMILTime elapsed);
void ServiceOnNextFrame();
void ScheduleWakeUp(base::TimeDelta delay_time, FrameSchedulingState);
bool HasPendingSynchronization() const;
......@@ -131,9 +131,9 @@ class SMILTimeContainer final
// The latest "restart" time for the time container's timeline. If the
// timeline has not been manipulated (seeked, paused) this will be zero.
double presentation_time_;
// The state all svg_smil_elements should be at.
double latest_update_time_;
SMILTime presentation_time_;
// The state all SVGSMILElements should be at.
SMILTime latest_update_time_;
// The time on the document timeline corresponding to |presentation_time_|.
base::TimeDelta reference_time_;
......
......@@ -559,7 +559,7 @@ bool SVGSVGElement::animationsPaused() const {
}
float SVGSVGElement::getCurrentTime() const {
return clampTo<float>(time_container_->Elapsed());
return clampTo<float>(time_container_->Elapsed().InSecondsF());
}
void SVGSVGElement::setCurrentTime(float seconds) {
......
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