mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
LibWeb: Resolve percentages in calc() for font-size
Fixes crashing on https://react.dev/
This commit is contained in:
parent
b64ed060d8
commit
28c9015bd8
5 changed files with 39 additions and 18 deletions
|
@ -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({}, {});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue