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

Simplify SVGSMILElement::ResolveInterval even more

First eliminate the |equals_minimum_ok| variable, and always pass true
when searching the 'begin' instance list. Since currently the only way
to set this to false is for the first interval, and for that interval we
always start searching for the first instance time greater than
Earliest(), we can make it always be true without problem.

We also recognize zero-length intervals are not of any interest, as
indicated by the:

  first && temp_begin == temp_end... and
  !first && temp_end == interval_.end

clauses (note that |begin_after| == |interval_.end| when !first, and
thus if |temp_begin| ends up being equal to |interval_.end| this is
essentially checking that the interval isn't zero-length). Thus we can
always look for an 'end' instance that is greater than |temp_begin|
directly rather than checking for one that is potentially equal. This
should also mean that any newly found end time (as we loop) will never
equal the previous end that we got - allowing us to drop the
|last_interval_temp_end| construct.

Because we should no longer get zero-length intervals, we can drop the
special case for temp_begin == 0 and temp_end == 0 (zero-length first
interval that starts [and ends] at t=0).

Bug: 998526
Change-Id: I4d27372b50d24879af91bd35d7156c5bf9a1271d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1816547Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#698558}
parent 7ad40977
......@@ -809,30 +809,27 @@ SMILTime SVGSMILElement::ResolveActiveEnd(SMILTime resolved_begin,
SMILInterval SVGSMILElement::ResolveInterval(
IntervalSelector interval_selector) const {
bool first = interval_selector == kFirstInterval;
// See the pseudocode in http://www.w3.org/TR/SMIL3/smil-timing.html#q90.
// Simplified version of the pseudocode in
// http://www.w3.org/TR/SMIL3/smil-timing.html#q90.
SMILTime begin_after = first ? SMILTime::Earliest() : interval_.end;
SMILTime last_interval_temp_end = SMILTime::Indefinite();
while (true) {
bool equals_minimum_ok = !first || interval_.end > interval_.begin;
SMILTime temp_begin =
FindInstanceTime(kBegin, begin_after, equals_minimum_ok);
SMILTime temp_begin = FindInstanceTime(kBegin, begin_after, true);
if (temp_begin.IsUnresolved())
break;
SMILTime temp_end = FindInstanceTime(kEnd, temp_begin, true);
if (!end_times_.IsEmpty()) {
if ((first && temp_begin == temp_end &&
temp_end == last_interval_temp_end) ||
(!first && temp_end == interval_.end))
temp_end = FindInstanceTime(kEnd, temp_begin, false);
if (temp_end.IsUnresolved() && !has_end_event_conditions_)
SMILTime temp_end = FindInstanceTime(kEnd, temp_begin, false);
if (temp_end.IsUnresolved()) {
// If we have no pending end conditions, don't generate a new interval.
if (!end_times_.IsEmpty() && !has_end_event_conditions_)
break;
}
temp_end = ResolveActiveEnd(temp_begin, temp_end);
if (!first || temp_end > SMILTime() || (!temp_begin && !temp_end))
// If this is the first interval being resolved, don't allow it to end
// before the origin of the timeline.
// TODO(fs): Don't resolve intervals that end "in the past".
if (!first || temp_end > SMILTime())
return SMILInterval(temp_begin, temp_end);
begin_after = temp_end;
last_interval_temp_end = temp_end;
}
return SMILInterval(SMILTime::Unresolved(), SMILTime::Unresolved());
}
......
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