1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 04:18:14 +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

@ -206,6 +206,9 @@ public:
void apply_style(const CSS::StyleProperties&);
const Gfx::Font& font() const { return *m_font; }
float line_height() const { return m_line_height; }
float font_size() const { return m_font_size; }
const CSS::ImageStyleValue* background_image() const { return m_background_image; }
protected:
NodeWithStyle(DOM::Document&, DOM::Node*, NonnullRefPtr<CSS::StyleProperties>);
@ -213,6 +216,9 @@ protected:
private:
CSS::ComputedValues m_computed_values;
RefPtr<Gfx::Font> m_font;
float m_line_height { 0 };
float m_font_size { 0 };
RefPtr<CSS::ImageStyleValue> m_background_image;
NonnullRefPtr<CSS::StyleProperties> m_specified_style;
CSS::Position m_position;
@ -240,6 +246,13 @@ inline const Gfx::Font& Node::font() const
return parent()->font();
}
inline float Node::font_size() const
{
if (m_has_style)
return static_cast<const NodeWithStyle*>(this)->font_size();
return parent()->font_size();
}
inline const CSS::StyleProperties& Node::specified_style() const
{
if (m_has_style)