Bug 1834892 - permit fractional SMIL timecount values to omit leading 0 r=dholbert

Differential Revision: https://phabricator.services.mozilla.com/D178995
This commit is contained in:
Robert Longson 2023-05-25 07:38:16 +00:00
parent 20e77a0edd
commit fcb8ef3146
3 changed files with 10 additions and 3 deletions

View File

@ -165,7 +165,7 @@ bool ParseClockValue(RangedPtr<const char16_t>& aIter,
iter = aIter;
int32_t hours = 0, timecount;
int32_t hours = 0, timecount = 0;
double fraction = 0.0;
uint32_t minutes, seconds, multiplier;
@ -192,7 +192,8 @@ bool ParseClockValue(RangedPtr<const char16_t>& aIter,
aIter = iter;
return true;
case TIMECOUNT_VALUE:
if (!SVGContentUtils::ParseInteger(iter, aEnd, timecount)) {
if (*iter != '.' &&
!SVGContentUtils::ParseInteger(iter, aEnd, timecount)) {
return false;
}
if (iter != aEnd && *iter == '.' &&

View File

@ -33,6 +33,8 @@ function main() {
/* Check basic operation */
anim.setAttribute("dur", "1s");
is(anim.getSimpleDuration(), 1);
anim.setAttribute("dur", ".15s");
isfuzzy(anim.getSimpleDuration(), 0.15, 0.001);
anim.setAttribute("dur", "1.5s");
is(anim.getSimpleDuration(), 1.5);

View File

@ -60,10 +60,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=941315
a.setAttribute("dur", "50s");
is(b.safeGetStartTime(), 50, "valid simple duration");
// Check an invalid value also causes the model to be updated
// Check invalid values also cause the model to be updated
a.setAttribute("dur", "abc"); // -> indefinite
is(b.safeGetStartTime(), "none", "invalid simple duration");
a.setAttribute("dur", "50s");
a.setAttribute("dur", "-.1s"); // -> indefinite
is(b.safeGetStartTime(), "none", "invalid simple duration");
// Restore state
a.setAttribute("dur", "100s");
}