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

Split SVGSMILElement::Progress(...)

This splits said method into a CheckAndUpdateInterval() and an
UpdateActiveState(). CheckForNewRestartInterval() is also folded into
the former.

Bug: 998526
Change-Id: Ie1b10e06cfc0aed64e8576c820c59978596c5083
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1795428
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695538}
parent 3a5b9b1c
......@@ -63,7 +63,8 @@ void SMILAnimationSandwich::UpdateTiming(double elapsed) {
DCHECK(animation->HasValidTarget());
if (animation->NeedsToProgress(elapsed)) {
animation->Progress(elapsed);
bool interval_restart = animation->CheckAndUpdateInterval(elapsed);
animation->UpdateActiveState(elapsed, interval_restart);
active_.push_back(animation);
} else if (animation->IsContributing(elapsed)) {
active_.push_back(animation);
......
......@@ -946,30 +946,37 @@ void SVGSMILElement::EndListChanged(SMILTime) {
time_container_->NotifyIntervalsChanged();
}
base::Optional<SMILInterval> SVGSMILElement::CheckForNewRestartInterval(
double elapsed) {
bool SVGSMILElement::CheckAndUpdateInterval(double elapsed) {
DCHECK(!is_waiting_for_first_interval_);
DCHECK(elapsed >= interval_.begin);
Restart restart = GetRestart();
if (restart == kRestartNever)
return base::nullopt;
return false;
base::Optional<SMILInterval> modified;
base::Optional<SMILInterval> new_interval;
if (elapsed < interval_.end && restart == kRestartAlways) {
SMILTime next_begin = FindInstanceTime(kBegin, interval_.begin, false);
if (next_begin < interval_.end) {
modified = interval_;
modified->end = next_begin;
new_interval = interval_;
new_interval->end = next_begin;
}
}
if ((modified && elapsed >= modified->end) ||
(!modified && elapsed >= interval_.end)) {
modified = ResolveNextInterval();
if ((new_interval && elapsed >= new_interval->end) ||
(!new_interval && elapsed >= interval_.end)) {
new_interval = ResolveNextInterval();
}
return modified;
// Track "restarts" to handle active -> active transitions.
bool interval_restart = (new_interval && *new_interval != interval_);
if (new_interval) {
previous_interval_ = interval_;
interval_ = *new_interval;
interval_has_changed_ = true;
}
return interval_restart;
}
const SMILInterval& SVGSMILElement::GetActiveInterval(double elapsed) const {
......@@ -1139,19 +1146,7 @@ void SVGSMILElement::UpdateNextProgressTime(double elapsed) {
next_progress_time_ = CalculateNextProgressTime(elapsed);
}
void SVGSMILElement::Progress(double elapsed) {
base::Optional<SMILInterval> new_interval =
CheckForNewRestartInterval(elapsed);
// Track "restarts" to handle active -> active transitions.
bool interval_restart = (new_interval && *new_interval != interval_);
if (new_interval) {
previous_interval_ = interval_;
interval_ = *new_interval;
interval_has_changed_ = true;
}
void SVGSMILElement::UpdateActiveState(double elapsed, bool interval_restart) {
ActiveState old_active_state = GetActiveState();
active_state_ = DetermineActiveState(elapsed);
......
......@@ -85,7 +85,10 @@ class CORE_EXPORT SVGSMILElement : public SVGElement, public SVGTests {
SMILTime SimpleDuration() const;
bool NeedsToProgress(double elapsed);
void Progress(double elapsed);
// Check if the current interval is still current, and if not compute the
// next interval. Returns true if the interval was restarted.
bool CheckAndUpdateInterval(double elapsed);
void UpdateActiveState(double elapsed, bool interval_restart);
void TriggerPendingEvents(double elapsed);
void UpdateSyncBases();
void UpdateNextProgressTime(double elapsed);
......@@ -191,7 +194,6 @@ class CORE_EXPORT SVGSMILElement : public SVGElement, public SVGTests {
SMILTime RepeatingDuration() const;
const SMILInterval& GetActiveInterval(double elapsed) const;
base::Optional<SMILInterval> CheckForNewRestartInterval(double elapsed);
void BeginListChanged(SMILTime event_time);
void EndListChanged(SMILTime event_time);
......
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