Skip to content

Commit 4034ce9

Browse files
Calme1709AtkinsSJ
authored andcommitted
LibWeb: Account for transition-{delay,duration} always being a list
This fixes the optimization implemented in 46acdbd that was no longer working after e937f5d
1 parent d7d4f90 commit 4034ce9

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

Libraries/LibWeb/CSS/StyleComputer.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,8 +1237,21 @@ static void compute_transitioned_properties(ComputedProperties const& style, DOM
12371237
auto const& delay = style.property(PropertyID::TransitionDelay);
12381238
auto const& duration = style.property(PropertyID::TransitionDuration);
12391239

1240-
// FIXME: Change this to support the associated StyleValueList values when we update
1241-
// parse_simple_comma_separated_value_list to always return a StyleValueList.
1240+
auto const value_is_list_containing_a_single_time_of_zero_seconds = [](StyleValue const& value) -> bool {
1241+
if (!value.is_value_list())
1242+
return false;
1243+
1244+
auto const& value_list = value.as_value_list().values();
1245+
1246+
if (value_list.size() != 1)
1247+
return false;
1248+
1249+
if (!value_list[0]->is_time())
1250+
return false;
1251+
1252+
return value_list[0]->as_time().time().to_seconds() == 0;
1253+
};
1254+
12421255
// OPTIMIZATION: Registered transitions with a "combined duration" of less than or equal to 0s are equivalent to not
12431256
// having a transition registered at all, except in the case that we already have an associated
12441257
// transition for that property, so we can skip registering them. This implementation intentionally
@@ -1248,8 +1261,8 @@ static void compute_transitioned_properties(ComputedProperties const& style, DOM
12481261
// gains.
12491262
if (
12501263
element.property_ids_with_existing_transitions(pseudo_element).is_empty()
1251-
&& delay.is_time() && delay.as_time().time().to_seconds() == 0
1252-
&& duration.is_time() && duration.as_time().time().to_seconds() == 0) {
1264+
&& value_is_list_containing_a_single_time_of_zero_seconds(delay)
1265+
&& value_is_list_containing_a_single_time_of_zero_seconds(duration)) {
12531266
return;
12541267
}
12551268

0 commit comments

Comments
 (0)