1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09:00

LibWeb: Resolve percentages in calc() for font-size

Fixes crashing on https://react.dev/
This commit is contained in:
Aliaksandr Kalenik 2023-10-04 16:24:24 +02:00 committed by Andreas Kling
parent b64ed060d8
commit 28c9015bd8
Notes: sideshowbarker 2024-07-17 01:12:07 +09:00
5 changed files with 39 additions and 18 deletions

View file

@ -2371,7 +2371,17 @@ Optional<Length> CalculatedStyleValue::resolve_length(Layout::Node const& layout
Optional<Length> CalculatedStyleValue::resolve_length_percentage(Layout::Node const& layout_node, Length const& percentage_basis) const
{
auto result = m_calculation->resolve(Length::ResolutionContext::for_layout_node(layout_node), percentage_basis);
return resolve_length_percentage(Length::ResolutionContext::for_layout_node(layout_node), percentage_basis);
}
Optional<Length> CalculatedStyleValue::resolve_length_percentage(Layout::Node const& layout_node, CSSPixels percentage_basis) const
{
return resolve_length_percentage(Length::ResolutionContext::for_layout_node(layout_node), Length::make_px(percentage_basis));
}
Optional<Length> CalculatedStyleValue::resolve_length_percentage(Length::ResolutionContext const& resolution_context, Length const& percentage_basis) const
{
auto result = m_calculation->resolve(resolution_context, percentage_basis);
return result.value().visit(
[&](Length const& length) -> Optional<Length> {
@ -2385,22 +2395,6 @@ Optional<Length> CalculatedStyleValue::resolve_length_percentage(Layout::Node co
});
}
Optional<Length> CalculatedStyleValue::resolve_length_percentage(Layout::Node const& layout_node, CSSPixels percentage_basis) const
{
auto result = m_calculation->resolve(Length::ResolutionContext::for_layout_node(layout_node), Length::make_px(percentage_basis));
return result.value().visit(
[&](Length const& length) -> Optional<Length> {
return length;
},
[&](Percentage const& percentage) -> Optional<Length> {
return Length::make_px(CSSPixels(percentage.value() * percentage_basis) / 100);
},
[&](auto const&) -> Optional<Length> {
return {};
});
}
Optional<Percentage> CalculatedStyleValue::resolve_percentage() const
{
auto result = m_calculation->resolve({}, {});