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

Ensure SMILTime::From{Microseconds,SecondsD} always return finite values

Clamp the result to the [Min(), Latest()] range.
Remove the IsFinite() checks from SVGSMILElement::ParseOffsetValue() and
SVGSMILElement::ParseClockValue() since they will no longer trigger.

Bug: 1012665
Change-Id: I7183888fe1a0a2dd598fb42c152dee94d216d66c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1852924Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#704840}
parent 4a743572
......@@ -70,10 +70,10 @@ class SMILTime {
return base::TimeDelta::FromMicroseconds(1);
}
static constexpr SMILTime FromSecondsD(double seconds) {
return base::TimeDelta::FromSecondsD(seconds);
return std::min(SMILTime(base::TimeDelta::FromSecondsD(seconds)), Latest());
}
static constexpr SMILTime FromMicroseconds(int64_t us) {
return base::TimeDelta::FromMicroseconds(us);
return std::min(SMILTime(base::TimeDelta::FromMicroseconds(us)), Latest());
}
// Used for computing progress. Don't use for anything else.
......
......@@ -321,10 +321,7 @@ SMILTime SVGSMILElement::ParseOffsetValue(const String& data) {
result = parse.ToDouble(&ok);
if (!ok)
return SMILTime::Unresolved();
SMILTime offset_value = SMILTime::FromSecondsD(result);
if (!offset_value.IsFinite())
return SMILTime::Unresolved();
return offset_value;
return SMILTime::FromSecondsD(result);
}
SMILTime SVGSMILElement::ParseClockValue(const String& data) {
......@@ -361,10 +358,7 @@ SMILTime SVGSMILElement::ParseClockValue(const String& data) {
if (!ok)
return SMILTime::Unresolved();
SMILTime clock_value = SMILTime::FromSecondsD(result);
if (!clock_value.IsFinite())
return SMILTime::Unresolved();
return clock_value;
return SMILTime::FromSecondsD(result);
}
bool SVGSMILElement::ParseCondition(const String& value,
......
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