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

Add SMILInterval::Unresolved() helper

Use this when discarding or otherwise initializing an interval to an
unresolved state - which hopefully slightly more readable than what is
currently used.

Drop some friend declarations from SMILTime that are no longer needed,
while we're in the vicinity.

Bug: 998526
Change-Id: I08531a906c0e093f2786c4c1a925ebd823f99ca4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1856163
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705399}
parent 0060cccc
......@@ -130,9 +130,6 @@ class SMILTime {
bool operator<=(SMILTime other) const { return time_ <= other.time_; }
private:
friend bool operator!=(const SMILInterval& a, const SMILInterval& b);
friend struct SMILTimeHash;
constexpr SMILTime(base::TimeDelta time) : time_(time) {}
base::TimeDelta time_;
......@@ -177,10 +174,13 @@ inline bool operator<(const SMILTimeWithOrigin& a,
// (https://www.w3.org/TR/SMIL3/smil-timing.html#q101)
struct SMILInterval {
DISALLOW_NEW();
SMILInterval() = default;
SMILInterval(const SMILTime& begin, const SMILTime& end)
constexpr SMILInterval(const SMILTime& begin, const SMILTime& end)
: begin(begin), end(end) {}
static constexpr SMILInterval Unresolved() {
return {SMILTime::Unresolved(), SMILTime::Unresolved()};
}
bool IsResolved() const { return begin.IsFinite(); }
bool BeginsAfter(SMILTime time) const { return time < begin; }
bool BeginsBefore(SMILTime time) const { return !BeginsAfter(time); }
......
......@@ -186,8 +186,8 @@ SVGSMILElement::SVGSMILElement(const QualifiedName& tag_name, Document& doc)
has_end_event_conditions_(false),
is_waiting_for_first_interval_(true),
is_scheduled_(false),
interval_{SMILTime::Unresolved(), SMILTime::Unresolved()},
previous_interval_{SMILTime::Unresolved(), SMILTime::Unresolved()},
interval_(SMILInterval::Unresolved()),
previous_interval_(SMILInterval::Unresolved()),
next_interval_time_(SMILTime::Earliest()),
active_state_(kInactive),
restart_(kRestartAlways),
......@@ -255,8 +255,8 @@ static inline void RemoveInstanceTimesWithOrigin(
void SVGSMILElement::Reset() {
active_state_ = kInactive;
is_waiting_for_first_interval_ = true;
interval_ = {SMILTime::Unresolved(), SMILTime::Unresolved()};
previous_interval_ = {SMILTime::Unresolved(), SMILTime::Unresolved()};
interval_ = SMILInterval::Unresolved();
previous_interval_ = SMILInterval::Unresolved();
next_interval_time_ = SMILTime::Earliest();
last_progress_ = {0.0f, 0};
}
......@@ -809,7 +809,7 @@ SMILInterval SVGSMILElement::ResolveInterval(SMILTime begin_after,
begin_after = temp_end;
}
return SMILInterval(SMILTime::Unresolved(), SMILTime::Unresolved());
return SMILInterval::Unresolved();
}
void SVGSMILElement::SetNewInterval(const SMILInterval& interval,
......@@ -875,7 +875,7 @@ void SVGSMILElement::DiscardOrRevalidateCurrentInterval(
return;
// If the current interval has not yet started, discard it and re-resolve.
if (interval_.BeginsAfter(presentation_time)) {
interval_ = {SMILTime::Unresolved(), SMILTime::Unresolved()};
interval_ = SMILInterval::Unresolved();
return;
}
......@@ -886,7 +886,7 @@ void SVGSMILElement::DiscardOrRevalidateCurrentInterval(
if (new_end.IsUnresolved()) {
// If we have no pending end conditions, discard the current interval.
if (!end_times_.IsEmpty() && !has_end_event_conditions_) {
interval_ = {SMILTime::Unresolved(), SMILTime::Unresolved()};
interval_ = SMILInterval::Unresolved();
return;
}
}
......
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