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

Move body of PriorityCompare to SVGSMILElement

Move the priority comparison between two timed elements into the new
SVGSMILElement::IsHigherPriorityThan() method. This ought to make fixing
the existing FIXME easier.

Bug: 998526
Change-Id: I05492faa770cb9eaf8589e88cbf86845f870c9ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1841131
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703081}
parent cdf2adb0
...@@ -37,13 +37,7 @@ struct PriorityCompare { ...@@ -37,13 +37,7 @@ struct PriorityCompare {
PriorityCompare(SMILTime elapsed) : elapsed_(elapsed) {} PriorityCompare(SMILTime elapsed) : elapsed_(elapsed) {}
bool operator()(const Member<SVGSMILElement>& a, bool operator()(const Member<SVGSMILElement>& a,
const Member<SVGSMILElement>& b) { const Member<SVGSMILElement>& b) {
// FIXME: This should also consider possible timing relations between the return b->IsHigherPriorityThan(a, elapsed_);
// elements.
SMILTime a_begin = a->BeginTimeForPrioritization(elapsed_);
SMILTime b_begin = b->BeginTimeForPrioritization(elapsed_);
if (a_begin == b_begin)
return a->DocumentOrderIndex() < b->DocumentOrderIndex();
return a_begin < b_begin;
} }
SMILTime elapsed_; SMILTime elapsed_;
}; };
......
...@@ -605,6 +605,17 @@ SMILTime SVGSMILElement::BeginTimeForPrioritization( ...@@ -605,6 +605,17 @@ SMILTime SVGSMILElement::BeginTimeForPrioritization(
return interval_.begin; return interval_.begin;
} }
bool SVGSMILElement::IsHigherPriorityThan(const SVGSMILElement* other,
SMILTime presentation_time) const {
// FIXME: This should also consider possible timing relations between the
// elements.
SMILTime this_begin = BeginTimeForPrioritization(presentation_time);
SMILTime other_begin = other->BeginTimeForPrioritization(presentation_time);
if (this_begin == other_begin)
return DocumentOrderIndex() > other->DocumentOrderIndex();
return this_begin > other_begin;
}
SMILTime SVGSMILElement::Dur() const { SMILTime SVGSMILElement::Dur() const {
if (cached_dur_ != kInvalidCachedTime) if (cached_dur_ != kInvalidCachedTime)
return cached_dur_; return cached_dur_;
......
...@@ -82,12 +82,13 @@ class CORE_EXPORT SVGSMILElement : public SVGElement, public SVGTests { ...@@ -82,12 +82,13 @@ class CORE_EXPORT SVGSMILElement : public SVGElement, public SVGTests {
SMILTime Elapsed() const; SMILTime Elapsed() const;
SMILTime IntervalBegin() const { return interval_.begin; } SMILTime IntervalBegin() const { return interval_.begin; }
SMILTime BeginTimeForPrioritization(SMILTime presentation_time) const;
SMILTime SimpleDuration() const; SMILTime SimpleDuration() const;
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);
bool IsHigherPriorityThan(const SVGSMILElement* other,
SMILTime presentation_time) const;
SMILTime NextInterestingTime(SMILTime elapsed) const; SMILTime NextInterestingTime(SMILTime elapsed) const;
SMILTime NextProgressTime(SMILTime elapsed) const; SMILTime NextProgressTime(SMILTime elapsed) const;
...@@ -157,6 +158,7 @@ class CORE_EXPORT SVGSMILElement : public SVGElement, public SVGTests { ...@@ -157,6 +158,7 @@ class CORE_EXPORT SVGSMILElement : public SVGElement, public SVGTests {
SMILTime FindInstanceTime(BeginOrEnd, SMILTime FindInstanceTime(BeginOrEnd,
SMILTime minimum_time, SMILTime minimum_time,
bool equals_minimum_ok) const; bool equals_minimum_ok) const;
SMILTime BeginTimeForPrioritization(SMILTime presentation_time) const;
SMILInterval ResolveInterval(SMILTime begin_after, SMILTime end_after) const; SMILInterval ResolveInterval(SMILTime begin_after, SMILTime end_after) const;
bool ResolveFirstInterval(); bool ResolveFirstInterval();
......
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