1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +00:00

LibWeb: Copy some properties from specified style into layout node

Another step towards not having to carry the full specified style with
us everywhere. This isn't the ideal final layout, since we're mixing
computed and used values a bit randomly here, but one step at a time.
This commit is contained in:
Andreas Kling 2021-01-06 11:31:19 +01:00
parent e5490ae1d1
commit 2cc39cfb0e
4 changed files with 30 additions and 18 deletions

View file

@ -157,13 +157,6 @@ void Node::set_needs_display()
}
}
float Node::font_size() const
{
// FIXME: This doesn't work right for relative font-sizes
auto length = specified_style().length_or_fallback(CSS::PropertyID::FontSize, CSS::Length(10, CSS::Length::Type::Px));
return length.raw_value();
}
Gfx::FloatPoint Node::box_type_agnostic_position() const
{
if (is<Box>(*this))
@ -223,6 +216,18 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
auto& computed_values = static_cast<CSS::MutableComputedValues&>(m_computed_values);
m_font = specified_style.font();
m_line_height = specified_style.line_height(*this);
{
// FIXME: This doesn't work right for relative font-sizes
auto length = specified_style.length_or_fallback(CSS::PropertyID::FontSize, CSS::Length(10, CSS::Length::Type::Px));
m_font_size = length.raw_value();
}
auto bgimage = specified_style.property(CSS::PropertyID::BackgroundImage);
if (bgimage.has_value() && bgimage.value()->is_image()) {
m_background_image = static_ptr_cast<CSS::ImageStyleValue>(bgimage.value());
}
auto position = specified_style.position();
if (position.has_value())
@ -310,5 +315,4 @@ bool Node::is_inline_block() const
{
return is_inline() && is<BlockBox>(*this);
}
}