LibWeb/CSS: Fix crashing when calc() is used for border-radius

`BorderRadiusStyleValue::absolutized` should not try to extract length
from LengthPercentage that represents calculated.
This commit is contained in:
Aliaksandr Kalenik 2023-12-31 23:46:59 +01:00 committed by Andreas Kling
parent d8fa226a8f
commit e8f04be3ae
3 changed files with 41 additions and 2 deletions

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<link rel="match" href="reference/calc-border-radius-ref.html" />
<style>
.box {
width: 200px;
height: 200px;
background-color: lightblue;
border-radius: calc(2 * 10px);
border: 2px solid black;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<style>
.box {
width: 200px;
height: 200px;
background-color: lightblue;
border-radius: 20px;
border: 2px solid black;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>

View file

@ -24,9 +24,9 @@ ValueComparingNonnullRefPtr<StyleValue const> BorderRadiusStyleValue::absolutize
return *this;
auto absolutized_horizontal_radius = m_properties.horizontal_radius;
auto absolutized_vertical_radius = m_properties.vertical_radius;
if (!m_properties.horizontal_radius.is_percentage())
if (m_properties.horizontal_radius.is_length())
absolutized_horizontal_radius = m_properties.horizontal_radius.length().absolutized(viewport_rect, font_metrics, root_font_metrics);
if (!m_properties.vertical_radius.is_percentage())
if (m_properties.vertical_radius.is_length())
absolutized_vertical_radius = m_properties.vertical_radius.length().absolutized(viewport_rect, font_metrics, root_font_metrics);
return BorderRadiusStyleValue::create(absolutized_horizontal_radius, absolutized_vertical_radius);
}