LibWeb: Don't crash with invalid transform-origin values

This commit is contained in:
Gingeh 2025-07-01 20:25:03 +10:00 committed by Sam Atkins
parent 0e3386bb4c
commit b8f78e3bc1
3 changed files with 12 additions and 3 deletions

View File

@ -3907,14 +3907,14 @@ RefPtr<CSSStyleValue const> Parser::parse_transform_origin_value(TokenStream<Com
auto second_value = to_axis_offset(parse_css_value_for_property(PropertyID::TransformOrigin, tokens));
auto third_value = parse_length_value(tokens);
if (!first_value.has_value() || !second_value.has_value())
return nullptr;
if ((first_value->offset->is_length() || first_value->offset->is_percentage()) && second_value->axis == Axis::X)
return nullptr;
if ((second_value->offset->is_length() || second_value->offset->is_percentage()) && first_value->axis == Axis::Y)
return nullptr;
if (!first_value.has_value() || !second_value.has_value())
return nullptr;
if (!third_value)
third_value = zero_value;

View File

@ -0,0 +1 @@
PASS (didn't crash)

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<script src="include.js"></script>
<div style="transform-origin: bad value"></div>
<script>
test(() => {
println("PASS (didn't crash)");
});
</script>