1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:37:44 +00:00

LibWeb: Add Layout::Node::line_height()

This allows you to call line_height() on any layout node, even if it's a
text node (in which case we'll ask the parent node for its line-height.)
This commit is contained in:
Andreas Kling 2022-03-24 17:37:24 +01:00
parent c914e732d2
commit 329f06d59a

View file

@ -108,6 +108,7 @@ public:
const Gfx::Font& font() const;
const CSS::ImmutableComputedValues& computed_values() const;
float line_height() const;
NodeWithStyle* parent();
const NodeWithStyle* parent() const;
@ -227,6 +228,13 @@ inline const CSS::ImmutableComputedValues& Node::computed_values() const
return parent()->computed_values();
}
inline float Node::line_height() const
{
if (m_has_style)
return static_cast<NodeWithStyle const*>(this)->line_height();
return parent()->line_height();
}
inline const NodeWithStyle* Node::parent() const
{
return static_cast<const NodeWithStyle*>(TreeNode<Node>::parent());