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

Move the update of the active state for SMIL out of UpdateTiming

This moves the call to SVGSMILElement::UpdateActiveState() from
SMILAnimationSandwich's UpdateTiming() method to UpdateSyncBases() and
renames the latter UpdateActiveStateAndOrder().
The reset of the |interval_has_changed_| flag is moved to
UpdateActiveState(), and SVGSMILElement::UpdateSyncBases() is
decommissioned.
This exposed that SVGSMILElement::UpdateInterval(...) could end up
clobbering |previous_interval_| when re-resolving the current interval.

Bug: 998526
Change-Id: I0b3787f93898b062a3a1e790bf761402c0515156
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1834351
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702353}
parent f7806422
...@@ -60,7 +60,6 @@ void SMILAnimationSandwich::UpdateTiming(SMILTime elapsed) { ...@@ -60,7 +60,6 @@ void SMILAnimationSandwich::UpdateTiming(SMILTime elapsed) {
if (!animation->CurrentIntervalIsActive(elapsed)) if (!animation->CurrentIntervalIsActive(elapsed))
continue; continue;
animation->UpdateInterval(elapsed); animation->UpdateInterval(elapsed);
animation->UpdateActiveState(elapsed);
} }
} }
...@@ -86,13 +85,15 @@ SMILTime SMILAnimationSandwich::NextProgressTime( ...@@ -86,13 +85,15 @@ SMILTime SMILAnimationSandwich::NextProgressTime(
return earliest_progress_time; return earliest_progress_time;
} }
void SMILAnimationSandwich::UpdateSyncBases(SMILTime elapsed) { void SMILAnimationSandwich::UpdateActiveStateAndOrder(
SMILTime presentation_time) {
for (auto& animation : sandwich_) for (auto& animation : sandwich_)
animation->UpdateSyncBases(); animation->UpdateActiveState(presentation_time);
if (!std::is_sorted(sandwich_.begin(), sandwich_.end(), if (!std::is_sorted(sandwich_.begin(), sandwich_.end(),
PriorityCompare(elapsed))) { PriorityCompare(presentation_time))) {
std::sort(sandwich_.begin(), sandwich_.end(), PriorityCompare(elapsed)); std::sort(sandwich_.begin(), sandwich_.end(),
PriorityCompare(presentation_time));
} }
} }
......
...@@ -105,8 +105,8 @@ struct PriorityCompare { ...@@ -105,8 +105,8 @@ struct PriorityCompare {
// //
// UpdateTiming() handles updates to interval and transitions the active state. // UpdateTiming() handles updates to interval and transitions the active state.
// //
// UpdateSyncBases() handles the sorting described above (as well notifying // UpdateActiveStateAndOrder() handles the sorting described above and updates
// about new intervals). // the active state of the elements in the sandwich.
// //
// UpdateActiveAnimationStack() constructs a vector containing only the active // UpdateActiveAnimationStack() constructs a vector containing only the active
// elements. // elements.
...@@ -123,9 +123,9 @@ class SMILAnimationSandwich : public GarbageCollected<SMILAnimationSandwich> { ...@@ -123,9 +123,9 @@ class SMILAnimationSandwich : public GarbageCollected<SMILAnimationSandwich> {
void Unschedule(SVGSMILElement* animation); void Unschedule(SVGSMILElement* animation);
void Reset(); void Reset();
void UpdateTiming(SMILTime elapsed); void UpdateTiming(SMILTime presentation_time);
void UpdateSyncBases(SMILTime elapsed); void UpdateActiveStateAndOrder(SMILTime presentation_time);
void UpdateActiveAnimationStack(SMILTime elapsed); void UpdateActiveAnimationStack(SMILTime presentation_time);
SVGSMILElement* ApplyAnimationValues(); SVGSMILElement* ApplyAnimationValues();
SMILTime NextInterestingTime(SMILTime presentation_time) const; SMILTime NextInterestingTime(SMILTime presentation_time) const;
......
...@@ -489,7 +489,7 @@ void SMILTimeContainer::UpdateIntervals(SMILTime document_time) { ...@@ -489,7 +489,7 @@ void SMILTimeContainer::UpdateIntervals(SMILTime document_time) {
sandwich->UpdateTiming(document_time); sandwich->UpdateTiming(document_time);
for (auto& sandwich : scheduled_animations_.Values()) for (auto& sandwich : scheduled_animations_.Values())
sandwich->UpdateSyncBases(document_time); sandwich->UpdateActiveStateAndOrder(document_time);
} while (intervals_dirty_); } while (intervals_dirty_);
} }
......
...@@ -934,7 +934,8 @@ void SVGSMILElement::UpdateInterval(SMILTime presentation_time) { ...@@ -934,7 +934,8 @@ void SVGSMILElement::UpdateInterval(SMILTime presentation_time) {
SMILInterval next_interval = ResolveInterval(begin_after, presentation_time); SMILInterval next_interval = ResolveInterval(begin_after, presentation_time);
if (!next_interval.IsResolved() || next_interval == interval_) if (!next_interval.IsResolved() || next_interval == interval_)
return; return;
previous_interval_ = interval_; if (interval_.IsResolved())
previous_interval_ = interval_;
interval_ = next_interval; interval_ = next_interval;
NotifyDependentsOnNewInterval(interval_); NotifyDependentsOnNewInterval(interval_);
interval_has_changed_ = true; interval_has_changed_ = true;
...@@ -1068,18 +1069,15 @@ bool SVGSMILElement::CurrentIntervalIsActive(SMILTime elapsed) { ...@@ -1068,18 +1069,15 @@ bool SVGSMILElement::CurrentIntervalIsActive(SMILTime elapsed) {
return true; return true;
} }
void SVGSMILElement::UpdateSyncBases() {
if (!interval_has_changed_)
return;
interval_has_changed_ = false;
}
void SVGSMILElement::UpdateActiveState(SMILTime elapsed) { void SVGSMILElement::UpdateActiveState(SMILTime elapsed) {
if (is_waiting_for_first_interval_)
return;
const bool was_active = GetActiveState() == kActive; const bool was_active = GetActiveState() == kActive;
active_state_ = DetermineActiveState(elapsed); active_state_ = DetermineActiveState(elapsed);
const bool is_active = GetActiveState() == kActive; const bool is_active = GetActiveState() == kActive;
const bool interval_restart = const bool interval_restart =
interval_has_changed_ && previous_interval_.end == interval_.begin; interval_has_changed_ && previous_interval_.end == interval_.begin;
interval_has_changed_ = false;
if ((was_active && !is_active) || interval_restart) { if ((was_active && !is_active) || interval_restart) {
ScheduleEvent(event_type_names::kEndEvent); ScheduleEvent(event_type_names::kEndEvent);
......
...@@ -88,7 +88,6 @@ class CORE_EXPORT SVGSMILElement : public SVGElement, public SVGTests { ...@@ -88,7 +88,6 @@ class CORE_EXPORT SVGSMILElement : public SVGElement, public SVGTests {
bool CurrentIntervalIsActive(SMILTime elapsed); bool CurrentIntervalIsActive(SMILTime elapsed);
void UpdateInterval(SMILTime presentation_time); void UpdateInterval(SMILTime presentation_time);
void UpdateActiveState(SMILTime elapsed); void UpdateActiveState(SMILTime elapsed);
void UpdateSyncBases();
SMILTime NextInterestingTime(SMILTime elapsed) const; SMILTime NextInterestingTime(SMILTime elapsed) const;
SMILTime NextProgressTime(SMILTime elapsed) const; SMILTime NextProgressTime(SMILTime elapsed) const;
......
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