Skip to content
Browse files
[CSS-Typed-OM] transition-duration property shouldn't allow negativ…
…e values

Reviewed by Simon Fraser.

`transition-duration` property shouldn't allow negative values, as per:

This means that StylePropertyMap.set() should wrap the value in a `calc()` when
negative, and that the computed value should be clamped to [0, inf].

* LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/transition-duration-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/transition-duration.html:
* Source/WebCore/css/typedom/CSSUnitValue.cpp:

Canonical link:
  • Loading branch information
cdumez committed Dec 23, 2022
1 parent 456497b commit ab21f8049d3417478d88f55de3dcd783e7f06a42
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
@@ -5,7 +5,7 @@ PASS Can set 'transition-duration' to CSS-wide keywords: unset
PASS Can set 'transition-duration' to CSS-wide keywords: revert
PASS Can set 'transition-duration' to var() references: var(--A)
PASS Can set 'transition-duration' to a time: 0s
FAIL Can set 'transition-duration' to a time: -3.14ms Invalid values
PASS Can set 'transition-duration' to a time: -3.14ms
PASS Can set 'transition-duration' to a time: 3.14s
PASS Can set 'transition-duration' to a time: calc(0s + 0ms)
PASS Setting 'transition-duration' to a length: 0px throws TypeError
@@ -13,7 +13,17 @@
'use strict';

runListValuedPropertyTests('transition-duration', [
{ syntax: '<time>' },
syntax: '<time>',
specified: assert_is_equal_with_range_handling,
computed: (input, result) => {
const time ='s').value;
if (time < 0)
assert_style_value_equals(result, new CSSUnitValue(0, 's'));
assert_style_value_equals(result, new CSSUnitValue(time, 's'));

@@ -254,6 +254,7 @@ static bool isValueOutOfRangeForProperty(CSSPropertyID propertyID, double value,
case CSSPropertyStrokeDasharray:
case CSSPropertyStrokeMiterlimit:
case CSSPropertyStrokeWidth:
case CSSPropertyTransitionDuration:
return value < 0;
case CSSPropertyFontWeight:
return value < 1 || value > 1000;

0 comments on commit ab21f80

Please sign in to comment.