mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:37:44 +00:00
LibWeb: Resolve numeric line-heights against element's own font size
For things like "line-height: 2" to work, the font size must be assigned before resolving the line height. Previously, the line-height was resolved first, which meant that numeric and other relative units were resolved against the default font-size instead.
This commit is contained in:
parent
5118a4c1e7
commit
fb9ee26c43
1 changed files with 5 additions and 3 deletions
|
@ -231,7 +231,12 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
|
||||||
{
|
{
|
||||||
auto& computed_values = static_cast<CSS::MutableComputedValues&>(m_computed_values);
|
auto& computed_values = static_cast<CSS::MutableComputedValues&>(m_computed_values);
|
||||||
|
|
||||||
|
// NOTE: We have to be careful that font-related properties get set in the right order.
|
||||||
|
// m_font is used by Length::to_px() when resolving sizes against this layout node.
|
||||||
|
// That's why it has to be set before everything else.
|
||||||
m_font = specified_style.computed_font();
|
m_font = specified_style.computed_font();
|
||||||
|
computed_values.set_font_size(specified_style.property(CSS::PropertyID::FontSize).value()->to_length().to_px(*this));
|
||||||
|
computed_values.set_font_weight(specified_style.property(CSS::PropertyID::FontWeight).value()->to_integer());
|
||||||
m_line_height = specified_style.line_height(*this);
|
m_line_height = specified_style.line_height(*this);
|
||||||
|
|
||||||
computed_values.set_vertical_align(specified_style.vertical_align());
|
computed_values.set_vertical_align(specified_style.vertical_align());
|
||||||
|
@ -360,9 +365,6 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
|
||||||
|
|
||||||
computed_values.set_box_sizing(specified_style.box_sizing());
|
computed_values.set_box_sizing(specified_style.box_sizing());
|
||||||
|
|
||||||
computed_values.set_font_size(specified_style.property(CSS::PropertyID::FontSize).value()->to_length().to_px(*this));
|
|
||||||
computed_values.set_font_weight(specified_style.property(CSS::PropertyID::FontWeight).value()->to_integer());
|
|
||||||
|
|
||||||
if (auto maybe_font_variant = specified_style.font_variant(); maybe_font_variant.has_value())
|
if (auto maybe_font_variant = specified_style.font_variant(); maybe_font_variant.has_value())
|
||||||
computed_values.set_font_variant(maybe_font_variant.release_value());
|
computed_values.set_font_variant(maybe_font_variant.release_value());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue