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:
parent
b64ed060d8
commit
28c9015bd8
Notes:
sideshowbarker
2024-07-17 01:12:07 +09:00
Author: https://github.com/kalenikaliaksandr
Commit: 28c9015bd8
Pull-request: https://github.com/SerenityOS/serenity/pull/21325
Reviewed-by: https://github.com/AtkinsSJ
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