Commit 5b93bdd3 authored by fs@opera.com's avatar fs@opera.com

Improve comparison of intervals in SVGSMILElement::resolveFirstInterval

For open-ended intervals such as [3) - i.e. begin=3s and end/duration/etc
unspecified - every call to resolveFirstInterval() would think that a new
interval had been created, and notify/require a reschedule of the
animations.
Add a new type SMILInterval and a suitable operator for that, and then
use it to compare the raw values (i.e. if both endpoints are exacly the same.)

BUG=377329

Review URL: https://codereview.chromium.org/298043005

git-svn-id: svn://svn.chromium.org/blink/trunk@175122 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2caf5aa7
......@@ -80,6 +80,14 @@ private:
Origin m_origin;
};
struct SMILInterval {
SMILInterval() { }
SMILInterval(const SMILTime& begin, const SMILTime& end) : begin(begin), end(end) { }
SMILTime begin;
SMILTime end;
};
inline bool operator==(const SMILTime& a, const SMILTime& b) { return a.isFinite() && a.value() == b.value(); }
inline bool operator!(const SMILTime& a) { return !a.isFinite() || !a.value(); }
inline bool operator!=(const SMILTime& a, const SMILTime& b) { return !operator==(a, b); }
......@@ -94,6 +102,13 @@ SMILTime operator-(const SMILTime&, const SMILTime&);
// So multiplying times does not make too much sense but SMIL defines it for duration * repeatCount
SMILTime operator*(const SMILTime&, const SMILTime&);
inline bool operator!=(const SMILInterval& a, const SMILInterval& b)
{
// Compare the "raw" values since the operator!= for SMILTime always return
// true for non-finite times.
return a.begin.value() != b.begin.value() || a.end.value() != b.end.value();
}
}
#endif // SMILTime_h
......@@ -935,14 +935,13 @@ void SVGSMILElement::resolveInterval(bool first, SMILTime& beginResult, SMILTime
void SVGSMILElement::resolveFirstInterval()
{
SMILTime begin;
SMILTime end;
resolveInterval(true, begin, end);
ASSERT(!begin.isIndefinite());
SMILInterval firstInterval;
resolveInterval(true, firstInterval.begin, firstInterval.end);
ASSERT(!firstInterval.begin.isIndefinite());
if (!begin.isUnresolved() && (begin != m_intervalBegin || end != m_intervalEnd)) {
m_intervalBegin = begin;
m_intervalEnd = end;
if (!firstInterval.begin.isUnresolved() && firstInterval != SMILInterval(m_intervalBegin, m_intervalEnd)) {
m_intervalBegin = firstInterval.begin;
m_intervalEnd = firstInterval.end;
notifyDependentsIntervalChanged();
m_nextProgressTime = min(m_nextProgressTime, m_intervalBegin);
......
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