mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1751107 Part 3 - Clamp current time for SVG elements. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D140449
This commit is contained in:
parent
e03afacdd6
commit
34da4aaf3e
@ -200,7 +200,7 @@ void SVGSVGElement::SetCurrentTime(float seconds) {
|
||||
double fMilliseconds = double(seconds) * PR_MSEC_PER_SEC;
|
||||
// Round to nearest whole number before converting, to avoid precision
|
||||
// errors
|
||||
SMILTime lMilliseconds = int64_t(NS_round(fMilliseconds));
|
||||
SMILTime lMilliseconds = SVGUtils::ClampToInt64(NS_round(fMilliseconds));
|
||||
mTimedDocumentRoot->SetCurrentTime(lMilliseconds);
|
||||
AnimationNeedsResample();
|
||||
// Trigger synchronous sample now, to:
|
||||
|
@ -467,6 +467,15 @@ class SVGUtils final {
|
||||
std::max(double(INT32_MIN), std::min(double(INT32_MAX), aVal)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a floating-point value to a 64-bit integer value, clamping to
|
||||
* the lowest and highest integers that can be safely compared to a double.
|
||||
*/
|
||||
static int64_t ClampToInt64(double aVal) {
|
||||
return static_cast<int64_t>(
|
||||
std::clamp<double>(aVal, INT64_MIN, std::nexttoward(INT64_MAX, 0)));
|
||||
}
|
||||
|
||||
static nscolor GetFallbackOrPaintColor(
|
||||
const ComputedStyle&, StyleSVGPaint nsStyleSVG::*aFillOrStroke);
|
||||
|
||||
|
@ -0,0 +1,2 @@
|
||||
[end-of-time-001-crash.html]
|
||||
expected: TIMEOUT
|
Loading…
Reference in New Issue
Block a user