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