mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 08:11:13 +00:00
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:
parent
d8fa226a8f
commit
e8f04be3ae
Notes:
sideshowbarker
2024-07-17 04:41:05 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/e8f04be3ae Pull-request: https://github.com/SerenityOS/serenity/pull/22523
20
Tests/LibWeb/Ref/calc-border-radius.html
Normal file
20
Tests/LibWeb/Ref/calc-border-radius.html
Normal 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>
|
19
Tests/LibWeb/Ref/reference/calc-border-radius-ref.html
Normal file
19
Tests/LibWeb/Ref/reference/calc-border-radius-ref.html
Normal 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>
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue