diff options
author | Andreas Kling <kling@serenityos.org> | 2022-03-24 17:37:24 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-24 18:14:01 +0100 |
commit | 329f06d59a8713b644fad120460b6509be09ac53 (patch) | |
tree | 26fdd42fec892276f322ccb83dd8f07a61955eda /Userland/Libraries/LibWeb | |
parent | c914e732d2e3b701ebb60c0bf5309656c4820e60 (diff) | |
download | serenity-329f06d59a8713b644fad120460b6509be09ac53.zip |
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.)
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/Node.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/Node.h b/Userland/Libraries/LibWeb/Layout/Node.h index 95910180e4..0c7bccfbab 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.h +++ b/Userland/Libraries/LibWeb/Layout/Node.h @@ -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()); |